• Home
  • Raw
  • Download

Lines Matching refs:sb

50 static int ext3_commit_super(struct super_block *sb,
53 static void ext3_mark_recovery_complete(struct super_block * sb,
55 static void ext3_clear_journal_err(struct super_block * sb,
57 static int ext3_sync_fs(struct super_block *sb, int wait);
58 static const char *ext3_decode_error(struct super_block * sb, int errno,
60 static int ext3_remount (struct super_block * sb, int * flags, char * data);
62 static int ext3_unfreeze(struct super_block *sb);
63 static int ext3_freeze(struct super_block *sb);
68 handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks) in ext3_journal_start_sb() argument
72 if (sb->s_flags & MS_RDONLY) in ext3_journal_start_sb()
78 journal = EXT3_SB(sb)->s_journal; in ext3_journal_start_sb()
80 ext3_abort(sb, __func__, in ext3_journal_start_sb()
90 struct super_block *sb; in __ext3_journal_stop() local
94 sb = handle->h_transaction->t_journal->j_private; in __ext3_journal_stop()
101 __ext3_std_error(sb, where, err); in __ext3_journal_stop()
126 void ext3_msg(struct super_block *sb, const char *prefix, in ext3_msg() argument
137 printk("%sEXT3-fs (%s): %pV\n", prefix, sb->s_id, &vaf); in ext3_msg()
157 static void ext3_handle_error(struct super_block *sb) in ext3_handle_error() argument
159 struct ext3_super_block *es = EXT3_SB(sb)->s_es; in ext3_handle_error()
161 EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; in ext3_handle_error()
164 if (sb->s_flags & MS_RDONLY) in ext3_handle_error()
167 if (!test_opt (sb, ERRORS_CONT)) { in ext3_handle_error()
168 journal_t *journal = EXT3_SB(sb)->s_journal; in ext3_handle_error()
170 set_opt(EXT3_SB(sb)->s_mount_opt, ABORT); in ext3_handle_error()
174 if (test_opt (sb, ERRORS_RO)) { in ext3_handle_error()
175 ext3_msg(sb, KERN_CRIT, in ext3_handle_error()
177 sb->s_flags |= MS_RDONLY; in ext3_handle_error()
179 ext3_commit_super(sb, es, 1); in ext3_handle_error()
180 if (test_opt(sb, ERRORS_PANIC)) in ext3_handle_error()
182 sb->s_id); in ext3_handle_error()
185 void ext3_error(struct super_block *sb, const char *function, in ext3_error() argument
197 sb->s_id, function, &vaf); in ext3_error()
201 ext3_handle_error(sb); in ext3_error()
204 static const char *ext3_decode_error(struct super_block * sb, int errno, in ext3_decode_error() argument
217 if (!sb || EXT3_SB(sb)->s_journal->j_flags & JFS_ABORT) in ext3_decode_error()
240 void __ext3_std_error (struct super_block * sb, const char * function, in __ext3_std_error() argument
250 (sb->s_flags & MS_RDONLY)) in __ext3_std_error()
253 errstr = ext3_decode_error(sb, errno, nbuf); in __ext3_std_error()
254 ext3_msg(sb, KERN_CRIT, "error in %s: %s", function, errstr); in __ext3_std_error()
256 ext3_handle_error(sb); in __ext3_std_error()
269 void ext3_abort(struct super_block *sb, const char *function, in ext3_abort() argument
281 sb->s_id, function, &vaf); in ext3_abort()
285 if (test_opt(sb, ERRORS_PANIC)) in ext3_abort()
288 if (sb->s_flags & MS_RDONLY) in ext3_abort()
291 ext3_msg(sb, KERN_CRIT, in ext3_abort()
293 EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; in ext3_abort()
294 sb->s_flags |= MS_RDONLY; in ext3_abort()
295 set_opt(EXT3_SB(sb)->s_mount_opt, ABORT); in ext3_abort()
296 if (EXT3_SB(sb)->s_journal) in ext3_abort()
297 journal_abort(EXT3_SB(sb)->s_journal, -EIO); in ext3_abort()
300 void ext3_warning(struct super_block *sb, const char *function, in ext3_warning() argument
312 sb->s_id, function, &vaf); in ext3_warning()
317 void ext3_update_dynamic_rev(struct super_block *sb) in ext3_update_dynamic_rev() argument
319 struct ext3_super_block *es = EXT3_SB(sb)->s_es; in ext3_update_dynamic_rev()
324 ext3_msg(sb, KERN_WARNING, in ext3_update_dynamic_rev()
345 static struct block_device *ext3_blkdev_get(dev_t dev, struct super_block *sb) in ext3_blkdev_get() argument
350 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb); in ext3_blkdev_get()
356 ext3_msg(sb, KERN_ERR, "error: failed to open journal device %s: %ld", in ext3_blkdev_get()
385 static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi) in dump_orphan_list() argument
389 ext3_msg(sb, KERN_ERR, "error: sb orphan head is %d", in dump_orphan_list()
392 ext3_msg(sb, KERN_ERR, "sb_info orphan list:"); in dump_orphan_list()
395 ext3_msg(sb, KERN_ERR, " " in dump_orphan_list()
403 static void ext3_put_super (struct super_block * sb) in ext3_put_super() argument
405 struct ext3_sb_info *sbi = EXT3_SB(sb); in ext3_put_super()
409 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); in ext3_put_super()
410 ext3_xattr_put_super(sb); in ext3_put_super()
414 ext3_abort(sb, __func__, "Couldn't clean up the journal"); in ext3_put_super()
416 if (!(sb->s_flags & MS_RDONLY)) { in ext3_put_super()
417 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); in ext3_put_super()
421 ext3_commit_super(sb, es, 1); in ext3_put_super()
441 dump_orphan_list(sb, sbi); in ext3_put_super()
444 invalidate_bdev(sb->s_bdev); in ext3_put_super()
445 if (sbi->journal_bdev && sbi->journal_bdev != sb->s_bdev) { in ext3_put_super()
455 sb->s_fs_info = NULL; in ext3_put_super()
465 static struct inode *ext3_alloc_inode(struct super_block *sb) in ext3_alloc_inode() argument
540 static inline void ext3_show_quota_options(struct seq_file *seq, struct super_block *sb) in ext3_show_quota_options() argument
543 struct ext3_sb_info *sbi = EXT3_SB(sb); in ext3_show_quota_options()
568 if (test_opt(sb, USRQUOTA)) in ext3_show_quota_options()
571 if (test_opt(sb, GRPQUOTA)) in ext3_show_quota_options()
596 struct super_block *sb = root->d_sb; in ext3_show_options() local
597 struct ext3_sb_info *sbi = EXT3_SB(sb); in ext3_show_options()
605 if (test_opt(sb, MINIX_DF)) in ext3_show_options()
607 if (test_opt(sb, GRPID)) in ext3_show_options()
609 if (!test_opt(sb, GRPID) && (def_mount_opts & EXT3_DEFM_BSDGROUPS)) in ext3_show_options()
621 if (test_opt(sb, ERRORS_RO)) { in ext3_show_options()
629 if (test_opt(sb, ERRORS_CONT)) in ext3_show_options()
631 if (test_opt(sb, ERRORS_PANIC)) in ext3_show_options()
633 if (test_opt(sb, NO_UID32)) in ext3_show_options()
635 if (test_opt(sb, DEBUG)) in ext3_show_options()
638 if (test_opt(sb, XATTR_USER)) in ext3_show_options()
640 if (!test_opt(sb, XATTR_USER) && in ext3_show_options()
646 if (test_opt(sb, POSIX_ACL)) in ext3_show_options()
648 if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT3_DEFM_ACL)) in ext3_show_options()
651 if (!test_opt(sb, RESERVATION)) in ext3_show_options()
662 seq_puts(seq, test_opt(sb, BARRIER) ? "1" : "0"); in ext3_show_options()
663 seq_printf(seq, ",data=%s", data_mode_string(test_opt(sb, DATA_FLAGS))); in ext3_show_options()
664 if (test_opt(sb, DATA_ERR_ABORT)) in ext3_show_options()
667 if (test_opt(sb, NOLOAD)) in ext3_show_options()
670 ext3_show_quota_options(seq, sb); in ext3_show_options()
676 static struct inode *ext3_nfs_get_inode(struct super_block *sb, in ext3_nfs_get_inode() argument
681 if (ino < EXT3_FIRST_INO(sb) && ino != EXT3_ROOT_INO) in ext3_nfs_get_inode()
683 if (ino > le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count)) in ext3_nfs_get_inode()
694 inode = ext3_iget(sb, ino); in ext3_nfs_get_inode()
705 static struct dentry *ext3_fh_to_dentry(struct super_block *sb, struct fid *fid, in ext3_fh_to_dentry() argument
708 return generic_fh_to_dentry(sb, fid, fh_len, fh_type, in ext3_fh_to_dentry()
712 static struct dentry *ext3_fh_to_parent(struct super_block *sb, struct fid *fid, in ext3_fh_to_parent() argument
715 return generic_fh_to_parent(sb, fid, fh_len, fh_type, in ext3_fh_to_parent()
725 static int bdev_try_to_free_page(struct super_block *sb, struct page *page, in bdev_try_to_free_page() argument
728 journal_t *journal = EXT3_SB(sb)->s_journal; in bdev_try_to_free_page()
747 static int ext3_write_info(struct super_block *sb, int type);
748 static int ext3_quota_on(struct super_block *sb, int type, int format_id,
750 static int ext3_quota_on_mount(struct super_block *sb, int type);
751 static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data,
753 static ssize_t ext3_quota_write(struct super_block *sb, int type,
876 static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb) in get_sb_block() argument
887 ext3_msg(sb, KERN_ERR, "error: invalid sb specification: %s", in get_sb_block()
898 static int set_qf_name(struct super_block *sb, int qtype, substring_t *args) in set_qf_name() argument
900 struct ext3_sb_info *sbi = EXT3_SB(sb); in set_qf_name()
903 if (sb_any_quota_loaded(sb) && in set_qf_name()
905 ext3_msg(sb, KERN_ERR, in set_qf_name()
912 ext3_msg(sb, KERN_ERR, in set_qf_name()
921 ext3_msg(sb, KERN_ERR, in set_qf_name()
928 ext3_msg(sb, KERN_ERR, in set_qf_name()
938 static int clear_qf_name(struct super_block *sb, int qtype) { in clear_qf_name() argument
940 struct ext3_sb_info *sbi = EXT3_SB(sb); in clear_qf_name()
942 if (sb_any_quota_loaded(sb) && in clear_qf_name()
944 ext3_msg(sb, KERN_ERR, "Cannot change journaled quota options" in clear_qf_name()
956 static int parse_options (char *options, struct super_block *sb, in parse_options() argument
960 struct ext3_sb_info *sbi = EXT3_SB(sb); in parse_options()
1002 ext3_msg(sb, KERN_ERR, "Invalid uid value %d", option); in parse_options()
1013 ext3_msg(sb, KERN_ERR, "Invalid gid value %d", option); in parse_options()
1047 ext3_msg(sb, KERN_WARNING, in parse_options()
1051 ext3_msg(sb, KERN_WARNING, in parse_options()
1064 ext3_msg(sb, KERN_INFO, in parse_options()
1078 ext3_msg(sb, KERN_INFO, in parse_options()
1095 ext3_msg(sb, KERN_ERR, "error: cannot specify " in parse_options()
1103 ext3_msg(sb, KERN_ERR, "error: cannot specify " in parse_options()
1113 ext3_msg(sb, KERN_ERR, "error: cannot specify " in parse_options()
1143 if (test_opt(sb, DATA_FLAGS) == data_opt) in parse_options()
1145 ext3_msg(sb, KERN_ERR, in parse_options()
1150 data_mode_string(test_opt(sb, in parse_options()
1167 if (!set_qf_name(sb, USRQUOTA, &args[0])) in parse_options()
1171 if (!set_qf_name(sb, GRPQUOTA, &args[0])) in parse_options()
1175 if (!clear_qf_name(sb, USRQUOTA)) in parse_options()
1179 if (!clear_qf_name(sb, GRPQUOTA)) in parse_options()
1191 if (sb_any_quota_loaded(sb) && in parse_options()
1193 ext3_msg(sb, KERN_ERR, "error: cannot change " in parse_options()
1210 if (sb_any_quota_loaded(sb)) { in parse_options()
1211 ext3_msg(sb, KERN_ERR, "error: cannot change " in parse_options()
1223 ext3_msg(sb, KERN_ERR, in parse_options()
1233 ext3_msg(sb, KERN_ERR, in parse_options()
1261 ext3_msg(sb, KERN_ERR, in parse_options()
1271 ext3_msg(sb, KERN_WARNING, in parse_options()
1275 ext3_msg(sb, KERN_WARNING, in parse_options()
1279 ext3_msg(sb, KERN_ERR, in parse_options()
1287 if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) in parse_options()
1289 if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) in parse_options()
1292 if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { in parse_options()
1293 ext3_msg(sb, KERN_ERR, "error: old and new quota " in parse_options()
1299 ext3_msg(sb, KERN_ERR, "error: journaled quota format " in parse_options()
1305 ext3_msg(sb, KERN_ERR, "error: journaled quota format " in parse_options()
1315 static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, in ext3_setup_super() argument
1318 struct ext3_sb_info *sbi = EXT3_SB(sb); in ext3_setup_super()
1322 ext3_msg(sb, KERN_ERR, in ext3_setup_super()
1330 ext3_msg(sb, KERN_WARNING, in ext3_setup_super()
1334 ext3_msg(sb, KERN_WARNING, in ext3_setup_super()
1340 ext3_msg(sb, KERN_WARNING, in ext3_setup_super()
1346 ext3_msg(sb, KERN_WARNING, in ext3_setup_super()
1360 ext3_update_dynamic_rev(sb); in ext3_setup_super()
1361 EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); in ext3_setup_super()
1363 ext3_commit_super(sb, es, 1); in ext3_setup_super()
1364 if (test_opt(sb, DEBUG)) in ext3_setup_super()
1365 ext3_msg(sb, KERN_INFO, "[bs=%lu, gc=%lu, " in ext3_setup_super()
1367 sb->s_blocksize, in ext3_setup_super()
1369 EXT3_BLOCKS_PER_GROUP(sb), in ext3_setup_super()
1370 EXT3_INODES_PER_GROUP(sb), in ext3_setup_super()
1373 if (EXT3_SB(sb)->s_journal->j_inode == NULL) { in ext3_setup_super()
1375 ext3_msg(sb, KERN_INFO, "using external journal on %s", in ext3_setup_super()
1376 bdevname(EXT3_SB(sb)->s_journal->j_dev, b)); in ext3_setup_super()
1378 ext3_msg(sb, KERN_INFO, "using internal journal"); in ext3_setup_super()
1380 cleancache_init_fs(sb); in ext3_setup_super()
1385 static int ext3_check_descriptors(struct super_block *sb) in ext3_check_descriptors() argument
1387 struct ext3_sb_info *sbi = EXT3_SB(sb); in ext3_check_descriptors()
1393 struct ext3_group_desc *gdp = ext3_get_group_desc(sb, i, NULL); in ext3_check_descriptors()
1394 ext3_fsblk_t first_block = ext3_group_first_block_no(sb, i); in ext3_check_descriptors()
1401 (EXT3_BLOCKS_PER_GROUP(sb) - 1); in ext3_check_descriptors()
1406 ext3_error (sb, "ext3_check_descriptors", in ext3_check_descriptors()
1416 ext3_error (sb, "ext3_check_descriptors", in ext3_check_descriptors()
1427 ext3_error (sb, "ext3_check_descriptors", in ext3_check_descriptors()
1436 sbi->s_es->s_free_blocks_count=cpu_to_le32(ext3_count_free_blocks(sb)); in ext3_check_descriptors()
1437 sbi->s_es->s_free_inodes_count=cpu_to_le32(ext3_count_free_inodes(sb)); in ext3_check_descriptors()
1459 static void ext3_orphan_cleanup (struct super_block * sb, in ext3_orphan_cleanup() argument
1462 unsigned int s_flags = sb->s_flags; in ext3_orphan_cleanup()
1472 if (bdev_read_only(sb->s_bdev)) { in ext3_orphan_cleanup()
1473 ext3_msg(sb, KERN_ERR, "error: write access " in ext3_orphan_cleanup()
1479 if (EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP)) { in ext3_orphan_cleanup()
1480 ext3_msg(sb, KERN_INFO, "Skipping orphan cleanup due to " in ext3_orphan_cleanup()
1485 if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) { in ext3_orphan_cleanup()
1497 ext3_msg(sb, KERN_INFO, "orphan cleanup on readonly fs"); in ext3_orphan_cleanup()
1498 sb->s_flags &= ~MS_RDONLY; in ext3_orphan_cleanup()
1502 sb->s_flags |= MS_ACTIVE; in ext3_orphan_cleanup()
1505 if (EXT3_SB(sb)->s_qf_names[i]) { in ext3_orphan_cleanup()
1506 int ret = ext3_quota_on_mount(sb, i); in ext3_orphan_cleanup()
1508 ext3_msg(sb, KERN_ERR, in ext3_orphan_cleanup()
1518 inode = ext3_orphan_get(sb, le32_to_cpu(es->s_last_orphan)); in ext3_orphan_cleanup()
1524 list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); in ext3_orphan_cleanup()
1548 ext3_msg(sb, KERN_INFO, "%d orphan inode%s deleted", in ext3_orphan_cleanup()
1551 ext3_msg(sb, KERN_INFO, "%d truncate%s cleaned up", in ext3_orphan_cleanup()
1556 if (sb_dqopt(sb)->files[i]) in ext3_orphan_cleanup()
1557 dquot_quota_off(sb, i); in ext3_orphan_cleanup()
1560 sb->s_flags = s_flags; /* Restore MS_RDONLY status */ in ext3_orphan_cleanup()
1610 static ext3_fsblk_t descriptor_loc(struct super_block *sb, in descriptor_loc() argument
1614 struct ext3_sb_info *sbi = EXT3_SB(sb); in descriptor_loc()
1620 if (!EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_META_BG) || in descriptor_loc()
1624 if (ext3_bg_has_super(sb, bg)) in descriptor_loc()
1626 return (has_super + ext3_group_first_block_no(sb, bg)); in descriptor_loc()
1630 static int ext3_fill_super (struct super_block *sb, void *data, int silent) in ext3_fill_super() argument
1636 ext3_fsblk_t sb_block = get_sb_block(&data, sb); in ext3_fill_super()
1662 sb->s_fs_info = sbi; in ext3_fill_super()
1665 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); in ext3_fill_super()
1667 ext3_msg(sb, KERN_ERR, "error: unable to set blocksize"); in ext3_fill_super()
1682 if (!(bh = sb_bread(sb, logic_sb_block))) { in ext3_fill_super()
1683 ext3_msg(sb, KERN_ERR, "error: unable to read superblock"); in ext3_fill_super()
1692 sb->s_magic = le16_to_cpu(es->s_magic); in ext3_fill_super()
1693 if (sb->s_magic != EXT3_SUPER_MAGIC) in ext3_fill_super()
1733 if (!parse_options ((char *) data, sb, &journal_inum, &journal_devnum, in ext3_fill_super()
1737 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | in ext3_fill_super()
1738 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); in ext3_fill_super()
1741 (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) || in ext3_fill_super()
1742 EXT3_HAS_RO_COMPAT_FEATURE(sb, ~0U) || in ext3_fill_super()
1743 EXT3_HAS_INCOMPAT_FEATURE(sb, ~0U))) in ext3_fill_super()
1744 ext3_msg(sb, KERN_WARNING, in ext3_fill_super()
1752 features = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP); in ext3_fill_super()
1754 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1759 features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP); in ext3_fill_super()
1760 if (!(sb->s_flags & MS_RDONLY) && features) { in ext3_fill_super()
1761 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1770 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1776 hblock = bdev_logical_block_size(sb->s_bdev); in ext3_fill_super()
1777 if (sb->s_blocksize != blocksize) { in ext3_fill_super()
1783 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1790 if (!sb_set_blocksize(sb, blocksize)) { in ext3_fill_super()
1791 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1797 bh = sb_bread(sb, logic_sb_block); in ext3_fill_super()
1799 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1806 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1812 sb->s_maxbytes = ext3_max_size(sb->s_blocksize_bits); in ext3_fill_super()
1823 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1832 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1841 if (EXT3_INODE_SIZE(sb) == 0 || EXT3_INODES_PER_GROUP(sb) == 0) in ext3_fill_super()
1843 sbi->s_inodes_per_block = blocksize / EXT3_INODE_SIZE(sb); in ext3_fill_super()
1851 sbi->s_addr_per_block_bits = ilog2(EXT3_ADDR_PER_BLOCK(sb)); in ext3_fill_super()
1852 sbi->s_desc_per_block_bits = ilog2(EXT3_DESC_PER_BLOCK(sb)); in ext3_fill_super()
1869 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1875 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1881 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1887 err = generic_check_addressable(sb->s_blocksize_bits, in ext3_fill_super()
1890 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1893 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1899 if (EXT3_BLOCKS_PER_GROUP(sb) == 0) in ext3_fill_super()
1903 / EXT3_BLOCKS_PER_GROUP(sb)) + 1; in ext3_fill_super()
1904 db_count = DIV_ROUND_UP(sbi->s_groups_count, EXT3_DESC_PER_BLOCK(sb)); in ext3_fill_super()
1908 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1917 block = descriptor_loc(sb, logic_sb_block, i); in ext3_fill_super()
1918 sbi->s_group_desc[i] = sb_bread(sb, block); in ext3_fill_super()
1920 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1926 if (!ext3_check_descriptors (sb)) { in ext3_fill_super()
1927 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1946 ext3_rsv_window_add(sb, &sbi->s_rsv_window_head); in ext3_fill_super()
1951 sb->s_op = &ext3_sops; in ext3_fill_super()
1952 sb->s_export_op = &ext3_export_ops; in ext3_fill_super()
1953 sb->s_xattr = ext3_xattr_handlers; in ext3_fill_super()
1955 sb->s_qcop = &ext3_qctl_operations; in ext3_fill_super()
1956 sb->dq_op = &ext3_quota_operations; in ext3_fill_super()
1958 memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid)); in ext3_fill_super()
1963 sb->s_root = NULL; in ext3_fill_super()
1966 EXT3_HAS_INCOMPAT_FEATURE(sb, in ext3_fill_super()
1973 if (!test_opt(sb, NOLOAD) && in ext3_fill_super()
1974 EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) { in ext3_fill_super()
1975 if (ext3_load_journal(sb, es, journal_devnum)) in ext3_fill_super()
1978 if (ext3_create_journal(sb, es, journal_inum)) in ext3_fill_super()
1982 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
1988 ext3_count_free_blocks(sb)); in ext3_fill_super()
1991 ext3_count_free_inodes(sb)); in ext3_fill_super()
1995 ext3_count_dirs(sb)); in ext3_fill_super()
1998 ext3_msg(sb, KERN_ERR, "error: insufficient memory"); in ext3_fill_super()
2005 switch (test_opt(sb, DATA_FLAGS)) { in ext3_fill_super()
2021 ext3_msg(sb, KERN_ERR, in ext3_fill_super()
2035 root = ext3_iget(sb, EXT3_ROOT_INO); in ext3_fill_super()
2037 ext3_msg(sb, KERN_ERR, "error: get root inode failed"); in ext3_fill_super()
2043 ext3_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck"); in ext3_fill_super()
2046 sb->s_root = d_make_root(root); in ext3_fill_super()
2047 if (!sb->s_root) { in ext3_fill_super()
2048 ext3_msg(sb, KERN_ERR, "error: get root dentry failed"); in ext3_fill_super()
2053 if (ext3_setup_super(sb, es, sb->s_flags & MS_RDONLY)) in ext3_fill_super()
2054 sb->s_flags |= MS_RDONLY; in ext3_fill_super()
2056 EXT3_SB(sb)->s_mount_state |= EXT3_ORPHAN_FS; in ext3_fill_super()
2057 ext3_orphan_cleanup(sb, es); in ext3_fill_super()
2058 EXT3_SB(sb)->s_mount_state &= ~EXT3_ORPHAN_FS; in ext3_fill_super()
2060 ext3_mark_recovery_complete(sb, es); in ext3_fill_super()
2061 ext3_msg(sb, KERN_INFO, "recovery complete"); in ext3_fill_super()
2063 ext3_msg(sb, KERN_INFO, "mounted filesystem with %s data mode", in ext3_fill_super()
2064 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal": in ext3_fill_super()
2065 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": in ext3_fill_super()
2072 ext3_msg(sb, KERN_INFO, in ext3_fill_super()
2074 sb->s_id); in ext3_fill_super()
2094 sb->s_fs_info = NULL; in ext3_fill_super()
2105 static void ext3_init_journal_params(struct super_block *sb, journal_t *journal) in ext3_init_journal_params() argument
2107 struct ext3_sb_info *sbi = EXT3_SB(sb); in ext3_init_journal_params()
2116 if (test_opt(sb, BARRIER)) in ext3_init_journal_params()
2120 if (test_opt(sb, DATA_ERR_ABORT)) in ext3_init_journal_params()
2127 static journal_t *ext3_get_journal(struct super_block *sb, in ext3_get_journal() argument
2137 journal_inode = ext3_iget(sb, journal_inum); in ext3_get_journal()
2139 ext3_msg(sb, KERN_ERR, "error: no journal found"); in ext3_get_journal()
2145 ext3_msg(sb, KERN_ERR, "error: journal inode is deleted"); in ext3_get_journal()
2152 ext3_msg(sb, KERN_ERR, "error: invalid journal inode"); in ext3_get_journal()
2159 ext3_msg(sb, KERN_ERR, "error: could not load journal inode"); in ext3_get_journal()
2163 journal->j_private = sb; in ext3_get_journal()
2164 ext3_init_journal_params(sb, journal); in ext3_get_journal()
2168 static journal_t *ext3_get_dev_journal(struct super_block *sb, in ext3_get_dev_journal() argument
2181 bdev = ext3_blkdev_get(j_dev, sb); in ext3_get_dev_journal()
2185 blocksize = sb->s_blocksize; in ext3_get_dev_journal()
2188 ext3_msg(sb, KERN_ERR, in ext3_get_dev_journal()
2197 ext3_msg(sb, KERN_ERR, "error: couldn't read superblock of " in ext3_get_dev_journal()
2206 ext3_msg(sb, KERN_ERR, "error: external journal has " in ext3_get_dev_journal()
2212 if (memcmp(EXT3_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { in ext3_get_dev_journal()
2213 ext3_msg(sb, KERN_ERR, "error: journal UUID does not match"); in ext3_get_dev_journal()
2222 journal = journal_init_dev(bdev, sb->s_bdev, in ext3_get_dev_journal()
2225 ext3_msg(sb, KERN_ERR, in ext3_get_dev_journal()
2229 journal->j_private = sb; in ext3_get_dev_journal()
2232 ext3_msg(sb, KERN_ERR, "I/O error on journal device"); in ext3_get_dev_journal()
2237 ext3_msg(sb, KERN_ERR, in ext3_get_dev_journal()
2243 EXT3_SB(sb)->journal_bdev = bdev; in ext3_get_dev_journal()
2244 ext3_init_journal_params(sb, journal); in ext3_get_dev_journal()
2253 static int ext3_load_journal(struct super_block *sb, in ext3_load_journal() argument
2265 ext3_msg(sb, KERN_INFO, "external journal device major/minor " in ext3_load_journal()
2271 really_read_only = bdev_read_only(sb->s_bdev); in ext3_load_journal()
2279 if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) { in ext3_load_journal()
2280 if (sb->s_flags & MS_RDONLY) { in ext3_load_journal()
2281 ext3_msg(sb, KERN_INFO, in ext3_load_journal()
2284 ext3_msg(sb, KERN_ERR, "error: write access " in ext3_load_journal()
2288 ext3_msg(sb, KERN_INFO, in ext3_load_journal()
2294 ext3_msg(sb, KERN_ERR, "error: filesystem has both journal " in ext3_load_journal()
2300 if (!(journal = ext3_get_journal(sb, journal_inum))) in ext3_load_journal()
2303 if (!(journal = ext3_get_dev_journal(sb, journal_dev))) in ext3_load_journal()
2310 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { in ext3_load_journal()
2313 ext3_msg(sb, KERN_ERR, "error updating journal"); in ext3_load_journal()
2319 if (!EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) in ext3_load_journal()
2325 ext3_msg(sb, KERN_ERR, "error loading journal"); in ext3_load_journal()
2330 EXT3_SB(sb)->s_journal = journal; in ext3_load_journal()
2331 ext3_clear_journal_err(sb, es); in ext3_load_journal()
2338 ext3_commit_super(sb, es, 1); in ext3_load_journal()
2344 static int ext3_create_journal(struct super_block *sb, in ext3_create_journal() argument
2351 if (sb->s_flags & MS_RDONLY) { in ext3_create_journal()
2352 ext3_msg(sb, KERN_ERR, in ext3_create_journal()
2358 journal = ext3_get_journal(sb, journal_inum); in ext3_create_journal()
2362 ext3_msg(sb, KERN_INFO, "creating new journal on inode %u", in ext3_create_journal()
2367 ext3_msg(sb, KERN_ERR, "error creating journal"); in ext3_create_journal()
2372 EXT3_SB(sb)->s_journal = journal; in ext3_create_journal()
2374 ext3_update_dynamic_rev(sb); in ext3_create_journal()
2375 EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); in ext3_create_journal()
2376 EXT3_SET_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL); in ext3_create_journal()
2381 ext3_commit_super(sb, es, 1); in ext3_create_journal()
2386 static int ext3_commit_super(struct super_block *sb, in ext3_commit_super() argument
2390 struct buffer_head *sbh = EXT3_SB(sb)->s_sbh; in ext3_commit_super()
2405 ext3_msg(sb, KERN_ERR, "previous I/O error to " in ext3_commit_super()
2420 if (!(sb->s_flags & MS_RDONLY)) in ext3_commit_super()
2422 es->s_free_blocks_count = cpu_to_le32(ext3_count_free_blocks(sb)); in ext3_commit_super()
2423 es->s_free_inodes_count = cpu_to_le32(ext3_count_free_inodes(sb)); in ext3_commit_super()
2429 ext3_msg(sb, KERN_ERR, "I/O error while writing " in ext3_commit_super()
2444 static void ext3_mark_recovery_complete(struct super_block * sb, in ext3_mark_recovery_complete() argument
2447 journal_t *journal = EXT3_SB(sb)->s_journal; in ext3_mark_recovery_complete()
2453 if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER) && in ext3_mark_recovery_complete()
2454 sb->s_flags & MS_RDONLY) { in ext3_mark_recovery_complete()
2455 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); in ext3_mark_recovery_complete()
2456 ext3_commit_super(sb, es, 1); in ext3_mark_recovery_complete()
2468 static void ext3_clear_journal_err(struct super_block *sb, in ext3_clear_journal_err() argument
2475 journal = EXT3_SB(sb)->s_journal; in ext3_clear_journal_err()
2486 errstr = ext3_decode_error(sb, j_errno, nbuf); in ext3_clear_journal_err()
2487 ext3_warning(sb, __func__, "Filesystem error recorded " in ext3_clear_journal_err()
2489 ext3_warning(sb, __func__, "Marking fs in need of " in ext3_clear_journal_err()
2492 EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; in ext3_clear_journal_err()
2494 ext3_commit_super (sb, es, 1); in ext3_clear_journal_err()
2504 int ext3_force_commit(struct super_block *sb) in ext3_force_commit() argument
2509 if (sb->s_flags & MS_RDONLY) in ext3_force_commit()
2512 journal = EXT3_SB(sb)->s_journal; in ext3_force_commit()
2517 static int ext3_sync_fs(struct super_block *sb, int wait) in ext3_sync_fs() argument
2521 trace_ext3_sync_fs(sb, wait); in ext3_sync_fs()
2526 dquot_writeback_dquots(sb, -1); in ext3_sync_fs()
2527 if (journal_start_commit(EXT3_SB(sb)->s_journal, &target)) { in ext3_sync_fs()
2529 log_wait_commit(EXT3_SB(sb)->s_journal, target); in ext3_sync_fs()
2538 static int ext3_freeze(struct super_block *sb) in ext3_freeze() argument
2543 if (!(sb->s_flags & MS_RDONLY)) { in ext3_freeze()
2544 journal = EXT3_SB(sb)->s_journal; in ext3_freeze()
2558 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); in ext3_freeze()
2559 error = ext3_commit_super(sb, EXT3_SB(sb)->s_es, 1); in ext3_freeze()
2574 static int ext3_unfreeze(struct super_block *sb) in ext3_unfreeze() argument
2576 if (!(sb->s_flags & MS_RDONLY)) { in ext3_unfreeze()
2578 EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); in ext3_unfreeze()
2579 ext3_commit_super(sb, EXT3_SB(sb)->s_es, 1); in ext3_unfreeze()
2580 journal_unlock_updates(EXT3_SB(sb)->s_journal); in ext3_unfreeze()
2585 static int ext3_remount (struct super_block * sb, int * flags, char * data) in ext3_remount() argument
2588 struct ext3_sb_info *sbi = EXT3_SB(sb); in ext3_remount()
2598 sync_filesystem(sb); in ext3_remount()
2601 old_sb_flags = sb->s_flags; in ext3_remount()
2626 if (!parse_options(data, sb, NULL, NULL, &n_blocks_count, 1)) { in ext3_remount()
2631 if (test_opt(sb, ABORT)) in ext3_remount()
2632 ext3_abort(sb, __func__, "Abort forced by user"); in ext3_remount()
2634 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | in ext3_remount()
2635 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); in ext3_remount()
2639 ext3_init_journal_params(sb, sbi->s_journal); in ext3_remount()
2641 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || in ext3_remount()
2643 if (test_opt(sb, ABORT)) { in ext3_remount()
2649 err = dquot_suspend(sb, -1); in ext3_remount()
2657 sb->s_flags |= MS_RDONLY; in ext3_remount()
2668 ext3_mark_recovery_complete(sb, es); in ext3_remount()
2671 if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb, in ext3_remount()
2673 ext3_msg(sb, KERN_WARNING, in ext3_remount()
2687 ext3_msg(sb, KERN_WARNING, "warning: couldn't " in ext3_remount()
2701 ext3_clear_journal_err(sb, es); in ext3_remount()
2703 if ((err = ext3_group_extend(sb, es, n_blocks_count))) in ext3_remount()
2705 if (!ext3_setup_super (sb, es, 0)) in ext3_remount()
2706 sb->s_flags &= ~MS_RDONLY; in ext3_remount()
2716 dquot_resume(sb, -1); in ext3_remount()
2719 sb->s_flags = old_sb_flags; in ext3_remount()
2736 struct super_block *sb = dentry->d_sb; in ext3_statfs() local
2737 struct ext3_sb_info *sbi = EXT3_SB(sb); in ext3_statfs()
2741 if (test_opt(sb, MINIX_DF)) { in ext3_statfs()
2766 overhead += ext3_bg_has_super(sb, i) + in ext3_statfs()
2767 ext3_bg_num_gdb(sb, i); in ext3_statfs()
2782 buf->f_bsize = sb->s_blocksize; in ext3_statfs()
2880 static int ext3_write_info(struct super_block *sb, int type) in ext3_write_info() argument
2886 handle = ext3_journal_start(sb->s_root->d_inode, 2); in ext3_write_info()
2889 ret = dquot_commit_info(sb, type); in ext3_write_info()
2900 static int ext3_quota_on_mount(struct super_block *sb, int type) in ext3_quota_on_mount() argument
2902 return dquot_quota_on_mount(sb, EXT3_SB(sb)->s_qf_names[type], in ext3_quota_on_mount()
2903 EXT3_SB(sb)->s_jquota_fmt, type); in ext3_quota_on_mount()
2909 static int ext3_quota_on(struct super_block *sb, int type, int format_id, in ext3_quota_on() argument
2914 if (!test_opt(sb, QUOTA)) in ext3_quota_on()
2918 if (path->dentry->d_sb != sb) in ext3_quota_on()
2921 if (EXT3_SB(sb)->s_qf_names[type]) { in ext3_quota_on()
2923 if (path->dentry->d_parent != sb->s_root) in ext3_quota_on()
2924 ext3_msg(sb, KERN_WARNING, in ext3_quota_on()
2938 journal_lock_updates(EXT3_SB(sb)->s_journal); in ext3_quota_on()
2939 err = journal_flush(EXT3_SB(sb)->s_journal); in ext3_quota_on()
2940 journal_unlock_updates(EXT3_SB(sb)->s_journal); in ext3_quota_on()
2945 return dquot_quota_on(sb, type, format_id, path); in ext3_quota_on()
2952 static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data, in ext3_quota_read() argument
2955 struct inode *inode = sb_dqopt(sb)->files[type]; in ext3_quota_read()
2956 sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb); in ext3_quota_read()
2958 int offset = off & (sb->s_blocksize - 1); in ext3_quota_read()
2970 tocopy = sb->s_blocksize - offset < toread ? in ext3_quota_read()
2971 sb->s_blocksize - offset : toread; in ext3_quota_read()
2990 static ssize_t ext3_quota_write(struct super_block *sb, int type, in ext3_quota_write() argument
2993 struct inode *inode = sb_dqopt(sb)->files[type]; in ext3_quota_write()
2994 sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb); in ext3_quota_write()
2996 int offset = off & (sb->s_blocksize - 1); in ext3_quota_write()
2997 int journal_quota = EXT3_SB(sb)->s_qf_names[type] != NULL; in ext3_quota_write()
3002 ext3_msg(sb, KERN_WARNING, in ext3_quota_write()
3013 if (sb->s_blocksize - offset < len) { in ext3_quota_write()
3014 ext3_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" in ext3_quota_write()