Lines Matching refs:sb

39 static void ext2_sync_super(struct super_block *sb,
41 static int ext2_remount (struct super_block * sb, int * flags, char * data);
43 static int ext2_sync_fs(struct super_block *sb, int wait);
44 static int ext2_freeze(struct super_block *sb);
45 static int ext2_unfreeze(struct super_block *sb);
47 void ext2_error(struct super_block *sb, const char *function, in ext2_error() argument
52 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_error()
55 if (!(sb->s_flags & MS_RDONLY)) { in ext2_error()
60 ext2_sync_super(sb, es, 1); in ext2_error()
69 sb->s_id, function, &vaf); in ext2_error()
73 if (test_opt(sb, ERRORS_PANIC)) in ext2_error()
75 if (test_opt(sb, ERRORS_RO)) { in ext2_error()
76 ext2_msg(sb, KERN_CRIT, in ext2_error()
78 sb->s_flags |= MS_RDONLY; in ext2_error()
82 void ext2_msg(struct super_block *sb, const char *prefix, in ext2_msg() argument
93 printk("%sEXT2-fs (%s): %pV\n", prefix, sb->s_id, &vaf); in ext2_msg()
101 void ext2_update_dynamic_rev(struct super_block *sb) in ext2_update_dynamic_rev() argument
103 struct ext2_super_block *es = EXT2_SB(sb)->s_es; in ext2_update_dynamic_rev()
108 ext2_msg(sb, KERN_WARNING, in ext2_update_dynamic_rev()
126 static void ext2_put_super (struct super_block * sb) in ext2_put_super() argument
130 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_put_super()
132 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); in ext2_put_super()
134 ext2_xattr_put_super(sb); in ext2_put_super()
135 if (!(sb->s_flags & MS_RDONLY)) { in ext2_put_super()
141 ext2_sync_super(sb, es, 1); in ext2_put_super()
153 sb->s_fs_info = NULL; in ext2_put_super()
160 static struct inode *ext2_alloc_inode(struct super_block *sb) in ext2_alloc_inode() argument
222 struct super_block *sb = root->d_sb; in ext2_show_options() local
223 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_show_options()
232 if (test_opt(sb, MINIX_DF)) in ext2_show_options()
234 if (test_opt(sb, GRPID)) in ext2_show_options()
236 if (!test_opt(sb, GRPID) && (def_mount_opts & EXT2_DEFM_BSDGROUPS)) in ext2_show_options()
248 if (test_opt(sb, ERRORS_RO)) { in ext2_show_options()
256 if (test_opt(sb, ERRORS_CONT)) in ext2_show_options()
258 if (test_opt(sb, ERRORS_PANIC)) in ext2_show_options()
260 if (test_opt(sb, NO_UID32)) in ext2_show_options()
262 if (test_opt(sb, DEBUG)) in ext2_show_options()
264 if (test_opt(sb, OLDALLOC)) in ext2_show_options()
268 if (test_opt(sb, XATTR_USER)) in ext2_show_options()
270 if (!test_opt(sb, XATTR_USER) && in ext2_show_options()
277 if (test_opt(sb, POSIX_ACL)) in ext2_show_options()
279 if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT2_DEFM_ACL)) in ext2_show_options()
283 if (test_opt(sb, NOBH)) in ext2_show_options()
301 if (!test_opt(sb, RESERVATION)) in ext2_show_options()
309 static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, size_t len, loff_t off…
310 static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *data, size_t len, lof…
336 static struct inode *ext2_nfs_get_inode(struct super_block *sb, in ext2_nfs_get_inode() argument
341 if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO) in ext2_nfs_get_inode()
343 if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count)) in ext2_nfs_get_inode()
351 inode = ext2_iget(sb, ino); in ext2_nfs_get_inode()
362 static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid *fid, in ext2_fh_to_dentry() argument
365 return generic_fh_to_dentry(sb, fid, fh_len, fh_type, in ext2_fh_to_dentry()
369 static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid, in ext2_fh_to_parent() argument
372 return generic_fh_to_parent(sb, fid, fh_len, fh_type, in ext2_fh_to_parent()
446 static int parse_options(char *options, struct super_block *sb) in parse_options() argument
449 struct ext2_sb_info *sbi = EXT2_SB(sb); in parse_options()
482 ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option); in parse_options()
493 ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option); in parse_options()
545 ext2_msg(sb, KERN_INFO, "(no)user_xattr options" in parse_options()
559 ext2_msg(sb, KERN_INFO, in parse_options()
564 ext2_msg(sb, KERN_INFO, "use dax instead of xip"); in parse_options()
571 ext2_msg(sb, KERN_INFO, "dax option not supported"); in parse_options()
588 ext2_msg(sb, KERN_INFO, in parse_options()
595 ext2_msg(sb, KERN_INFO, "reservations ON"); in parse_options()
599 ext2_msg(sb, KERN_INFO, "reservations OFF"); in parse_options()
610 static int ext2_setup_super (struct super_block * sb, in ext2_setup_super() argument
615 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_setup_super()
618 ext2_msg(sb, KERN_ERR, in ext2_setup_super()
626 ext2_msg(sb, KERN_WARNING, in ext2_setup_super()
630 ext2_msg(sb, KERN_WARNING, in ext2_setup_super()
636 ext2_msg(sb, KERN_WARNING, in ext2_setup_super()
642 ext2_msg(sb, KERN_WARNING, in ext2_setup_super()
648 if (test_opt (sb, DEBUG)) in ext2_setup_super()
649 ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, " in ext2_setup_super()
651 EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, in ext2_setup_super()
654 EXT2_BLOCKS_PER_GROUP(sb), in ext2_setup_super()
655 EXT2_INODES_PER_GROUP(sb), in ext2_setup_super()
660 static int ext2_check_descriptors(struct super_block *sb) in ext2_check_descriptors() argument
663 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_check_descriptors()
668 struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL); in ext2_check_descriptors()
669 ext2_fsblk_t first_block = ext2_group_first_block_no(sb, i); in ext2_check_descriptors()
676 (EXT2_BLOCKS_PER_GROUP(sb) - 1); in ext2_check_descriptors()
681 ext2_error (sb, "ext2_check_descriptors", in ext2_check_descriptors()
690 ext2_error (sb, "ext2_check_descriptors", in ext2_check_descriptors()
700 ext2_error (sb, "ext2_check_descriptors", in ext2_check_descriptors()
757 static unsigned long descriptor_loc(struct super_block *sb, in descriptor_loc() argument
761 struct ext2_sb_info *sbi = EXT2_SB(sb); in descriptor_loc()
767 if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) || in descriptor_loc()
771 if (ext2_bg_has_super(sb, bg)) in descriptor_loc()
774 return ext2_group_first_block_no(sb, bg) + has_super; in descriptor_loc()
777 static int ext2_fill_super(struct super_block *sb, void *data, int silent) in ext2_fill_super() argument
806 sb->s_fs_info = sbi; in ext2_fill_super()
818 blocksize = sb_min_blocksize(sb, BLOCK_SIZE); in ext2_fill_super()
820 ext2_msg(sb, KERN_ERR, "error: unable to set blocksize"); in ext2_fill_super()
835 if (!(bh = sb_bread(sb, logic_sb_block))) { in ext2_fill_super()
836 ext2_msg(sb, KERN_ERR, "error: unable to read superblock"); in ext2_fill_super()
845 sb->s_magic = le16_to_cpu(es->s_magic); in ext2_fill_super()
847 if (sb->s_magic != EXT2_SUPER_MAGIC) in ext2_fill_super()
879 if (!parse_options((char *) data, sb)) in ext2_fill_super()
882 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | in ext2_fill_super()
883 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? in ext2_fill_super()
887 (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) || in ext2_fill_super()
888 EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) || in ext2_fill_super()
889 EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U))) in ext2_fill_super()
890 ext2_msg(sb, KERN_WARNING, in ext2_fill_super()
898 features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP); in ext2_fill_super()
900 ext2_msg(sb, KERN_ERR, "error: couldn't mount because of " in ext2_fill_super()
905 if (!(sb->s_flags & MS_RDONLY) && in ext2_fill_super()
906 (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){ in ext2_fill_super()
907 ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of " in ext2_fill_super()
917 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
921 if (!sb->s_bdev->bd_disk->fops->direct_access) { in ext2_fill_super()
922 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
929 if (sb->s_blocksize != blocksize) { in ext2_fill_super()
932 if (!sb_set_blocksize(sb, blocksize)) { in ext2_fill_super()
933 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
940 bh = sb_bread(sb, logic_sb_block); in ext2_fill_super()
942 ext2_msg(sb, KERN_ERR, "error: couldn't read" in ext2_fill_super()
949 ext2_msg(sb, KERN_ERR, "error: magic mismatch"); in ext2_fill_super()
954 sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits); in ext2_fill_super()
955 sb->s_max_links = EXT2_LINK_MAX; in ext2_fill_super()
966 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
977 sbi->s_frags_per_block = sb->s_blocksize / sbi->s_frag_size; in ext2_fill_super()
983 if (EXT2_INODE_SIZE(sb) == 0) in ext2_fill_super()
985 sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb); in ext2_fill_super()
990 sbi->s_desc_per_block = sb->s_blocksize / in ext2_fill_super()
995 ilog2 (EXT2_ADDR_PER_BLOCK(sb)); in ext2_fill_super()
997 ilog2 (EXT2_DESC_PER_BLOCK(sb)); in ext2_fill_super()
999 if (sb->s_magic != EXT2_SUPER_MAGIC) in ext2_fill_super()
1002 if (sb->s_blocksize != bh->b_size) { in ext2_fill_super()
1004 ext2_msg(sb, KERN_ERR, "error: unsupported blocksize"); in ext2_fill_super()
1008 if (sb->s_blocksize != sbi->s_frag_size) { in ext2_fill_super()
1009 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1012 sbi->s_frag_size, sb->s_blocksize); in ext2_fill_super()
1016 if (sbi->s_blocks_per_group > sb->s_blocksize * 8) { in ext2_fill_super()
1017 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1022 if (sbi->s_frags_per_group > sb->s_blocksize * 8) { in ext2_fill_super()
1023 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1028 if (sbi->s_inodes_per_group > sb->s_blocksize * 8) { in ext2_fill_super()
1029 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1035 if (EXT2_BLOCKS_PER_GROUP(sb) == 0) in ext2_fill_super()
1039 / EXT2_BLOCKS_PER_GROUP(sb)) + 1; in ext2_fill_super()
1040 db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / in ext2_fill_super()
1041 EXT2_DESC_PER_BLOCK(sb); in ext2_fill_super()
1044 ext2_msg(sb, KERN_ERR, "error: not enough memory"); in ext2_fill_super()
1050 ext2_msg(sb, KERN_ERR, "error: not enough memory"); in ext2_fill_super()
1054 block = descriptor_loc(sb, logic_sb_block, i); in ext2_fill_super()
1055 sbi->s_group_desc[i] = sb_bread(sb, block); in ext2_fill_super()
1059 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1064 if (!ext2_check_descriptors (sb)) { in ext2_fill_super()
1065 ext2_msg(sb, KERN_ERR, "group descriptors corrupted"); in ext2_fill_super()
1085 ext2_rsv_window_add(sb, &sbi->s_rsv_window_head); in ext2_fill_super()
1088 ext2_count_free_blocks(sb), GFP_KERNEL); in ext2_fill_super()
1091 ext2_count_free_inodes(sb), GFP_KERNEL); in ext2_fill_super()
1095 ext2_count_dirs(sb), GFP_KERNEL); in ext2_fill_super()
1098 ext2_msg(sb, KERN_ERR, "error: insufficient memory"); in ext2_fill_super()
1104 sb->s_op = &ext2_sops; in ext2_fill_super()
1105 sb->s_export_op = &ext2_export_ops; in ext2_fill_super()
1106 sb->s_xattr = ext2_xattr_handlers; in ext2_fill_super()
1109 sb->dq_op = &dquot_operations; in ext2_fill_super()
1110 sb->s_qcop = &dquot_quotactl_ops; in ext2_fill_super()
1111 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP; in ext2_fill_super()
1114 root = ext2_iget(sb, EXT2_ROOT_INO); in ext2_fill_super()
1121 ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck"); in ext2_fill_super()
1125 sb->s_root = d_make_root(root); in ext2_fill_super()
1126 if (!sb->s_root) { in ext2_fill_super()
1127 ext2_msg(sb, KERN_ERR, "error: get root inode failed"); in ext2_fill_super()
1131 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) in ext2_fill_super()
1132 ext2_msg(sb, KERN_WARNING, in ext2_fill_super()
1134 if (ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY)) in ext2_fill_super()
1135 sb->s_flags |= MS_RDONLY; in ext2_fill_super()
1136 ext2_write_super(sb); in ext2_fill_super()
1141 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1143 sb->s_id); in ext2_fill_super()
1158 sb->s_fs_info = NULL; in ext2_fill_super()
1165 static void ext2_clear_super_error(struct super_block *sb) in ext2_clear_super_error() argument
1167 struct buffer_head *sbh = EXT2_SB(sb)->s_sbh; in ext2_clear_super_error()
1178 ext2_msg(sb, KERN_ERR, in ext2_clear_super_error()
1185 static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es, in ext2_sync_super() argument
1188 ext2_clear_super_error(sb); in ext2_sync_super()
1189 spin_lock(&EXT2_SB(sb)->s_lock); in ext2_sync_super()
1190 es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); in ext2_sync_super()
1191 es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); in ext2_sync_super()
1194 spin_unlock(&EXT2_SB(sb)->s_lock); in ext2_sync_super()
1195 mark_buffer_dirty(EXT2_SB(sb)->s_sbh); in ext2_sync_super()
1197 sync_dirty_buffer(EXT2_SB(sb)->s_sbh); in ext2_sync_super()
1210 static int ext2_sync_fs(struct super_block *sb, int wait) in ext2_sync_fs() argument
1212 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_sync_fs()
1213 struct ext2_super_block *es = EXT2_SB(sb)->s_es; in ext2_sync_fs()
1219 dquot_writeback_dquots(sb, -1); in ext2_sync_fs()
1227 ext2_sync_super(sb, es, wait); in ext2_sync_fs()
1231 static int ext2_freeze(struct super_block *sb) in ext2_freeze() argument
1233 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_freeze()
1240 if (atomic_long_read(&sb->s_remove_count)) { in ext2_freeze()
1241 ext2_sync_fs(sb, 1); in ext2_freeze()
1248 ext2_sync_super(sb, sbi->s_es, 1); in ext2_freeze()
1253 static int ext2_unfreeze(struct super_block *sb) in ext2_unfreeze() argument
1256 ext2_write_super(sb); in ext2_unfreeze()
1261 void ext2_write_super(struct super_block *sb) in ext2_write_super() argument
1263 if (!(sb->s_flags & MS_RDONLY)) in ext2_write_super()
1264 ext2_sync_fs(sb, 1); in ext2_write_super()
1267 static int ext2_remount (struct super_block * sb, int * flags, char * data) in ext2_remount() argument
1269 struct ext2_sb_info * sbi = EXT2_SB(sb); in ext2_remount()
1275 sync_filesystem(sb); in ext2_remount()
1279 old_sb_flags = sb->s_flags; in ext2_remount()
1287 if (!parse_options(data, sb)) { in ext2_remount()
1292 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | in ext2_remount()
1297 ext2_msg(sb, KERN_WARNING, "warning: refusing change of " in ext2_remount()
1301 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { in ext2_remount()
1320 err = dquot_suspend(sb, -1); in ext2_remount()
1326 ext2_sync_super(sb, es, 1); in ext2_remount()
1328 __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb, in ext2_remount()
1331 ext2_msg(sb, KERN_WARNING, in ext2_remount()
1344 if (!ext2_setup_super (sb, es, 0)) in ext2_remount()
1345 sb->s_flags &= ~MS_RDONLY; in ext2_remount()
1348 ext2_write_super(sb); in ext2_remount()
1350 dquot_resume(sb, -1); in ext2_remount()
1358 sb->s_flags = old_sb_flags; in ext2_remount()
1365 struct super_block *sb = dentry->d_sb; in ext2_statfs() local
1366 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_statfs()
1372 if (test_opt (sb, MINIX_DF)) in ext2_statfs()
1396 overhead += ext2_bg_has_super(sb, i) + in ext2_statfs()
1397 ext2_bg_num_gdb(sb, i); in ext2_statfs()
1411 buf->f_bsize = sb->s_blocksize; in ext2_statfs()
1413 buf->f_bfree = ext2_count_free_blocks(sb); in ext2_statfs()
1419 buf->f_ffree = ext2_count_free_inodes(sb); in ext2_statfs()
1442 static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, in ext2_quota_read() argument
1445 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_read()
1446 sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb); in ext2_quota_read()
1448 int offset = off & (sb->s_blocksize - 1); in ext2_quota_read()
1461 tocopy = sb->s_blocksize - offset < toread ? in ext2_quota_read()
1462 sb->s_blocksize - offset : toread; in ext2_quota_read()
1465 tmp_bh.b_size = sb->s_blocksize; in ext2_quota_read()
1472 bh = sb_bread(sb, tmp_bh.b_blocknr); in ext2_quota_read()
1487 static ssize_t ext2_quota_write(struct super_block *sb, int type, in ext2_quota_write() argument
1490 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_write()
1491 sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb); in ext2_quota_write()
1493 int offset = off & (sb->s_blocksize - 1); in ext2_quota_write()
1500 tocopy = sb->s_blocksize - offset < towrite ? in ext2_quota_write()
1501 sb->s_blocksize - offset : towrite; in ext2_quota_write()
1504 tmp_bh.b_size = sb->s_blocksize; in ext2_quota_write()
1508 if (offset || tocopy != EXT2_BLOCK_SIZE(sb)) in ext2_quota_write()
1509 bh = sb_bread(sb, tmp_bh.b_blocknr); in ext2_quota_write()
1511 bh = sb_getblk(sb, tmp_bh.b_blocknr); in ext2_quota_write()