aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c289
1 files changed, 147 insertions, 142 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 8f4f079e6b9a..312211ee05af 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -45,17 +45,11 @@
45#include "ext4_jbd2.h" 45#include "ext4_jbd2.h"
46#include "xattr.h" 46#include "xattr.h"
47#include "acl.h" 47#include "acl.h"
48#include "mballoc.h"
48 49
49#define CREATE_TRACE_POINTS 50#define CREATE_TRACE_POINTS
50#include <trace/events/ext4.h> 51#include <trace/events/ext4.h>
51 52
52static int default_mb_history_length = 1000;
53
54module_param_named(default_mb_history_length, default_mb_history_length,
55 int, 0644);
56MODULE_PARM_DESC(default_mb_history_length,
57 "Default number of entries saved for mb_history");
58
59struct proc_dir_entry *ext4_proc_root; 53struct proc_dir_entry *ext4_proc_root;
60static struct kset *ext4_kset; 54static struct kset *ext4_kset;
61 55
@@ -188,6 +182,36 @@ void ext4_itable_unused_set(struct super_block *sb,
188 bg->bg_itable_unused_hi = cpu_to_le16(count >> 16); 182 bg->bg_itable_unused_hi = cpu_to_le16(count >> 16);
189} 183}
190 184
185
186/* Just increment the non-pointer handle value */
187static handle_t *ext4_get_nojournal(void)
188{
189 handle_t *handle = current->journal_info;
190 unsigned long ref_cnt = (unsigned long)handle;
191
192 BUG_ON(ref_cnt >= EXT4_NOJOURNAL_MAX_REF_COUNT);
193
194 ref_cnt++;
195 handle = (handle_t *)ref_cnt;
196
197 current->journal_info = handle;
198 return handle;
199}
200
201
202/* Decrement the non-pointer handle value */
203static void ext4_put_nojournal(handle_t *handle)
204{
205 unsigned long ref_cnt = (unsigned long)handle;
206
207 BUG_ON(ref_cnt == 0);
208
209 ref_cnt--;
210 handle = (handle_t *)ref_cnt;
211
212 current->journal_info = handle;
213}
214
191/* 215/*
192 * Wrappers for jbd2_journal_start/end. 216 * Wrappers for jbd2_journal_start/end.
193 * 217 *
@@ -214,11 +238,7 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)
214 } 238 }
215 return jbd2_journal_start(journal, nblocks); 239 return jbd2_journal_start(journal, nblocks);
216 } 240 }
217 /* 241 return ext4_get_nojournal();
218 * We're not journaling, return the appropriate indication.
219 */
220 current->journal_info = EXT4_NOJOURNAL_HANDLE;
221 return current->journal_info;
222} 242}
223 243
224/* 244/*
@@ -234,11 +254,7 @@ int __ext4_journal_stop(const char *where, handle_t *handle)
234 int rc; 254 int rc;
235 255
236 if (!ext4_handle_valid(handle)) { 256 if (!ext4_handle_valid(handle)) {
237 /* 257 ext4_put_nojournal(handle);
238 * Do this here since we don't call jbd2_journal_stop() in
239 * no-journal mode.
240 */
241 current->journal_info = NULL;
242 return 0; 258 return 0;
243 } 259 }
244 sb = handle->h_transaction->t_journal->j_private; 260 sb = handle->h_transaction->t_journal->j_private;
@@ -344,7 +360,8 @@ static const char *ext4_decode_error(struct super_block *sb, int errno,
344 errstr = "Out of memory"; 360 errstr = "Out of memory";
345 break; 361 break;
346 case -EROFS: 362 case -EROFS:
347 if (!sb || EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT) 363 if (!sb || (EXT4_SB(sb)->s_journal &&
364 EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT))
348 errstr = "Journal has aborted"; 365 errstr = "Journal has aborted";
349 else 366 else
350 errstr = "Readonly filesystem"; 367 errstr = "Readonly filesystem";
@@ -578,6 +595,9 @@ static void ext4_put_super(struct super_block *sb)
578 struct ext4_super_block *es = sbi->s_es; 595 struct ext4_super_block *es = sbi->s_es;
579 int i, err; 596 int i, err;
580 597
598 flush_workqueue(sbi->dio_unwritten_wq);
599 destroy_workqueue(sbi->dio_unwritten_wq);
600
581 lock_super(sb); 601 lock_super(sb);
582 lock_kernel(); 602 lock_kernel();
583 if (sb->s_dirt) 603 if (sb->s_dirt)
@@ -682,6 +702,8 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
682 ei->i_allocated_meta_blocks = 0; 702 ei->i_allocated_meta_blocks = 0;
683 ei->i_delalloc_reserved_flag = 0; 703 ei->i_delalloc_reserved_flag = 0;
684 spin_lock_init(&(ei->i_block_reservation_lock)); 704 spin_lock_init(&(ei->i_block_reservation_lock));
705 INIT_LIST_HEAD(&ei->i_aio_dio_complete_list);
706 ei->cur_aio_dio = NULL;
685 707
686 return &ei->vfs_inode; 708 return &ei->vfs_inode;
687} 709}
@@ -962,7 +984,7 @@ static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
962static ssize_t ext4_quota_write(struct super_block *sb, int type, 984static ssize_t ext4_quota_write(struct super_block *sb, int type,
963 const char *data, size_t len, loff_t off); 985 const char *data, size_t len, loff_t off);
964 986
965static struct dquot_operations ext4_quota_operations = { 987static const struct dquot_operations ext4_quota_operations = {
966 .initialize = dquot_initialize, 988 .initialize = dquot_initialize,
967 .drop = dquot_drop, 989 .drop = dquot_drop,
968 .alloc_space = dquot_alloc_space, 990 .alloc_space = dquot_alloc_space,
@@ -983,7 +1005,7 @@ static struct dquot_operations ext4_quota_operations = {
983 .destroy_dquot = dquot_destroy, 1005 .destroy_dquot = dquot_destroy,
984}; 1006};
985 1007
986static struct quotactl_ops ext4_qctl_operations = { 1008static const struct quotactl_ops ext4_qctl_operations = {
987 .quota_on = ext4_quota_on, 1009 .quota_on = ext4_quota_on,
988 .quota_off = vfs_quota_off, 1010 .quota_off = vfs_quota_off,
989 .quota_sync = vfs_quota_sync, 1011 .quota_sync = vfs_quota_sync,
@@ -1050,7 +1072,7 @@ enum {
1050 Opt_journal_update, Opt_journal_dev, 1072 Opt_journal_update, Opt_journal_dev,
1051 Opt_journal_checksum, Opt_journal_async_commit, 1073 Opt_journal_checksum, Opt_journal_async_commit,
1052 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, 1074 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
1053 Opt_data_err_abort, Opt_data_err_ignore, Opt_mb_history_length, 1075 Opt_data_err_abort, Opt_data_err_ignore,
1054 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, 1076 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
1055 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, 1077 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
1056 Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize, 1078 Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize,
@@ -1097,7 +1119,6 @@ static const match_table_t tokens = {
1097 {Opt_data_writeback, "data=writeback"}, 1119 {Opt_data_writeback, "data=writeback"},
1098 {Opt_data_err_abort, "data_err=abort"}, 1120 {Opt_data_err_abort, "data_err=abort"},
1099 {Opt_data_err_ignore, "data_err=ignore"}, 1121 {Opt_data_err_ignore, "data_err=ignore"},
1100 {Opt_mb_history_length, "mb_history_length=%u"},
1101 {Opt_offusrjquota, "usrjquota="}, 1122 {Opt_offusrjquota, "usrjquota="},
1102 {Opt_usrjquota, "usrjquota=%s"}, 1123 {Opt_usrjquota, "usrjquota=%s"},
1103 {Opt_offgrpjquota, "grpjquota="}, 1124 {Opt_offgrpjquota, "grpjquota="},
@@ -1279,11 +1300,9 @@ static int parse_options(char *options, struct super_block *sb,
1279 *journal_devnum = option; 1300 *journal_devnum = option;
1280 break; 1301 break;
1281 case Opt_journal_checksum: 1302 case Opt_journal_checksum:
1282 set_opt(sbi->s_mount_opt, JOURNAL_CHECKSUM); 1303 break; /* Kept for backwards compatibility */
1283 break;
1284 case Opt_journal_async_commit: 1304 case Opt_journal_async_commit:
1285 set_opt(sbi->s_mount_opt, JOURNAL_ASYNC_COMMIT); 1305 set_opt(sbi->s_mount_opt, JOURNAL_ASYNC_COMMIT);
1286 set_opt(sbi->s_mount_opt, JOURNAL_CHECKSUM);
1287 break; 1306 break;
1288 case Opt_noload: 1307 case Opt_noload:
1289 set_opt(sbi->s_mount_opt, NOLOAD); 1308 set_opt(sbi->s_mount_opt, NOLOAD);
@@ -1340,13 +1359,6 @@ static int parse_options(char *options, struct super_block *sb,
1340 case Opt_data_err_ignore: 1359 case Opt_data_err_ignore:
1341 clear_opt(sbi->s_mount_opt, DATA_ERR_ABORT); 1360 clear_opt(sbi->s_mount_opt, DATA_ERR_ABORT);
1342 break; 1361 break;
1343 case Opt_mb_history_length:
1344 if (match_int(&args[0], &option))
1345 return 0;
1346 if (option < 0)
1347 return 0;
1348 sbi->s_mb_history_max = option;
1349 break;
1350#ifdef CONFIG_QUOTA 1362#ifdef CONFIG_QUOTA
1351 case Opt_usrjquota: 1363 case Opt_usrjquota:
1352 qtype = USRQUOTA; 1364 qtype = USRQUOTA;
@@ -1646,13 +1658,6 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
1646 EXT4_INODES_PER_GROUP(sb), 1658 EXT4_INODES_PER_GROUP(sb),
1647 sbi->s_mount_opt); 1659 sbi->s_mount_opt);
1648 1660
1649 if (EXT4_SB(sb)->s_journal) {
1650 ext4_msg(sb, KERN_INFO, "%s journal on %s",
1651 EXT4_SB(sb)->s_journal->j_inode ? "internal" :
1652 "external", EXT4_SB(sb)->s_journal->j_devname);
1653 } else {
1654 ext4_msg(sb, KERN_INFO, "no journal");
1655 }
1656 return res; 1661 return res;
1657} 1662}
1658 1663
@@ -1695,12 +1700,12 @@ static int ext4_fill_flex_info(struct super_block *sb)
1695 gdp = ext4_get_group_desc(sb, i, NULL); 1700 gdp = ext4_get_group_desc(sb, i, NULL);
1696 1701
1697 flex_group = ext4_flex_group(sbi, i); 1702 flex_group = ext4_flex_group(sbi, i);
1698 atomic_set(&sbi->s_flex_groups[flex_group].free_inodes, 1703 atomic_add(ext4_free_inodes_count(sb, gdp),
1699 ext4_free_inodes_count(sb, gdp)); 1704 &sbi->s_flex_groups[flex_group].free_inodes);
1700 atomic_set(&sbi->s_flex_groups[flex_group].free_blocks, 1705 atomic_add(ext4_free_blks_count(sb, gdp),
1701 ext4_free_blks_count(sb, gdp)); 1706 &sbi->s_flex_groups[flex_group].free_blocks);
1702 atomic_set(&sbi->s_flex_groups[flex_group].used_dirs, 1707 atomic_add(ext4_used_dirs_count(sb, gdp),
1703 ext4_used_dirs_count(sb, gdp)); 1708 &sbi->s_flex_groups[flex_group].used_dirs);
1704 } 1709 }
1705 1710
1706 return 1; 1711 return 1;
@@ -2197,6 +2202,7 @@ EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
2197EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs); 2202EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs);
2198EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request); 2203EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request);
2199EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc); 2204EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc);
2205EXT4_RW_ATTR_SBI_UI(max_writeback_mb_bump, s_max_writeback_mb_bump);
2200 2206
2201static struct attribute *ext4_attrs[] = { 2207static struct attribute *ext4_attrs[] = {
2202 ATTR_LIST(delayed_allocation_blocks), 2208 ATTR_LIST(delayed_allocation_blocks),
@@ -2210,6 +2216,7 @@ static struct attribute *ext4_attrs[] = {
2210 ATTR_LIST(mb_order2_req), 2216 ATTR_LIST(mb_order2_req),
2211 ATTR_LIST(mb_stream_req), 2217 ATTR_LIST(mb_stream_req),
2212 ATTR_LIST(mb_group_prealloc), 2218 ATTR_LIST(mb_group_prealloc),
2219 ATTR_LIST(max_writeback_mb_bump),
2213 NULL, 2220 NULL,
2214}; 2221};
2215 2222
@@ -2253,6 +2260,49 @@ static struct kobj_type ext4_ktype = {
2253 .release = ext4_sb_release, 2260 .release = ext4_sb_release,
2254}; 2261};
2255 2262
2263/*
2264 * Check whether this filesystem can be mounted based on
2265 * the features present and the RDONLY/RDWR mount requested.
2266 * Returns 1 if this filesystem can be mounted as requested,
2267 * 0 if it cannot be.
2268 */
2269static int ext4_feature_set_ok(struct super_block *sb, int readonly)
2270{
2271 if (EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP)) {
2272 ext4_msg(sb, KERN_ERR,
2273 "Couldn't mount because of "
2274 "unsupported optional features (%x)",
2275 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) &
2276 ~EXT4_FEATURE_INCOMPAT_SUPP));
2277 return 0;
2278 }
2279
2280 if (readonly)
2281 return 1;
2282
2283 /* Check that feature set is OK for a read-write mount */
2284 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP)) {
2285 ext4_msg(sb, KERN_ERR, "couldn't mount RDWR because of "
2286 "unsupported optional features (%x)",
2287 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) &
2288 ~EXT4_FEATURE_RO_COMPAT_SUPP));
2289 return 0;
2290 }
2291 /*
2292 * Large file size enabled file system can only be mounted
2293 * read-write on 32-bit systems if kernel is built with CONFIG_LBDAF
2294 */
2295 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) {
2296 if (sizeof(blkcnt_t) < sizeof(u64)) {
2297 ext4_msg(sb, KERN_ERR, "Filesystem with huge files "
2298 "cannot be mounted RDWR without "
2299 "CONFIG_LBDAF");
2300 return 0;
2301 }
2302 }
2303 return 1;
2304}
2305
2256static int ext4_fill_super(struct super_block *sb, void *data, int silent) 2306static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2257 __releases(kernel_lock) 2307 __releases(kernel_lock)
2258 __acquires(kernel_lock) 2308 __acquires(kernel_lock)
@@ -2274,7 +2324,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2274 unsigned int db_count; 2324 unsigned int db_count;
2275 unsigned int i; 2325 unsigned int i;
2276 int needs_recovery, has_huge_files; 2326 int needs_recovery, has_huge_files;
2277 int features;
2278 __u64 blocks_count; 2327 __u64 blocks_count;
2279 int err; 2328 int err;
2280 unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; 2329 unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
@@ -2371,7 +2420,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2371 sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ; 2420 sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ;
2372 sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; 2421 sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME;
2373 sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; 2422 sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME;
2374 sbi->s_mb_history_max = default_mb_history_length;
2375 2423
2376 set_opt(sbi->s_mount_opt, BARRIER); 2424 set_opt(sbi->s_mount_opt, BARRIER);
2377 2425
@@ -2401,39 +2449,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2401 * previously didn't change the revision level when setting the flags, 2449 * previously didn't change the revision level when setting the flags,
2402 * so there is a chance incompat flags are set on a rev 0 filesystem. 2450 * so there is a chance incompat flags are set on a rev 0 filesystem.
2403 */ 2451 */
2404 features = EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP); 2452 if (!ext4_feature_set_ok(sb, (sb->s_flags & MS_RDONLY)))
2405 if (features) {
2406 ext4_msg(sb, KERN_ERR,
2407 "Couldn't mount because of "
2408 "unsupported optional features (%x)",
2409 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) &
2410 ~EXT4_FEATURE_INCOMPAT_SUPP));
2411 goto failed_mount; 2453 goto failed_mount;
2412 } 2454
2413 features = EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP);
2414 if (!(sb->s_flags & MS_RDONLY) && features) {
2415 ext4_msg(sb, KERN_ERR,
2416 "Couldn't mount RDWR because of "
2417 "unsupported optional features (%x)",
2418 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) &
2419 ~EXT4_FEATURE_RO_COMPAT_SUPP));
2420 goto failed_mount;
2421 }
2422 has_huge_files = EXT4_HAS_RO_COMPAT_FEATURE(sb,
2423 EXT4_FEATURE_RO_COMPAT_HUGE_FILE);
2424 if (has_huge_files) {
2425 /*
2426 * Large file size enabled file system can only be
2427 * mount if kernel is build with CONFIG_LBDAF
2428 */
2429 if (sizeof(root->i_blocks) < sizeof(u64) &&
2430 !(sb->s_flags & MS_RDONLY)) {
2431 ext4_msg(sb, KERN_ERR, "Filesystem with huge "
2432 "files cannot be mounted read-write "
2433 "without CONFIG_LBDAF");
2434 goto failed_mount;
2435 }
2436 }
2437 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); 2455 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
2438 2456
2439 if (blocksize < EXT4_MIN_BLOCK_SIZE || 2457 if (blocksize < EXT4_MIN_BLOCK_SIZE ||
@@ -2469,6 +2487,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2469 } 2487 }
2470 } 2488 }
2471 2489
2490 has_huge_files = EXT4_HAS_RO_COMPAT_FEATURE(sb,
2491 EXT4_FEATURE_RO_COMPAT_HUGE_FILE);
2472 sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits, 2492 sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits,
2473 has_huge_files); 2493 has_huge_files);
2474 sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files); 2494 sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files);
@@ -2549,12 +2569,19 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2549 goto failed_mount; 2569 goto failed_mount;
2550 } 2570 }
2551 2571
2552 if (ext4_blocks_count(es) > 2572 /*
2553 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { 2573 * Test whether we have more sectors than will fit in sector_t,
2574 * and whether the max offset is addressable by the page cache.
2575 */
2576 if ((ext4_blocks_count(es) >
2577 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) ||
2578 (ext4_blocks_count(es) >
2579 (pgoff_t)(~0ULL) >> (PAGE_CACHE_SHIFT - sb->s_blocksize_bits))) {
2554 ext4_msg(sb, KERN_ERR, "filesystem" 2580 ext4_msg(sb, KERN_ERR, "filesystem"
2555 " too large to mount safely"); 2581 " too large to mount safely on this system");
2556 if (sizeof(sector_t) < 8) 2582 if (sizeof(sector_t) < 8)
2557 ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled"); 2583 ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled");
2584 ret = -EFBIG;
2558 goto failed_mount; 2585 goto failed_mount;
2559 } 2586 }
2560 2587
@@ -2595,6 +2622,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2595 goto failed_mount; 2622 goto failed_mount;
2596 } 2623 }
2597 sbi->s_groups_count = blocks_count; 2624 sbi->s_groups_count = blocks_count;
2625 sbi->s_blockfile_groups = min_t(ext4_group_t, sbi->s_groups_count,
2626 (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb)));
2598 db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / 2627 db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
2599 EXT4_DESC_PER_BLOCK(sb); 2628 EXT4_DESC_PER_BLOCK(sb);
2600 sbi->s_group_desc = kmalloc(db_count * sizeof(struct buffer_head *), 2629 sbi->s_group_desc = kmalloc(db_count * sizeof(struct buffer_head *),
@@ -2656,6 +2685,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2656 } 2685 }
2657 2686
2658 sbi->s_stripe = ext4_get_stripe_size(sbi); 2687 sbi->s_stripe = ext4_get_stripe_size(sbi);
2688 sbi->s_max_writeback_mb_bump = 128;
2659 2689
2660 /* 2690 /*
2661 * set up enough so that it can read an inode 2691 * set up enough so that it can read an inode
@@ -2729,20 +2759,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2729 goto failed_mount4; 2759 goto failed_mount4;
2730 } 2760 }
2731 2761
2732 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { 2762 jbd2_journal_set_features(sbi->s_journal,
2733 jbd2_journal_set_features(sbi->s_journal, 2763 JBD2_FEATURE_COMPAT_CHECKSUM, 0, 0);
2734 JBD2_FEATURE_COMPAT_CHECKSUM, 0, 2764 if (test_opt(sb, JOURNAL_ASYNC_COMMIT))
2765 jbd2_journal_set_features(sbi->s_journal, 0, 0,
2735 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT); 2766 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT);
2736 } else if (test_opt(sb, JOURNAL_CHECKSUM)) { 2767 else
2737 jbd2_journal_set_features(sbi->s_journal,
2738 JBD2_FEATURE_COMPAT_CHECKSUM, 0, 0);
2739 jbd2_journal_clear_features(sbi->s_journal, 0, 0, 2768 jbd2_journal_clear_features(sbi->s_journal, 0, 0,
2740 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT); 2769 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT);
2741 } else {
2742 jbd2_journal_clear_features(sbi->s_journal,
2743 JBD2_FEATURE_COMPAT_CHECKSUM, 0,
2744 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT);
2745 }
2746 2770
2747 /* We have now updated the journal if required, so we can 2771 /* We have now updated the journal if required, so we can
2748 * validate the data journaling mode. */ 2772 * validate the data journaling mode. */
@@ -2781,6 +2805,12 @@ no_journal:
2781 clear_opt(sbi->s_mount_opt, NOBH); 2805 clear_opt(sbi->s_mount_opt, NOBH);
2782 } 2806 }
2783 } 2807 }
2808 EXT4_SB(sb)->dio_unwritten_wq = create_workqueue("ext4-dio-unwritten");
2809 if (!EXT4_SB(sb)->dio_unwritten_wq) {
2810 printk(KERN_ERR "EXT4-fs: failed to create DIO workqueue\n");
2811 goto failed_mount_wq;
2812 }
2813
2784 /* 2814 /*
2785 * The jbd2_journal_load will have done any necessary log recovery, 2815 * The jbd2_journal_load will have done any necessary log recovery,
2786 * so we can safely mount the rest of the filesystem now. 2816 * so we can safely mount the rest of the filesystem now.
@@ -2832,12 +2862,12 @@ no_journal:
2832 "available"); 2862 "available");
2833 } 2863 }
2834 2864
2835 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { 2865 if (test_opt(sb, DELALLOC) &&
2866 (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)) {
2836 ext4_msg(sb, KERN_WARNING, "Ignoring delalloc option - " 2867 ext4_msg(sb, KERN_WARNING, "Ignoring delalloc option - "
2837 "requested data journaling mode"); 2868 "requested data journaling mode");
2838 clear_opt(sbi->s_mount_opt, DELALLOC); 2869 clear_opt(sbi->s_mount_opt, DELALLOC);
2839 } else if (test_opt(sb, DELALLOC)) 2870 }
2840 ext4_msg(sb, KERN_INFO, "delayed allocation enabled");
2841 2871
2842 err = ext4_setup_system_zone(sb); 2872 err = ext4_setup_system_zone(sb);
2843 if (err) { 2873 if (err) {
@@ -2893,6 +2923,8 @@ cantfind_ext4:
2893 2923
2894failed_mount4: 2924failed_mount4:
2895 ext4_msg(sb, KERN_ERR, "mount failed"); 2925 ext4_msg(sb, KERN_ERR, "mount failed");
2926 destroy_workqueue(EXT4_SB(sb)->dio_unwritten_wq);
2927failed_mount_wq:
2896 ext4_release_system_zone(sb); 2928 ext4_release_system_zone(sb);
2897 if (sbi->s_journal) { 2929 if (sbi->s_journal) {
2898 jbd2_journal_destroy(sbi->s_journal); 2930 jbd2_journal_destroy(sbi->s_journal);
@@ -3147,9 +3179,7 @@ static int ext4_load_journal(struct super_block *sb,
3147 return -EINVAL; 3179 return -EINVAL;
3148 } 3180 }
3149 3181
3150 if (journal->j_flags & JBD2_BARRIER) 3182 if (!(journal->j_flags & JBD2_BARRIER))
3151 ext4_msg(sb, KERN_INFO, "barriers enabled");
3152 else
3153 ext4_msg(sb, KERN_INFO, "barriers disabled"); 3183 ext4_msg(sb, KERN_INFO, "barriers disabled");
3154 3184
3155 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { 3185 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) {
@@ -3208,7 +3238,18 @@ static int ext4_commit_super(struct super_block *sb, int sync)
3208 clear_buffer_write_io_error(sbh); 3238 clear_buffer_write_io_error(sbh);
3209 set_buffer_uptodate(sbh); 3239 set_buffer_uptodate(sbh);
3210 } 3240 }
3211 es->s_wtime = cpu_to_le32(get_seconds()); 3241 /*
3242 * If the file system is mounted read-only, don't update the
3243 * superblock write time. This avoids updating the superblock
3244 * write time when we are mounting the root file system
3245 * read/only but we need to replay the journal; at that point,
3246 * for people who are east of GMT and who make their clock
3247 * tick in localtime for Windows bug-for-bug compatibility,
3248 * the clock is set in the future, and this will cause e2fsck
3249 * to complain and force a full file system check.
3250 */
3251 if (!(sb->s_flags & MS_RDONLY))
3252 es->s_wtime = cpu_to_le32(get_seconds());
3212 es->s_kbytes_written = 3253 es->s_kbytes_written =
3213 cpu_to_le64(EXT4_SB(sb)->s_kbytes_written + 3254 cpu_to_le64(EXT4_SB(sb)->s_kbytes_written +
3214 ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) - 3255 ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
@@ -3333,11 +3374,13 @@ static int ext4_sync_fs(struct super_block *sb, int wait)
3333{ 3374{
3334 int ret = 0; 3375 int ret = 0;
3335 tid_t target; 3376 tid_t target;
3377 struct ext4_sb_info *sbi = EXT4_SB(sb);
3336 3378
3337 trace_ext4_sync_fs(sb, wait); 3379 trace_ext4_sync_fs(sb, wait);
3338 if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, &target)) { 3380 flush_workqueue(sbi->dio_unwritten_wq);
3381 if (jbd2_journal_start_commit(sbi->s_journal, &target)) {
3339 if (wait) 3382 if (wait)
3340 jbd2_log_wait_commit(EXT4_SB(sb)->s_journal, target); 3383 jbd2_log_wait_commit(sbi->s_journal, target);
3341 } 3384 }
3342 return ret; 3385 return ret;
3343} 3386}
@@ -3477,18 +3520,11 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
3477 if (sbi->s_journal) 3520 if (sbi->s_journal)
3478 ext4_mark_recovery_complete(sb, es); 3521 ext4_mark_recovery_complete(sb, es);
3479 } else { 3522 } else {
3480 int ret; 3523 /* Make sure we can mount this feature set readwrite */
3481 if ((ret = EXT4_HAS_RO_COMPAT_FEATURE(sb, 3524 if (!ext4_feature_set_ok(sb, 0)) {
3482 ~EXT4_FEATURE_RO_COMPAT_SUPP))) {
3483 ext4_msg(sb, KERN_WARNING, "couldn't "
3484 "remount RDWR because of unsupported "
3485 "optional features (%x)",
3486 (le32_to_cpu(sbi->s_es->s_feature_ro_compat) &
3487 ~EXT4_FEATURE_RO_COMPAT_SUPP));
3488 err = -EROFS; 3525 err = -EROFS;
3489 goto restore_opts; 3526 goto restore_opts;
3490 } 3527 }
3491
3492 /* 3528 /*
3493 * Make sure the group descriptor checksums 3529 * Make sure the group descriptor checksums
3494 * are sane. If they aren't, refuse to remount r/w. 3530 * are sane. If they aren't, refuse to remount r/w.
@@ -3930,27 +3966,6 @@ static struct file_system_type ext4_fs_type = {
3930 .fs_flags = FS_REQUIRES_DEV, 3966 .fs_flags = FS_REQUIRES_DEV,
3931}; 3967};
3932 3968
3933#ifdef CONFIG_EXT4DEV_COMPAT
3934static int ext4dev_get_sb(struct file_system_type *fs_type, int flags,
3935 const char *dev_name, void *data,struct vfsmount *mnt)
3936{
3937 printk(KERN_WARNING "EXT4-fs (%s): Update your userspace programs "
3938 "to mount using ext4\n", dev_name);
3939 printk(KERN_WARNING "EXT4-fs (%s): ext4dev backwards compatibility "
3940 "will go away by 2.6.31\n", dev_name);
3941 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt);
3942}
3943
3944static struct file_system_type ext4dev_fs_type = {
3945 .owner = THIS_MODULE,
3946 .name = "ext4dev",
3947 .get_sb = ext4dev_get_sb,
3948 .kill_sb = kill_block_super,
3949 .fs_flags = FS_REQUIRES_DEV,
3950};
3951MODULE_ALIAS("ext4dev");
3952#endif
3953
3954static int __init init_ext4_fs(void) 3969static int __init init_ext4_fs(void)
3955{ 3970{
3956 int err; 3971 int err;
@@ -3975,13 +3990,6 @@ static int __init init_ext4_fs(void)
3975 err = register_filesystem(&ext4_fs_type); 3990 err = register_filesystem(&ext4_fs_type);
3976 if (err) 3991 if (err)
3977 goto out; 3992 goto out;
3978#ifdef CONFIG_EXT4DEV_COMPAT
3979 err = register_filesystem(&ext4dev_fs_type);
3980 if (err) {
3981 unregister_filesystem(&ext4_fs_type);
3982 goto out;
3983 }
3984#endif
3985 return 0; 3993 return 0;
3986out: 3994out:
3987 destroy_inodecache(); 3995 destroy_inodecache();
@@ -4000,9 +4008,6 @@ out4:
4000static void __exit exit_ext4_fs(void) 4008static void __exit exit_ext4_fs(void)
4001{ 4009{
4002 unregister_filesystem(&ext4_fs_type); 4010 unregister_filesystem(&ext4_fs_type);
4003#ifdef CONFIG_EXT4DEV_COMPAT
4004 unregister_filesystem(&ext4dev_fs_type);
4005#endif
4006 destroy_inodecache(); 4011 destroy_inodecache();
4007 exit_ext4_xattr(); 4012 exit_ext4_xattr();
4008 exit_ext4_mballoc(); 4013 exit_ext4_mballoc();