Lines Matching defs:sb

42 static void ext2_write_super(struct super_block *sb);
43 static int ext2_remount (struct super_block * sb, int * flags, char * data);
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,
54 struct ext2_sb_info *sbi = EXT2_SB(sb);
57 if (!sb_rdonly(sb)) {
62 ext2_sync_super(sb, es, 1);
71 sb->s_id, function, &vaf);
75 if (test_opt(sb, ERRORS_PANIC))
77 if (!sb_rdonly(sb) && test_opt(sb, ERRORS_RO)) {
78 ext2_msg(sb, KERN_CRIT,
80 sb->s_flags |= SB_RDONLY;
84 void ext2_msg(struct super_block *sb, const char *prefix,
95 printk("%sEXT2-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
103 void ext2_update_dynamic_rev(struct super_block *sb)
105 struct ext2_super_block *es = EXT2_SB(sb)->s_es;
110 ext2_msg(sb, KERN_WARNING,
129 static int ext2_quota_off(struct super_block *sb, int type);
131 static void ext2_quota_off_umount(struct super_block *sb)
136 ext2_quota_off(sb, type);
139 static inline void ext2_quota_off_umount(struct super_block *sb)
144 static void ext2_put_super (struct super_block * sb)
148 struct ext2_sb_info *sbi = EXT2_SB(sb);
150 ext2_quota_off_umount(sb);
155 if (!sb_rdonly(sb)) {
161 ext2_sync_super(sb, es, 1);
172 sb->s_fs_info = NULL;
180 static struct inode *ext2_alloc_inode(struct super_block *sb)
183 ei = alloc_inode_sb(sb, ext2_inode_cachep, GFP_KERNEL);
237 struct super_block *sb = root->d_sb;
238 struct ext2_sb_info *sbi = EXT2_SB(sb);
246 seq_printf(seq, ",sb=%lu", sbi->s_sb_block);
247 if (test_opt(sb, MINIX_DF))
249 if (test_opt(sb, GRPID))
251 if (!test_opt(sb, GRPID) && (def_mount_opts & EXT2_DEFM_BSDGROUPS))
263 if (test_opt(sb, ERRORS_RO)) {
271 if (test_opt(sb, ERRORS_CONT))
273 if (test_opt(sb, ERRORS_PANIC))
275 if (test_opt(sb, NO_UID32))
277 if (test_opt(sb, DEBUG))
279 if (test_opt(sb, OLDALLOC))
283 if (test_opt(sb, XATTR_USER))
285 if (!test_opt(sb, XATTR_USER) &&
292 if (test_opt(sb, POSIX_ACL))
294 if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT2_DEFM_ACL))
298 if (test_opt(sb, USRQUOTA))
301 if (test_opt(sb, GRPQUOTA))
304 if (test_opt(sb, XIP))
307 if (test_opt(sb, DAX))
310 if (!test_opt(sb, RESERVATION))
318 static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, size_t len, loff_t off);
319 static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *data, size_t len, loff_t off);
320 static int ext2_quota_on(struct super_block *sb, int type, int format_id,
358 static struct inode *ext2_nfs_get_inode(struct super_block *sb,
363 if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO)
365 if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count))
373 inode = ext2_iget(sb, ino);
384 static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid *fid,
387 return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
391 static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid,
394 return generic_fh_to_parent(sb, fid, fh_len, fh_type,
410 if (!options || strncmp(options, "sb=", 3) != 0)
415 printk("EXT2-fs: Invalid sb specification: %s\n",
443 {Opt_sb, "sb=%u"},
467 static int parse_options(char *options, struct super_block *sb,
503 ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option);
514 ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option);
551 ext2_msg(sb, KERN_INFO,
564 ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
578 ext2_msg(sb, KERN_INFO,
583 ext2_msg(sb, KERN_INFO, "use dax instead of xip");
588 ext2_msg(sb, KERN_WARNING,
592 ext2_msg(sb, KERN_INFO, "dax option not supported");
609 ext2_msg(sb, KERN_INFO,
616 ext2_msg(sb, KERN_INFO, "reservations ON");
620 ext2_msg(sb, KERN_INFO, "reservations OFF");
631 static int ext2_setup_super (struct super_block * sb,
636 struct ext2_sb_info *sbi = EXT2_SB(sb);
639 ext2_msg(sb, KERN_ERR,
647 ext2_msg(sb, KERN_WARNING,
651 ext2_msg(sb, KERN_WARNING,
657 ext2_msg(sb, KERN_WARNING,
664 ext2_msg(sb, KERN_WARNING,
670 if (test_opt (sb, DEBUG))
671 ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, gc=%lu, "
673 EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
675 EXT2_BLOCKS_PER_GROUP(sb),
676 EXT2_INODES_PER_GROUP(sb),
681 static int ext2_check_descriptors(struct super_block *sb)
684 struct ext2_sb_info *sbi = EXT2_SB(sb);
689 struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL);
690 ext2_fsblk_t first_block = ext2_group_first_block_no(sb, i);
691 ext2_fsblk_t last_block = ext2_group_last_block_no(sb, i);
696 ext2_error (sb, "ext2_check_descriptors",
705 ext2_error (sb, "ext2_check_descriptors",
715 ext2_error (sb, "ext2_check_descriptors",
787 static unsigned long descriptor_loc(struct super_block *sb,
791 struct ext2_sb_info *sbi = EXT2_SB(sb);
796 if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) ||
801 return ext2_group_first_block_no(sb, bg) + ext2_bg_has_super(sb, bg);
804 static int ext2_fill_super(struct super_block *sb, void *data, int silent)
833 sb->s_fs_info = sbi;
835 sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->s_dax_part_off,
848 blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
850 ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
865 if (!(bh = sb_bread(sb, logic_sb_block))) {
866 ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
875 sb->s_magic = le16_to_cpu(es->s_magic);
877 if (sb->s_magic != EXT2_SUPER_MAGIC)
910 if (!parse_options((char *) data, sb, &opts))
917 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
918 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
919 sb->s_iflags |= SB_I_CGROUPWB;
922 (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
923 EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
924 EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
925 ext2_msg(sb, KERN_WARNING,
933 features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
935 ext2_msg(sb, KERN_ERR, "error: couldn't mount because of "
940 if (!sb_rdonly(sb) && (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
941 ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
949 ext2_msg(sb, KERN_ERR,
956 if (test_opt(sb, DAX)) {
958 ext2_msg(sb, KERN_ERR,
962 ext2_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n");
968 if (sb->s_blocksize != blocksize) {
971 if (!sb_set_blocksize(sb, blocksize)) {
972 ext2_msg(sb, KERN_ERR,
979 bh = sb_bread(sb, logic_sb_block);
981 ext2_msg(sb, KERN_ERR, "error: couldn't read"
988 ext2_msg(sb, KERN_ERR, "error: magic mismatch");
993 sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits);
994 sb->s_max_links = EXT2_LINK_MAX;
995 sb->s_time_min = S32_MIN;
996 sb->s_time_max = S32_MAX;
1007 ext2_msg(sb, KERN_ERR,
1017 sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb);
1022 sbi->s_desc_per_block = sb->s_blocksize /
1027 ilog2 (EXT2_ADDR_PER_BLOCK(sb));
1029 ilog2 (EXT2_DESC_PER_BLOCK(sb));
1031 if (sb->s_magic != EXT2_SUPER_MAGIC)
1034 if (sb->s_blocksize != bh->b_size) {
1036 ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
1041 ext2_msg(sb, KERN_ERR,
1043 le32_to_cpu(es->s_log_frag_size), sb->s_blocksize_bits);
1047 if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
1048 ext2_msg(sb, KERN_ERR,
1053 /* At least inode table, bitmaps, and sb have to fit in one group */
1055 ext2_msg(sb, KERN_ERR,
1061 sbi->s_inodes_per_group > sb->s_blocksize * 8) {
1062 ext2_msg(sb, KERN_ERR,
1067 if (sb_bdev_nr_blocks(sb) < le32_to_cpu(es->s_blocks_count)) {
1068 ext2_msg(sb, KERN_ERR,
1071 (unsigned)sb_bdev_nr_blocks(sb));
1077 / EXT2_BLOCKS_PER_GROUP(sb)) + 1;
1080 ext2_msg(sb, KERN_ERR, "error: invalid #inodes: %u vs computed %llu",
1085 db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
1086 EXT2_DESC_PER_BLOCK(sb);
1092 ext2_msg(sb, KERN_ERR, "error: not enough memory");
1099 ext2_msg(sb, KERN_ERR, "error: not enough memory");
1103 block = descriptor_loc(sb, logic_sb_block, i);
1104 sbi->s_group_desc[i] = sb_bread(sb, block);
1108 ext2_msg(sb, KERN_ERR,
1113 if (!ext2_check_descriptors (sb)) {
1114 ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
1134 ext2_rsv_window_add(sb, &sbi->s_rsv_window_head);
1137 ext2_count_free_blocks(sb), GFP_KERNEL);
1140 ext2_count_free_inodes(sb), GFP_KERNEL);
1144 ext2_count_dirs(sb), GFP_KERNEL);
1148 ext2_msg(sb, KERN_ERR, "error: insufficient memory");
1156 ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
1163 sb->s_op = &ext2_sops;
1164 sb->s_export_op = &ext2_export_ops;
1165 sb->s_xattr = ext2_xattr_handlers;
1168 sb->dq_op = &dquot_operations;
1169 sb->s_qcop = &ext2_quotactl_ops;
1170 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
1173 root = ext2_iget(sb, EXT2_ROOT_INO);
1180 ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
1184 sb->s_root = d_make_root(root);
1185 if (!sb->s_root) {
1186 ext2_msg(sb, KERN_ERR, "error: get root inode failed");
1190 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
1191 ext2_msg(sb, KERN_WARNING,
1193 if (ext2_setup_super (sb, es, sb_rdonly(sb)))
1194 sb->s_flags |= SB_RDONLY;
1195 ext2_write_super(sb);
1200 ext2_msg(sb, KERN_ERR,
1202 sb->s_id);
1219 sb->s_fs_info = NULL;
1225 static void ext2_clear_super_error(struct super_block *sb)
1227 struct buffer_head *sbh = EXT2_SB(sb)->s_sbh;
1238 ext2_msg(sb, KERN_ERR,
1245 void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es,
1248 ext2_clear_super_error(sb);
1249 spin_lock(&EXT2_SB(sb)->s_lock);
1250 es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb));
1251 es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb));
1254 spin_unlock(&EXT2_SB(sb)->s_lock);
1255 mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
1257 sync_dirty_buffer(EXT2_SB(sb)->s_sbh);
1270 static int ext2_sync_fs(struct super_block *sb, int wait)
1272 struct ext2_sb_info *sbi = EXT2_SB(sb);
1273 struct ext2_super_block *es = EXT2_SB(sb)->s_es;
1279 dquot_writeback_dquots(sb, -1);
1287 ext2_sync_super(sb, es, wait);
1291 static int ext2_freeze(struct super_block *sb)
1293 struct ext2_sb_info *sbi = EXT2_SB(sb);
1300 if (atomic_long_read(&sb->s_remove_count)) {
1301 ext2_sync_fs(sb, 1);
1308 ext2_sync_super(sb, sbi->s_es, 1);
1313 static int ext2_unfreeze(struct super_block *sb)
1315 /* Just write sb to clear EXT2_VALID_FS flag */
1316 ext2_write_super(sb);
1321 static void ext2_write_super(struct super_block *sb)
1323 if (!sb_rdonly(sb))
1324 ext2_sync_fs(sb, 1);
1327 static int ext2_remount (struct super_block * sb, int * flags, char * data)
1329 struct ext2_sb_info * sbi = EXT2_SB(sb);
1334 sync_filesystem(sb);
1342 if (!parse_options(data, sb, &new_opts))
1348 ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
1352 if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb))
1367 err = dquot_suspend(sb, -1);
1371 ext2_sync_super(sb, es, 1);
1373 __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
1377 ext2_msg(sb, KERN_WARNING,
1389 if (!ext2_setup_super (sb, es, 0))
1390 sb->s_flags &= ~SB_RDONLY;
1393 ext2_write_super(sb);
1395 dquot_resume(sb, -1);
1403 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
1404 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
1412 struct super_block *sb = dentry->d_sb;
1413 struct ext2_sb_info *sbi = EXT2_SB(sb);
1418 if (test_opt (sb, MINIX_DF))
1442 overhead += ext2_bg_has_super(sb, i) +
1443 ext2_bg_num_gdb(sb, i);
1457 buf->f_bsize = sb->s_blocksize;
1459 buf->f_bfree = ext2_count_free_blocks(sb);
1465 buf->f_ffree = ext2_count_free_inodes(sb);
1485 static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data,
1488 struct inode *inode = sb_dqopt(sb)->files[type];
1489 sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb);
1491 int offset = off & (sb->s_blocksize - 1);
1504 tocopy = min_t(size_t, sb->s_blocksize - offset, toread);
1507 tmp_bh.b_size = sb->s_blocksize;
1514 bh = sb_bread(sb, tmp_bh.b_blocknr);
1529 static ssize_t ext2_quota_write(struct super_block *sb, int type,
1532 struct inode *inode = sb_dqopt(sb)->files[type];
1533 sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb);
1535 int offset = off & (sb->s_blocksize - 1);
1542 tocopy = min_t(size_t, sb->s_blocksize - offset, towrite);
1545 tmp_bh.b_size = sb->s_blocksize;
1549 if (offset || tocopy != EXT2_BLOCK_SIZE(sb))
1550 bh = sb_bread(sb, tmp_bh.b_blocknr);
1552 bh = sb_getblk(sb, tmp_bh.b_blocknr);
1580 static int ext2_quota_on(struct super_block *sb, int type, int format_id,
1586 err = dquot_quota_on(sb, type, format_id, path);
1601 static int ext2_quota_off(struct super_block *sb, int type)
1603 struct inode *inode = sb_dqopt(sb)->files[type];
1609 err = dquot_quota_off(sb, type);
1622 return dquot_quota_off(sb, type);