Lines Matching full:sb

43 static void ext2_write_super(struct super_block *sb);
45 static int ext2_sync_fs(struct super_block *sb, int wait);
46 static int ext2_freeze(struct super_block *sb);
47 static int ext2_unfreeze(struct super_block *sb);
49 void ext2_error(struct super_block *sb, const char *function, in ext2_error() argument
54 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_error()
57 if (!sb_rdonly(sb)) { in ext2_error()
62 ext2_sync_super(sb, es, 1); in ext2_error()
71 sb->s_id, function, &vaf); in ext2_error()
75 if (test_opt(sb, ERRORS_PANIC)) in ext2_error()
77 if (!sb_rdonly(sb) && test_opt(sb, ERRORS_RO)) { in ext2_error()
78 ext2_msg(sb, KERN_CRIT, in ext2_error()
80 sb->s_flags |= SB_RDONLY; in ext2_error()
111 void ext2_msg(struct super_block *sb, const char *prefix, in ext2_msg() argument
122 printk("%sEXT2-fs (%s): %pV\n", prefix, sb->s_id, &vaf); in ext2_msg()
130 void ext2_update_dynamic_rev(struct super_block *sb) in ext2_update_dynamic_rev() argument
132 struct ext2_super_block *es = EXT2_SB(sb)->s_es; in ext2_update_dynamic_rev()
137 ext2_msg(sb, KERN_WARNING, in ext2_update_dynamic_rev()
156 static int ext2_quota_off(struct super_block *sb, int type);
158 static void ext2_quota_off_umount(struct super_block *sb) in ext2_quota_off_umount() argument
163 ext2_quota_off(sb, type); in ext2_quota_off_umount()
166 static inline void ext2_quota_off_umount(struct super_block *sb) in ext2_quota_off_umount() argument
171 static void ext2_put_super (struct super_block * sb) in ext2_put_super() argument
175 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_put_super()
177 ext2_quota_off_umount(sb); in ext2_put_super()
182 if (!sb_rdonly(sb)) { in ext2_put_super()
188 ext2_sync_super(sb, es, 1); in ext2_put_super()
199 sb->s_fs_info = NULL; in ext2_put_super()
207 static struct inode *ext2_alloc_inode(struct super_block *sb) in ext2_alloc_inode() argument
210 ei = alloc_inode_sb(sb, ext2_inode_cachep, GFP_KERNEL); in ext2_alloc_inode()
264 struct super_block *sb = root->d_sb; in ext2_show_options() local
265 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_show_options()
273 seq_printf(seq, ",sb=%lu", sbi->s_sb_block); in ext2_show_options()
274 if (test_opt(sb, MINIX_DF)) in ext2_show_options()
276 if (test_opt(sb, GRPID)) in ext2_show_options()
278 if (!test_opt(sb, GRPID) && (def_mount_opts & EXT2_DEFM_BSDGROUPS)) in ext2_show_options()
290 if (test_opt(sb, ERRORS_RO)) { in ext2_show_options()
298 if (test_opt(sb, ERRORS_CONT)) in ext2_show_options()
300 if (test_opt(sb, ERRORS_PANIC)) in ext2_show_options()
302 if (test_opt(sb, NO_UID32)) in ext2_show_options()
304 if (test_opt(sb, DEBUG)) in ext2_show_options()
306 if (test_opt(sb, OLDALLOC)) in ext2_show_options()
310 if (test_opt(sb, XATTR_USER)) in ext2_show_options()
312 if (!test_opt(sb, XATTR_USER) && in ext2_show_options()
319 if (test_opt(sb, POSIX_ACL)) in ext2_show_options()
321 if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT2_DEFM_ACL)) in ext2_show_options()
325 if (test_opt(sb, USRQUOTA)) in ext2_show_options()
328 if (test_opt(sb, GRPQUOTA)) in ext2_show_options()
331 if (test_opt(sb, XIP)) in ext2_show_options()
334 if (test_opt(sb, DAX)) in ext2_show_options()
337 if (!test_opt(sb, RESERVATION)) in ext2_show_options()
345 static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, size_t len, loff_t off…
346 static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *data, size_t len, lof…
347 static int ext2_quota_on(struct super_block *sb, int type, int format_id,
384 static struct inode *ext2_nfs_get_inode(struct super_block *sb, in ext2_nfs_get_inode() argument
389 if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO) in ext2_nfs_get_inode()
391 if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count)) in ext2_nfs_get_inode()
399 inode = ext2_iget(sb, ino); in ext2_nfs_get_inode()
410 static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid *fid, in ext2_fh_to_dentry() argument
413 return generic_fh_to_dentry(sb, fid, fh_len, fh_type, in ext2_fh_to_dentry()
417 static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid, in ext2_fh_to_parent() argument
420 return generic_fh_to_parent(sb, fid, fh_len, fh_type, in ext2_fh_to_parent()
454 fsparam_u32 ("sb", Opt_sb),
644 static int ext2_setup_super (struct super_block * sb, in ext2_setup_super() argument
649 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_setup_super()
652 ext2_msg(sb, KERN_ERR, in ext2_setup_super()
660 ext2_msg(sb, KERN_WARNING, in ext2_setup_super()
664 ext2_msg(sb, KERN_WARNING, in ext2_setup_super()
670 ext2_msg(sb, KERN_WARNING, in ext2_setup_super()
677 ext2_msg(sb, KERN_WARNING, in ext2_setup_super()
683 if (test_opt (sb, DEBUG)) in ext2_setup_super()
684 ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, gc=%lu, " in ext2_setup_super()
686 EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, in ext2_setup_super()
688 EXT2_BLOCKS_PER_GROUP(sb), in ext2_setup_super()
689 EXT2_INODES_PER_GROUP(sb), in ext2_setup_super()
694 static int ext2_check_descriptors(struct super_block *sb) in ext2_check_descriptors() argument
697 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_check_descriptors()
702 struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL); in ext2_check_descriptors()
703 ext2_fsblk_t first_block = ext2_group_first_block_no(sb, i); in ext2_check_descriptors()
704 ext2_fsblk_t last_block = ext2_group_last_block_no(sb, i); in ext2_check_descriptors()
709 ext2_error (sb, "ext2_check_descriptors", in ext2_check_descriptors()
718 ext2_error (sb, "ext2_check_descriptors", in ext2_check_descriptors()
728 ext2_error (sb, "ext2_check_descriptors", in ext2_check_descriptors()
800 static unsigned long descriptor_loc(struct super_block *sb, in descriptor_loc() argument
804 struct ext2_sb_info *sbi = EXT2_SB(sb); in descriptor_loc()
809 if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) || in descriptor_loc()
814 return ext2_group_first_block_no(sb, bg) + ext2_bg_has_super(sb, bg); in descriptor_loc()
876 static int ext2_fill_super(struct super_block *sb, struct fs_context *fc) in ext2_fill_super() argument
905 sb->s_fs_info = sbi; in ext2_fill_super()
907 sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->s_dax_part_off, in ext2_fill_super()
920 blocksize = sb_min_blocksize(sb, BLOCK_SIZE); in ext2_fill_super()
922 ext2_msg(sb, KERN_ERR, "error: unable to set blocksize"); in ext2_fill_super()
937 if (!(bh = sb_bread(sb, logic_sb_block))) { in ext2_fill_super()
938 ext2_msg(sb, KERN_ERR, "error: unable to read superblock"); in ext2_fill_super()
947 sb->s_magic = le16_to_cpu(es->s_magic); in ext2_fill_super()
949 if (sb->s_magic != EXT2_SUPER_MAGIC) in ext2_fill_super()
954 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext2_fill_super()
955 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); in ext2_fill_super()
956 sb->s_iflags |= SB_I_CGROUPWB; in ext2_fill_super()
959 (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) || in ext2_fill_super()
960 EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) || in ext2_fill_super()
961 EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U))) in ext2_fill_super()
962 ext2_msg(sb, KERN_WARNING, in ext2_fill_super()
970 features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP); in ext2_fill_super()
972 ext2_msg(sb, KERN_ERR, "error: couldn't mount because of " in ext2_fill_super()
977 if (!sb_rdonly(sb) && (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){ in ext2_fill_super()
978 ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of " in ext2_fill_super()
986 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
993 if (test_opt(sb, DAX)) { in ext2_fill_super()
995 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
999 ext2_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n"); in ext2_fill_super()
1005 if (sb->s_blocksize != blocksize) { in ext2_fill_super()
1008 if (!sb_set_blocksize(sb, blocksize)) { in ext2_fill_super()
1009 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1016 bh = sb_bread(sb, logic_sb_block); in ext2_fill_super()
1018 ext2_msg(sb, KERN_ERR, "error: couldn't read" in ext2_fill_super()
1025 ext2_msg(sb, KERN_ERR, "error: magic mismatch"); in ext2_fill_super()
1030 sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits); in ext2_fill_super()
1031 sb->s_max_links = EXT2_LINK_MAX; in ext2_fill_super()
1032 sb->s_time_min = S32_MIN; in ext2_fill_super()
1033 sb->s_time_max = S32_MAX; in ext2_fill_super()
1044 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1054 sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb); in ext2_fill_super()
1059 sbi->s_desc_per_block = sb->s_blocksize / in ext2_fill_super()
1064 ilog2 (EXT2_ADDR_PER_BLOCK(sb)); in ext2_fill_super()
1066 ilog2 (EXT2_DESC_PER_BLOCK(sb)); in ext2_fill_super()
1068 if (sb->s_magic != EXT2_SUPER_MAGIC) in ext2_fill_super()
1071 if (sb->s_blocksize != bh->b_size) { in ext2_fill_super()
1073 ext2_msg(sb, KERN_ERR, "error: unsupported blocksize"); in ext2_fill_super()
1078 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1080 le32_to_cpu(es->s_log_frag_size), sb->s_blocksize_bits); in ext2_fill_super()
1084 if (sbi->s_blocks_per_group > sb->s_blocksize * 8) { in ext2_fill_super()
1085 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1090 /* At least inode table, bitmaps, and sb have to fit in one group */ in ext2_fill_super()
1092 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1098 sbi->s_inodes_per_group > sb->s_blocksize * 8) { in ext2_fill_super()
1099 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1104 if (sb_bdev_nr_blocks(sb) < le32_to_cpu(es->s_blocks_count)) { in ext2_fill_super()
1105 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1108 (unsigned)sb_bdev_nr_blocks(sb)); in ext2_fill_super()
1114 / EXT2_BLOCKS_PER_GROUP(sb)) + 1; in ext2_fill_super()
1117 ext2_msg(sb, KERN_ERR, "error: invalid #inodes: %u vs computed %llu", in ext2_fill_super()
1122 db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / in ext2_fill_super()
1123 EXT2_DESC_PER_BLOCK(sb); in ext2_fill_super()
1129 ext2_msg(sb, KERN_ERR, "error: not enough memory"); in ext2_fill_super()
1136 ext2_msg(sb, KERN_ERR, "error: not enough memory"); in ext2_fill_super()
1140 block = descriptor_loc(sb, logic_sb_block, i); in ext2_fill_super()
1141 sbi->s_group_desc[i] = sb_bread(sb, block); in ext2_fill_super()
1145 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1150 if (!ext2_check_descriptors (sb)) { in ext2_fill_super()
1151 ext2_msg(sb, KERN_ERR, "group descriptors corrupted"); in ext2_fill_super()
1171 ext2_rsv_window_add(sb, &sbi->s_rsv_window_head); in ext2_fill_super()
1174 ext2_count_free_blocks(sb), GFP_KERNEL); in ext2_fill_super()
1177 ext2_count_free_inodes(sb), GFP_KERNEL); in ext2_fill_super()
1181 ext2_count_dirs(sb), GFP_KERNEL); in ext2_fill_super()
1185 ext2_msg(sb, KERN_ERR, "error: insufficient memory"); in ext2_fill_super()
1193 ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache"); in ext2_fill_super()
1200 sb->s_op = &ext2_sops; in ext2_fill_super()
1201 sb->s_export_op = &ext2_export_ops; in ext2_fill_super()
1202 sb->s_xattr = ext2_xattr_handlers; in ext2_fill_super()
1205 sb->dq_op = &dquot_operations; in ext2_fill_super()
1206 sb->s_qcop = &ext2_quotactl_ops; in ext2_fill_super()
1207 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP; in ext2_fill_super()
1210 root = ext2_iget(sb, EXT2_ROOT_INO); in ext2_fill_super()
1217 ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck"); in ext2_fill_super()
1221 sb->s_root = d_make_root(root); in ext2_fill_super()
1222 if (!sb->s_root) { in ext2_fill_super()
1223 ext2_msg(sb, KERN_ERR, "error: get root inode failed"); in ext2_fill_super()
1227 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) in ext2_fill_super()
1228 ext2_msg(sb, KERN_WARNING, in ext2_fill_super()
1230 if (ext2_setup_super (sb, es, sb_rdonly(sb))) in ext2_fill_super()
1231 sb->s_flags |= SB_RDONLY; in ext2_fill_super()
1232 ext2_write_super(sb); in ext2_fill_super()
1237 ext2_msg(sb, KERN_ERR, in ext2_fill_super()
1239 sb->s_id); in ext2_fill_super()
1256 sb->s_fs_info = NULL; in ext2_fill_super()
1262 static void ext2_clear_super_error(struct super_block *sb) in ext2_clear_super_error() argument
1264 struct buffer_head *sbh = EXT2_SB(sb)->s_sbh; in ext2_clear_super_error()
1275 ext2_msg(sb, KERN_ERR, in ext2_clear_super_error()
1282 void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es, in ext2_sync_super() argument
1285 ext2_clear_super_error(sb); in ext2_sync_super()
1286 spin_lock(&EXT2_SB(sb)->s_lock); in ext2_sync_super()
1287 es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); in ext2_sync_super()
1288 es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); in ext2_sync_super()
1291 spin_unlock(&EXT2_SB(sb)->s_lock); in ext2_sync_super()
1292 mark_buffer_dirty(EXT2_SB(sb)->s_sbh); in ext2_sync_super()
1294 sync_dirty_buffer(EXT2_SB(sb)->s_sbh); in ext2_sync_super()
1307 static int ext2_sync_fs(struct super_block *sb, int wait) in ext2_sync_fs() argument
1309 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_sync_fs()
1310 struct ext2_super_block *es = EXT2_SB(sb)->s_es; in ext2_sync_fs()
1316 dquot_writeback_dquots(sb, -1); in ext2_sync_fs()
1324 ext2_sync_super(sb, es, wait); in ext2_sync_fs()
1328 static int ext2_freeze(struct super_block *sb) in ext2_freeze() argument
1330 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_freeze()
1337 if (atomic_long_read(&sb->s_remove_count)) { in ext2_freeze()
1338 ext2_sync_fs(sb, 1); in ext2_freeze()
1345 ext2_sync_super(sb, sbi->s_es, 1); in ext2_freeze()
1350 static int ext2_unfreeze(struct super_block *sb) in ext2_unfreeze() argument
1352 /* Just write sb to clear EXT2_VALID_FS flag */ in ext2_unfreeze()
1353 ext2_write_super(sb); in ext2_unfreeze()
1358 static void ext2_write_super(struct super_block *sb) in ext2_write_super() argument
1360 if (!sb_rdonly(sb)) in ext2_write_super()
1361 ext2_sync_fs(sb, 1); in ext2_write_super()
1367 struct super_block *sb = fc->root->d_sb; in ext2_reconfigure() local
1368 struct ext2_sb_info * sbi = EXT2_SB(sb); in ext2_reconfigure()
1374 sync_filesystem(sb); in ext2_reconfigure()
1383 ext2_msg(sb, KERN_WARNING, "warning: refusing change of " in ext2_reconfigure()
1387 if ((bool)(flags & SB_RDONLY) == sb_rdonly(sb)) in ext2_reconfigure()
1402 err = dquot_suspend(sb, -1); in ext2_reconfigure()
1406 ext2_sync_super(sb, es, 1); in ext2_reconfigure()
1408 __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb, in ext2_reconfigure()
1412 ext2_msg(sb, KERN_WARNING, in ext2_reconfigure()
1424 if (!ext2_setup_super (sb, es, 0)) in ext2_reconfigure()
1425 sb->s_flags &= ~SB_RDONLY; in ext2_reconfigure()
1428 ext2_write_super(sb); in ext2_reconfigure()
1430 dquot_resume(sb, -1); in ext2_reconfigure()
1438 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext2_reconfigure()
1439 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); in ext2_reconfigure()
1447 struct super_block *sb = dentry->d_sb; in ext2_statfs() local
1448 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_statfs()
1453 if (test_opt (sb, MINIX_DF)) in ext2_statfs()
1477 overhead += ext2_bg_has_super(sb, i) + in ext2_statfs()
1478 ext2_bg_num_gdb(sb, i); in ext2_statfs()
1492 buf->f_bsize = sb->s_blocksize; in ext2_statfs()
1494 buf->f_bfree = ext2_count_free_blocks(sb); in ext2_statfs()
1500 buf->f_ffree = ext2_count_free_inodes(sb); in ext2_statfs()
1519 static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, in ext2_quota_read() argument
1522 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_read()
1523 sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb); in ext2_quota_read()
1525 int offset = off & (sb->s_blocksize - 1); in ext2_quota_read()
1538 tocopy = min_t(size_t, sb->s_blocksize - offset, toread); in ext2_quota_read()
1541 tmp_bh.b_size = sb->s_blocksize; in ext2_quota_read()
1548 bh = sb_bread(sb, tmp_bh.b_blocknr); in ext2_quota_read()
1563 static ssize_t ext2_quota_write(struct super_block *sb, int type, in ext2_quota_write() argument
1566 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_write()
1567 sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb); in ext2_quota_write()
1569 int offset = off & (sb->s_blocksize - 1); in ext2_quota_write()
1576 tocopy = min_t(size_t, sb->s_blocksize - offset, towrite); in ext2_quota_write()
1579 tmp_bh.b_size = sb->s_blocksize; in ext2_quota_write()
1583 if (offset || tocopy != EXT2_BLOCK_SIZE(sb)) in ext2_quota_write()
1584 bh = sb_bread(sb, tmp_bh.b_blocknr); in ext2_quota_write()
1586 bh = sb_getblk(sb, tmp_bh.b_blocknr); in ext2_quota_write()
1614 static int ext2_quota_on(struct super_block *sb, int type, int format_id, in ext2_quota_on() argument
1620 err = dquot_quota_on(sb, type, format_id, path); in ext2_quota_on()
1635 static int ext2_quota_off(struct super_block *sb, int type) in ext2_quota_off() argument
1637 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_off()
1643 err = dquot_quota_off(sb, type); in ext2_quota_off()
1656 return dquot_quota_off(sb, type); in ext2_quota_off()
1677 struct super_block *sb = fc->root->d_sb; in ext2_init_fs_context() local
1678 struct ext2_sb_info *sbi = EXT2_SB(sb); in ext2_init_fs_context()
1682 ctx->vals_s_flags = sb->s_flags; in ext2_init_fs_context()