super.c (47e4937a4a7ca4184fd282791dfee76c6799966a) | super.c (8d8a09b093d7073465c824f74caf315c073d3875) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2017-2018 HUAWEI, Inc. 4 * http://www.huawei.com/ 5 * Created by Gao Xiang <gaoxiang25@huawei.com> 6 */ 7#include <linux/module.h> 8#include <linux/buffer_head.h> --- 93 unchanged lines hidden (view full) --- 102 ret = -EINVAL; 103 if (le32_to_cpu(layout->magic) != EROFS_SUPER_MAGIC_V1) { 104 errln("cannot find valid erofs superblock"); 105 goto out; 106 } 107 108 blkszbits = layout->blkszbits; 109 /* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2017-2018 HUAWEI, Inc. 4 * http://www.huawei.com/ 5 * Created by Gao Xiang <gaoxiang25@huawei.com> 6 */ 7#include <linux/module.h> 8#include <linux/buffer_head.h> --- 93 unchanged lines hidden (view full) --- 102 ret = -EINVAL; 103 if (le32_to_cpu(layout->magic) != EROFS_SUPER_MAGIC_V1) { 104 errln("cannot find valid erofs superblock"); 105 goto out; 106 } 107 108 blkszbits = layout->blkszbits; 109 /* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ |
110 if (unlikely(blkszbits != LOG_BLOCK_SIZE)) { | 110 if (blkszbits != LOG_BLOCK_SIZE) { |
111 errln("blksize %u isn't supported on this platform", 112 1 << blkszbits); 113 goto out; 114 } 115 116 if (!check_layout_compatibility(sb, layout)) 117 goto out; 118 --- 255 unchanged lines hidden (view full) --- 374 .invalidatepage = managed_cache_invalidatepage, 375}; 376 377static int erofs_init_managed_cache(struct super_block *sb) 378{ 379 struct erofs_sb_info *const sbi = EROFS_SB(sb); 380 struct inode *const inode = new_inode(sb); 381 | 111 errln("blksize %u isn't supported on this platform", 112 1 << blkszbits); 113 goto out; 114 } 115 116 if (!check_layout_compatibility(sb, layout)) 117 goto out; 118 --- 255 unchanged lines hidden (view full) --- 374 .invalidatepage = managed_cache_invalidatepage, 375}; 376 377static int erofs_init_managed_cache(struct super_block *sb) 378{ 379 struct erofs_sb_info *const sbi = EROFS_SB(sb); 380 struct inode *const inode = new_inode(sb); 381 |
382 if (unlikely(!inode)) | 382 if (!inode) |
383 return -ENOMEM; 384 385 set_nlink(inode, 1); 386 inode->i_size = OFFSET_MAX; 387 388 inode->i_mapping->a_ops = &managed_cache_aops; 389 mapping_set_gfp_mask(inode->i_mapping, 390 GFP_NOFS | __GFP_HIGHMEM | __GFP_MOVABLE); --- 10 unchanged lines hidden (view full) --- 401 struct erofs_sb_info *sbi; 402 int err; 403 404 infoln("fill_super, device -> %s", sb->s_id); 405 infoln("options -> %s", (char *)data); 406 407 sb->s_magic = EROFS_SUPER_MAGIC; 408 | 383 return -ENOMEM; 384 385 set_nlink(inode, 1); 386 inode->i_size = OFFSET_MAX; 387 388 inode->i_mapping->a_ops = &managed_cache_aops; 389 mapping_set_gfp_mask(inode->i_mapping, 390 GFP_NOFS | __GFP_HIGHMEM | __GFP_MOVABLE); --- 10 unchanged lines hidden (view full) --- 401 struct erofs_sb_info *sbi; 402 int err; 403 404 infoln("fill_super, device -> %s", sb->s_id); 405 infoln("options -> %s", (char *)data); 406 407 sb->s_magic = EROFS_SUPER_MAGIC; 408 |
409 if (unlikely(!sb_set_blocksize(sb, EROFS_BLKSIZ))) { | 409 if (!sb_set_blocksize(sb, EROFS_BLKSIZ)) { |
410 errln("failed to set erofs blksize"); 411 return -EINVAL; 412 } 413 414 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 410 errln("failed to set erofs blksize"); 411 return -EINVAL; 412 } 413 414 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
415 if (unlikely(!sbi)) | 415 if (!sbi) |
416 return -ENOMEM; 417 418 sb->s_fs_info = sbi; 419 err = superblock_read(sb); 420 if (err) 421 return err; 422 423 sb->s_flags |= SB_RDONLY | SB_NOATIME; --- 4 unchanged lines hidden (view full) --- 428 429#ifdef CONFIG_EROFS_FS_XATTR 430 sb->s_xattr = erofs_xattr_handlers; 431#endif 432 /* set erofs default mount options */ 433 default_options(sbi); 434 435 err = parse_options(sb, data); | 416 return -ENOMEM; 417 418 sb->s_fs_info = sbi; 419 err = superblock_read(sb); 420 if (err) 421 return err; 422 423 sb->s_flags |= SB_RDONLY | SB_NOATIME; --- 4 unchanged lines hidden (view full) --- 428 429#ifdef CONFIG_EROFS_FS_XATTR 430 sb->s_xattr = erofs_xattr_handlers; 431#endif 432 /* set erofs default mount options */ 433 default_options(sbi); 434 435 err = parse_options(sb, data); |
436 if (unlikely(err)) | 436 if (err) |
437 return err; 438 439 if (!silent) 440 infoln("root inode @ nid %llu", ROOT_NID(sbi)); 441 442 if (test_opt(sbi, POSIX_ACL)) 443 sb->s_flags |= SB_POSIXACL; 444 else 445 sb->s_flags &= ~SB_POSIXACL; 446 447#ifdef CONFIG_EROFS_FS_ZIP 448 INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC); 449#endif 450 451 /* get the root inode */ 452 inode = erofs_iget(sb, ROOT_NID(sbi), true); 453 if (IS_ERR(inode)) 454 return PTR_ERR(inode); 455 | 437 return err; 438 439 if (!silent) 440 infoln("root inode @ nid %llu", ROOT_NID(sbi)); 441 442 if (test_opt(sbi, POSIX_ACL)) 443 sb->s_flags |= SB_POSIXACL; 444 else 445 sb->s_flags &= ~SB_POSIXACL; 446 447#ifdef CONFIG_EROFS_FS_ZIP 448 INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC); 449#endif 450 451 /* get the root inode */ 452 inode = erofs_iget(sb, ROOT_NID(sbi), true); 453 if (IS_ERR(inode)) 454 return PTR_ERR(inode); 455 |
456 if (unlikely(!S_ISDIR(inode->i_mode))) { | 456 if (!S_ISDIR(inode->i_mode)) { |
457 errln("rootino(nid %llu) is not a directory(i_mode %o)", 458 ROOT_NID(sbi), inode->i_mode); 459 iput(inode); 460 return -EINVAL; 461 } 462 463 sb->s_root = d_make_root(inode); | 457 errln("rootino(nid %llu) is not a directory(i_mode %o)", 458 ROOT_NID(sbi), inode->i_mode); 459 iput(inode); 460 return -EINVAL; 461 } 462 463 sb->s_root = d_make_root(inode); |
464 if (unlikely(!sb->s_root)) | 464 if (!sb->s_root) |
465 return -ENOMEM; 466 467 erofs_shrinker_register(sb); 468 /* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */ 469 err = erofs_init_managed_cache(sb); | 465 return -ENOMEM; 466 467 erofs_shrinker_register(sb); 468 /* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */ 469 err = erofs_init_managed_cache(sb); |
470 if (unlikely(err)) | 470 if (err) |
471 return err; 472 473 if (!silent) 474 infoln("mounted on %s with opts: %s.", sb->s_id, (char *)data); 475 return 0; 476} 477 478static struct dentry *erofs_mount(struct file_system_type *fs_type, int flags, --- 191 unchanged lines hidden --- | 471 return err; 472 473 if (!silent) 474 infoln("mounted on %s with opts: %s.", sb->s_id, (char *)data); 475 return 0; 476} 477 478static struct dentry *erofs_mount(struct file_system_type *fs_type, int flags, --- 191 unchanged lines hidden --- |