diff options
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 686 |
1 files changed, 434 insertions, 252 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index e4a241c65dbe..e5f06a5f045e 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -51,9 +51,7 @@ struct proc_dir_entry *ext4_proc_root; | |||
51 | 51 | ||
52 | static int ext4_load_journal(struct super_block *, struct ext4_super_block *, | 52 | static int ext4_load_journal(struct super_block *, struct ext4_super_block *, |
53 | unsigned long journal_devnum); | 53 | unsigned long journal_devnum); |
54 | static int ext4_create_journal(struct super_block *, struct ext4_super_block *, | 54 | static int ext4_commit_super(struct super_block *sb, |
55 | unsigned int); | ||
56 | static void ext4_commit_super(struct super_block *sb, | ||
57 | struct ext4_super_block *es, int sync); | 55 | struct ext4_super_block *es, int sync); |
58 | static void ext4_mark_recovery_complete(struct super_block *sb, | 56 | static void ext4_mark_recovery_complete(struct super_block *sb, |
59 | struct ext4_super_block *es); | 57 | struct ext4_super_block *es); |
@@ -64,9 +62,9 @@ static const char *ext4_decode_error(struct super_block *sb, int errno, | |||
64 | char nbuf[16]); | 62 | char nbuf[16]); |
65 | static int ext4_remount(struct super_block *sb, int *flags, char *data); | 63 | static int ext4_remount(struct super_block *sb, int *flags, char *data); |
66 | static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf); | 64 | static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf); |
67 | static void ext4_unlockfs(struct super_block *sb); | 65 | static int ext4_unfreeze(struct super_block *sb); |
68 | static void ext4_write_super(struct super_block *sb); | 66 | static void ext4_write_super(struct super_block *sb); |
69 | static void ext4_write_super_lockfs(struct super_block *sb); | 67 | static int ext4_freeze(struct super_block *sb); |
70 | 68 | ||
71 | 69 | ||
72 | ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, | 70 | ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, |
@@ -93,6 +91,38 @@ ext4_fsblk_t ext4_inode_table(struct super_block *sb, | |||
93 | (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0); | 91 | (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0); |
94 | } | 92 | } |
95 | 93 | ||
94 | __u32 ext4_free_blks_count(struct super_block *sb, | ||
95 | struct ext4_group_desc *bg) | ||
96 | { | ||
97 | return le16_to_cpu(bg->bg_free_blocks_count_lo) | | ||
98 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | ||
99 | (__u32)le16_to_cpu(bg->bg_free_blocks_count_hi) << 16 : 0); | ||
100 | } | ||
101 | |||
102 | __u32 ext4_free_inodes_count(struct super_block *sb, | ||
103 | struct ext4_group_desc *bg) | ||
104 | { | ||
105 | return le16_to_cpu(bg->bg_free_inodes_count_lo) | | ||
106 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | ||
107 | (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0); | ||
108 | } | ||
109 | |||
110 | __u32 ext4_used_dirs_count(struct super_block *sb, | ||
111 | struct ext4_group_desc *bg) | ||
112 | { | ||
113 | return le16_to_cpu(bg->bg_used_dirs_count_lo) | | ||
114 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | ||
115 | (__u32)le16_to_cpu(bg->bg_used_dirs_count_hi) << 16 : 0); | ||
116 | } | ||
117 | |||
118 | __u32 ext4_itable_unused_count(struct super_block *sb, | ||
119 | struct ext4_group_desc *bg) | ||
120 | { | ||
121 | return le16_to_cpu(bg->bg_itable_unused_lo) | | ||
122 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | ||
123 | (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0); | ||
124 | } | ||
125 | |||
96 | void ext4_block_bitmap_set(struct super_block *sb, | 126 | void ext4_block_bitmap_set(struct super_block *sb, |
97 | struct ext4_group_desc *bg, ext4_fsblk_t blk) | 127 | struct ext4_group_desc *bg, ext4_fsblk_t blk) |
98 | { | 128 | { |
@@ -117,6 +147,38 @@ void ext4_inode_table_set(struct super_block *sb, | |||
117 | bg->bg_inode_table_hi = cpu_to_le32(blk >> 32); | 147 | bg->bg_inode_table_hi = cpu_to_le32(blk >> 32); |
118 | } | 148 | } |
119 | 149 | ||
150 | void ext4_free_blks_set(struct super_block *sb, | ||
151 | struct ext4_group_desc *bg, __u32 count) | ||
152 | { | ||
153 | bg->bg_free_blocks_count_lo = cpu_to_le16((__u16)count); | ||
154 | if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) | ||
155 | bg->bg_free_blocks_count_hi = cpu_to_le16(count >> 16); | ||
156 | } | ||
157 | |||
158 | void ext4_free_inodes_set(struct super_block *sb, | ||
159 | struct ext4_group_desc *bg, __u32 count) | ||
160 | { | ||
161 | bg->bg_free_inodes_count_lo = cpu_to_le16((__u16)count); | ||
162 | if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) | ||
163 | bg->bg_free_inodes_count_hi = cpu_to_le16(count >> 16); | ||
164 | } | ||
165 | |||
166 | void ext4_used_dirs_set(struct super_block *sb, | ||
167 | struct ext4_group_desc *bg, __u32 count) | ||
168 | { | ||
169 | bg->bg_used_dirs_count_lo = cpu_to_le16((__u16)count); | ||
170 | if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) | ||
171 | bg->bg_used_dirs_count_hi = cpu_to_le16(count >> 16); | ||
172 | } | ||
173 | |||
174 | void ext4_itable_unused_set(struct super_block *sb, | ||
175 | struct ext4_group_desc *bg, __u32 count) | ||
176 | { | ||
177 | bg->bg_itable_unused_lo = cpu_to_le16((__u16)count); | ||
178 | if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT) | ||
179 | bg->bg_itable_unused_hi = cpu_to_le16(count >> 16); | ||
180 | } | ||
181 | |||
120 | /* | 182 | /* |
121 | * Wrappers for jbd2_journal_start/end. | 183 | * Wrappers for jbd2_journal_start/end. |
122 | * | 184 | * |
@@ -136,13 +198,19 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) | |||
136 | * backs (eg. EIO in the commit thread), then we still need to | 198 | * backs (eg. EIO in the commit thread), then we still need to |
137 | * take the FS itself readonly cleanly. */ | 199 | * take the FS itself readonly cleanly. */ |
138 | journal = EXT4_SB(sb)->s_journal; | 200 | journal = EXT4_SB(sb)->s_journal; |
139 | if (is_journal_aborted(journal)) { | 201 | if (journal) { |
140 | ext4_abort(sb, __func__, | 202 | if (is_journal_aborted(journal)) { |
141 | "Detected aborted journal"); | 203 | ext4_abort(sb, __func__, |
142 | return ERR_PTR(-EROFS); | 204 | "Detected aborted journal"); |
205 | return ERR_PTR(-EROFS); | ||
206 | } | ||
207 | return jbd2_journal_start(journal, nblocks); | ||
143 | } | 208 | } |
144 | 209 | /* | |
145 | return jbd2_journal_start(journal, nblocks); | 210 | * We're not journaling, return the appropriate indication. |
211 | */ | ||
212 | current->journal_info = EXT4_NOJOURNAL_HANDLE; | ||
213 | return current->journal_info; | ||
146 | } | 214 | } |
147 | 215 | ||
148 | /* | 216 | /* |
@@ -157,6 +225,14 @@ int __ext4_journal_stop(const char *where, handle_t *handle) | |||
157 | int err; | 225 | int err; |
158 | int rc; | 226 | int rc; |
159 | 227 | ||
228 | if (!ext4_handle_valid(handle)) { | ||
229 | /* | ||
230 | * Do this here since we don't call jbd2_journal_stop() in | ||
231 | * no-journal mode. | ||
232 | */ | ||
233 | current->journal_info = NULL; | ||
234 | return 0; | ||
235 | } | ||
160 | sb = handle->h_transaction->t_journal->j_private; | 236 | sb = handle->h_transaction->t_journal->j_private; |
161 | err = handle->h_err; | 237 | err = handle->h_err; |
162 | rc = jbd2_journal_stop(handle); | 238 | rc = jbd2_journal_stop(handle); |
@@ -174,6 +250,8 @@ void ext4_journal_abort_handle(const char *caller, const char *err_fn, | |||
174 | char nbuf[16]; | 250 | char nbuf[16]; |
175 | const char *errstr = ext4_decode_error(NULL, err, nbuf); | 251 | const char *errstr = ext4_decode_error(NULL, err, nbuf); |
176 | 252 | ||
253 | BUG_ON(!ext4_handle_valid(handle)); | ||
254 | |||
177 | if (bh) | 255 | if (bh) |
178 | BUFFER_TRACE(bh, "abort"); | 256 | BUFFER_TRACE(bh, "abort"); |
179 | 257 | ||
@@ -350,6 +428,44 @@ void ext4_warning(struct super_block *sb, const char *function, | |||
350 | va_end(args); | 428 | va_end(args); |
351 | } | 429 | } |
352 | 430 | ||
431 | void ext4_grp_locked_error(struct super_block *sb, ext4_group_t grp, | ||
432 | const char *function, const char *fmt, ...) | ||
433 | __releases(bitlock) | ||
434 | __acquires(bitlock) | ||
435 | { | ||
436 | va_list args; | ||
437 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | ||
438 | |||
439 | va_start(args, fmt); | ||
440 | printk(KERN_CRIT "EXT4-fs error (device %s): %s: ", sb->s_id, function); | ||
441 | vprintk(fmt, args); | ||
442 | printk("\n"); | ||
443 | va_end(args); | ||
444 | |||
445 | if (test_opt(sb, ERRORS_CONT)) { | ||
446 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | ||
447 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | ||
448 | ext4_commit_super(sb, es, 0); | ||
449 | return; | ||
450 | } | ||
451 | ext4_unlock_group(sb, grp); | ||
452 | ext4_handle_error(sb); | ||
453 | /* | ||
454 | * We only get here in the ERRORS_RO case; relocking the group | ||
455 | * may be dangerous, but nothing bad will happen since the | ||
456 | * filesystem will have already been marked read/only and the | ||
457 | * journal has been aborted. We return 1 as a hint to callers | ||
458 | * who might what to use the return value from | ||
459 | * ext4_grp_locked_error() to distinguish beween the | ||
460 | * ERRORS_CONT and ERRORS_RO case, and perhaps return more | ||
461 | * aggressively from the ext4 function in question, with a | ||
462 | * more appropriate error code. | ||
463 | */ | ||
464 | ext4_lock_group(sb, grp); | ||
465 | return; | ||
466 | } | ||
467 | |||
468 | |||
353 | void ext4_update_dynamic_rev(struct super_block *sb) | 469 | void ext4_update_dynamic_rev(struct super_block *sb) |
354 | { | 470 | { |
355 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | 471 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; |
@@ -389,7 +505,7 @@ static struct block_device *ext4_blkdev_get(dev_t dev) | |||
389 | return bdev; | 505 | return bdev; |
390 | 506 | ||
391 | fail: | 507 | fail: |
392 | printk(KERN_ERR "EXT4: failed to open journal device %s: %ld\n", | 508 | printk(KERN_ERR "EXT4-fs: failed to open journal device %s: %ld\n", |
393 | __bdevname(dev, b), PTR_ERR(bdev)); | 509 | __bdevname(dev, b), PTR_ERR(bdev)); |
394 | return NULL; | 510 | return NULL; |
395 | } | 511 | } |
@@ -448,11 +564,13 @@ static void ext4_put_super(struct super_block *sb) | |||
448 | ext4_mb_release(sb); | 564 | ext4_mb_release(sb); |
449 | ext4_ext_release(sb); | 565 | ext4_ext_release(sb); |
450 | ext4_xattr_put_super(sb); | 566 | ext4_xattr_put_super(sb); |
451 | err = jbd2_journal_destroy(sbi->s_journal); | 567 | if (sbi->s_journal) { |
452 | sbi->s_journal = NULL; | 568 | err = jbd2_journal_destroy(sbi->s_journal); |
453 | if (err < 0) | 569 | sbi->s_journal = NULL; |
454 | ext4_abort(sb, __func__, "Couldn't clean up the journal"); | 570 | if (err < 0) |
455 | 571 | ext4_abort(sb, __func__, | |
572 | "Couldn't clean up the journal"); | ||
573 | } | ||
456 | if (!(sb->s_flags & MS_RDONLY)) { | 574 | if (!(sb->s_flags & MS_RDONLY)) { |
457 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 575 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
458 | es->s_state = cpu_to_le16(sbi->s_mount_state); | 576 | es->s_state = cpu_to_le16(sbi->s_mount_state); |
@@ -522,6 +640,11 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
522 | memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); | 640 | memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); |
523 | INIT_LIST_HEAD(&ei->i_prealloc_list); | 641 | INIT_LIST_HEAD(&ei->i_prealloc_list); |
524 | spin_lock_init(&ei->i_prealloc_lock); | 642 | spin_lock_init(&ei->i_prealloc_lock); |
643 | /* | ||
644 | * Note: We can be called before EXT4_SB(sb)->s_journal is set, | ||
645 | * therefore it can be null here. Don't check it, just initialize | ||
646 | * jinode. | ||
647 | */ | ||
525 | jbd2_journal_init_jbd_inode(&ei->jinode, &ei->vfs_inode); | 648 | jbd2_journal_init_jbd_inode(&ei->jinode, &ei->vfs_inode); |
526 | ei->i_reserved_data_blocks = 0; | 649 | ei->i_reserved_data_blocks = 0; |
527 | ei->i_reserved_meta_blocks = 0; | 650 | ei->i_reserved_meta_blocks = 0; |
@@ -588,7 +711,8 @@ static void ext4_clear_inode(struct inode *inode) | |||
588 | } | 711 | } |
589 | #endif | 712 | #endif |
590 | ext4_discard_preallocations(inode); | 713 | ext4_discard_preallocations(inode); |
591 | jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal, | 714 | if (EXT4_JOURNAL(inode)) |
715 | jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal, | ||
592 | &EXT4_I(inode)->jinode); | 716 | &EXT4_I(inode)->jinode); |
593 | } | 717 | } |
594 | 718 | ||
@@ -681,10 +805,19 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
681 | #endif | 805 | #endif |
682 | if (!test_opt(sb, RESERVATION)) | 806 | if (!test_opt(sb, RESERVATION)) |
683 | seq_puts(seq, ",noreservation"); | 807 | seq_puts(seq, ",noreservation"); |
684 | if (sbi->s_commit_interval) { | 808 | if (sbi->s_commit_interval != JBD2_DEFAULT_MAX_COMMIT_AGE*HZ) { |
685 | seq_printf(seq, ",commit=%u", | 809 | seq_printf(seq, ",commit=%u", |
686 | (unsigned) (sbi->s_commit_interval / HZ)); | 810 | (unsigned) (sbi->s_commit_interval / HZ)); |
687 | } | 811 | } |
812 | if (sbi->s_min_batch_time != EXT4_DEF_MIN_BATCH_TIME) { | ||
813 | seq_printf(seq, ",min_batch_time=%u", | ||
814 | (unsigned) sbi->s_min_batch_time); | ||
815 | } | ||
816 | if (sbi->s_max_batch_time != EXT4_DEF_MAX_BATCH_TIME) { | ||
817 | seq_printf(seq, ",max_batch_time=%u", | ||
818 | (unsigned) sbi->s_min_batch_time); | ||
819 | } | ||
820 | |||
688 | /* | 821 | /* |
689 | * We're changing the default of barrier mount option, so | 822 | * We're changing the default of barrier mount option, so |
690 | * let's always display its mount state so it's clear what its | 823 | * let's always display its mount state so it's clear what its |
@@ -696,8 +829,6 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
696 | seq_puts(seq, ",journal_async_commit"); | 829 | seq_puts(seq, ",journal_async_commit"); |
697 | if (test_opt(sb, NOBH)) | 830 | if (test_opt(sb, NOBH)) |
698 | seq_puts(seq, ",nobh"); | 831 | seq_puts(seq, ",nobh"); |
699 | if (!test_opt(sb, EXTENTS)) | ||
700 | seq_puts(seq, ",noextents"); | ||
701 | if (test_opt(sb, I_VERSION)) | 832 | if (test_opt(sb, I_VERSION)) |
702 | seq_puts(seq, ",i_version"); | 833 | seq_puts(seq, ",i_version"); |
703 | if (!test_opt(sb, DELALLOC)) | 834 | if (!test_opt(sb, DELALLOC)) |
@@ -772,6 +903,25 @@ static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, | |||
772 | ext4_nfs_get_inode); | 903 | ext4_nfs_get_inode); |
773 | } | 904 | } |
774 | 905 | ||
906 | /* | ||
907 | * Try to release metadata pages (indirect blocks, directories) which are | ||
908 | * mapped via the block device. Since these pages could have journal heads | ||
909 | * which would prevent try_to_free_buffers() from freeing them, we must use | ||
910 | * jbd2 layer's try_to_free_buffers() function to release them. | ||
911 | */ | ||
912 | static int bdev_try_to_free_page(struct super_block *sb, struct page *page, gfp_t wait) | ||
913 | { | ||
914 | journal_t *journal = EXT4_SB(sb)->s_journal; | ||
915 | |||
916 | WARN_ON(PageChecked(page)); | ||
917 | if (!page_has_buffers(page)) | ||
918 | return 0; | ||
919 | if (journal) | ||
920 | return jbd2_journal_try_to_free_buffers(journal, page, | ||
921 | wait & ~__GFP_WAIT); | ||
922 | return try_to_free_buffers(page); | ||
923 | } | ||
924 | |||
775 | #ifdef CONFIG_QUOTA | 925 | #ifdef CONFIG_QUOTA |
776 | #define QTYPE2NAME(t) ((t) == USRQUOTA ? "user" : "group") | 926 | #define QTYPE2NAME(t) ((t) == USRQUOTA ? "user" : "group") |
777 | #define QTYPE2MOPT(on, t) ((t) == USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) | 927 | #define QTYPE2MOPT(on, t) ((t) == USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) |
@@ -803,7 +953,9 @@ static struct dquot_operations ext4_quota_operations = { | |||
803 | .acquire_dquot = ext4_acquire_dquot, | 953 | .acquire_dquot = ext4_acquire_dquot, |
804 | .release_dquot = ext4_release_dquot, | 954 | .release_dquot = ext4_release_dquot, |
805 | .mark_dirty = ext4_mark_dquot_dirty, | 955 | .mark_dirty = ext4_mark_dquot_dirty, |
806 | .write_info = ext4_write_info | 956 | .write_info = ext4_write_info, |
957 | .alloc_dquot = dquot_alloc, | ||
958 | .destroy_dquot = dquot_destroy, | ||
807 | }; | 959 | }; |
808 | 960 | ||
809 | static struct quotactl_ops ext4_qctl_operations = { | 961 | static struct quotactl_ops ext4_qctl_operations = { |
@@ -826,8 +978,8 @@ static const struct super_operations ext4_sops = { | |||
826 | .put_super = ext4_put_super, | 978 | .put_super = ext4_put_super, |
827 | .write_super = ext4_write_super, | 979 | .write_super = ext4_write_super, |
828 | .sync_fs = ext4_sync_fs, | 980 | .sync_fs = ext4_sync_fs, |
829 | .write_super_lockfs = ext4_write_super_lockfs, | 981 | .freeze_fs = ext4_freeze, |
830 | .unlockfs = ext4_unlockfs, | 982 | .unfreeze_fs = ext4_unfreeze, |
831 | .statfs = ext4_statfs, | 983 | .statfs = ext4_statfs, |
832 | .remount_fs = ext4_remount, | 984 | .remount_fs = ext4_remount, |
833 | .clear_inode = ext4_clear_inode, | 985 | .clear_inode = ext4_clear_inode, |
@@ -836,6 +988,7 @@ static const struct super_operations ext4_sops = { | |||
836 | .quota_read = ext4_quota_read, | 988 | .quota_read = ext4_quota_read, |
837 | .quota_write = ext4_quota_write, | 989 | .quota_write = ext4_quota_write, |
838 | #endif | 990 | #endif |
991 | .bdev_try_to_free_page = bdev_try_to_free_page, | ||
839 | }; | 992 | }; |
840 | 993 | ||
841 | static const struct export_operations ext4_export_ops = { | 994 | static const struct export_operations ext4_export_ops = { |
@@ -850,16 +1003,17 @@ enum { | |||
850 | Opt_nouid32, Opt_debug, Opt_oldalloc, Opt_orlov, | 1003 | Opt_nouid32, Opt_debug, Opt_oldalloc, Opt_orlov, |
851 | Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, | 1004 | Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, |
852 | Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, Opt_bh, | 1005 | Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, Opt_bh, |
853 | Opt_commit, Opt_journal_update, Opt_journal_inum, Opt_journal_dev, | 1006 | Opt_commit, Opt_min_batch_time, Opt_max_batch_time, |
1007 | Opt_journal_update, Opt_journal_dev, | ||
854 | Opt_journal_checksum, Opt_journal_async_commit, | 1008 | Opt_journal_checksum, Opt_journal_async_commit, |
855 | Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, | 1009 | Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, |
856 | Opt_data_err_abort, Opt_data_err_ignore, | 1010 | Opt_data_err_abort, Opt_data_err_ignore, |
857 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, | 1011 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, |
858 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, | 1012 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, |
859 | Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, | 1013 | Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, |
860 | Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version, | 1014 | Opt_grpquota, Opt_i_version, |
861 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, | 1015 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, |
862 | Opt_inode_readahead_blks | 1016 | Opt_inode_readahead_blks, Opt_journal_ioprio |
863 | }; | 1017 | }; |
864 | 1018 | ||
865 | static const match_table_t tokens = { | 1019 | static const match_table_t tokens = { |
@@ -889,8 +1043,9 @@ static const match_table_t tokens = { | |||
889 | {Opt_nobh, "nobh"}, | 1043 | {Opt_nobh, "nobh"}, |
890 | {Opt_bh, "bh"}, | 1044 | {Opt_bh, "bh"}, |
891 | {Opt_commit, "commit=%u"}, | 1045 | {Opt_commit, "commit=%u"}, |
1046 | {Opt_min_batch_time, "min_batch_time=%u"}, | ||
1047 | {Opt_max_batch_time, "max_batch_time=%u"}, | ||
892 | {Opt_journal_update, "journal=update"}, | 1048 | {Opt_journal_update, "journal=update"}, |
893 | {Opt_journal_inum, "journal=%u"}, | ||
894 | {Opt_journal_dev, "journal_dev=%u"}, | 1049 | {Opt_journal_dev, "journal_dev=%u"}, |
895 | {Opt_journal_checksum, "journal_checksum"}, | 1050 | {Opt_journal_checksum, "journal_checksum"}, |
896 | {Opt_journal_async_commit, "journal_async_commit"}, | 1051 | {Opt_journal_async_commit, "journal_async_commit"}, |
@@ -911,14 +1066,13 @@ static const match_table_t tokens = { | |||
911 | {Opt_quota, "quota"}, | 1066 | {Opt_quota, "quota"}, |
912 | {Opt_usrquota, "usrquota"}, | 1067 | {Opt_usrquota, "usrquota"}, |
913 | {Opt_barrier, "barrier=%u"}, | 1068 | {Opt_barrier, "barrier=%u"}, |
914 | {Opt_extents, "extents"}, | ||
915 | {Opt_noextents, "noextents"}, | ||
916 | {Opt_i_version, "i_version"}, | 1069 | {Opt_i_version, "i_version"}, |
917 | {Opt_stripe, "stripe=%u"}, | 1070 | {Opt_stripe, "stripe=%u"}, |
918 | {Opt_resize, "resize"}, | 1071 | {Opt_resize, "resize"}, |
919 | {Opt_delalloc, "delalloc"}, | 1072 | {Opt_delalloc, "delalloc"}, |
920 | {Opt_nodelalloc, "nodelalloc"}, | 1073 | {Opt_nodelalloc, "nodelalloc"}, |
921 | {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, | 1074 | {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, |
1075 | {Opt_journal_ioprio, "journal_ioprio=%u"}, | ||
922 | {Opt_err, NULL}, | 1076 | {Opt_err, NULL}, |
923 | }; | 1077 | }; |
924 | 1078 | ||
@@ -943,8 +1097,11 @@ static ext4_fsblk_t get_sb_block(void **data) | |||
943 | return sb_block; | 1097 | return sb_block; |
944 | } | 1098 | } |
945 | 1099 | ||
1100 | #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3)) | ||
1101 | |||
946 | static int parse_options(char *options, struct super_block *sb, | 1102 | static int parse_options(char *options, struct super_block *sb, |
947 | unsigned int *inum, unsigned long *journal_devnum, | 1103 | unsigned long *journal_devnum, |
1104 | unsigned int *journal_ioprio, | ||
948 | ext4_fsblk_t *n_blocks_count, int is_remount) | 1105 | ext4_fsblk_t *n_blocks_count, int is_remount) |
949 | { | 1106 | { |
950 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 1107 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
@@ -956,7 +1113,6 @@ static int parse_options(char *options, struct super_block *sb, | |||
956 | int qtype, qfmt; | 1113 | int qtype, qfmt; |
957 | char *qname; | 1114 | char *qname; |
958 | #endif | 1115 | #endif |
959 | ext4_fsblk_t last_block; | ||
960 | 1116 | ||
961 | if (!options) | 1117 | if (!options) |
962 | return 1; | 1118 | return 1; |
@@ -1068,16 +1224,6 @@ static int parse_options(char *options, struct super_block *sb, | |||
1068 | } | 1224 | } |
1069 | set_opt(sbi->s_mount_opt, UPDATE_JOURNAL); | 1225 | set_opt(sbi->s_mount_opt, UPDATE_JOURNAL); |
1070 | break; | 1226 | break; |
1071 | case Opt_journal_inum: | ||
1072 | if (is_remount) { | ||
1073 | printk(KERN_ERR "EXT4-fs: cannot specify " | ||
1074 | "journal on remount\n"); | ||
1075 | return 0; | ||
1076 | } | ||
1077 | if (match_int(&args[0], &option)) | ||
1078 | return 0; | ||
1079 | *inum = option; | ||
1080 | break; | ||
1081 | case Opt_journal_dev: | 1227 | case Opt_journal_dev: |
1082 | if (is_remount) { | 1228 | if (is_remount) { |
1083 | printk(KERN_ERR "EXT4-fs: cannot specify " | 1229 | printk(KERN_ERR "EXT4-fs: cannot specify " |
@@ -1107,6 +1253,22 @@ static int parse_options(char *options, struct super_block *sb, | |||
1107 | option = JBD2_DEFAULT_MAX_COMMIT_AGE; | 1253 | option = JBD2_DEFAULT_MAX_COMMIT_AGE; |
1108 | sbi->s_commit_interval = HZ * option; | 1254 | sbi->s_commit_interval = HZ * option; |
1109 | break; | 1255 | break; |
1256 | case Opt_max_batch_time: | ||
1257 | if (match_int(&args[0], &option)) | ||
1258 | return 0; | ||
1259 | if (option < 0) | ||
1260 | return 0; | ||
1261 | if (option == 0) | ||
1262 | option = EXT4_DEF_MAX_BATCH_TIME; | ||
1263 | sbi->s_max_batch_time = option; | ||
1264 | break; | ||
1265 | case Opt_min_batch_time: | ||
1266 | if (match_int(&args[0], &option)) | ||
1267 | return 0; | ||
1268 | if (option < 0) | ||
1269 | return 0; | ||
1270 | sbi->s_min_batch_time = option; | ||
1271 | break; | ||
1110 | case Opt_data_journal: | 1272 | case Opt_data_journal: |
1111 | data_opt = EXT4_MOUNT_JOURNAL_DATA; | 1273 | data_opt = EXT4_MOUNT_JOURNAL_DATA; |
1112 | goto datacheck; | 1274 | goto datacheck; |
@@ -1142,8 +1304,7 @@ static int parse_options(char *options, struct super_block *sb, | |||
1142 | case Opt_grpjquota: | 1304 | case Opt_grpjquota: |
1143 | qtype = GRPQUOTA; | 1305 | qtype = GRPQUOTA; |
1144 | set_qf_name: | 1306 | set_qf_name: |
1145 | if ((sb_any_quota_enabled(sb) || | 1307 | if (sb_any_quota_loaded(sb) && |
1146 | sb_any_quota_suspended(sb)) && | ||
1147 | !sbi->s_qf_names[qtype]) { | 1308 | !sbi->s_qf_names[qtype]) { |
1148 | printk(KERN_ERR | 1309 | printk(KERN_ERR |
1149 | "EXT4-fs: Cannot change journaled " | 1310 | "EXT4-fs: Cannot change journaled " |
@@ -1182,8 +1343,7 @@ set_qf_name: | |||
1182 | case Opt_offgrpjquota: | 1343 | case Opt_offgrpjquota: |
1183 | qtype = GRPQUOTA; | 1344 | qtype = GRPQUOTA; |
1184 | clear_qf_name: | 1345 | clear_qf_name: |
1185 | if ((sb_any_quota_enabled(sb) || | 1346 | if (sb_any_quota_loaded(sb) && |
1186 | sb_any_quota_suspended(sb)) && | ||
1187 | sbi->s_qf_names[qtype]) { | 1347 | sbi->s_qf_names[qtype]) { |
1188 | printk(KERN_ERR "EXT4-fs: Cannot change " | 1348 | printk(KERN_ERR "EXT4-fs: Cannot change " |
1189 | "journaled quota options when " | 1349 | "journaled quota options when " |
@@ -1202,8 +1362,7 @@ clear_qf_name: | |||
1202 | case Opt_jqfmt_vfsv0: | 1362 | case Opt_jqfmt_vfsv0: |
1203 | qfmt = QFMT_VFS_V0; | 1363 | qfmt = QFMT_VFS_V0; |
1204 | set_qf_format: | 1364 | set_qf_format: |
1205 | if ((sb_any_quota_enabled(sb) || | 1365 | if (sb_any_quota_loaded(sb) && |
1206 | sb_any_quota_suspended(sb)) && | ||
1207 | sbi->s_jquota_fmt != qfmt) { | 1366 | sbi->s_jquota_fmt != qfmt) { |
1208 | printk(KERN_ERR "EXT4-fs: Cannot change " | 1367 | printk(KERN_ERR "EXT4-fs: Cannot change " |
1209 | "journaled quota options when " | 1368 | "journaled quota options when " |
@@ -1222,7 +1381,7 @@ set_qf_format: | |||
1222 | set_opt(sbi->s_mount_opt, GRPQUOTA); | 1381 | set_opt(sbi->s_mount_opt, GRPQUOTA); |
1223 | break; | 1382 | break; |
1224 | case Opt_noquota: | 1383 | case Opt_noquota: |
1225 | if (sb_any_quota_enabled(sb)) { | 1384 | if (sb_any_quota_loaded(sb)) { |
1226 | printk(KERN_ERR "EXT4-fs: Cannot change quota " | 1385 | printk(KERN_ERR "EXT4-fs: Cannot change quota " |
1227 | "options when quota turned on.\n"); | 1386 | "options when quota turned on.\n"); |
1228 | return 0; | 1387 | return 0; |
@@ -1280,33 +1439,6 @@ set_qf_format: | |||
1280 | case Opt_bh: | 1439 | case Opt_bh: |
1281 | clear_opt(sbi->s_mount_opt, NOBH); | 1440 | clear_opt(sbi->s_mount_opt, NOBH); |
1282 | break; | 1441 | break; |
1283 | case Opt_extents: | ||
1284 | if (!EXT4_HAS_INCOMPAT_FEATURE(sb, | ||
1285 | EXT4_FEATURE_INCOMPAT_EXTENTS)) { | ||
1286 | ext4_warning(sb, __func__, | ||
1287 | "extents feature not enabled " | ||
1288 | "on this filesystem, use tune2fs\n"); | ||
1289 | return 0; | ||
1290 | } | ||
1291 | set_opt(sbi->s_mount_opt, EXTENTS); | ||
1292 | break; | ||
1293 | case Opt_noextents: | ||
1294 | /* | ||
1295 | * When e2fsprogs support resizing an already existing | ||
1296 | * ext3 file system to greater than 2**32 we need to | ||
1297 | * add support to block allocator to handle growing | ||
1298 | * already existing block mapped inode so that blocks | ||
1299 | * allocated for them fall within 2**32 | ||
1300 | */ | ||
1301 | last_block = ext4_blocks_count(sbi->s_es) - 1; | ||
1302 | if (last_block > 0xffffffffULL) { | ||
1303 | printk(KERN_ERR "EXT4-fs: Filesystem too " | ||
1304 | "large to mount with " | ||
1305 | "-o noextents options\n"); | ||
1306 | return 0; | ||
1307 | } | ||
1308 | clear_opt(sbi->s_mount_opt, EXTENTS); | ||
1309 | break; | ||
1310 | case Opt_i_version: | 1442 | case Opt_i_version: |
1311 | set_opt(sbi->s_mount_opt, I_VERSION); | 1443 | set_opt(sbi->s_mount_opt, I_VERSION); |
1312 | sb->s_flags |= MS_I_VERSION; | 1444 | sb->s_flags |= MS_I_VERSION; |
@@ -1331,6 +1463,14 @@ set_qf_format: | |||
1331 | return 0; | 1463 | return 0; |
1332 | sbi->s_inode_readahead_blks = option; | 1464 | sbi->s_inode_readahead_blks = option; |
1333 | break; | 1465 | break; |
1466 | case Opt_journal_ioprio: | ||
1467 | if (match_int(&args[0], &option)) | ||
1468 | return 0; | ||
1469 | if (option < 0 || option > 7) | ||
1470 | break; | ||
1471 | *journal_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, | ||
1472 | option); | ||
1473 | break; | ||
1334 | default: | 1474 | default: |
1335 | printk(KERN_ERR | 1475 | printk(KERN_ERR |
1336 | "EXT4-fs: Unrecognized mount option \"%s\" " | 1476 | "EXT4-fs: Unrecognized mount option \"%s\" " |
@@ -1406,24 +1546,19 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, | |||
1406 | printk(KERN_WARNING | 1546 | printk(KERN_WARNING |
1407 | "EXT4-fs warning: checktime reached, " | 1547 | "EXT4-fs warning: checktime reached, " |
1408 | "running e2fsck is recommended\n"); | 1548 | "running e2fsck is recommended\n"); |
1409 | #if 0 | 1549 | if (!sbi->s_journal) |
1410 | /* @@@ We _will_ want to clear the valid bit if we find | 1550 | es->s_state &= cpu_to_le16(~EXT4_VALID_FS); |
1411 | * inconsistencies, to force a fsck at reboot. But for | ||
1412 | * a plain journaled filesystem we can keep it set as | ||
1413 | * valid forever! :) | ||
1414 | */ | ||
1415 | es->s_state &= cpu_to_le16(~EXT4_VALID_FS); | ||
1416 | #endif | ||
1417 | if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) | 1551 | if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) |
1418 | es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT); | 1552 | es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT); |
1419 | le16_add_cpu(&es->s_mnt_count, 1); | 1553 | le16_add_cpu(&es->s_mnt_count, 1); |
1420 | es->s_mtime = cpu_to_le32(get_seconds()); | 1554 | es->s_mtime = cpu_to_le32(get_seconds()); |
1421 | ext4_update_dynamic_rev(sb); | 1555 | ext4_update_dynamic_rev(sb); |
1422 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 1556 | if (sbi->s_journal) |
1557 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | ||
1423 | 1558 | ||
1424 | ext4_commit_super(sb, es, 1); | 1559 | ext4_commit_super(sb, es, 1); |
1425 | if (test_opt(sb, DEBUG)) | 1560 | if (test_opt(sb, DEBUG)) |
1426 | printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%lu, " | 1561 | printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, " |
1427 | "bpg=%lu, ipg=%lu, mo=%04lx]\n", | 1562 | "bpg=%lu, ipg=%lu, mo=%04lx]\n", |
1428 | sb->s_blocksize, | 1563 | sb->s_blocksize, |
1429 | sbi->s_groups_count, | 1564 | sbi->s_groups_count, |
@@ -1431,9 +1566,13 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, | |||
1431 | EXT4_INODES_PER_GROUP(sb), | 1566 | EXT4_INODES_PER_GROUP(sb), |
1432 | sbi->s_mount_opt); | 1567 | sbi->s_mount_opt); |
1433 | 1568 | ||
1434 | printk(KERN_INFO "EXT4 FS on %s, %s journal on %s\n", | 1569 | if (EXT4_SB(sb)->s_journal) { |
1435 | sb->s_id, EXT4_SB(sb)->s_journal->j_inode ? "internal" : | 1570 | printk(KERN_INFO "EXT4 FS on %s, %s journal on %s\n", |
1436 | "external", EXT4_SB(sb)->s_journal->j_devname); | 1571 | sb->s_id, EXT4_SB(sb)->s_journal->j_inode ? "internal" : |
1572 | "external", EXT4_SB(sb)->s_journal->j_devname); | ||
1573 | } else { | ||
1574 | printk(KERN_INFO "EXT4 FS on %s, no journal\n", sb->s_id); | ||
1575 | } | ||
1437 | return res; | 1576 | return res; |
1438 | } | 1577 | } |
1439 | 1578 | ||
@@ -1445,7 +1584,6 @@ static int ext4_fill_flex_info(struct super_block *sb) | |||
1445 | ext4_group_t flex_group_count; | 1584 | ext4_group_t flex_group_count; |
1446 | ext4_group_t flex_group; | 1585 | ext4_group_t flex_group; |
1447 | int groups_per_flex = 0; | 1586 | int groups_per_flex = 0; |
1448 | __u64 block_bitmap = 0; | ||
1449 | int i; | 1587 | int i; |
1450 | 1588 | ||
1451 | if (!sbi->s_es->s_log_groups_per_flex) { | 1589 | if (!sbi->s_es->s_log_groups_per_flex) { |
@@ -1464,21 +1602,18 @@ static int ext4_fill_flex_info(struct super_block *sb) | |||
1464 | sizeof(struct flex_groups), GFP_KERNEL); | 1602 | sizeof(struct flex_groups), GFP_KERNEL); |
1465 | if (sbi->s_flex_groups == NULL) { | 1603 | if (sbi->s_flex_groups == NULL) { |
1466 | printk(KERN_ERR "EXT4-fs: not enough memory for " | 1604 | printk(KERN_ERR "EXT4-fs: not enough memory for " |
1467 | "%lu flex groups\n", flex_group_count); | 1605 | "%u flex groups\n", flex_group_count); |
1468 | goto failed; | 1606 | goto failed; |
1469 | } | 1607 | } |
1470 | 1608 | ||
1471 | gdp = ext4_get_group_desc(sb, 1, &bh); | ||
1472 | block_bitmap = ext4_block_bitmap(sb, gdp) - 1; | ||
1473 | |||
1474 | for (i = 0; i < sbi->s_groups_count; i++) { | 1609 | for (i = 0; i < sbi->s_groups_count; i++) { |
1475 | gdp = ext4_get_group_desc(sb, i, &bh); | 1610 | gdp = ext4_get_group_desc(sb, i, &bh); |
1476 | 1611 | ||
1477 | flex_group = ext4_flex_group(sbi, i); | 1612 | flex_group = ext4_flex_group(sbi, i); |
1478 | sbi->s_flex_groups[flex_group].free_inodes += | 1613 | sbi->s_flex_groups[flex_group].free_inodes += |
1479 | le16_to_cpu(gdp->bg_free_inodes_count); | 1614 | ext4_free_inodes_count(sb, gdp); |
1480 | sbi->s_flex_groups[flex_group].free_blocks += | 1615 | sbi->s_flex_groups[flex_group].free_blocks += |
1481 | le16_to_cpu(gdp->bg_free_blocks_count); | 1616 | ext4_free_blks_count(sb, gdp); |
1482 | } | 1617 | } |
1483 | 1618 | ||
1484 | return 1; | 1619 | return 1; |
@@ -1552,14 +1687,14 @@ static int ext4_check_descriptors(struct super_block *sb) | |||
1552 | block_bitmap = ext4_block_bitmap(sb, gdp); | 1687 | block_bitmap = ext4_block_bitmap(sb, gdp); |
1553 | if (block_bitmap < first_block || block_bitmap > last_block) { | 1688 | if (block_bitmap < first_block || block_bitmap > last_block) { |
1554 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1689 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " |
1555 | "Block bitmap for group %lu not in group " | 1690 | "Block bitmap for group %u not in group " |
1556 | "(block %llu)!\n", i, block_bitmap); | 1691 | "(block %llu)!\n", i, block_bitmap); |
1557 | return 0; | 1692 | return 0; |
1558 | } | 1693 | } |
1559 | inode_bitmap = ext4_inode_bitmap(sb, gdp); | 1694 | inode_bitmap = ext4_inode_bitmap(sb, gdp); |
1560 | if (inode_bitmap < first_block || inode_bitmap > last_block) { | 1695 | if (inode_bitmap < first_block || inode_bitmap > last_block) { |
1561 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1696 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " |
1562 | "Inode bitmap for group %lu not in group " | 1697 | "Inode bitmap for group %u not in group " |
1563 | "(block %llu)!\n", i, inode_bitmap); | 1698 | "(block %llu)!\n", i, inode_bitmap); |
1564 | return 0; | 1699 | return 0; |
1565 | } | 1700 | } |
@@ -1567,14 +1702,14 @@ static int ext4_check_descriptors(struct super_block *sb) | |||
1567 | if (inode_table < first_block || | 1702 | if (inode_table < first_block || |
1568 | inode_table + sbi->s_itb_per_group - 1 > last_block) { | 1703 | inode_table + sbi->s_itb_per_group - 1 > last_block) { |
1569 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1704 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " |
1570 | "Inode table for group %lu not in group " | 1705 | "Inode table for group %u not in group " |
1571 | "(block %llu)!\n", i, inode_table); | 1706 | "(block %llu)!\n", i, inode_table); |
1572 | return 0; | 1707 | return 0; |
1573 | } | 1708 | } |
1574 | spin_lock(sb_bgl_lock(sbi, i)); | 1709 | spin_lock(sb_bgl_lock(sbi, i)); |
1575 | if (!ext4_group_desc_csum_verify(sbi, i, gdp)) { | 1710 | if (!ext4_group_desc_csum_verify(sbi, i, gdp)) { |
1576 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1711 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " |
1577 | "Checksum for group %lu failed (%u!=%u)\n", | 1712 | "Checksum for group %u failed (%u!=%u)\n", |
1578 | i, le16_to_cpu(ext4_group_desc_csum(sbi, i, | 1713 | i, le16_to_cpu(ext4_group_desc_csum(sbi, i, |
1579 | gdp)), le16_to_cpu(gdp->bg_checksum)); | 1714 | gdp)), le16_to_cpu(gdp->bg_checksum)); |
1580 | if (!(sb->s_flags & MS_RDONLY)) { | 1715 | if (!(sb->s_flags & MS_RDONLY)) { |
@@ -1721,7 +1856,7 @@ static loff_t ext4_max_size(int blkbits, int has_huge_files) | |||
1721 | /* small i_blocks in vfs inode? */ | 1856 | /* small i_blocks in vfs inode? */ |
1722 | if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { | 1857 | if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { |
1723 | /* | 1858 | /* |
1724 | * CONFIG_LSF is not enabled implies the inode | 1859 | * CONFIG_LBD is not enabled implies the inode |
1725 | * i_block represent total blocks in 512 bytes | 1860 | * i_block represent total blocks in 512 bytes |
1726 | * 32 == size of vfs inode i_blocks * 8 | 1861 | * 32 == size of vfs inode i_blocks * 8 |
1727 | */ | 1862 | */ |
@@ -1764,7 +1899,7 @@ static loff_t ext4_max_bitmap_size(int bits, int has_huge_files) | |||
1764 | 1899 | ||
1765 | if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { | 1900 | if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { |
1766 | /* | 1901 | /* |
1767 | * !has_huge_files or CONFIG_LSF is not enabled | 1902 | * !has_huge_files or CONFIG_LBD is not enabled |
1768 | * implies the inode i_block represent total blocks in | 1903 | * implies the inode i_block represent total blocks in |
1769 | * 512 bytes 32 == size of vfs inode i_blocks * 8 | 1904 | * 512 bytes 32 == size of vfs inode i_blocks * 8 |
1770 | */ | 1905 | */ |
@@ -1866,19 +2001,20 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
1866 | ext4_fsblk_t sb_block = get_sb_block(&data); | 2001 | ext4_fsblk_t sb_block = get_sb_block(&data); |
1867 | ext4_fsblk_t logical_sb_block; | 2002 | ext4_fsblk_t logical_sb_block; |
1868 | unsigned long offset = 0; | 2003 | unsigned long offset = 0; |
1869 | unsigned int journal_inum = 0; | ||
1870 | unsigned long journal_devnum = 0; | 2004 | unsigned long journal_devnum = 0; |
1871 | unsigned long def_mount_opts; | 2005 | unsigned long def_mount_opts; |
1872 | struct inode *root; | 2006 | struct inode *root; |
1873 | char *cp; | 2007 | char *cp; |
2008 | const char *descr; | ||
1874 | int ret = -EINVAL; | 2009 | int ret = -EINVAL; |
1875 | int blocksize; | 2010 | int blocksize; |
1876 | int db_count; | 2011 | unsigned int db_count; |
1877 | int i; | 2012 | unsigned int i; |
1878 | int needs_recovery, has_huge_files; | 2013 | int needs_recovery, has_huge_files; |
1879 | __le32 features; | 2014 | int features; |
1880 | __u64 blocks_count; | 2015 | __u64 blocks_count; |
1881 | int err; | 2016 | int err; |
2017 | unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; | ||
1882 | 2018 | ||
1883 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 2019 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
1884 | if (!sbi) | 2020 | if (!sbi) |
@@ -1959,31 +2095,22 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
1959 | 2095 | ||
1960 | sbi->s_resuid = le16_to_cpu(es->s_def_resuid); | 2096 | sbi->s_resuid = le16_to_cpu(es->s_def_resuid); |
1961 | sbi->s_resgid = le16_to_cpu(es->s_def_resgid); | 2097 | sbi->s_resgid = le16_to_cpu(es->s_def_resgid); |
2098 | sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ; | ||
2099 | sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; | ||
2100 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; | ||
1962 | 2101 | ||
1963 | set_opt(sbi->s_mount_opt, RESERVATION); | 2102 | set_opt(sbi->s_mount_opt, RESERVATION); |
1964 | set_opt(sbi->s_mount_opt, BARRIER); | 2103 | set_opt(sbi->s_mount_opt, BARRIER); |
1965 | 2104 | ||
1966 | /* | 2105 | /* |
1967 | * turn on extents feature by default in ext4 filesystem | ||
1968 | * only if feature flag already set by mkfs or tune2fs. | ||
1969 | * Use -o noextents to turn it off | ||
1970 | */ | ||
1971 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) | ||
1972 | set_opt(sbi->s_mount_opt, EXTENTS); | ||
1973 | else | ||
1974 | ext4_warning(sb, __func__, | ||
1975 | "extents feature not enabled on this filesystem, " | ||
1976 | "use tune2fs.\n"); | ||
1977 | |||
1978 | /* | ||
1979 | * enable delayed allocation by default | 2106 | * enable delayed allocation by default |
1980 | * Use -o nodelalloc to turn it off | 2107 | * Use -o nodelalloc to turn it off |
1981 | */ | 2108 | */ |
1982 | set_opt(sbi->s_mount_opt, DELALLOC); | 2109 | set_opt(sbi->s_mount_opt, DELALLOC); |
1983 | 2110 | ||
1984 | 2111 | ||
1985 | if (!parse_options((char *) data, sb, &journal_inum, &journal_devnum, | 2112 | if (!parse_options((char *) data, sb, &journal_devnum, |
1986 | NULL, 0)) | 2113 | &journal_ioprio, NULL, 0)) |
1987 | goto failed_mount; | 2114 | goto failed_mount; |
1988 | 2115 | ||
1989 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | | 2116 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
@@ -2005,15 +2132,17 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2005 | features = EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP); | 2132 | features = EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP); |
2006 | if (features) { | 2133 | if (features) { |
2007 | printk(KERN_ERR "EXT4-fs: %s: couldn't mount because of " | 2134 | printk(KERN_ERR "EXT4-fs: %s: couldn't mount because of " |
2008 | "unsupported optional features (%x).\n", | 2135 | "unsupported optional features (%x).\n", sb->s_id, |
2009 | sb->s_id, le32_to_cpu(features)); | 2136 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) & |
2137 | ~EXT4_FEATURE_INCOMPAT_SUPP)); | ||
2010 | goto failed_mount; | 2138 | goto failed_mount; |
2011 | } | 2139 | } |
2012 | features = EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP); | 2140 | features = EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP); |
2013 | if (!(sb->s_flags & MS_RDONLY) && features) { | 2141 | if (!(sb->s_flags & MS_RDONLY) && features) { |
2014 | printk(KERN_ERR "EXT4-fs: %s: couldn't mount RDWR because of " | 2142 | printk(KERN_ERR "EXT4-fs: %s: couldn't mount RDWR because of " |
2015 | "unsupported optional features (%x).\n", | 2143 | "unsupported optional features (%x).\n", sb->s_id, |
2016 | sb->s_id, le32_to_cpu(features)); | 2144 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) & |
2145 | ~EXT4_FEATURE_RO_COMPAT_SUPP)); | ||
2017 | goto failed_mount; | 2146 | goto failed_mount; |
2018 | } | 2147 | } |
2019 | has_huge_files = EXT4_HAS_RO_COMPAT_FEATURE(sb, | 2148 | has_huge_files = EXT4_HAS_RO_COMPAT_FEATURE(sb, |
@@ -2021,13 +2150,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2021 | if (has_huge_files) { | 2150 | if (has_huge_files) { |
2022 | /* | 2151 | /* |
2023 | * Large file size enabled file system can only be | 2152 | * Large file size enabled file system can only be |
2024 | * mount if kernel is build with CONFIG_LSF | 2153 | * mount if kernel is build with CONFIG_LBD |
2025 | */ | 2154 | */ |
2026 | if (sizeof(root->i_blocks) < sizeof(u64) && | 2155 | if (sizeof(root->i_blocks) < sizeof(u64) && |
2027 | !(sb->s_flags & MS_RDONLY)) { | 2156 | !(sb->s_flags & MS_RDONLY)) { |
2028 | printk(KERN_ERR "EXT4-fs: %s: Filesystem with huge " | 2157 | printk(KERN_ERR "EXT4-fs: %s: Filesystem with huge " |
2029 | "files cannot be mounted read-write " | 2158 | "files cannot be mounted read-write " |
2030 | "without CONFIG_LSF.\n", sb->s_id); | 2159 | "without CONFIG_LBD.\n", sb->s_id); |
2031 | goto failed_mount; | 2160 | goto failed_mount; |
2032 | } | 2161 | } |
2033 | } | 2162 | } |
@@ -2118,6 +2247,18 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2118 | for (i = 0; i < 4; i++) | 2247 | for (i = 0; i < 4; i++) |
2119 | sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); | 2248 | sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); |
2120 | sbi->s_def_hash_version = es->s_def_hash_version; | 2249 | sbi->s_def_hash_version = es->s_def_hash_version; |
2250 | i = le32_to_cpu(es->s_flags); | ||
2251 | if (i & EXT2_FLAGS_UNSIGNED_HASH) | ||
2252 | sbi->s_hash_unsigned = 3; | ||
2253 | else if ((i & EXT2_FLAGS_SIGNED_HASH) == 0) { | ||
2254 | #ifdef __CHAR_UNSIGNED__ | ||
2255 | es->s_flags |= cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH); | ||
2256 | sbi->s_hash_unsigned = 3; | ||
2257 | #else | ||
2258 | es->s_flags |= cpu_to_le32(EXT2_FLAGS_SIGNED_HASH); | ||
2259 | #endif | ||
2260 | sb->s_dirt = 1; | ||
2261 | } | ||
2121 | 2262 | ||
2122 | if (sbi->s_blocks_per_group > blocksize * 8) { | 2263 | if (sbi->s_blocks_per_group > blocksize * 8) { |
2123 | printk(KERN_ERR | 2264 | printk(KERN_ERR |
@@ -2145,20 +2286,30 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2145 | if (EXT4_BLOCKS_PER_GROUP(sb) == 0) | 2286 | if (EXT4_BLOCKS_PER_GROUP(sb) == 0) |
2146 | goto cantfind_ext4; | 2287 | goto cantfind_ext4; |
2147 | 2288 | ||
2148 | /* ensure blocks_count calculation below doesn't sign-extend */ | 2289 | /* |
2149 | if (ext4_blocks_count(es) + EXT4_BLOCKS_PER_GROUP(sb) < | 2290 | * It makes no sense for the first data block to be beyond the end |
2150 | le32_to_cpu(es->s_first_data_block) + 1) { | 2291 | * of the filesystem. |
2151 | printk(KERN_WARNING "EXT4-fs: bad geometry: block count %llu, " | 2292 | */ |
2152 | "first data block %u, blocks per group %lu\n", | 2293 | if (le32_to_cpu(es->s_first_data_block) >= ext4_blocks_count(es)) { |
2153 | ext4_blocks_count(es), | 2294 | printk(KERN_WARNING "EXT4-fs: bad geometry: first data" |
2154 | le32_to_cpu(es->s_first_data_block), | 2295 | "block %u is beyond end of filesystem (%llu)\n", |
2155 | EXT4_BLOCKS_PER_GROUP(sb)); | 2296 | le32_to_cpu(es->s_first_data_block), |
2297 | ext4_blocks_count(es)); | ||
2156 | goto failed_mount; | 2298 | goto failed_mount; |
2157 | } | 2299 | } |
2158 | blocks_count = (ext4_blocks_count(es) - | 2300 | blocks_count = (ext4_blocks_count(es) - |
2159 | le32_to_cpu(es->s_first_data_block) + | 2301 | le32_to_cpu(es->s_first_data_block) + |
2160 | EXT4_BLOCKS_PER_GROUP(sb) - 1); | 2302 | EXT4_BLOCKS_PER_GROUP(sb) - 1); |
2161 | do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb)); | 2303 | do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb)); |
2304 | if (blocks_count > ((uint64_t)1<<32) - EXT4_DESC_PER_BLOCK(sb)) { | ||
2305 | printk(KERN_WARNING "EXT4-fs: groups count too large: %u " | ||
2306 | "(block count %llu, first data block %u, " | ||
2307 | "blocks per group %lu)\n", sbi->s_groups_count, | ||
2308 | ext4_blocks_count(es), | ||
2309 | le32_to_cpu(es->s_first_data_block), | ||
2310 | EXT4_BLOCKS_PER_GROUP(sb)); | ||
2311 | goto failed_mount; | ||
2312 | } | ||
2162 | sbi->s_groups_count = blocks_count; | 2313 | sbi->s_groups_count = blocks_count; |
2163 | db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / | 2314 | db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / |
2164 | EXT4_DESC_PER_BLOCK(sb); | 2315 | EXT4_DESC_PER_BLOCK(sb); |
@@ -2270,27 +2421,26 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2270 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | 2421 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; |
2271 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | 2422 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); |
2272 | ext4_commit_super(sb, es, 1); | 2423 | ext4_commit_super(sb, es, 1); |
2273 | printk(KERN_CRIT | ||
2274 | "EXT4-fs (device %s): mount failed\n", | ||
2275 | sb->s_id); | ||
2276 | goto failed_mount4; | 2424 | goto failed_mount4; |
2277 | } | 2425 | } |
2278 | } | 2426 | } |
2279 | } else if (journal_inum) { | 2427 | } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) && |
2280 | if (ext4_create_journal(sb, es, journal_inum)) | 2428 | EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { |
2281 | goto failed_mount3; | 2429 | printk(KERN_ERR "EXT4-fs: required journal recovery " |
2430 | "suppressed and not mounted read-only\n"); | ||
2431 | goto failed_mount4; | ||
2282 | } else { | 2432 | } else { |
2283 | if (!silent) | 2433 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); |
2284 | printk(KERN_ERR | 2434 | set_opt(sbi->s_mount_opt, WRITEBACK_DATA); |
2285 | "ext4: No journal on filesystem on %s\n", | 2435 | sbi->s_journal = NULL; |
2286 | sb->s_id); | 2436 | needs_recovery = 0; |
2287 | goto failed_mount3; | 2437 | goto no_journal; |
2288 | } | 2438 | } |
2289 | 2439 | ||
2290 | if (ext4_blocks_count(es) > 0xffffffffULL && | 2440 | if (ext4_blocks_count(es) > 0xffffffffULL && |
2291 | !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, | 2441 | !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, |
2292 | JBD2_FEATURE_INCOMPAT_64BIT)) { | 2442 | JBD2_FEATURE_INCOMPAT_64BIT)) { |
2293 | printk(KERN_ERR "ext4: Failed to set 64-bit journal feature\n"); | 2443 | printk(KERN_ERR "EXT4-fs: Failed to set 64-bit journal feature\n"); |
2294 | goto failed_mount4; | 2444 | goto failed_mount4; |
2295 | } | 2445 | } |
2296 | 2446 | ||
@@ -2335,6 +2485,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2335 | default: | 2485 | default: |
2336 | break; | 2486 | break; |
2337 | } | 2487 | } |
2488 | set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); | ||
2489 | |||
2490 | no_journal: | ||
2338 | 2491 | ||
2339 | if (test_opt(sb, NOBH)) { | 2492 | if (test_opt(sb, NOBH)) { |
2340 | if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { | 2493 | if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { |
@@ -2420,13 +2573,22 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2420 | EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS; | 2573 | EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS; |
2421 | ext4_orphan_cleanup(sb, es); | 2574 | ext4_orphan_cleanup(sb, es); |
2422 | EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; | 2575 | EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; |
2423 | if (needs_recovery) | 2576 | if (needs_recovery) { |
2424 | printk(KERN_INFO "EXT4-fs: recovery complete.\n"); | 2577 | printk(KERN_INFO "EXT4-fs: recovery complete.\n"); |
2425 | ext4_mark_recovery_complete(sb, es); | 2578 | ext4_mark_recovery_complete(sb, es); |
2426 | printk(KERN_INFO "EXT4-fs: mounted filesystem with %s data mode.\n", | 2579 | } |
2427 | test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ? "journal": | 2580 | if (EXT4_SB(sb)->s_journal) { |
2428 | test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered": | 2581 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) |
2429 | "writeback"); | 2582 | descr = " journalled data mode"; |
2583 | else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) | ||
2584 | descr = " ordered data mode"; | ||
2585 | else | ||
2586 | descr = " writeback data mode"; | ||
2587 | } else | ||
2588 | descr = "out journal"; | ||
2589 | |||
2590 | printk(KERN_INFO "EXT4-fs: mounted filesystem %s with%s\n", | ||
2591 | sb->s_id, descr); | ||
2430 | 2592 | ||
2431 | lock_kernel(); | 2593 | lock_kernel(); |
2432 | return 0; | 2594 | return 0; |
@@ -2438,8 +2600,11 @@ cantfind_ext4: | |||
2438 | goto failed_mount; | 2600 | goto failed_mount; |
2439 | 2601 | ||
2440 | failed_mount4: | 2602 | failed_mount4: |
2441 | jbd2_journal_destroy(sbi->s_journal); | 2603 | printk(KERN_ERR "EXT4-fs (device %s): mount failed\n", sb->s_id); |
2442 | sbi->s_journal = NULL; | 2604 | if (sbi->s_journal) { |
2605 | jbd2_journal_destroy(sbi->s_journal); | ||
2606 | sbi->s_journal = NULL; | ||
2607 | } | ||
2443 | failed_mount3: | 2608 | failed_mount3: |
2444 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | 2609 | percpu_counter_destroy(&sbi->s_freeblocks_counter); |
2445 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | 2610 | percpu_counter_destroy(&sbi->s_freeinodes_counter); |
@@ -2476,11 +2641,9 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) | |||
2476 | { | 2641 | { |
2477 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 2642 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
2478 | 2643 | ||
2479 | if (sbi->s_commit_interval) | 2644 | journal->j_commit_interval = sbi->s_commit_interval; |
2480 | journal->j_commit_interval = sbi->s_commit_interval; | 2645 | journal->j_min_batch_time = sbi->s_min_batch_time; |
2481 | /* We could also set up an ext4-specific default for the commit | 2646 | journal->j_max_batch_time = sbi->s_max_batch_time; |
2482 | * interval here, but for now we'll just fall back to the jbd | ||
2483 | * default. */ | ||
2484 | 2647 | ||
2485 | spin_lock(&journal->j_state_lock); | 2648 | spin_lock(&journal->j_state_lock); |
2486 | if (test_opt(sb, BARRIER)) | 2649 | if (test_opt(sb, BARRIER)) |
@@ -2500,6 +2663,8 @@ static journal_t *ext4_get_journal(struct super_block *sb, | |||
2500 | struct inode *journal_inode; | 2663 | struct inode *journal_inode; |
2501 | journal_t *journal; | 2664 | journal_t *journal; |
2502 | 2665 | ||
2666 | BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); | ||
2667 | |||
2503 | /* First, test for the existence of a valid inode on disk. Bad | 2668 | /* First, test for the existence of a valid inode on disk. Bad |
2504 | * things happen if we iget() an unused inode, as the subsequent | 2669 | * things happen if we iget() an unused inode, as the subsequent |
2505 | * iput() will try to delete it. */ | 2670 | * iput() will try to delete it. */ |
@@ -2548,13 +2713,15 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, | |||
2548 | struct ext4_super_block *es; | 2713 | struct ext4_super_block *es; |
2549 | struct block_device *bdev; | 2714 | struct block_device *bdev; |
2550 | 2715 | ||
2716 | BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); | ||
2717 | |||
2551 | bdev = ext4_blkdev_get(j_dev); | 2718 | bdev = ext4_blkdev_get(j_dev); |
2552 | if (bdev == NULL) | 2719 | if (bdev == NULL) |
2553 | return NULL; | 2720 | return NULL; |
2554 | 2721 | ||
2555 | if (bd_claim(bdev, sb)) { | 2722 | if (bd_claim(bdev, sb)) { |
2556 | printk(KERN_ERR | 2723 | printk(KERN_ERR |
2557 | "EXT4: failed to claim external journal device.\n"); | 2724 | "EXT4-fs: failed to claim external journal device.\n"); |
2558 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE); | 2725 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE); |
2559 | return NULL; | 2726 | return NULL; |
2560 | } | 2727 | } |
@@ -2635,6 +2802,8 @@ static int ext4_load_journal(struct super_block *sb, | |||
2635 | int err = 0; | 2802 | int err = 0; |
2636 | int really_read_only; | 2803 | int really_read_only; |
2637 | 2804 | ||
2805 | BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); | ||
2806 | |||
2638 | if (journal_devnum && | 2807 | if (journal_devnum && |
2639 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { | 2808 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { |
2640 | printk(KERN_INFO "EXT4-fs: external journal device major/minor " | 2809 | printk(KERN_INFO "EXT4-fs: external journal device major/minor " |
@@ -2719,55 +2888,14 @@ static int ext4_load_journal(struct super_block *sb, | |||
2719 | return 0; | 2888 | return 0; |
2720 | } | 2889 | } |
2721 | 2890 | ||
2722 | static int ext4_create_journal(struct super_block *sb, | 2891 | static int ext4_commit_super(struct super_block *sb, |
2723 | struct ext4_super_block *es, | ||
2724 | unsigned int journal_inum) | ||
2725 | { | ||
2726 | journal_t *journal; | ||
2727 | int err; | ||
2728 | |||
2729 | if (sb->s_flags & MS_RDONLY) { | ||
2730 | printk(KERN_ERR "EXT4-fs: readonly filesystem when trying to " | ||
2731 | "create journal.\n"); | ||
2732 | return -EROFS; | ||
2733 | } | ||
2734 | |||
2735 | journal = ext4_get_journal(sb, journal_inum); | ||
2736 | if (!journal) | ||
2737 | return -EINVAL; | ||
2738 | |||
2739 | printk(KERN_INFO "EXT4-fs: creating new journal on inode %u\n", | ||
2740 | journal_inum); | ||
2741 | |||
2742 | err = jbd2_journal_create(journal); | ||
2743 | if (err) { | ||
2744 | printk(KERN_ERR "EXT4-fs: error creating journal.\n"); | ||
2745 | jbd2_journal_destroy(journal); | ||
2746 | return -EIO; | ||
2747 | } | ||
2748 | |||
2749 | EXT4_SB(sb)->s_journal = journal; | ||
2750 | |||
2751 | ext4_update_dynamic_rev(sb); | ||
2752 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | ||
2753 | EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL); | ||
2754 | |||
2755 | es->s_journal_inum = cpu_to_le32(journal_inum); | ||
2756 | sb->s_dirt = 1; | ||
2757 | |||
2758 | /* Make sure we flush the recovery flag to disk. */ | ||
2759 | ext4_commit_super(sb, es, 1); | ||
2760 | |||
2761 | return 0; | ||
2762 | } | ||
2763 | |||
2764 | static void ext4_commit_super(struct super_block *sb, | ||
2765 | struct ext4_super_block *es, int sync) | 2892 | struct ext4_super_block *es, int sync) |
2766 | { | 2893 | { |
2767 | struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; | 2894 | struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; |
2895 | int error = 0; | ||
2768 | 2896 | ||
2769 | if (!sbh) | 2897 | if (!sbh) |
2770 | return; | 2898 | return error; |
2771 | if (buffer_write_io_error(sbh)) { | 2899 | if (buffer_write_io_error(sbh)) { |
2772 | /* | 2900 | /* |
2773 | * Oh, dear. A previous attempt to write the | 2901 | * Oh, dear. A previous attempt to write the |
@@ -2777,25 +2905,33 @@ static void ext4_commit_super(struct super_block *sb, | |||
2777 | * be remapped. Nothing we can do but to retry the | 2905 | * be remapped. Nothing we can do but to retry the |
2778 | * write and hope for the best. | 2906 | * write and hope for the best. |
2779 | */ | 2907 | */ |
2780 | printk(KERN_ERR "ext4: previous I/O error to " | 2908 | printk(KERN_ERR "EXT4-fs: previous I/O error to " |
2781 | "superblock detected for %s.\n", sb->s_id); | 2909 | "superblock detected for %s.\n", sb->s_id); |
2782 | clear_buffer_write_io_error(sbh); | 2910 | clear_buffer_write_io_error(sbh); |
2783 | set_buffer_uptodate(sbh); | 2911 | set_buffer_uptodate(sbh); |
2784 | } | 2912 | } |
2785 | es->s_wtime = cpu_to_le32(get_seconds()); | 2913 | es->s_wtime = cpu_to_le32(get_seconds()); |
2786 | ext4_free_blocks_count_set(es, ext4_count_free_blocks(sb)); | 2914 | ext4_free_blocks_count_set(es, percpu_counter_sum_positive( |
2787 | es->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb)); | 2915 | &EXT4_SB(sb)->s_freeblocks_counter)); |
2916 | es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive( | ||
2917 | &EXT4_SB(sb)->s_freeinodes_counter)); | ||
2918 | |||
2788 | BUFFER_TRACE(sbh, "marking dirty"); | 2919 | BUFFER_TRACE(sbh, "marking dirty"); |
2789 | mark_buffer_dirty(sbh); | 2920 | mark_buffer_dirty(sbh); |
2790 | if (sync) { | 2921 | if (sync) { |
2791 | sync_dirty_buffer(sbh); | 2922 | error = sync_dirty_buffer(sbh); |
2792 | if (buffer_write_io_error(sbh)) { | 2923 | if (error) |
2793 | printk(KERN_ERR "ext4: I/O error while writing " | 2924 | return error; |
2925 | |||
2926 | error = buffer_write_io_error(sbh); | ||
2927 | if (error) { | ||
2928 | printk(KERN_ERR "EXT4-fs: I/O error while writing " | ||
2794 | "superblock for %s.\n", sb->s_id); | 2929 | "superblock for %s.\n", sb->s_id); |
2795 | clear_buffer_write_io_error(sbh); | 2930 | clear_buffer_write_io_error(sbh); |
2796 | set_buffer_uptodate(sbh); | 2931 | set_buffer_uptodate(sbh); |
2797 | } | 2932 | } |
2798 | } | 2933 | } |
2934 | return error; | ||
2799 | } | 2935 | } |
2800 | 2936 | ||
2801 | 2937 | ||
@@ -2809,6 +2945,10 @@ static void ext4_mark_recovery_complete(struct super_block *sb, | |||
2809 | { | 2945 | { |
2810 | journal_t *journal = EXT4_SB(sb)->s_journal; | 2946 | journal_t *journal = EXT4_SB(sb)->s_journal; |
2811 | 2947 | ||
2948 | if (!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) { | ||
2949 | BUG_ON(journal != NULL); | ||
2950 | return; | ||
2951 | } | ||
2812 | jbd2_journal_lock_updates(journal); | 2952 | jbd2_journal_lock_updates(journal); |
2813 | if (jbd2_journal_flush(journal) < 0) | 2953 | if (jbd2_journal_flush(journal) < 0) |
2814 | goto out; | 2954 | goto out; |
@@ -2838,6 +2978,8 @@ static void ext4_clear_journal_err(struct super_block *sb, | |||
2838 | int j_errno; | 2978 | int j_errno; |
2839 | const char *errstr; | 2979 | const char *errstr; |
2840 | 2980 | ||
2981 | BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); | ||
2982 | |||
2841 | journal = EXT4_SB(sb)->s_journal; | 2983 | journal = EXT4_SB(sb)->s_journal; |
2842 | 2984 | ||
2843 | /* | 2985 | /* |
@@ -2870,14 +3012,17 @@ static void ext4_clear_journal_err(struct super_block *sb, | |||
2870 | int ext4_force_commit(struct super_block *sb) | 3012 | int ext4_force_commit(struct super_block *sb) |
2871 | { | 3013 | { |
2872 | journal_t *journal; | 3014 | journal_t *journal; |
2873 | int ret; | 3015 | int ret = 0; |
2874 | 3016 | ||
2875 | if (sb->s_flags & MS_RDONLY) | 3017 | if (sb->s_flags & MS_RDONLY) |
2876 | return 0; | 3018 | return 0; |
2877 | 3019 | ||
2878 | journal = EXT4_SB(sb)->s_journal; | 3020 | journal = EXT4_SB(sb)->s_journal; |
2879 | sb->s_dirt = 0; | 3021 | if (journal) { |
2880 | ret = ext4_journal_force_commit(journal); | 3022 | sb->s_dirt = 0; |
3023 | ret = ext4_journal_force_commit(journal); | ||
3024 | } | ||
3025 | |||
2881 | return ret; | 3026 | return ret; |
2882 | } | 3027 | } |
2883 | 3028 | ||
@@ -2889,9 +3034,13 @@ int ext4_force_commit(struct super_block *sb) | |||
2889 | */ | 3034 | */ |
2890 | static void ext4_write_super(struct super_block *sb) | 3035 | static void ext4_write_super(struct super_block *sb) |
2891 | { | 3036 | { |
2892 | if (mutex_trylock(&sb->s_lock) != 0) | 3037 | if (EXT4_SB(sb)->s_journal) { |
2893 | BUG(); | 3038 | if (mutex_trylock(&sb->s_lock) != 0) |
2894 | sb->s_dirt = 0; | 3039 | BUG(); |
3040 | sb->s_dirt = 0; | ||
3041 | } else { | ||
3042 | ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); | ||
3043 | } | ||
2895 | } | 3044 | } |
2896 | 3045 | ||
2897 | static int ext4_sync_fs(struct super_block *sb, int wait) | 3046 | static int ext4_sync_fs(struct super_block *sb, int wait) |
@@ -2900,10 +3049,14 @@ static int ext4_sync_fs(struct super_block *sb, int wait) | |||
2900 | 3049 | ||
2901 | trace_mark(ext4_sync_fs, "dev %s wait %d", sb->s_id, wait); | 3050 | trace_mark(ext4_sync_fs, "dev %s wait %d", sb->s_id, wait); |
2902 | sb->s_dirt = 0; | 3051 | sb->s_dirt = 0; |
2903 | if (wait) | 3052 | if (EXT4_SB(sb)->s_journal) { |
2904 | ret = ext4_force_commit(sb); | 3053 | if (wait) |
2905 | else | 3054 | ret = ext4_force_commit(sb); |
2906 | jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, NULL); | 3055 | else |
3056 | jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, NULL); | ||
3057 | } else { | ||
3058 | ext4_commit_super(sb, EXT4_SB(sb)->s_es, wait); | ||
3059 | } | ||
2907 | return ret; | 3060 | return ret; |
2908 | } | 3061 | } |
2909 | 3062 | ||
@@ -2911,36 +3064,48 @@ static int ext4_sync_fs(struct super_block *sb, int wait) | |||
2911 | * LVM calls this function before a (read-only) snapshot is created. This | 3064 | * LVM calls this function before a (read-only) snapshot is created. This |
2912 | * gives us a chance to flush the journal completely and mark the fs clean. | 3065 | * gives us a chance to flush the journal completely and mark the fs clean. |
2913 | */ | 3066 | */ |
2914 | static void ext4_write_super_lockfs(struct super_block *sb) | 3067 | static int ext4_freeze(struct super_block *sb) |
2915 | { | 3068 | { |
3069 | int error = 0; | ||
3070 | journal_t *journal; | ||
2916 | sb->s_dirt = 0; | 3071 | sb->s_dirt = 0; |
2917 | 3072 | ||
2918 | if (!(sb->s_flags & MS_RDONLY)) { | 3073 | if (!(sb->s_flags & MS_RDONLY)) { |
2919 | journal_t *journal = EXT4_SB(sb)->s_journal; | 3074 | journal = EXT4_SB(sb)->s_journal; |
2920 | 3075 | ||
2921 | /* Now we set up the journal barrier. */ | 3076 | if (journal) { |
2922 | jbd2_journal_lock_updates(journal); | 3077 | /* Now we set up the journal barrier. */ |
3078 | jbd2_journal_lock_updates(journal); | ||
2923 | 3079 | ||
2924 | /* | 3080 | /* |
2925 | * We don't want to clear needs_recovery flag when we failed | 3081 | * We don't want to clear needs_recovery flag when we |
2926 | * to flush the journal. | 3082 | * failed to flush the journal. |
2927 | */ | 3083 | */ |
2928 | if (jbd2_journal_flush(journal) < 0) | 3084 | error = jbd2_journal_flush(journal); |
2929 | return; | 3085 | if (error < 0) |
3086 | goto out; | ||
3087 | } | ||
2930 | 3088 | ||
2931 | /* Journal blocked and flushed, clear needs_recovery flag. */ | 3089 | /* Journal blocked and flushed, clear needs_recovery flag. */ |
2932 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 3090 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
2933 | ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); | 3091 | ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); |
3092 | error = ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); | ||
3093 | if (error) | ||
3094 | goto out; | ||
2934 | } | 3095 | } |
3096 | return 0; | ||
3097 | out: | ||
3098 | jbd2_journal_unlock_updates(journal); | ||
3099 | return error; | ||
2935 | } | 3100 | } |
2936 | 3101 | ||
2937 | /* | 3102 | /* |
2938 | * Called by LVM after the snapshot is done. We need to reset the RECOVER | 3103 | * Called by LVM after the snapshot is done. We need to reset the RECOVER |
2939 | * flag here, even though the filesystem is not technically dirty yet. | 3104 | * flag here, even though the filesystem is not technically dirty yet. |
2940 | */ | 3105 | */ |
2941 | static void ext4_unlockfs(struct super_block *sb) | 3106 | static int ext4_unfreeze(struct super_block *sb) |
2942 | { | 3107 | { |
2943 | if (!(sb->s_flags & MS_RDONLY)) { | 3108 | if (EXT4_SB(sb)->s_journal && !(sb->s_flags & MS_RDONLY)) { |
2944 | lock_super(sb); | 3109 | lock_super(sb); |
2945 | /* Reser the needs_recovery flag before the fs is unlocked. */ | 3110 | /* Reser the needs_recovery flag before the fs is unlocked. */ |
2946 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 3111 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
@@ -2948,6 +3113,7 @@ static void ext4_unlockfs(struct super_block *sb) | |||
2948 | unlock_super(sb); | 3113 | unlock_super(sb); |
2949 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | 3114 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); |
2950 | } | 3115 | } |
3116 | return 0; | ||
2951 | } | 3117 | } |
2952 | 3118 | ||
2953 | static int ext4_remount(struct super_block *sb, int *flags, char *data) | 3119 | static int ext4_remount(struct super_block *sb, int *flags, char *data) |
@@ -2958,6 +3124,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
2958 | unsigned long old_sb_flags; | 3124 | unsigned long old_sb_flags; |
2959 | struct ext4_mount_options old_opts; | 3125 | struct ext4_mount_options old_opts; |
2960 | ext4_group_t g; | 3126 | ext4_group_t g; |
3127 | unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; | ||
2961 | int err; | 3128 | int err; |
2962 | #ifdef CONFIG_QUOTA | 3129 | #ifdef CONFIG_QUOTA |
2963 | int i; | 3130 | int i; |
@@ -2969,16 +3136,21 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
2969 | old_opts.s_resuid = sbi->s_resuid; | 3136 | old_opts.s_resuid = sbi->s_resuid; |
2970 | old_opts.s_resgid = sbi->s_resgid; | 3137 | old_opts.s_resgid = sbi->s_resgid; |
2971 | old_opts.s_commit_interval = sbi->s_commit_interval; | 3138 | old_opts.s_commit_interval = sbi->s_commit_interval; |
3139 | old_opts.s_min_batch_time = sbi->s_min_batch_time; | ||
3140 | old_opts.s_max_batch_time = sbi->s_max_batch_time; | ||
2972 | #ifdef CONFIG_QUOTA | 3141 | #ifdef CONFIG_QUOTA |
2973 | old_opts.s_jquota_fmt = sbi->s_jquota_fmt; | 3142 | old_opts.s_jquota_fmt = sbi->s_jquota_fmt; |
2974 | for (i = 0; i < MAXQUOTAS; i++) | 3143 | for (i = 0; i < MAXQUOTAS; i++) |
2975 | old_opts.s_qf_names[i] = sbi->s_qf_names[i]; | 3144 | old_opts.s_qf_names[i] = sbi->s_qf_names[i]; |
2976 | #endif | 3145 | #endif |
3146 | if (sbi->s_journal && sbi->s_journal->j_task->io_context) | ||
3147 | journal_ioprio = sbi->s_journal->j_task->io_context->ioprio; | ||
2977 | 3148 | ||
2978 | /* | 3149 | /* |
2979 | * Allow the "check" option to be passed as a remount option. | 3150 | * Allow the "check" option to be passed as a remount option. |
2980 | */ | 3151 | */ |
2981 | if (!parse_options(data, sb, NULL, NULL, &n_blocks_count, 1)) { | 3152 | if (!parse_options(data, sb, NULL, &journal_ioprio, |
3153 | &n_blocks_count, 1)) { | ||
2982 | err = -EINVAL; | 3154 | err = -EINVAL; |
2983 | goto restore_opts; | 3155 | goto restore_opts; |
2984 | } | 3156 | } |
@@ -2991,7 +3163,10 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
2991 | 3163 | ||
2992 | es = sbi->s_es; | 3164 | es = sbi->s_es; |
2993 | 3165 | ||
2994 | ext4_init_journal_params(sb, sbi->s_journal); | 3166 | if (sbi->s_journal) { |
3167 | ext4_init_journal_params(sb, sbi->s_journal); | ||
3168 | set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); | ||
3169 | } | ||
2995 | 3170 | ||
2996 | if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || | 3171 | if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || |
2997 | n_blocks_count > ext4_blocks_count(es)) { | 3172 | n_blocks_count > ext4_blocks_count(es)) { |
@@ -3020,17 +3195,20 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3020 | * We have to unlock super so that we can wait for | 3195 | * We have to unlock super so that we can wait for |
3021 | * transactions. | 3196 | * transactions. |
3022 | */ | 3197 | */ |
3023 | unlock_super(sb); | 3198 | if (sbi->s_journal) { |
3024 | ext4_mark_recovery_complete(sb, es); | 3199 | unlock_super(sb); |
3025 | lock_super(sb); | 3200 | ext4_mark_recovery_complete(sb, es); |
3201 | lock_super(sb); | ||
3202 | } | ||
3026 | } else { | 3203 | } else { |
3027 | __le32 ret; | 3204 | int ret; |
3028 | if ((ret = EXT4_HAS_RO_COMPAT_FEATURE(sb, | 3205 | if ((ret = EXT4_HAS_RO_COMPAT_FEATURE(sb, |
3029 | ~EXT4_FEATURE_RO_COMPAT_SUPP))) { | 3206 | ~EXT4_FEATURE_RO_COMPAT_SUPP))) { |
3030 | printk(KERN_WARNING "EXT4-fs: %s: couldn't " | 3207 | printk(KERN_WARNING "EXT4-fs: %s: couldn't " |
3031 | "remount RDWR because of unsupported " | 3208 | "remount RDWR because of unsupported " |
3032 | "optional features (%x).\n", | 3209 | "optional features (%x).\n", sb->s_id, |
3033 | sb->s_id, le32_to_cpu(ret)); | 3210 | (le32_to_cpu(sbi->s_es->s_feature_ro_compat) & |
3211 | ~EXT4_FEATURE_RO_COMPAT_SUPP)); | ||
3034 | err = -EROFS; | 3212 | err = -EROFS; |
3035 | goto restore_opts; | 3213 | goto restore_opts; |
3036 | } | 3214 | } |
@@ -3047,7 +3225,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3047 | if (!ext4_group_desc_csum_verify(sbi, g, gdp)) { | 3225 | if (!ext4_group_desc_csum_verify(sbi, g, gdp)) { |
3048 | printk(KERN_ERR | 3226 | printk(KERN_ERR |
3049 | "EXT4-fs: ext4_remount: " | 3227 | "EXT4-fs: ext4_remount: " |
3050 | "Checksum for group %lu failed (%u!=%u)\n", | 3228 | "Checksum for group %u failed (%u!=%u)\n", |
3051 | g, le16_to_cpu(ext4_group_desc_csum(sbi, g, gdp)), | 3229 | g, le16_to_cpu(ext4_group_desc_csum(sbi, g, gdp)), |
3052 | le16_to_cpu(gdp->bg_checksum)); | 3230 | le16_to_cpu(gdp->bg_checksum)); |
3053 | err = -EINVAL; | 3231 | err = -EINVAL; |
@@ -3076,7 +3254,8 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3076 | * been changed by e2fsck since we originally mounted | 3254 | * been changed by e2fsck since we originally mounted |
3077 | * the partition.) | 3255 | * the partition.) |
3078 | */ | 3256 | */ |
3079 | ext4_clear_journal_err(sb, es); | 3257 | if (sbi->s_journal) |
3258 | ext4_clear_journal_err(sb, es); | ||
3080 | sbi->s_mount_state = le16_to_cpu(es->s_state); | 3259 | sbi->s_mount_state = le16_to_cpu(es->s_state); |
3081 | if ((err = ext4_group_extend(sb, es, n_blocks_count))) | 3260 | if ((err = ext4_group_extend(sb, es, n_blocks_count))) |
3082 | goto restore_opts; | 3261 | goto restore_opts; |
@@ -3084,6 +3263,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3084 | sb->s_flags &= ~MS_RDONLY; | 3263 | sb->s_flags &= ~MS_RDONLY; |
3085 | } | 3264 | } |
3086 | } | 3265 | } |
3266 | if (sbi->s_journal == NULL) | ||
3267 | ext4_commit_super(sb, es, 1); | ||
3268 | |||
3087 | #ifdef CONFIG_QUOTA | 3269 | #ifdef CONFIG_QUOTA |
3088 | /* Release old quota file names */ | 3270 | /* Release old quota file names */ |
3089 | for (i = 0; i < MAXQUOTAS; i++) | 3271 | for (i = 0; i < MAXQUOTAS; i++) |
@@ -3098,6 +3280,8 @@ restore_opts: | |||
3098 | sbi->s_resuid = old_opts.s_resuid; | 3280 | sbi->s_resuid = old_opts.s_resuid; |
3099 | sbi->s_resgid = old_opts.s_resgid; | 3281 | sbi->s_resgid = old_opts.s_resgid; |
3100 | sbi->s_commit_interval = old_opts.s_commit_interval; | 3282 | sbi->s_commit_interval = old_opts.s_commit_interval; |
3283 | sbi->s_min_batch_time = old_opts.s_min_batch_time; | ||
3284 | sbi->s_max_batch_time = old_opts.s_max_batch_time; | ||
3101 | #ifdef CONFIG_QUOTA | 3285 | #ifdef CONFIG_QUOTA |
3102 | sbi->s_jquota_fmt = old_opts.s_jquota_fmt; | 3286 | sbi->s_jquota_fmt = old_opts.s_jquota_fmt; |
3103 | for (i = 0; i < MAXQUOTAS; i++) { | 3287 | for (i = 0; i < MAXQUOTAS; i++) { |
@@ -3360,7 +3544,8 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, | |||
3360 | * When we journal data on quota file, we have to flush journal to see | 3544 | * When we journal data on quota file, we have to flush journal to see |
3361 | * all updates to the file when we bypass pagecache... | 3545 | * all updates to the file when we bypass pagecache... |
3362 | */ | 3546 | */ |
3363 | if (ext4_should_journal_data(path.dentry->d_inode)) { | 3547 | if (EXT4_SB(sb)->s_journal && |
3548 | ext4_should_journal_data(path.dentry->d_inode)) { | ||
3364 | /* | 3549 | /* |
3365 | * We don't need to lock updates but journal_flush() could | 3550 | * We don't need to lock updates but journal_flush() could |
3366 | * otherwise be livelocked... | 3551 | * otherwise be livelocked... |
@@ -3434,7 +3619,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
3434 | struct buffer_head *bh; | 3619 | struct buffer_head *bh; |
3435 | handle_t *handle = journal_current_handle(); | 3620 | handle_t *handle = journal_current_handle(); |
3436 | 3621 | ||
3437 | if (!handle) { | 3622 | if (EXT4_SB(sb)->s_journal && !handle) { |
3438 | printk(KERN_WARNING "EXT4-fs: Quota write (off=%llu, len=%llu)" | 3623 | printk(KERN_WARNING "EXT4-fs: Quota write (off=%llu, len=%llu)" |
3439 | " cancelled because transaction is not started.\n", | 3624 | " cancelled because transaction is not started.\n", |
3440 | (unsigned long long)off, (unsigned long long)len); | 3625 | (unsigned long long)off, (unsigned long long)len); |
@@ -3459,7 +3644,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
3459 | flush_dcache_page(bh->b_page); | 3644 | flush_dcache_page(bh->b_page); |
3460 | unlock_buffer(bh); | 3645 | unlock_buffer(bh); |
3461 | if (journal_quota) | 3646 | if (journal_quota) |
3462 | err = ext4_journal_dirty_metadata(handle, bh); | 3647 | err = ext4_handle_dirty_metadata(handle, NULL, bh); |
3463 | else { | 3648 | else { |
3464 | /* Always do at least ordered writes for quotas */ | 3649 | /* Always do at least ordered writes for quotas */ |
3465 | err = ext4_jbd2_file_inode(handle, inode); | 3650 | err = ext4_jbd2_file_inode(handle, inode); |
@@ -3513,18 +3698,15 @@ static int ext4_ui_proc_open(struct inode *inode, struct file *file) | |||
3513 | static ssize_t ext4_ui_proc_write(struct file *file, const char __user *buf, | 3698 | static ssize_t ext4_ui_proc_write(struct file *file, const char __user *buf, |
3514 | size_t cnt, loff_t *ppos) | 3699 | size_t cnt, loff_t *ppos) |
3515 | { | 3700 | { |
3516 | unsigned int *p = PDE(file->f_path.dentry->d_inode)->data; | 3701 | unsigned long *p = PDE(file->f_path.dentry->d_inode)->data; |
3517 | char str[32]; | 3702 | char str[32]; |
3518 | unsigned long value; | ||
3519 | 3703 | ||
3520 | if (cnt >= sizeof(str)) | 3704 | if (cnt >= sizeof(str)) |
3521 | return -EINVAL; | 3705 | return -EINVAL; |
3522 | if (copy_from_user(str, buf, cnt)) | 3706 | if (copy_from_user(str, buf, cnt)) |
3523 | return -EFAULT; | 3707 | return -EFAULT; |
3524 | value = simple_strtol(str, NULL, 0); | 3708 | |
3525 | if (value < 0) | 3709 | *p = simple_strtoul(str, NULL, 0); |
3526 | return -ERANGE; | ||
3527 | *p = value; | ||
3528 | return cnt; | 3710 | return cnt; |
3529 | } | 3711 | } |
3530 | 3712 | ||
@@ -3615,7 +3797,7 @@ static void __exit exit_ext4_fs(void) | |||
3615 | } | 3797 | } |
3616 | 3798 | ||
3617 | MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); | 3799 | MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); |
3618 | MODULE_DESCRIPTION("Fourth Extended Filesystem with extents"); | 3800 | MODULE_DESCRIPTION("Fourth Extended Filesystem"); |
3619 | MODULE_LICENSE("GPL"); | 3801 | MODULE_LICENSE("GPL"); |
3620 | module_init(init_ext4_fs) | 3802 | module_init(init_ext4_fs) |
3621 | module_exit(exit_ext4_fs) | 3803 | module_exit(exit_ext4_fs) |