Lines Matching +full:num +full:- +full:ids
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Squashfs - a compressed read only filesystem for Linux
13 * in-memory structures at mount time, and all the VFS glue code to register
76 opts->thread_ops = &squashfs_decompressor_single; in squashfs_parse_param_threads_str()
80 opts->thread_ops = &squashfs_decompressor_multi; in squashfs_parse_param_threads_str()
84 opts->thread_ops = &squashfs_decompressor_percpu; in squashfs_parse_param_threads_str()
88 return -EINVAL; in squashfs_parse_param_threads_str()
95 unsigned long num; in squashfs_parse_param_threads_num() local
97 ret = kstrtoul(str, 0, &num); in squashfs_parse_param_threads_num()
99 return -EINVAL; in squashfs_parse_param_threads_num()
100 if (num > 1) { in squashfs_parse_param_threads_num()
101 opts->thread_ops = &squashfs_decompressor_multi; in squashfs_parse_param_threads_num()
102 if (num > opts->thread_ops->max_decompressors()) in squashfs_parse_param_threads_num()
103 return -EINVAL; in squashfs_parse_param_threads_num()
104 opts->thread_num = (int)num; in squashfs_parse_param_threads_num()
108 if (num == 1) { in squashfs_parse_param_threads_num()
109 opts->thread_ops = &squashfs_decompressor_single; in squashfs_parse_param_threads_num()
110 opts->thread_num = 1; in squashfs_parse_param_threads_num()
115 return -EINVAL; in squashfs_parse_param_threads_num()
129 struct squashfs_mount_opts *opts = fc->fs_private; in squashfs_parse_param()
139 opts->errors = result.uint_32; in squashfs_parse_param()
142 if (squashfs_parse_param_threads(param->string, opts) != 0) in squashfs_parse_param()
143 return -EINVAL; in squashfs_parse_param()
146 return -EINVAL; in squashfs_parse_param()
170 if (!decompressor->supported) { in supported_squashfs_filesystem()
172 decompressor->name); in supported_squashfs_filesystem()
182 struct squashfs_mount_opts *opts = fc->fs_private; in squashfs_fill_super()
196 return -EINVAL; in squashfs_fill_super()
199 sb->s_fs_info = kzalloc(sizeof(*msblk), GFP_KERNEL); in squashfs_fill_super()
200 if (sb->s_fs_info == NULL) { in squashfs_fill_super()
202 return -ENOMEM; in squashfs_fill_super()
204 msblk = sb->s_fs_info; in squashfs_fill_super()
205 msblk->thread_ops = opts->thread_ops; in squashfs_fill_super()
207 msblk->panic_on_errors = (opts->errors == Opt_errors_panic); in squashfs_fill_super()
209 msblk->devblksize = devblksize; in squashfs_fill_super()
210 msblk->devblksize_log2 = ffz(~msblk->devblksize); in squashfs_fill_super()
212 mutex_init(&msblk->meta_index_mutex); in squashfs_fill_super()
215 * msblk->bytes_used is checked in squashfs_read_table to ensure reads in squashfs_fill_super()
220 msblk->bytes_used = sizeof(*sblk); in squashfs_fill_super()
230 err = -EINVAL; in squashfs_fill_super()
233 sb->s_magic = le32_to_cpu(sblk->s_magic); in squashfs_fill_super()
234 if (sb->s_magic != SQUASHFS_MAGIC) { in squashfs_fill_super()
235 if (!(fc->sb_flags & SB_SILENT)) in squashfs_fill_super()
237 sb->s_bdev); in squashfs_fill_super()
241 if (opts->thread_num == 0) { in squashfs_fill_super()
242 msblk->max_thread_num = msblk->thread_ops->max_decompressors(); in squashfs_fill_super()
244 msblk->max_thread_num = opts->thread_num; in squashfs_fill_super()
248 msblk->decompressor = supported_squashfs_filesystem( in squashfs_fill_super()
250 le16_to_cpu(sblk->s_major), in squashfs_fill_super()
251 le16_to_cpu(sblk->s_minor), in squashfs_fill_super()
252 le16_to_cpu(sblk->compression)); in squashfs_fill_super()
253 if (msblk->decompressor == NULL) in squashfs_fill_super()
258 msblk->bytes_used = le64_to_cpu(sblk->bytes_used); in squashfs_fill_super()
259 if (msblk->bytes_used < 0 || in squashfs_fill_super()
260 msblk->bytes_used > bdev_nr_bytes(sb->s_bdev)) in squashfs_fill_super()
264 msblk->block_size = le32_to_cpu(sblk->block_size); in squashfs_fill_super()
265 if (msblk->block_size > SQUASHFS_FILE_MAX_SIZE) in squashfs_fill_super()
272 if (PAGE_SIZE > msblk->block_size) { in squashfs_fill_super()
274 "currently not supported!", msblk->block_size); in squashfs_fill_super()
279 msblk->block_log = le16_to_cpu(sblk->block_log); in squashfs_fill_super()
280 if (msblk->block_log > SQUASHFS_FILE_MAX_LOG) in squashfs_fill_super()
284 if (msblk->block_size != (1 << msblk->block_log)) in squashfs_fill_super()
288 root_inode = le64_to_cpu(sblk->root_inode); in squashfs_fill_super()
292 msblk->inode_table = le64_to_cpu(sblk->inode_table_start); in squashfs_fill_super()
293 msblk->directory_table = le64_to_cpu(sblk->directory_table_start); in squashfs_fill_super()
294 msblk->inodes = le32_to_cpu(sblk->inodes); in squashfs_fill_super()
295 msblk->fragments = le32_to_cpu(sblk->fragments); in squashfs_fill_super()
296 msblk->ids = le16_to_cpu(sblk->no_ids); in squashfs_fill_super()
297 flags = le16_to_cpu(sblk->flags); in squashfs_fill_super()
299 TRACE("Found valid superblock on %pg\n", sb->s_bdev); in squashfs_fill_super()
304 TRACE("Filesystem size %lld bytes\n", msblk->bytes_used); in squashfs_fill_super()
305 TRACE("Block size %d\n", msblk->block_size); in squashfs_fill_super()
306 TRACE("Number of inodes %d\n", msblk->inodes); in squashfs_fill_super()
307 TRACE("Number of fragments %d\n", msblk->fragments); in squashfs_fill_super()
308 TRACE("Number of ids %d\n", msblk->ids); in squashfs_fill_super()
309 TRACE("sblk->inode_table_start %llx\n", msblk->inode_table); in squashfs_fill_super()
310 TRACE("sblk->directory_table_start %llx\n", msblk->directory_table); in squashfs_fill_super()
311 TRACE("sblk->fragment_table_start %llx\n", in squashfs_fill_super()
312 (u64) le64_to_cpu(sblk->fragment_table_start)); in squashfs_fill_super()
313 TRACE("sblk->id_table_start %llx\n", in squashfs_fill_super()
314 (u64) le64_to_cpu(sblk->id_table_start)); in squashfs_fill_super()
316 sb->s_maxbytes = MAX_LFS_FILESIZE; in squashfs_fill_super()
317 sb->s_time_min = 0; in squashfs_fill_super()
318 sb->s_time_max = U32_MAX; in squashfs_fill_super()
319 sb->s_flags |= SB_RDONLY; in squashfs_fill_super()
320 sb->s_op = &squashfs_super_ops; in squashfs_fill_super()
322 msblk->block_cache = squashfs_cache_init("metadata", in squashfs_fill_super()
324 if (IS_ERR(msblk->block_cache)) { in squashfs_fill_super()
325 err = PTR_ERR(msblk->block_cache); in squashfs_fill_super()
330 msblk->read_page = squashfs_cache_init("data", in squashfs_fill_super()
331 SQUASHFS_READ_PAGES, msblk->block_size); in squashfs_fill_super()
332 if (IS_ERR(msblk->read_page)) { in squashfs_fill_super()
334 err = PTR_ERR(msblk->read_page); in squashfs_fill_super()
338 if (msblk->devblksize == PAGE_SIZE) { in squashfs_fill_super()
342 err = -ENOMEM; in squashfs_fill_super()
347 cache->i_size = OFFSET_MAX; in squashfs_fill_super()
348 mapping_set_gfp_mask(cache->i_mapping, GFP_NOFS); in squashfs_fill_super()
350 msblk->cache_mapping = cache->i_mapping; in squashfs_fill_super()
353 msblk->stream = squashfs_decompressor_setup(sb, flags); in squashfs_fill_super()
354 if (IS_ERR(msblk->stream)) { in squashfs_fill_super()
355 err = PTR_ERR(msblk->stream); in squashfs_fill_super()
356 msblk->stream = NULL; in squashfs_fill_super()
361 sb->s_xattr = squashfs_xattr_handlers; in squashfs_fill_super()
362 xattr_id_table_start = le64_to_cpu(sblk->xattr_id_table_start); in squashfs_fill_super()
364 next_table = msblk->bytes_used; in squashfs_fill_super()
369 msblk->xattr_id_table = squashfs_read_xattr_id_table(sb, in squashfs_fill_super()
370 xattr_id_table_start, &msblk->xattr_table, &msblk->xattr_ids); in squashfs_fill_super()
371 if (IS_ERR(msblk->xattr_id_table)) { in squashfs_fill_super()
373 err = PTR_ERR(msblk->xattr_id_table); in squashfs_fill_super()
374 msblk->xattr_id_table = NULL; in squashfs_fill_super()
375 if (err != -ENOTSUPP) in squashfs_fill_super()
378 next_table = msblk->xattr_table; in squashfs_fill_super()
382 msblk->id_table = squashfs_read_id_index_table(sb, in squashfs_fill_super()
383 le64_to_cpu(sblk->id_table_start), next_table, msblk->ids); in squashfs_fill_super()
384 if (IS_ERR(msblk->id_table)) { in squashfs_fill_super()
386 err = PTR_ERR(msblk->id_table); in squashfs_fill_super()
387 msblk->id_table = NULL; in squashfs_fill_super()
390 next_table = le64_to_cpu(msblk->id_table[0]); in squashfs_fill_super()
393 lookup_table_start = le64_to_cpu(sblk->lookup_table_start); in squashfs_fill_super()
398 msblk->inode_lookup_table = squashfs_read_inode_lookup_table(sb, in squashfs_fill_super()
399 lookup_table_start, next_table, msblk->inodes); in squashfs_fill_super()
400 if (IS_ERR(msblk->inode_lookup_table)) { in squashfs_fill_super()
402 err = PTR_ERR(msblk->inode_lookup_table); in squashfs_fill_super()
403 msblk->inode_lookup_table = NULL; in squashfs_fill_super()
406 next_table = le64_to_cpu(msblk->inode_lookup_table[0]); in squashfs_fill_super()
408 sb->s_export_op = &squashfs_export_ops; in squashfs_fill_super()
411 fragments = msblk->fragments; in squashfs_fill_super()
415 msblk->fragment_cache = squashfs_cache_init("fragment", in squashfs_fill_super()
416 min(SQUASHFS_CACHED_FRAGMENTS, fragments), msblk->block_size); in squashfs_fill_super()
417 if (IS_ERR(msblk->fragment_cache)) { in squashfs_fill_super()
418 err = PTR_ERR(msblk->fragment_cache); in squashfs_fill_super()
423 msblk->fragment_index = squashfs_read_fragment_index_table(sb, in squashfs_fill_super()
424 le64_to_cpu(sblk->fragment_table_start), next_table, fragments); in squashfs_fill_super()
425 if (IS_ERR(msblk->fragment_index)) { in squashfs_fill_super()
427 err = PTR_ERR(msblk->fragment_index); in squashfs_fill_super()
428 msblk->fragment_index = NULL; in squashfs_fill_super()
431 next_table = le64_to_cpu(msblk->fragment_index[0]); in squashfs_fill_super()
435 if (msblk->directory_table > next_table) { in squashfs_fill_super()
436 err = -EINVAL; in squashfs_fill_super()
441 if (msblk->inode_table >= msblk->directory_table) { in squashfs_fill_super()
442 err = -EINVAL; in squashfs_fill_super()
449 err = -ENOMEM; in squashfs_fill_super()
461 sb->s_root = d_make_root(root); in squashfs_fill_super()
462 if (sb->s_root == NULL) { in squashfs_fill_super()
464 err = -ENOMEM; in squashfs_fill_super()
475 squashfs_cache_delete(msblk->block_cache); in squashfs_fill_super()
476 squashfs_cache_delete(msblk->fragment_cache); in squashfs_fill_super()
477 squashfs_cache_delete(msblk->read_page); in squashfs_fill_super()
478 if (msblk->cache_mapping) in squashfs_fill_super()
479 iput(msblk->cache_mapping->host); in squashfs_fill_super()
480 msblk->thread_ops->destroy(msblk); in squashfs_fill_super()
481 kfree(msblk->inode_lookup_table); in squashfs_fill_super()
482 kfree(msblk->fragment_index); in squashfs_fill_super()
483 kfree(msblk->id_table); in squashfs_fill_super()
484 kfree(msblk->xattr_id_table); in squashfs_fill_super()
485 kfree(sb->s_fs_info); in squashfs_fill_super()
486 sb->s_fs_info = NULL; in squashfs_fill_super()
498 struct super_block *sb = fc->root->d_sb; in squashfs_reconfigure()
499 struct squashfs_sb_info *msblk = sb->s_fs_info; in squashfs_reconfigure()
500 struct squashfs_mount_opts *opts = fc->fs_private; in squashfs_reconfigure()
502 sync_filesystem(fc->root->d_sb); in squashfs_reconfigure()
503 fc->sb_flags |= SB_RDONLY; in squashfs_reconfigure()
505 msblk->panic_on_errors = (opts->errors == Opt_errors_panic); in squashfs_reconfigure()
512 kfree(fc->fs_private); in squashfs_free_fs_context()
524 struct super_block *sb = root->d_sb; in squashfs_show_options()
525 struct squashfs_sb_info *msblk = sb->s_fs_info; in squashfs_show_options()
527 if (msblk->panic_on_errors) in squashfs_show_options()
533 if (msblk->thread_ops == &squashfs_decompressor_single) { in squashfs_show_options()
537 if (msblk->thread_ops == &squashfs_decompressor_percpu) { in squashfs_show_options()
543 seq_printf(s, ",threads=%d", msblk->max_thread_num); in squashfs_show_options()
554 return -ENOMEM; in squashfs_init_fs_context()
557 opts->thread_ops = &squashfs_decompressor_single; in squashfs_init_fs_context()
559 opts->thread_ops = &squashfs_decompressor_multi; in squashfs_init_fs_context()
561 opts->thread_ops = &squashfs_decompressor_percpu; in squashfs_init_fs_context()
565 opts->thread_num = 0; in squashfs_init_fs_context()
566 fc->fs_private = opts; in squashfs_init_fs_context()
567 fc->ops = &squashfs_context_ops; in squashfs_init_fs_context()
573 struct squashfs_sb_info *msblk = dentry->d_sb->s_fs_info; in squashfs_statfs()
574 u64 id = huge_encode_dev(dentry->d_sb->s_bdev->bd_dev); in squashfs_statfs()
578 buf->f_type = SQUASHFS_MAGIC; in squashfs_statfs()
579 buf->f_bsize = msblk->block_size; in squashfs_statfs()
580 buf->f_blocks = ((msblk->bytes_used - 1) >> msblk->block_log) + 1; in squashfs_statfs()
581 buf->f_bfree = buf->f_bavail = 0; in squashfs_statfs()
582 buf->f_files = msblk->inodes; in squashfs_statfs()
583 buf->f_ffree = 0; in squashfs_statfs()
584 buf->f_namelen = SQUASHFS_NAME_LEN; in squashfs_statfs()
585 buf->f_fsid = u64_to_fsid(id); in squashfs_statfs()
593 if (sb->s_fs_info) { in squashfs_put_super()
594 struct squashfs_sb_info *sbi = sb->s_fs_info; in squashfs_put_super()
595 squashfs_cache_delete(sbi->block_cache); in squashfs_put_super()
596 squashfs_cache_delete(sbi->fragment_cache); in squashfs_put_super()
597 squashfs_cache_delete(sbi->read_page); in squashfs_put_super()
598 if (sbi->cache_mapping) in squashfs_put_super()
599 iput(sbi->cache_mapping->host); in squashfs_put_super()
600 sbi->thread_ops->destroy(sbi); in squashfs_put_super()
601 kfree(sbi->id_table); in squashfs_put_super()
602 kfree(sbi->fragment_index); in squashfs_put_super()
603 kfree(sbi->meta_index); in squashfs_put_super()
604 kfree(sbi->inode_lookup_table); in squashfs_put_super()
605 kfree(sbi->xattr_id_table); in squashfs_put_super()
606 kfree(sb->s_fs_info); in squashfs_put_super()
607 sb->s_fs_info = NULL; in squashfs_put_super()
618 inode_init_once(&ei->vfs_inode); in init_once()
629 return squashfs_inode_cachep ? 0 : -ENOMEM; in init_inodecache()
675 return ei ? &ei->vfs_inode : NULL; in squashfs_alloc_inode()
704 MODULE_DESCRIPTION("squashfs 4.0, a compressed read-only filesystem");