diff options
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 849 |
1 files changed, 454 insertions, 395 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 2958f4e6f222..012c4251397e 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/string.h> | 20 | #include <linux/string.h> |
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/time.h> | 22 | #include <linux/time.h> |
23 | #include <linux/vmalloc.h> | ||
23 | #include <linux/jbd2.h> | 24 | #include <linux/jbd2.h> |
24 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
25 | #include <linux/init.h> | 26 | #include <linux/init.h> |
@@ -45,16 +46,20 @@ | |||
45 | #include "ext4_jbd2.h" | 46 | #include "ext4_jbd2.h" |
46 | #include "xattr.h" | 47 | #include "xattr.h" |
47 | #include "acl.h" | 48 | #include "acl.h" |
48 | #include "namei.h" | 49 | |
49 | #include "group.h" | 50 | static int default_mb_history_length = 1000; |
51 | |||
52 | module_param_named(default_mb_history_length, default_mb_history_length, | ||
53 | int, 0644); | ||
54 | MODULE_PARM_DESC(default_mb_history_length, | ||
55 | "Default number of entries saved for mb_history"); | ||
50 | 56 | ||
51 | struct proc_dir_entry *ext4_proc_root; | 57 | struct proc_dir_entry *ext4_proc_root; |
52 | static struct kset *ext4_kset; | 58 | static struct kset *ext4_kset; |
53 | 59 | ||
54 | static int ext4_load_journal(struct super_block *, struct ext4_super_block *, | 60 | static int ext4_load_journal(struct super_block *, struct ext4_super_block *, |
55 | unsigned long journal_devnum); | 61 | unsigned long journal_devnum); |
56 | static int ext4_commit_super(struct super_block *sb, | 62 | static int ext4_commit_super(struct super_block *sb, int sync); |
57 | struct ext4_super_block *es, int sync); | ||
58 | static void ext4_mark_recovery_complete(struct super_block *sb, | 63 | static void ext4_mark_recovery_complete(struct super_block *sb, |
59 | struct ext4_super_block *es); | 64 | struct ext4_super_block *es); |
60 | static void ext4_clear_journal_err(struct super_block *sb, | 65 | static void ext4_clear_journal_err(struct super_block *sb, |
@@ -74,7 +79,7 @@ ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, | |||
74 | { | 79 | { |
75 | return le32_to_cpu(bg->bg_block_bitmap_lo) | | 80 | return le32_to_cpu(bg->bg_block_bitmap_lo) | |
76 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | 81 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? |
77 | (ext4_fsblk_t)le32_to_cpu(bg->bg_block_bitmap_hi) << 32 : 0); | 82 | (ext4_fsblk_t)le32_to_cpu(bg->bg_block_bitmap_hi) << 32 : 0); |
78 | } | 83 | } |
79 | 84 | ||
80 | ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, | 85 | ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, |
@@ -82,7 +87,7 @@ ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, | |||
82 | { | 87 | { |
83 | return le32_to_cpu(bg->bg_inode_bitmap_lo) | | 88 | return le32_to_cpu(bg->bg_inode_bitmap_lo) | |
84 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | 89 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? |
85 | (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0); | 90 | (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0); |
86 | } | 91 | } |
87 | 92 | ||
88 | ext4_fsblk_t ext4_inode_table(struct super_block *sb, | 93 | ext4_fsblk_t ext4_inode_table(struct super_block *sb, |
@@ -90,7 +95,7 @@ ext4_fsblk_t ext4_inode_table(struct super_block *sb, | |||
90 | { | 95 | { |
91 | return le32_to_cpu(bg->bg_inode_table_lo) | | 96 | return le32_to_cpu(bg->bg_inode_table_lo) | |
92 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | 97 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? |
93 | (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0); | 98 | (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0); |
94 | } | 99 | } |
95 | 100 | ||
96 | __u32 ext4_free_blks_count(struct super_block *sb, | 101 | __u32 ext4_free_blks_count(struct super_block *sb, |
@@ -98,7 +103,7 @@ __u32 ext4_free_blks_count(struct super_block *sb, | |||
98 | { | 103 | { |
99 | return le16_to_cpu(bg->bg_free_blocks_count_lo) | | 104 | return le16_to_cpu(bg->bg_free_blocks_count_lo) | |
100 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | 105 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? |
101 | (__u32)le16_to_cpu(bg->bg_free_blocks_count_hi) << 16 : 0); | 106 | (__u32)le16_to_cpu(bg->bg_free_blocks_count_hi) << 16 : 0); |
102 | } | 107 | } |
103 | 108 | ||
104 | __u32 ext4_free_inodes_count(struct super_block *sb, | 109 | __u32 ext4_free_inodes_count(struct super_block *sb, |
@@ -106,7 +111,7 @@ __u32 ext4_free_inodes_count(struct super_block *sb, | |||
106 | { | 111 | { |
107 | return le16_to_cpu(bg->bg_free_inodes_count_lo) | | 112 | return le16_to_cpu(bg->bg_free_inodes_count_lo) | |
108 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | 113 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? |
109 | (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0); | 114 | (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0); |
110 | } | 115 | } |
111 | 116 | ||
112 | __u32 ext4_used_dirs_count(struct super_block *sb, | 117 | __u32 ext4_used_dirs_count(struct super_block *sb, |
@@ -114,7 +119,7 @@ __u32 ext4_used_dirs_count(struct super_block *sb, | |||
114 | { | 119 | { |
115 | return le16_to_cpu(bg->bg_used_dirs_count_lo) | | 120 | return le16_to_cpu(bg->bg_used_dirs_count_lo) | |
116 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | 121 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? |
117 | (__u32)le16_to_cpu(bg->bg_used_dirs_count_hi) << 16 : 0); | 122 | (__u32)le16_to_cpu(bg->bg_used_dirs_count_hi) << 16 : 0); |
118 | } | 123 | } |
119 | 124 | ||
120 | __u32 ext4_itable_unused_count(struct super_block *sb, | 125 | __u32 ext4_itable_unused_count(struct super_block *sb, |
@@ -122,7 +127,7 @@ __u32 ext4_itable_unused_count(struct super_block *sb, | |||
122 | { | 127 | { |
123 | return le16_to_cpu(bg->bg_itable_unused_lo) | | 128 | return le16_to_cpu(bg->bg_itable_unused_lo) | |
124 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? | 129 | (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? |
125 | (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0); | 130 | (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0); |
126 | } | 131 | } |
127 | 132 | ||
128 | void ext4_block_bitmap_set(struct super_block *sb, | 133 | void ext4_block_bitmap_set(struct super_block *sb, |
@@ -202,8 +207,7 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) | |||
202 | journal = EXT4_SB(sb)->s_journal; | 207 | journal = EXT4_SB(sb)->s_journal; |
203 | if (journal) { | 208 | if (journal) { |
204 | if (is_journal_aborted(journal)) { | 209 | if (is_journal_aborted(journal)) { |
205 | ext4_abort(sb, __func__, | 210 | ext4_abort(sb, __func__, "Detected aborted journal"); |
206 | "Detected aborted journal"); | ||
207 | return ERR_PTR(-EROFS); | 211 | return ERR_PTR(-EROFS); |
208 | } | 212 | } |
209 | return jbd2_journal_start(journal, nblocks); | 213 | return jbd2_journal_start(journal, nblocks); |
@@ -302,10 +306,10 @@ static void ext4_handle_error(struct super_block *sb) | |||
302 | jbd2_journal_abort(journal, -EIO); | 306 | jbd2_journal_abort(journal, -EIO); |
303 | } | 307 | } |
304 | if (test_opt(sb, ERRORS_RO)) { | 308 | if (test_opt(sb, ERRORS_RO)) { |
305 | printk(KERN_CRIT "Remounting filesystem read-only\n"); | 309 | ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); |
306 | sb->s_flags |= MS_RDONLY; | 310 | sb->s_flags |= MS_RDONLY; |
307 | } | 311 | } |
308 | ext4_commit_super(sb, es, 1); | 312 | ext4_commit_super(sb, 1); |
309 | if (test_opt(sb, ERRORS_PANIC)) | 313 | if (test_opt(sb, ERRORS_PANIC)) |
310 | panic("EXT4-fs (device %s): panic forced after error\n", | 314 | panic("EXT4-fs (device %s): panic forced after error\n", |
311 | sb->s_id); | 315 | sb->s_id); |
@@ -395,8 +399,6 @@ void ext4_abort(struct super_block *sb, const char *function, | |||
395 | { | 399 | { |
396 | va_list args; | 400 | va_list args; |
397 | 401 | ||
398 | printk(KERN_CRIT "ext4_abort called.\n"); | ||
399 | |||
400 | va_start(args, fmt); | 402 | va_start(args, fmt); |
401 | printk(KERN_CRIT "EXT4-fs error (device %s): %s: ", sb->s_id, function); | 403 | printk(KERN_CRIT "EXT4-fs error (device %s): %s: ", sb->s_id, function); |
402 | vprintk(fmt, args); | 404 | vprintk(fmt, args); |
@@ -409,7 +411,7 @@ void ext4_abort(struct super_block *sb, const char *function, | |||
409 | if (sb->s_flags & MS_RDONLY) | 411 | if (sb->s_flags & MS_RDONLY) |
410 | return; | 412 | return; |
411 | 413 | ||
412 | printk(KERN_CRIT "Remounting filesystem read-only\n"); | 414 | ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); |
413 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | 415 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; |
414 | sb->s_flags |= MS_RDONLY; | 416 | sb->s_flags |= MS_RDONLY; |
415 | EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; | 417 | EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; |
@@ -417,6 +419,18 @@ void ext4_abort(struct super_block *sb, const char *function, | |||
417 | jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); | 419 | jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); |
418 | } | 420 | } |
419 | 421 | ||
422 | void ext4_msg (struct super_block * sb, const char *prefix, | ||
423 | const char *fmt, ...) | ||
424 | { | ||
425 | va_list args; | ||
426 | |||
427 | va_start(args, fmt); | ||
428 | printk("%sEXT4-fs (%s): ", prefix, sb->s_id); | ||
429 | vprintk(fmt, args); | ||
430 | printk("\n"); | ||
431 | va_end(args); | ||
432 | } | ||
433 | |||
420 | void ext4_warning(struct super_block *sb, const char *function, | 434 | void ext4_warning(struct super_block *sb, const char *function, |
421 | const char *fmt, ...) | 435 | const char *fmt, ...) |
422 | { | 436 | { |
@@ -431,7 +445,7 @@ void ext4_warning(struct super_block *sb, const char *function, | |||
431 | } | 445 | } |
432 | 446 | ||
433 | void ext4_grp_locked_error(struct super_block *sb, ext4_group_t grp, | 447 | void ext4_grp_locked_error(struct super_block *sb, ext4_group_t grp, |
434 | const char *function, const char *fmt, ...) | 448 | const char *function, const char *fmt, ...) |
435 | __releases(bitlock) | 449 | __releases(bitlock) |
436 | __acquires(bitlock) | 450 | __acquires(bitlock) |
437 | { | 451 | { |
@@ -447,7 +461,7 @@ __acquires(bitlock) | |||
447 | if (test_opt(sb, ERRORS_CONT)) { | 461 | if (test_opt(sb, ERRORS_CONT)) { |
448 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | 462 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; |
449 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | 463 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); |
450 | ext4_commit_super(sb, es, 0); | 464 | ext4_commit_super(sb, 0); |
451 | return; | 465 | return; |
452 | } | 466 | } |
453 | ext4_unlock_group(sb, grp); | 467 | ext4_unlock_group(sb, grp); |
@@ -467,7 +481,6 @@ __acquires(bitlock) | |||
467 | return; | 481 | return; |
468 | } | 482 | } |
469 | 483 | ||
470 | |||
471 | void ext4_update_dynamic_rev(struct super_block *sb) | 484 | void ext4_update_dynamic_rev(struct super_block *sb) |
472 | { | 485 | { |
473 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | 486 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; |
@@ -496,7 +509,7 @@ void ext4_update_dynamic_rev(struct super_block *sb) | |||
496 | /* | 509 | /* |
497 | * Open the external journal device | 510 | * Open the external journal device |
498 | */ | 511 | */ |
499 | static struct block_device *ext4_blkdev_get(dev_t dev) | 512 | static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb) |
500 | { | 513 | { |
501 | struct block_device *bdev; | 514 | struct block_device *bdev; |
502 | char b[BDEVNAME_SIZE]; | 515 | char b[BDEVNAME_SIZE]; |
@@ -507,7 +520,7 @@ static struct block_device *ext4_blkdev_get(dev_t dev) | |||
507 | return bdev; | 520 | return bdev; |
508 | 521 | ||
509 | fail: | 522 | fail: |
510 | printk(KERN_ERR "EXT4-fs: failed to open journal device %s: %ld\n", | 523 | ext4_msg(sb, KERN_ERR, "failed to open journal device %s: %ld", |
511 | __bdevname(dev, b), PTR_ERR(bdev)); | 524 | __bdevname(dev, b), PTR_ERR(bdev)); |
512 | return NULL; | 525 | return NULL; |
513 | } | 526 | } |
@@ -543,8 +556,8 @@ static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi) | |||
543 | { | 556 | { |
544 | struct list_head *l; | 557 | struct list_head *l; |
545 | 558 | ||
546 | printk(KERN_ERR "sb orphan head is %d\n", | 559 | ext4_msg(sb, KERN_ERR, "sb orphan head is %d", |
547 | le32_to_cpu(sbi->s_es->s_last_orphan)); | 560 | le32_to_cpu(sbi->s_es->s_last_orphan)); |
548 | 561 | ||
549 | printk(KERN_ERR "sb_info orphan list:\n"); | 562 | printk(KERN_ERR "sb_info orphan list:\n"); |
550 | list_for_each(l, &sbi->s_orphan) { | 563 | list_for_each(l, &sbi->s_orphan) { |
@@ -563,6 +576,12 @@ static void ext4_put_super(struct super_block *sb) | |||
563 | struct ext4_super_block *es = sbi->s_es; | 576 | struct ext4_super_block *es = sbi->s_es; |
564 | int i, err; | 577 | int i, err; |
565 | 578 | ||
579 | lock_super(sb); | ||
580 | lock_kernel(); | ||
581 | if (sb->s_dirt) | ||
582 | ext4_commit_super(sb, 1); | ||
583 | |||
584 | ext4_release_system_zone(sb); | ||
566 | ext4_mb_release(sb); | 585 | ext4_mb_release(sb); |
567 | ext4_ext_release(sb); | 586 | ext4_ext_release(sb); |
568 | ext4_xattr_put_super(sb); | 587 | ext4_xattr_put_super(sb); |
@@ -576,7 +595,7 @@ static void ext4_put_super(struct super_block *sb) | |||
576 | if (!(sb->s_flags & MS_RDONLY)) { | 595 | if (!(sb->s_flags & MS_RDONLY)) { |
577 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 596 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
578 | es->s_state = cpu_to_le16(sbi->s_mount_state); | 597 | es->s_state = cpu_to_le16(sbi->s_mount_state); |
579 | ext4_commit_super(sb, es, 1); | 598 | ext4_commit_super(sb, 1); |
580 | } | 599 | } |
581 | if (sbi->s_proc) { | 600 | if (sbi->s_proc) { |
582 | remove_proc_entry(sb->s_id, ext4_proc_root); | 601 | remove_proc_entry(sb->s_id, ext4_proc_root); |
@@ -586,7 +605,10 @@ static void ext4_put_super(struct super_block *sb) | |||
586 | for (i = 0; i < sbi->s_gdb_count; i++) | 605 | for (i = 0; i < sbi->s_gdb_count; i++) |
587 | brelse(sbi->s_group_desc[i]); | 606 | brelse(sbi->s_group_desc[i]); |
588 | kfree(sbi->s_group_desc); | 607 | kfree(sbi->s_group_desc); |
589 | kfree(sbi->s_flex_groups); | 608 | if (is_vmalloc_addr(sbi->s_flex_groups)) |
609 | vfree(sbi->s_flex_groups); | ||
610 | else | ||
611 | kfree(sbi->s_flex_groups); | ||
590 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | 612 | percpu_counter_destroy(&sbi->s_freeblocks_counter); |
591 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | 613 | percpu_counter_destroy(&sbi->s_freeinodes_counter); |
592 | percpu_counter_destroy(&sbi->s_dirs_counter); | 614 | percpu_counter_destroy(&sbi->s_dirs_counter); |
@@ -625,11 +647,8 @@ static void ext4_put_super(struct super_block *sb) | |||
625 | unlock_super(sb); | 647 | unlock_super(sb); |
626 | kobject_put(&sbi->s_kobj); | 648 | kobject_put(&sbi->s_kobj); |
627 | wait_for_completion(&sbi->s_kobj_unregister); | 649 | wait_for_completion(&sbi->s_kobj_unregister); |
628 | lock_super(sb); | ||
629 | lock_kernel(); | ||
630 | kfree(sbi->s_blockgroup_lock); | 650 | kfree(sbi->s_blockgroup_lock); |
631 | kfree(sbi); | 651 | kfree(sbi); |
632 | return; | ||
633 | } | 652 | } |
634 | 653 | ||
635 | static struct kmem_cache *ext4_inode_cachep; | 654 | static struct kmem_cache *ext4_inode_cachep; |
@@ -644,6 +663,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
644 | ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS); | 663 | ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS); |
645 | if (!ei) | 664 | if (!ei) |
646 | return NULL; | 665 | return NULL; |
666 | |||
647 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 667 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
648 | ei->i_acl = EXT4_ACL_NOT_CACHED; | 668 | ei->i_acl = EXT4_ACL_NOT_CACHED; |
649 | ei->i_default_acl = EXT4_ACL_NOT_CACHED; | 669 | ei->i_default_acl = EXT4_ACL_NOT_CACHED; |
@@ -664,14 +684,16 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
664 | ei->i_allocated_meta_blocks = 0; | 684 | ei->i_allocated_meta_blocks = 0; |
665 | ei->i_delalloc_reserved_flag = 0; | 685 | ei->i_delalloc_reserved_flag = 0; |
666 | spin_lock_init(&(ei->i_block_reservation_lock)); | 686 | spin_lock_init(&(ei->i_block_reservation_lock)); |
687 | |||
667 | return &ei->vfs_inode; | 688 | return &ei->vfs_inode; |
668 | } | 689 | } |
669 | 690 | ||
670 | static void ext4_destroy_inode(struct inode *inode) | 691 | static void ext4_destroy_inode(struct inode *inode) |
671 | { | 692 | { |
672 | if (!list_empty(&(EXT4_I(inode)->i_orphan))) { | 693 | if (!list_empty(&(EXT4_I(inode)->i_orphan))) { |
673 | printk("EXT4 Inode %p: orphan list check failed!\n", | 694 | ext4_msg(inode->i_sb, KERN_ERR, |
674 | EXT4_I(inode)); | 695 | "Inode %lu (%p): orphan list check failed!", |
696 | inode->i_ino, EXT4_I(inode)); | ||
675 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 16, 4, | 697 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 16, 4, |
676 | EXT4_I(inode), sizeof(struct ext4_inode_info), | 698 | EXT4_I(inode), sizeof(struct ext4_inode_info), |
677 | true); | 699 | true); |
@@ -870,12 +892,12 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
870 | seq_puts(seq, ",noauto_da_alloc"); | 892 | seq_puts(seq, ",noauto_da_alloc"); |
871 | 893 | ||
872 | ext4_show_quota_options(seq, sb); | 894 | ext4_show_quota_options(seq, sb); |
895 | |||
873 | return 0; | 896 | return 0; |
874 | } | 897 | } |
875 | 898 | ||
876 | |||
877 | static struct inode *ext4_nfs_get_inode(struct super_block *sb, | 899 | static struct inode *ext4_nfs_get_inode(struct super_block *sb, |
878 | u64 ino, u32 generation) | 900 | u64 ino, u32 generation) |
879 | { | 901 | { |
880 | struct inode *inode; | 902 | struct inode *inode; |
881 | 903 | ||
@@ -904,14 +926,14 @@ static struct inode *ext4_nfs_get_inode(struct super_block *sb, | |||
904 | } | 926 | } |
905 | 927 | ||
906 | static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid, | 928 | static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid, |
907 | int fh_len, int fh_type) | 929 | int fh_len, int fh_type) |
908 | { | 930 | { |
909 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, | 931 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, |
910 | ext4_nfs_get_inode); | 932 | ext4_nfs_get_inode); |
911 | } | 933 | } |
912 | 934 | ||
913 | static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, | 935 | static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, |
914 | int fh_len, int fh_type) | 936 | int fh_len, int fh_type) |
915 | { | 937 | { |
916 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, | 938 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, |
917 | ext4_nfs_get_inode); | 939 | ext4_nfs_get_inode); |
@@ -923,7 +945,8 @@ static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, | |||
923 | * which would prevent try_to_free_buffers() from freeing them, we must use | 945 | * which would prevent try_to_free_buffers() from freeing them, we must use |
924 | * jbd2 layer's try_to_free_buffers() function to release them. | 946 | * jbd2 layer's try_to_free_buffers() function to release them. |
925 | */ | 947 | */ |
926 | static int bdev_try_to_free_page(struct super_block *sb, struct page *page, gfp_t wait) | 948 | static int bdev_try_to_free_page(struct super_block *sb, struct page *page, |
949 | gfp_t wait) | ||
927 | { | 950 | { |
928 | journal_t *journal = EXT4_SB(sb)->s_journal; | 951 | journal_t *journal = EXT4_SB(sb)->s_journal; |
929 | 952 | ||
@@ -992,7 +1015,6 @@ static const struct super_operations ext4_sops = { | |||
992 | .dirty_inode = ext4_dirty_inode, | 1015 | .dirty_inode = ext4_dirty_inode, |
993 | .delete_inode = ext4_delete_inode, | 1016 | .delete_inode = ext4_delete_inode, |
994 | .put_super = ext4_put_super, | 1017 | .put_super = ext4_put_super, |
995 | .write_super = ext4_write_super, | ||
996 | .sync_fs = ext4_sync_fs, | 1018 | .sync_fs = ext4_sync_fs, |
997 | .freeze_fs = ext4_freeze, | 1019 | .freeze_fs = ext4_freeze, |
998 | .unfreeze_fs = ext4_unfreeze, | 1020 | .unfreeze_fs = ext4_unfreeze, |
@@ -1007,6 +1029,25 @@ static const struct super_operations ext4_sops = { | |||
1007 | .bdev_try_to_free_page = bdev_try_to_free_page, | 1029 | .bdev_try_to_free_page = bdev_try_to_free_page, |
1008 | }; | 1030 | }; |
1009 | 1031 | ||
1032 | static const struct super_operations ext4_nojournal_sops = { | ||
1033 | .alloc_inode = ext4_alloc_inode, | ||
1034 | .destroy_inode = ext4_destroy_inode, | ||
1035 | .write_inode = ext4_write_inode, | ||
1036 | .dirty_inode = ext4_dirty_inode, | ||
1037 | .delete_inode = ext4_delete_inode, | ||
1038 | .write_super = ext4_write_super, | ||
1039 | .put_super = ext4_put_super, | ||
1040 | .statfs = ext4_statfs, | ||
1041 | .remount_fs = ext4_remount, | ||
1042 | .clear_inode = ext4_clear_inode, | ||
1043 | .show_options = ext4_show_options, | ||
1044 | #ifdef CONFIG_QUOTA | ||
1045 | .quota_read = ext4_quota_read, | ||
1046 | .quota_write = ext4_quota_write, | ||
1047 | #endif | ||
1048 | .bdev_try_to_free_page = bdev_try_to_free_page, | ||
1049 | }; | ||
1050 | |||
1010 | static const struct export_operations ext4_export_ops = { | 1051 | static const struct export_operations ext4_export_ops = { |
1011 | .fh_to_dentry = ext4_fh_to_dentry, | 1052 | .fh_to_dentry = ext4_fh_to_dentry, |
1012 | .fh_to_parent = ext4_fh_to_parent, | 1053 | .fh_to_parent = ext4_fh_to_parent, |
@@ -1023,12 +1064,13 @@ enum { | |||
1023 | Opt_journal_update, Opt_journal_dev, | 1064 | Opt_journal_update, Opt_journal_dev, |
1024 | Opt_journal_checksum, Opt_journal_async_commit, | 1065 | Opt_journal_checksum, Opt_journal_async_commit, |
1025 | Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, | 1066 | Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, |
1026 | Opt_data_err_abort, Opt_data_err_ignore, | 1067 | Opt_data_err_abort, Opt_data_err_ignore, Opt_mb_history_length, |
1027 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, | 1068 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, |
1028 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, | 1069 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, |
1029 | Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize, | 1070 | Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize, |
1030 | Opt_usrquota, Opt_grpquota, Opt_i_version, | 1071 | Opt_usrquota, Opt_grpquota, Opt_i_version, |
1031 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, | 1072 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, |
1073 | Opt_block_validity, Opt_noblock_validity, | ||
1032 | Opt_inode_readahead_blks, Opt_journal_ioprio | 1074 | Opt_inode_readahead_blks, Opt_journal_ioprio |
1033 | }; | 1075 | }; |
1034 | 1076 | ||
@@ -1069,6 +1111,7 @@ static const match_table_t tokens = { | |||
1069 | {Opt_data_writeback, "data=writeback"}, | 1111 | {Opt_data_writeback, "data=writeback"}, |
1070 | {Opt_data_err_abort, "data_err=abort"}, | 1112 | {Opt_data_err_abort, "data_err=abort"}, |
1071 | {Opt_data_err_ignore, "data_err=ignore"}, | 1113 | {Opt_data_err_ignore, "data_err=ignore"}, |
1114 | {Opt_mb_history_length, "mb_history_length=%u"}, | ||
1072 | {Opt_offusrjquota, "usrjquota="}, | 1115 | {Opt_offusrjquota, "usrjquota="}, |
1073 | {Opt_usrjquota, "usrjquota=%s"}, | 1116 | {Opt_usrjquota, "usrjquota=%s"}, |
1074 | {Opt_offgrpjquota, "grpjquota="}, | 1117 | {Opt_offgrpjquota, "grpjquota="}, |
@@ -1087,6 +1130,8 @@ static const match_table_t tokens = { | |||
1087 | {Opt_resize, "resize"}, | 1130 | {Opt_resize, "resize"}, |
1088 | {Opt_delalloc, "delalloc"}, | 1131 | {Opt_delalloc, "delalloc"}, |
1089 | {Opt_nodelalloc, "nodelalloc"}, | 1132 | {Opt_nodelalloc, "nodelalloc"}, |
1133 | {Opt_block_validity, "block_validity"}, | ||
1134 | {Opt_noblock_validity, "noblock_validity"}, | ||
1090 | {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, | 1135 | {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, |
1091 | {Opt_journal_ioprio, "journal_ioprio=%u"}, | 1136 | {Opt_journal_ioprio, "journal_ioprio=%u"}, |
1092 | {Opt_auto_da_alloc, "auto_da_alloc=%u"}, | 1137 | {Opt_auto_da_alloc, "auto_da_alloc=%u"}, |
@@ -1102,8 +1147,9 @@ static ext4_fsblk_t get_sb_block(void **data) | |||
1102 | 1147 | ||
1103 | if (!options || strncmp(options, "sb=", 3) != 0) | 1148 | if (!options || strncmp(options, "sb=", 3) != 0) |
1104 | return 1; /* Default location */ | 1149 | return 1; /* Default location */ |
1150 | |||
1105 | options += 3; | 1151 | options += 3; |
1106 | /*todo: use simple_strtoll with >32bit ext4 */ | 1152 | /* TODO: use simple_strtoll with >32bit ext4 */ |
1107 | sb_block = simple_strtoul(options, &options, 0); | 1153 | sb_block = simple_strtoul(options, &options, 0); |
1108 | if (*options && *options != ',') { | 1154 | if (*options && *options != ',') { |
1109 | printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n", | 1155 | printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n", |
@@ -1113,6 +1159,7 @@ static ext4_fsblk_t get_sb_block(void **data) | |||
1113 | if (*options == ',') | 1159 | if (*options == ',') |
1114 | options++; | 1160 | options++; |
1115 | *data = (void *) options; | 1161 | *data = (void *) options; |
1162 | |||
1116 | return sb_block; | 1163 | return sb_block; |
1117 | } | 1164 | } |
1118 | 1165 | ||
@@ -1206,8 +1253,7 @@ static int parse_options(char *options, struct super_block *sb, | |||
1206 | #else | 1253 | #else |
1207 | case Opt_user_xattr: | 1254 | case Opt_user_xattr: |
1208 | case Opt_nouser_xattr: | 1255 | case Opt_nouser_xattr: |
1209 | printk(KERN_ERR "EXT4 (no)user_xattr options " | 1256 | ext4_msg(sb, KERN_ERR, "(no)user_xattr options not supported"); |
1210 | "not supported\n"); | ||
1211 | break; | 1257 | break; |
1212 | #endif | 1258 | #endif |
1213 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 1259 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
@@ -1220,8 +1266,7 @@ static int parse_options(char *options, struct super_block *sb, | |||
1220 | #else | 1266 | #else |
1221 | case Opt_acl: | 1267 | case Opt_acl: |
1222 | case Opt_noacl: | 1268 | case Opt_noacl: |
1223 | printk(KERN_ERR "EXT4 (no)acl options " | 1269 | ext4_msg(sb, KERN_ERR, "(no)acl options not supported"); |
1224 | "not supported\n"); | ||
1225 | break; | 1270 | break; |
1226 | #endif | 1271 | #endif |
1227 | case Opt_journal_update: | 1272 | case Opt_journal_update: |
@@ -1231,16 +1276,16 @@ static int parse_options(char *options, struct super_block *sb, | |||
1231 | user to specify an existing inode to be the | 1276 | user to specify an existing inode to be the |
1232 | journal file. */ | 1277 | journal file. */ |
1233 | if (is_remount) { | 1278 | if (is_remount) { |
1234 | printk(KERN_ERR "EXT4-fs: cannot specify " | 1279 | ext4_msg(sb, KERN_ERR, |
1235 | "journal on remount\n"); | 1280 | "Cannot specify journal on remount"); |
1236 | return 0; | 1281 | return 0; |
1237 | } | 1282 | } |
1238 | set_opt(sbi->s_mount_opt, UPDATE_JOURNAL); | 1283 | set_opt(sbi->s_mount_opt, UPDATE_JOURNAL); |
1239 | break; | 1284 | break; |
1240 | case Opt_journal_dev: | 1285 | case Opt_journal_dev: |
1241 | if (is_remount) { | 1286 | if (is_remount) { |
1242 | printk(KERN_ERR "EXT4-fs: cannot specify " | 1287 | ext4_msg(sb, KERN_ERR, |
1243 | "journal on remount\n"); | 1288 | "Cannot specify journal on remount"); |
1244 | return 0; | 1289 | return 0; |
1245 | } | 1290 | } |
1246 | if (match_int(&args[0], &option)) | 1291 | if (match_int(&args[0], &option)) |
@@ -1294,9 +1339,8 @@ static int parse_options(char *options, struct super_block *sb, | |||
1294 | if (is_remount) { | 1339 | if (is_remount) { |
1295 | if ((sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS) | 1340 | if ((sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS) |
1296 | != data_opt) { | 1341 | != data_opt) { |
1297 | printk(KERN_ERR | 1342 | ext4_msg(sb, KERN_ERR, |
1298 | "EXT4-fs: cannot change data " | 1343 | "Cannot change data mode on remount"); |
1299 | "mode on remount\n"); | ||
1300 | return 0; | 1344 | return 0; |
1301 | } | 1345 | } |
1302 | } else { | 1346 | } else { |
@@ -1310,6 +1354,13 @@ static int parse_options(char *options, struct super_block *sb, | |||
1310 | case Opt_data_err_ignore: | 1354 | case Opt_data_err_ignore: |
1311 | clear_opt(sbi->s_mount_opt, DATA_ERR_ABORT); | 1355 | clear_opt(sbi->s_mount_opt, DATA_ERR_ABORT); |
1312 | break; | 1356 | break; |
1357 | case Opt_mb_history_length: | ||
1358 | if (match_int(&args[0], &option)) | ||
1359 | return 0; | ||
1360 | if (option < 0) | ||
1361 | return 0; | ||
1362 | sbi->s_mb_history_max = option; | ||
1363 | break; | ||
1313 | #ifdef CONFIG_QUOTA | 1364 | #ifdef CONFIG_QUOTA |
1314 | case Opt_usrjquota: | 1365 | case Opt_usrjquota: |
1315 | qtype = USRQUOTA; | 1366 | qtype = USRQUOTA; |
@@ -1319,31 +1370,31 @@ static int parse_options(char *options, struct super_block *sb, | |||
1319 | set_qf_name: | 1370 | set_qf_name: |
1320 | if (sb_any_quota_loaded(sb) && | 1371 | if (sb_any_quota_loaded(sb) && |
1321 | !sbi->s_qf_names[qtype]) { | 1372 | !sbi->s_qf_names[qtype]) { |
1322 | printk(KERN_ERR | 1373 | ext4_msg(sb, KERN_ERR, |
1323 | "EXT4-fs: Cannot change journaled " | 1374 | "Cannot change journaled " |
1324 | "quota options when quota turned on.\n"); | 1375 | "quota options when quota turned on"); |
1325 | return 0; | 1376 | return 0; |
1326 | } | 1377 | } |
1327 | qname = match_strdup(&args[0]); | 1378 | qname = match_strdup(&args[0]); |
1328 | if (!qname) { | 1379 | if (!qname) { |
1329 | printk(KERN_ERR | 1380 | ext4_msg(sb, KERN_ERR, |
1330 | "EXT4-fs: not enough memory for " | 1381 | "Not enough memory for " |
1331 | "storing quotafile name.\n"); | 1382 | "storing quotafile name"); |
1332 | return 0; | 1383 | return 0; |
1333 | } | 1384 | } |
1334 | if (sbi->s_qf_names[qtype] && | 1385 | if (sbi->s_qf_names[qtype] && |
1335 | strcmp(sbi->s_qf_names[qtype], qname)) { | 1386 | strcmp(sbi->s_qf_names[qtype], qname)) { |
1336 | printk(KERN_ERR | 1387 | ext4_msg(sb, KERN_ERR, |
1337 | "EXT4-fs: %s quota file already " | 1388 | "%s quota file already " |
1338 | "specified.\n", QTYPE2NAME(qtype)); | 1389 | "specified", QTYPE2NAME(qtype)); |
1339 | kfree(qname); | 1390 | kfree(qname); |
1340 | return 0; | 1391 | return 0; |
1341 | } | 1392 | } |
1342 | sbi->s_qf_names[qtype] = qname; | 1393 | sbi->s_qf_names[qtype] = qname; |
1343 | if (strchr(sbi->s_qf_names[qtype], '/')) { | 1394 | if (strchr(sbi->s_qf_names[qtype], '/')) { |
1344 | printk(KERN_ERR | 1395 | ext4_msg(sb, KERN_ERR, |
1345 | "EXT4-fs: quotafile must be on " | 1396 | "quotafile must be on " |
1346 | "filesystem root.\n"); | 1397 | "filesystem root"); |
1347 | kfree(sbi->s_qf_names[qtype]); | 1398 | kfree(sbi->s_qf_names[qtype]); |
1348 | sbi->s_qf_names[qtype] = NULL; | 1399 | sbi->s_qf_names[qtype] = NULL; |
1349 | return 0; | 1400 | return 0; |
@@ -1358,9 +1409,9 @@ set_qf_name: | |||
1358 | clear_qf_name: | 1409 | clear_qf_name: |
1359 | if (sb_any_quota_loaded(sb) && | 1410 | if (sb_any_quota_loaded(sb) && |
1360 | sbi->s_qf_names[qtype]) { | 1411 | sbi->s_qf_names[qtype]) { |
1361 | printk(KERN_ERR "EXT4-fs: Cannot change " | 1412 | ext4_msg(sb, KERN_ERR, "Cannot change " |
1362 | "journaled quota options when " | 1413 | "journaled quota options when " |
1363 | "quota turned on.\n"); | 1414 | "quota turned on"); |
1364 | return 0; | 1415 | return 0; |
1365 | } | 1416 | } |
1366 | /* | 1417 | /* |
@@ -1377,9 +1428,9 @@ clear_qf_name: | |||
1377 | set_qf_format: | 1428 | set_qf_format: |
1378 | if (sb_any_quota_loaded(sb) && | 1429 | if (sb_any_quota_loaded(sb) && |
1379 | sbi->s_jquota_fmt != qfmt) { | 1430 | sbi->s_jquota_fmt != qfmt) { |
1380 | printk(KERN_ERR "EXT4-fs: Cannot change " | 1431 | ext4_msg(sb, KERN_ERR, "Cannot change " |
1381 | "journaled quota options when " | 1432 | "journaled quota options when " |
1382 | "quota turned on.\n"); | 1433 | "quota turned on"); |
1383 | return 0; | 1434 | return 0; |
1384 | } | 1435 | } |
1385 | sbi->s_jquota_fmt = qfmt; | 1436 | sbi->s_jquota_fmt = qfmt; |
@@ -1395,8 +1446,8 @@ set_qf_format: | |||
1395 | break; | 1446 | break; |
1396 | case Opt_noquota: | 1447 | case Opt_noquota: |
1397 | if (sb_any_quota_loaded(sb)) { | 1448 | if (sb_any_quota_loaded(sb)) { |
1398 | printk(KERN_ERR "EXT4-fs: Cannot change quota " | 1449 | ext4_msg(sb, KERN_ERR, "Cannot change quota " |
1399 | "options when quota turned on.\n"); | 1450 | "options when quota turned on"); |
1400 | return 0; | 1451 | return 0; |
1401 | } | 1452 | } |
1402 | clear_opt(sbi->s_mount_opt, QUOTA); | 1453 | clear_opt(sbi->s_mount_opt, QUOTA); |
@@ -1407,8 +1458,8 @@ set_qf_format: | |||
1407 | case Opt_quota: | 1458 | case Opt_quota: |
1408 | case Opt_usrquota: | 1459 | case Opt_usrquota: |
1409 | case Opt_grpquota: | 1460 | case Opt_grpquota: |
1410 | printk(KERN_ERR | 1461 | ext4_msg(sb, KERN_ERR, |
1411 | "EXT4-fs: quota options not supported.\n"); | 1462 | "quota options not supported"); |
1412 | break; | 1463 | break; |
1413 | case Opt_usrjquota: | 1464 | case Opt_usrjquota: |
1414 | case Opt_grpjquota: | 1465 | case Opt_grpjquota: |
@@ -1416,9 +1467,8 @@ set_qf_format: | |||
1416 | case Opt_offgrpjquota: | 1467 | case Opt_offgrpjquota: |
1417 | case Opt_jqfmt_vfsold: | 1468 | case Opt_jqfmt_vfsold: |
1418 | case Opt_jqfmt_vfsv0: | 1469 | case Opt_jqfmt_vfsv0: |
1419 | printk(KERN_ERR | 1470 | ext4_msg(sb, KERN_ERR, |
1420 | "EXT4-fs: journaled quota options not " | 1471 | "journaled quota options not supported"); |
1421 | "supported.\n"); | ||
1422 | break; | 1472 | break; |
1423 | case Opt_noquota: | 1473 | case Opt_noquota: |
1424 | break; | 1474 | break; |
@@ -1443,8 +1493,9 @@ set_qf_format: | |||
1443 | break; | 1493 | break; |
1444 | case Opt_resize: | 1494 | case Opt_resize: |
1445 | if (!is_remount) { | 1495 | if (!is_remount) { |
1446 | printk("EXT4-fs: resize option only available " | 1496 | ext4_msg(sb, KERN_ERR, |
1447 | "for remount\n"); | 1497 | "resize option only available " |
1498 | "for remount"); | ||
1448 | return 0; | 1499 | return 0; |
1449 | } | 1500 | } |
1450 | if (match_int(&args[0], &option) != 0) | 1501 | if (match_int(&args[0], &option) != 0) |
@@ -1474,14 +1525,21 @@ set_qf_format: | |||
1474 | case Opt_delalloc: | 1525 | case Opt_delalloc: |
1475 | set_opt(sbi->s_mount_opt, DELALLOC); | 1526 | set_opt(sbi->s_mount_opt, DELALLOC); |
1476 | break; | 1527 | break; |
1528 | case Opt_block_validity: | ||
1529 | set_opt(sbi->s_mount_opt, BLOCK_VALIDITY); | ||
1530 | break; | ||
1531 | case Opt_noblock_validity: | ||
1532 | clear_opt(sbi->s_mount_opt, BLOCK_VALIDITY); | ||
1533 | break; | ||
1477 | case Opt_inode_readahead_blks: | 1534 | case Opt_inode_readahead_blks: |
1478 | if (match_int(&args[0], &option)) | 1535 | if (match_int(&args[0], &option)) |
1479 | return 0; | 1536 | return 0; |
1480 | if (option < 0 || option > (1 << 30)) | 1537 | if (option < 0 || option > (1 << 30)) |
1481 | return 0; | 1538 | return 0; |
1482 | if (option & (option - 1)) { | 1539 | if (!is_power_of_2(option)) { |
1483 | printk(KERN_ERR "EXT4-fs: inode_readahead_blks" | 1540 | ext4_msg(sb, KERN_ERR, |
1484 | " must be a power of 2\n"); | 1541 | "EXT4-fs: inode_readahead_blks" |
1542 | " must be a power of 2"); | ||
1485 | return 0; | 1543 | return 0; |
1486 | } | 1544 | } |
1487 | sbi->s_inode_readahead_blks = option; | 1545 | sbi->s_inode_readahead_blks = option; |
@@ -1508,9 +1566,9 @@ set_qf_format: | |||
1508 | set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); | 1566 | set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); |
1509 | break; | 1567 | break; |
1510 | default: | 1568 | default: |
1511 | printk(KERN_ERR | 1569 | ext4_msg(sb, KERN_ERR, |
1512 | "EXT4-fs: Unrecognized mount option \"%s\" " | 1570 | "Unrecognized mount option \"%s\" " |
1513 | "or missing value\n", p); | 1571 | "or missing value", p); |
1514 | return 0; | 1572 | return 0; |
1515 | } | 1573 | } |
1516 | } | 1574 | } |
@@ -1528,21 +1586,21 @@ set_qf_format: | |||
1528 | (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA)) || | 1586 | (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA)) || |
1529 | (sbi->s_qf_names[GRPQUOTA] && | 1587 | (sbi->s_qf_names[GRPQUOTA] && |
1530 | (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA))) { | 1588 | (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA))) { |
1531 | printk(KERN_ERR "EXT4-fs: old and new quota " | 1589 | ext4_msg(sb, KERN_ERR, "old and new quota " |
1532 | "format mixing.\n"); | 1590 | "format mixing"); |
1533 | return 0; | 1591 | return 0; |
1534 | } | 1592 | } |
1535 | 1593 | ||
1536 | if (!sbi->s_jquota_fmt) { | 1594 | if (!sbi->s_jquota_fmt) { |
1537 | printk(KERN_ERR "EXT4-fs: journaled quota format " | 1595 | ext4_msg(sb, KERN_ERR, "journaled quota format " |
1538 | "not specified.\n"); | 1596 | "not specified"); |
1539 | return 0; | 1597 | return 0; |
1540 | } | 1598 | } |
1541 | } else { | 1599 | } else { |
1542 | if (sbi->s_jquota_fmt) { | 1600 | if (sbi->s_jquota_fmt) { |
1543 | printk(KERN_ERR "EXT4-fs: journaled quota format " | 1601 | ext4_msg(sb, KERN_ERR, "journaled quota format " |
1544 | "specified with no journaling " | 1602 | "specified with no journaling " |
1545 | "enabled.\n"); | 1603 | "enabled"); |
1546 | return 0; | 1604 | return 0; |
1547 | } | 1605 | } |
1548 | } | 1606 | } |
@@ -1557,32 +1615,32 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, | |||
1557 | int res = 0; | 1615 | int res = 0; |
1558 | 1616 | ||
1559 | if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) { | 1617 | if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) { |
1560 | printk(KERN_ERR "EXT4-fs warning: revision level too high, " | 1618 | ext4_msg(sb, KERN_ERR, "revision level too high, " |
1561 | "forcing read-only mode\n"); | 1619 | "forcing read-only mode"); |
1562 | res = MS_RDONLY; | 1620 | res = MS_RDONLY; |
1563 | } | 1621 | } |
1564 | if (read_only) | 1622 | if (read_only) |
1565 | return res; | 1623 | return res; |
1566 | if (!(sbi->s_mount_state & EXT4_VALID_FS)) | 1624 | if (!(sbi->s_mount_state & EXT4_VALID_FS)) |
1567 | printk(KERN_WARNING "EXT4-fs warning: mounting unchecked fs, " | 1625 | ext4_msg(sb, KERN_WARNING, "warning: mounting unchecked fs, " |
1568 | "running e2fsck is recommended\n"); | 1626 | "running e2fsck is recommended"); |
1569 | else if ((sbi->s_mount_state & EXT4_ERROR_FS)) | 1627 | else if ((sbi->s_mount_state & EXT4_ERROR_FS)) |
1570 | printk(KERN_WARNING | 1628 | ext4_msg(sb, KERN_WARNING, |
1571 | "EXT4-fs warning: mounting fs with errors, " | 1629 | "warning: mounting fs with errors, " |
1572 | "running e2fsck is recommended\n"); | 1630 | "running e2fsck is recommended"); |
1573 | else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && | 1631 | else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && |
1574 | le16_to_cpu(es->s_mnt_count) >= | 1632 | le16_to_cpu(es->s_mnt_count) >= |
1575 | (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) | 1633 | (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) |
1576 | printk(KERN_WARNING | 1634 | ext4_msg(sb, KERN_WARNING, |
1577 | "EXT4-fs warning: maximal mount count reached, " | 1635 | "warning: maximal mount count reached, " |
1578 | "running e2fsck is recommended\n"); | 1636 | "running e2fsck is recommended"); |
1579 | else if (le32_to_cpu(es->s_checkinterval) && | 1637 | else if (le32_to_cpu(es->s_checkinterval) && |
1580 | (le32_to_cpu(es->s_lastcheck) + | 1638 | (le32_to_cpu(es->s_lastcheck) + |
1581 | le32_to_cpu(es->s_checkinterval) <= get_seconds())) | 1639 | le32_to_cpu(es->s_checkinterval) <= get_seconds())) |
1582 | printk(KERN_WARNING | 1640 | ext4_msg(sb, KERN_WARNING, |
1583 | "EXT4-fs warning: checktime reached, " | 1641 | "warning: checktime reached, " |
1584 | "running e2fsck is recommended\n"); | 1642 | "running e2fsck is recommended"); |
1585 | if (!sbi->s_journal) | 1643 | if (!sbi->s_journal) |
1586 | es->s_state &= cpu_to_le16(~EXT4_VALID_FS); | 1644 | es->s_state &= cpu_to_le16(~EXT4_VALID_FS); |
1587 | if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) | 1645 | if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) |
1588 | es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT); | 1646 | es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT); |
@@ -1592,7 +1650,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, | |||
1592 | if (sbi->s_journal) | 1650 | if (sbi->s_journal) |
1593 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 1651 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
1594 | 1652 | ||
1595 | ext4_commit_super(sb, es, 1); | 1653 | ext4_commit_super(sb, 1); |
1596 | if (test_opt(sb, DEBUG)) | 1654 | if (test_opt(sb, DEBUG)) |
1597 | printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, " | 1655 | printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, " |
1598 | "bpg=%lu, ipg=%lu, mo=%04lx]\n", | 1656 | "bpg=%lu, ipg=%lu, mo=%04lx]\n", |
@@ -1603,11 +1661,11 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, | |||
1603 | sbi->s_mount_opt); | 1661 | sbi->s_mount_opt); |
1604 | 1662 | ||
1605 | if (EXT4_SB(sb)->s_journal) { | 1663 | if (EXT4_SB(sb)->s_journal) { |
1606 | printk(KERN_INFO "EXT4 FS on %s, %s journal on %s\n", | 1664 | ext4_msg(sb, KERN_INFO, "%s journal on %s", |
1607 | sb->s_id, EXT4_SB(sb)->s_journal->j_inode ? "internal" : | 1665 | EXT4_SB(sb)->s_journal->j_inode ? "internal" : |
1608 | "external", EXT4_SB(sb)->s_journal->j_devname); | 1666 | "external", EXT4_SB(sb)->s_journal->j_devname); |
1609 | } else { | 1667 | } else { |
1610 | printk(KERN_INFO "EXT4 FS on %s, no journal\n", sb->s_id); | 1668 | ext4_msg(sb, KERN_INFO, "no journal"); |
1611 | } | 1669 | } |
1612 | return res; | 1670 | return res; |
1613 | } | 1671 | } |
@@ -1616,10 +1674,10 @@ static int ext4_fill_flex_info(struct super_block *sb) | |||
1616 | { | 1674 | { |
1617 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 1675 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
1618 | struct ext4_group_desc *gdp = NULL; | 1676 | struct ext4_group_desc *gdp = NULL; |
1619 | struct buffer_head *bh; | ||
1620 | ext4_group_t flex_group_count; | 1677 | ext4_group_t flex_group_count; |
1621 | ext4_group_t flex_group; | 1678 | ext4_group_t flex_group; |
1622 | int groups_per_flex = 0; | 1679 | int groups_per_flex = 0; |
1680 | size_t size; | ||
1623 | int i; | 1681 | int i; |
1624 | 1682 | ||
1625 | if (!sbi->s_es->s_log_groups_per_flex) { | 1683 | if (!sbi->s_es->s_log_groups_per_flex) { |
@@ -1634,16 +1692,21 @@ static int ext4_fill_flex_info(struct super_block *sb) | |||
1634 | flex_group_count = ((sbi->s_groups_count + groups_per_flex - 1) + | 1692 | flex_group_count = ((sbi->s_groups_count + groups_per_flex - 1) + |
1635 | ((le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) + 1) << | 1693 | ((le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) + 1) << |
1636 | EXT4_DESC_PER_BLOCK_BITS(sb))) / groups_per_flex; | 1694 | EXT4_DESC_PER_BLOCK_BITS(sb))) / groups_per_flex; |
1637 | sbi->s_flex_groups = kzalloc(flex_group_count * | 1695 | size = flex_group_count * sizeof(struct flex_groups); |
1638 | sizeof(struct flex_groups), GFP_KERNEL); | 1696 | sbi->s_flex_groups = kzalloc(size, GFP_KERNEL); |
1697 | if (sbi->s_flex_groups == NULL) { | ||
1698 | sbi->s_flex_groups = vmalloc(size); | ||
1699 | if (sbi->s_flex_groups) | ||
1700 | memset(sbi->s_flex_groups, 0, size); | ||
1701 | } | ||
1639 | if (sbi->s_flex_groups == NULL) { | 1702 | if (sbi->s_flex_groups == NULL) { |
1640 | printk(KERN_ERR "EXT4-fs: not enough memory for " | 1703 | ext4_msg(sb, KERN_ERR, "not enough memory for " |
1641 | "%u flex groups\n", flex_group_count); | 1704 | "%u flex groups", flex_group_count); |
1642 | goto failed; | 1705 | goto failed; |
1643 | } | 1706 | } |
1644 | 1707 | ||
1645 | for (i = 0; i < sbi->s_groups_count; i++) { | 1708 | for (i = 0; i < sbi->s_groups_count; i++) { |
1646 | gdp = ext4_get_group_desc(sb, i, &bh); | 1709 | gdp = ext4_get_group_desc(sb, i, NULL); |
1647 | 1710 | ||
1648 | flex_group = ext4_flex_group(sbi, i); | 1711 | flex_group = ext4_flex_group(sbi, i); |
1649 | atomic_set(&sbi->s_flex_groups[flex_group].free_inodes, | 1712 | atomic_set(&sbi->s_flex_groups[flex_group].free_inodes, |
@@ -1724,44 +1787,44 @@ static int ext4_check_descriptors(struct super_block *sb) | |||
1724 | 1787 | ||
1725 | block_bitmap = ext4_block_bitmap(sb, gdp); | 1788 | block_bitmap = ext4_block_bitmap(sb, gdp); |
1726 | if (block_bitmap < first_block || block_bitmap > last_block) { | 1789 | if (block_bitmap < first_block || block_bitmap > last_block) { |
1727 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1790 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
1728 | "Block bitmap for group %u not in group " | 1791 | "Block bitmap for group %u not in group " |
1729 | "(block %llu)!\n", i, block_bitmap); | 1792 | "(block %llu)!", i, block_bitmap); |
1730 | return 0; | 1793 | return 0; |
1731 | } | 1794 | } |
1732 | inode_bitmap = ext4_inode_bitmap(sb, gdp); | 1795 | inode_bitmap = ext4_inode_bitmap(sb, gdp); |
1733 | if (inode_bitmap < first_block || inode_bitmap > last_block) { | 1796 | if (inode_bitmap < first_block || inode_bitmap > last_block) { |
1734 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1797 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
1735 | "Inode bitmap for group %u not in group " | 1798 | "Inode bitmap for group %u not in group " |
1736 | "(block %llu)!\n", i, inode_bitmap); | 1799 | "(block %llu)!", i, inode_bitmap); |
1737 | return 0; | 1800 | return 0; |
1738 | } | 1801 | } |
1739 | inode_table = ext4_inode_table(sb, gdp); | 1802 | inode_table = ext4_inode_table(sb, gdp); |
1740 | if (inode_table < first_block || | 1803 | if (inode_table < first_block || |
1741 | inode_table + sbi->s_itb_per_group - 1 > last_block) { | 1804 | inode_table + sbi->s_itb_per_group - 1 > last_block) { |
1742 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1805 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
1743 | "Inode table for group %u not in group " | 1806 | "Inode table for group %u not in group " |
1744 | "(block %llu)!\n", i, inode_table); | 1807 | "(block %llu)!", i, inode_table); |
1745 | return 0; | 1808 | return 0; |
1746 | } | 1809 | } |
1747 | spin_lock(sb_bgl_lock(sbi, i)); | 1810 | ext4_lock_group(sb, i); |
1748 | if (!ext4_group_desc_csum_verify(sbi, i, gdp)) { | 1811 | if (!ext4_group_desc_csum_verify(sbi, i, gdp)) { |
1749 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1812 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
1750 | "Checksum for group %u failed (%u!=%u)\n", | 1813 | "Checksum for group %u failed (%u!=%u)", |
1751 | i, le16_to_cpu(ext4_group_desc_csum(sbi, i, | 1814 | i, le16_to_cpu(ext4_group_desc_csum(sbi, i, |
1752 | gdp)), le16_to_cpu(gdp->bg_checksum)); | 1815 | gdp)), le16_to_cpu(gdp->bg_checksum)); |
1753 | if (!(sb->s_flags & MS_RDONLY)) { | 1816 | if (!(sb->s_flags & MS_RDONLY)) { |
1754 | spin_unlock(sb_bgl_lock(sbi, i)); | 1817 | ext4_unlock_group(sb, i); |
1755 | return 0; | 1818 | return 0; |
1756 | } | 1819 | } |
1757 | } | 1820 | } |
1758 | spin_unlock(sb_bgl_lock(sbi, i)); | 1821 | ext4_unlock_group(sb, i); |
1759 | if (!flexbg_flag) | 1822 | if (!flexbg_flag) |
1760 | first_block += EXT4_BLOCKS_PER_GROUP(sb); | 1823 | first_block += EXT4_BLOCKS_PER_GROUP(sb); |
1761 | } | 1824 | } |
1762 | 1825 | ||
1763 | ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb)); | 1826 | ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb)); |
1764 | sbi->s_es->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb)); | 1827 | sbi->s_es->s_free_inodes_count =cpu_to_le32(ext4_count_free_inodes(sb)); |
1765 | return 1; | 1828 | return 1; |
1766 | } | 1829 | } |
1767 | 1830 | ||
@@ -1796,8 +1859,8 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1796 | } | 1859 | } |
1797 | 1860 | ||
1798 | if (bdev_read_only(sb->s_bdev)) { | 1861 | if (bdev_read_only(sb->s_bdev)) { |
1799 | printk(KERN_ERR "EXT4-fs: write access " | 1862 | ext4_msg(sb, KERN_ERR, "write access " |
1800 | "unavailable, skipping orphan cleanup.\n"); | 1863 | "unavailable, skipping orphan cleanup"); |
1801 | return; | 1864 | return; |
1802 | } | 1865 | } |
1803 | 1866 | ||
@@ -1811,8 +1874,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1811 | } | 1874 | } |
1812 | 1875 | ||
1813 | if (s_flags & MS_RDONLY) { | 1876 | if (s_flags & MS_RDONLY) { |
1814 | printk(KERN_INFO "EXT4-fs: %s: orphan cleanup on readonly fs\n", | 1877 | ext4_msg(sb, KERN_INFO, "orphan cleanup on readonly fs"); |
1815 | sb->s_id); | ||
1816 | sb->s_flags &= ~MS_RDONLY; | 1878 | sb->s_flags &= ~MS_RDONLY; |
1817 | } | 1879 | } |
1818 | #ifdef CONFIG_QUOTA | 1880 | #ifdef CONFIG_QUOTA |
@@ -1823,9 +1885,9 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1823 | if (EXT4_SB(sb)->s_qf_names[i]) { | 1885 | if (EXT4_SB(sb)->s_qf_names[i]) { |
1824 | int ret = ext4_quota_on_mount(sb, i); | 1886 | int ret = ext4_quota_on_mount(sb, i); |
1825 | if (ret < 0) | 1887 | if (ret < 0) |
1826 | printk(KERN_ERR | 1888 | ext4_msg(sb, KERN_ERR, |
1827 | "EXT4-fs: Cannot turn on journaled " | 1889 | "Cannot turn on journaled " |
1828 | "quota: error %d\n", ret); | 1890 | "quota: error %d", ret); |
1829 | } | 1891 | } |
1830 | } | 1892 | } |
1831 | #endif | 1893 | #endif |
@@ -1842,16 +1904,16 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1842 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); | 1904 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); |
1843 | vfs_dq_init(inode); | 1905 | vfs_dq_init(inode); |
1844 | if (inode->i_nlink) { | 1906 | if (inode->i_nlink) { |
1845 | printk(KERN_DEBUG | 1907 | ext4_msg(sb, KERN_DEBUG, |
1846 | "%s: truncating inode %lu to %lld bytes\n", | 1908 | "%s: truncating inode %lu to %lld bytes", |
1847 | __func__, inode->i_ino, inode->i_size); | 1909 | __func__, inode->i_ino, inode->i_size); |
1848 | jbd_debug(2, "truncating inode %lu to %lld bytes\n", | 1910 | jbd_debug(2, "truncating inode %lu to %lld bytes\n", |
1849 | inode->i_ino, inode->i_size); | 1911 | inode->i_ino, inode->i_size); |
1850 | ext4_truncate(inode); | 1912 | ext4_truncate(inode); |
1851 | nr_truncates++; | 1913 | nr_truncates++; |
1852 | } else { | 1914 | } else { |
1853 | printk(KERN_DEBUG | 1915 | ext4_msg(sb, KERN_DEBUG, |
1854 | "%s: deleting unreferenced inode %lu\n", | 1916 | "%s: deleting unreferenced inode %lu", |
1855 | __func__, inode->i_ino); | 1917 | __func__, inode->i_ino); |
1856 | jbd_debug(2, "deleting unreferenced inode %lu\n", | 1918 | jbd_debug(2, "deleting unreferenced inode %lu\n", |
1857 | inode->i_ino); | 1919 | inode->i_ino); |
@@ -1863,11 +1925,11 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1863 | #define PLURAL(x) (x), ((x) == 1) ? "" : "s" | 1925 | #define PLURAL(x) (x), ((x) == 1) ? "" : "s" |
1864 | 1926 | ||
1865 | if (nr_orphans) | 1927 | if (nr_orphans) |
1866 | printk(KERN_INFO "EXT4-fs: %s: %d orphan inode%s deleted\n", | 1928 | ext4_msg(sb, KERN_INFO, "%d orphan inode%s deleted", |
1867 | sb->s_id, PLURAL(nr_orphans)); | 1929 | PLURAL(nr_orphans)); |
1868 | if (nr_truncates) | 1930 | if (nr_truncates) |
1869 | printk(KERN_INFO "EXT4-fs: %s: %d truncate%s cleaned up\n", | 1931 | ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up", |
1870 | sb->s_id, PLURAL(nr_truncates)); | 1932 | PLURAL(nr_truncates)); |
1871 | #ifdef CONFIG_QUOTA | 1933 | #ifdef CONFIG_QUOTA |
1872 | /* Turn quotas off */ | 1934 | /* Turn quotas off */ |
1873 | for (i = 0; i < MAXQUOTAS; i++) { | 1935 | for (i = 0; i < MAXQUOTAS; i++) { |
@@ -1877,6 +1939,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1877 | #endif | 1939 | #endif |
1878 | sb->s_flags = s_flags; /* Restore MS_RDONLY status */ | 1940 | sb->s_flags = s_flags; /* Restore MS_RDONLY status */ |
1879 | } | 1941 | } |
1942 | |||
1880 | /* | 1943 | /* |
1881 | * Maximal extent format file size. | 1944 | * Maximal extent format file size. |
1882 | * Resulting logical blkno at s_maxbytes must fit in our on-disk | 1945 | * Resulting logical blkno at s_maxbytes must fit in our on-disk |
@@ -1927,19 +1990,19 @@ static loff_t ext4_max_bitmap_size(int bits, int has_huge_files) | |||
1927 | loff_t res = EXT4_NDIR_BLOCKS; | 1990 | loff_t res = EXT4_NDIR_BLOCKS; |
1928 | int meta_blocks; | 1991 | int meta_blocks; |
1929 | loff_t upper_limit; | 1992 | loff_t upper_limit; |
1930 | /* This is calculated to be the largest file size for a | 1993 | /* This is calculated to be the largest file size for a dense, block |
1931 | * dense, bitmapped file such that the total number of | 1994 | * mapped file such that the file's total number of 512-byte sectors, |
1932 | * sectors in the file, including data and all indirect blocks, | 1995 | * including data and all indirect blocks, does not exceed (2^48 - 1). |
1933 | * does not exceed 2^48 -1 | 1996 | * |
1934 | * __u32 i_blocks_lo and _u16 i_blocks_high representing the | 1997 | * __u32 i_blocks_lo and _u16 i_blocks_high represent the total |
1935 | * total number of 512 bytes blocks of the file | 1998 | * number of 512-byte sectors of the file. |
1936 | */ | 1999 | */ |
1937 | 2000 | ||
1938 | if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { | 2001 | if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { |
1939 | /* | 2002 | /* |
1940 | * !has_huge_files or CONFIG_LBD is not enabled | 2003 | * !has_huge_files or CONFIG_LBD not enabled implies that |
1941 | * implies the inode i_block represent total blocks in | 2004 | * the inode i_block field represents total file blocks in |
1942 | * 512 bytes 32 == size of vfs inode i_blocks * 8 | 2005 | * 2^32 512-byte sectors == size of vfs inode i_blocks * 8 |
1943 | */ | 2006 | */ |
1944 | upper_limit = (1LL << 32) - 1; | 2007 | upper_limit = (1LL << 32) - 1; |
1945 | 2008 | ||
@@ -1981,7 +2044,7 @@ static loff_t ext4_max_bitmap_size(int bits, int has_huge_files) | |||
1981 | } | 2044 | } |
1982 | 2045 | ||
1983 | static ext4_fsblk_t descriptor_loc(struct super_block *sb, | 2046 | static ext4_fsblk_t descriptor_loc(struct super_block *sb, |
1984 | ext4_fsblk_t logical_sb_block, int nr) | 2047 | ext4_fsblk_t logical_sb_block, int nr) |
1985 | { | 2048 | { |
1986 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 2049 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
1987 | ext4_group_t bg, first_meta_bg; | 2050 | ext4_group_t bg, first_meta_bg; |
@@ -1995,6 +2058,7 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb, | |||
1995 | bg = sbi->s_desc_per_block * nr; | 2058 | bg = sbi->s_desc_per_block * nr; |
1996 | if (ext4_bg_has_super(sb, bg)) | 2059 | if (ext4_bg_has_super(sb, bg)) |
1997 | has_super = 1; | 2060 | has_super = 1; |
2061 | |||
1998 | return (has_super + ext4_group_first_block_no(sb, bg)); | 2062 | return (has_super + ext4_group_first_block_no(sb, bg)); |
1999 | } | 2063 | } |
2000 | 2064 | ||
@@ -2091,8 +2155,7 @@ static ssize_t inode_readahead_blks_store(struct ext4_attr *a, | |||
2091 | if (parse_strtoul(buf, 0x40000000, &t)) | 2155 | if (parse_strtoul(buf, 0x40000000, &t)) |
2092 | return -EINVAL; | 2156 | return -EINVAL; |
2093 | 2157 | ||
2094 | /* inode_readahead_blks must be a power of 2 */ | 2158 | if (!is_power_of_2(t)) |
2095 | if (t & (t-1)) | ||
2096 | return -EINVAL; | 2159 | return -EINVAL; |
2097 | 2160 | ||
2098 | sbi->s_inode_readahead_blks = t; | 2161 | sbi->s_inode_readahead_blks = t; |
@@ -2100,7 +2163,7 @@ static ssize_t inode_readahead_blks_store(struct ext4_attr *a, | |||
2100 | } | 2163 | } |
2101 | 2164 | ||
2102 | static ssize_t sbi_ui_show(struct ext4_attr *a, | 2165 | static ssize_t sbi_ui_show(struct ext4_attr *a, |
2103 | struct ext4_sb_info *sbi, char *buf) | 2166 | struct ext4_sb_info *sbi, char *buf) |
2104 | { | 2167 | { |
2105 | unsigned int *ui = (unsigned int *) (((char *) sbi) + a->offset); | 2168 | unsigned int *ui = (unsigned int *) (((char *) sbi) + a->offset); |
2106 | 2169 | ||
@@ -2205,7 +2268,6 @@ static struct kobj_type ext4_ktype = { | |||
2205 | static int ext4_fill_super(struct super_block *sb, void *data, int silent) | 2268 | static int ext4_fill_super(struct super_block *sb, void *data, int silent) |
2206 | __releases(kernel_lock) | 2269 | __releases(kernel_lock) |
2207 | __acquires(kernel_lock) | 2270 | __acquires(kernel_lock) |
2208 | |||
2209 | { | 2271 | { |
2210 | struct buffer_head *bh; | 2272 | struct buffer_head *bh; |
2211 | struct ext4_super_block *es = NULL; | 2273 | struct ext4_super_block *es = NULL; |
@@ -2256,7 +2318,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2256 | 2318 | ||
2257 | blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); | 2319 | blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); |
2258 | if (!blocksize) { | 2320 | if (!blocksize) { |
2259 | printk(KERN_ERR "EXT4-fs: unable to set blocksize\n"); | 2321 | ext4_msg(sb, KERN_ERR, "unable to set blocksize"); |
2260 | goto out_fail; | 2322 | goto out_fail; |
2261 | } | 2323 | } |
2262 | 2324 | ||
@@ -2272,7 +2334,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2272 | } | 2334 | } |
2273 | 2335 | ||
2274 | if (!(bh = sb_bread(sb, logical_sb_block))) { | 2336 | if (!(bh = sb_bread(sb, logical_sb_block))) { |
2275 | printk(KERN_ERR "EXT4-fs: unable to read superblock\n"); | 2337 | ext4_msg(sb, KERN_ERR, "unable to read superblock"); |
2276 | goto out_fail; | 2338 | goto out_fail; |
2277 | } | 2339 | } |
2278 | /* | 2340 | /* |
@@ -2321,6 +2383,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2321 | sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ; | 2383 | sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ; |
2322 | sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; | 2384 | sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; |
2323 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; | 2385 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; |
2386 | sbi->s_mb_history_max = default_mb_history_length; | ||
2324 | 2387 | ||
2325 | set_opt(sbi->s_mount_opt, BARRIER); | 2388 | set_opt(sbi->s_mount_opt, BARRIER); |
2326 | 2389 | ||
@@ -2330,7 +2393,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2330 | */ | 2393 | */ |
2331 | set_opt(sbi->s_mount_opt, DELALLOC); | 2394 | set_opt(sbi->s_mount_opt, DELALLOC); |
2332 | 2395 | ||
2333 | |||
2334 | if (!parse_options((char *) data, sb, &journal_devnum, | 2396 | if (!parse_options((char *) data, sb, &journal_devnum, |
2335 | &journal_ioprio, NULL, 0)) | 2397 | &journal_ioprio, NULL, 0)) |
2336 | goto failed_mount; | 2398 | goto failed_mount; |
@@ -2342,9 +2404,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2342 | (EXT4_HAS_COMPAT_FEATURE(sb, ~0U) || | 2404 | (EXT4_HAS_COMPAT_FEATURE(sb, ~0U) || |
2343 | EXT4_HAS_RO_COMPAT_FEATURE(sb, ~0U) || | 2405 | EXT4_HAS_RO_COMPAT_FEATURE(sb, ~0U) || |
2344 | EXT4_HAS_INCOMPAT_FEATURE(sb, ~0U))) | 2406 | EXT4_HAS_INCOMPAT_FEATURE(sb, ~0U))) |
2345 | printk(KERN_WARNING | 2407 | ext4_msg(sb, KERN_WARNING, |
2346 | "EXT4-fs warning: feature flags set on rev 0 fs, " | 2408 | "feature flags set on rev 0 fs, " |
2347 | "running e2fsck is recommended\n"); | 2409 | "running e2fsck is recommended"); |
2348 | 2410 | ||
2349 | /* | 2411 | /* |
2350 | * Check feature flags regardless of the revision level, since we | 2412 | * Check feature flags regardless of the revision level, since we |
@@ -2353,16 +2415,18 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2353 | */ | 2415 | */ |
2354 | features = EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP); | 2416 | features = EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP); |
2355 | if (features) { | 2417 | if (features) { |
2356 | printk(KERN_ERR "EXT4-fs: %s: couldn't mount because of " | 2418 | ext4_msg(sb, KERN_ERR, |
2357 | "unsupported optional features (%x).\n", sb->s_id, | 2419 | "Couldn't mount because of " |
2420 | "unsupported optional features (%x)", | ||
2358 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) & | 2421 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) & |
2359 | ~EXT4_FEATURE_INCOMPAT_SUPP)); | 2422 | ~EXT4_FEATURE_INCOMPAT_SUPP)); |
2360 | goto failed_mount; | 2423 | goto failed_mount; |
2361 | } | 2424 | } |
2362 | features = EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP); | 2425 | features = EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP); |
2363 | if (!(sb->s_flags & MS_RDONLY) && features) { | 2426 | if (!(sb->s_flags & MS_RDONLY) && features) { |
2364 | printk(KERN_ERR "EXT4-fs: %s: couldn't mount RDWR because of " | 2427 | ext4_msg(sb, KERN_ERR, |
2365 | "unsupported optional features (%x).\n", sb->s_id, | 2428 | "Couldn't mount RDWR because of " |
2429 | "unsupported optional features (%x)", | ||
2366 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) & | 2430 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) & |
2367 | ~EXT4_FEATURE_RO_COMPAT_SUPP)); | 2431 | ~EXT4_FEATURE_RO_COMPAT_SUPP)); |
2368 | goto failed_mount; | 2432 | goto failed_mount; |
@@ -2376,9 +2440,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2376 | */ | 2440 | */ |
2377 | if (sizeof(root->i_blocks) < sizeof(u64) && | 2441 | if (sizeof(root->i_blocks) < sizeof(u64) && |
2378 | !(sb->s_flags & MS_RDONLY)) { | 2442 | !(sb->s_flags & MS_RDONLY)) { |
2379 | printk(KERN_ERR "EXT4-fs: %s: Filesystem with huge " | 2443 | ext4_msg(sb, KERN_ERR, "Filesystem with huge " |
2380 | "files cannot be mounted read-write " | 2444 | "files cannot be mounted read-write " |
2381 | "without CONFIG_LBD.\n", sb->s_id); | 2445 | "without CONFIG_LBD"); |
2382 | goto failed_mount; | 2446 | goto failed_mount; |
2383 | } | 2447 | } |
2384 | } | 2448 | } |
@@ -2386,17 +2450,15 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2386 | 2450 | ||
2387 | if (blocksize < EXT4_MIN_BLOCK_SIZE || | 2451 | if (blocksize < EXT4_MIN_BLOCK_SIZE || |
2388 | blocksize > EXT4_MAX_BLOCK_SIZE) { | 2452 | blocksize > EXT4_MAX_BLOCK_SIZE) { |
2389 | printk(KERN_ERR | 2453 | ext4_msg(sb, KERN_ERR, |
2390 | "EXT4-fs: Unsupported filesystem blocksize %d on %s.\n", | 2454 | "Unsupported filesystem blocksize %d", blocksize); |
2391 | blocksize, sb->s_id); | ||
2392 | goto failed_mount; | 2455 | goto failed_mount; |
2393 | } | 2456 | } |
2394 | 2457 | ||
2395 | if (sb->s_blocksize != blocksize) { | 2458 | if (sb->s_blocksize != blocksize) { |
2396 | |||
2397 | /* Validate the filesystem blocksize */ | 2459 | /* Validate the filesystem blocksize */ |
2398 | if (!sb_set_blocksize(sb, blocksize)) { | 2460 | if (!sb_set_blocksize(sb, blocksize)) { |
2399 | printk(KERN_ERR "EXT4-fs: bad block size %d.\n", | 2461 | ext4_msg(sb, KERN_ERR, "bad block size %d", |
2400 | blocksize); | 2462 | blocksize); |
2401 | goto failed_mount; | 2463 | goto failed_mount; |
2402 | } | 2464 | } |
@@ -2406,15 +2468,15 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2406 | offset = do_div(logical_sb_block, blocksize); | 2468 | offset = do_div(logical_sb_block, blocksize); |
2407 | bh = sb_bread(sb, logical_sb_block); | 2469 | bh = sb_bread(sb, logical_sb_block); |
2408 | if (!bh) { | 2470 | if (!bh) { |
2409 | printk(KERN_ERR | 2471 | ext4_msg(sb, KERN_ERR, |
2410 | "EXT4-fs: Can't read superblock on 2nd try.\n"); | 2472 | "Can't read superblock on 2nd try"); |
2411 | goto failed_mount; | 2473 | goto failed_mount; |
2412 | } | 2474 | } |
2413 | es = (struct ext4_super_block *)(((char *)bh->b_data) + offset); | 2475 | es = (struct ext4_super_block *)(((char *)bh->b_data) + offset); |
2414 | sbi->s_es = es; | 2476 | sbi->s_es = es; |
2415 | if (es->s_magic != cpu_to_le16(EXT4_SUPER_MAGIC)) { | 2477 | if (es->s_magic != cpu_to_le16(EXT4_SUPER_MAGIC)) { |
2416 | printk(KERN_ERR | 2478 | ext4_msg(sb, KERN_ERR, |
2417 | "EXT4-fs: Magic mismatch, very weird !\n"); | 2479 | "Magic mismatch, very weird!"); |
2418 | goto failed_mount; | 2480 | goto failed_mount; |
2419 | } | 2481 | } |
2420 | } | 2482 | } |
@@ -2432,30 +2494,33 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2432 | if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) || | 2494 | if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) || |
2433 | (!is_power_of_2(sbi->s_inode_size)) || | 2495 | (!is_power_of_2(sbi->s_inode_size)) || |
2434 | (sbi->s_inode_size > blocksize)) { | 2496 | (sbi->s_inode_size > blocksize)) { |
2435 | printk(KERN_ERR | 2497 | ext4_msg(sb, KERN_ERR, |
2436 | "EXT4-fs: unsupported inode size: %d\n", | 2498 | "unsupported inode size: %d", |
2437 | sbi->s_inode_size); | 2499 | sbi->s_inode_size); |
2438 | goto failed_mount; | 2500 | goto failed_mount; |
2439 | } | 2501 | } |
2440 | if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) | 2502 | if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) |
2441 | sb->s_time_gran = 1 << (EXT4_EPOCH_BITS - 2); | 2503 | sb->s_time_gran = 1 << (EXT4_EPOCH_BITS - 2); |
2442 | } | 2504 | } |
2505 | |||
2443 | sbi->s_desc_size = le16_to_cpu(es->s_desc_size); | 2506 | sbi->s_desc_size = le16_to_cpu(es->s_desc_size); |
2444 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) { | 2507 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) { |
2445 | if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT || | 2508 | if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT || |
2446 | sbi->s_desc_size > EXT4_MAX_DESC_SIZE || | 2509 | sbi->s_desc_size > EXT4_MAX_DESC_SIZE || |
2447 | !is_power_of_2(sbi->s_desc_size)) { | 2510 | !is_power_of_2(sbi->s_desc_size)) { |
2448 | printk(KERN_ERR | 2511 | ext4_msg(sb, KERN_ERR, |
2449 | "EXT4-fs: unsupported descriptor size %lu\n", | 2512 | "unsupported descriptor size %lu", |
2450 | sbi->s_desc_size); | 2513 | sbi->s_desc_size); |
2451 | goto failed_mount; | 2514 | goto failed_mount; |
2452 | } | 2515 | } |
2453 | } else | 2516 | } else |
2454 | sbi->s_desc_size = EXT4_MIN_DESC_SIZE; | 2517 | sbi->s_desc_size = EXT4_MIN_DESC_SIZE; |
2518 | |||
2455 | sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group); | 2519 | sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group); |
2456 | sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); | 2520 | sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); |
2457 | if (EXT4_INODE_SIZE(sb) == 0 || EXT4_INODES_PER_GROUP(sb) == 0) | 2521 | if (EXT4_INODE_SIZE(sb) == 0 || EXT4_INODES_PER_GROUP(sb) == 0) |
2458 | goto cantfind_ext4; | 2522 | goto cantfind_ext4; |
2523 | |||
2459 | sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb); | 2524 | sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb); |
2460 | if (sbi->s_inodes_per_block == 0) | 2525 | if (sbi->s_inodes_per_block == 0) |
2461 | goto cantfind_ext4; | 2526 | goto cantfind_ext4; |
@@ -2466,6 +2531,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2466 | sbi->s_mount_state = le16_to_cpu(es->s_state); | 2531 | sbi->s_mount_state = le16_to_cpu(es->s_state); |
2467 | sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); | 2532 | sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); |
2468 | sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); | 2533 | sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); |
2534 | |||
2469 | for (i = 0; i < 4; i++) | 2535 | for (i = 0; i < 4; i++) |
2470 | sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); | 2536 | sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); |
2471 | sbi->s_def_hash_version = es->s_def_hash_version; | 2537 | sbi->s_def_hash_version = es->s_def_hash_version; |
@@ -2483,25 +2549,24 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2483 | } | 2549 | } |
2484 | 2550 | ||
2485 | if (sbi->s_blocks_per_group > blocksize * 8) { | 2551 | if (sbi->s_blocks_per_group > blocksize * 8) { |
2486 | printk(KERN_ERR | 2552 | ext4_msg(sb, KERN_ERR, |
2487 | "EXT4-fs: #blocks per group too big: %lu\n", | 2553 | "#blocks per group too big: %lu", |
2488 | sbi->s_blocks_per_group); | 2554 | sbi->s_blocks_per_group); |
2489 | goto failed_mount; | 2555 | goto failed_mount; |
2490 | } | 2556 | } |
2491 | if (sbi->s_inodes_per_group > blocksize * 8) { | 2557 | if (sbi->s_inodes_per_group > blocksize * 8) { |
2492 | printk(KERN_ERR | 2558 | ext4_msg(sb, KERN_ERR, |
2493 | "EXT4-fs: #inodes per group too big: %lu\n", | 2559 | "#inodes per group too big: %lu", |
2494 | sbi->s_inodes_per_group); | 2560 | sbi->s_inodes_per_group); |
2495 | goto failed_mount; | 2561 | goto failed_mount; |
2496 | } | 2562 | } |
2497 | 2563 | ||
2498 | if (ext4_blocks_count(es) > | 2564 | if (ext4_blocks_count(es) > |
2499 | (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { | 2565 | (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { |
2500 | printk(KERN_ERR "EXT4-fs: filesystem on %s:" | 2566 | ext4_msg(sb, KERN_ERR, "filesystem" |
2501 | " too large to mount safely\n", sb->s_id); | 2567 | " too large to mount safely"); |
2502 | if (sizeof(sector_t) < 8) | 2568 | if (sizeof(sector_t) < 8) |
2503 | printk(KERN_WARNING "EXT4-fs: CONFIG_LBD not " | 2569 | ext4_msg(sb, KERN_WARNING, "CONFIG_LBD not enabled"); |
2504 | "enabled\n"); | ||
2505 | goto failed_mount; | 2570 | goto failed_mount; |
2506 | } | 2571 | } |
2507 | 2572 | ||
@@ -2511,21 +2576,21 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2511 | /* check blocks count against device size */ | 2576 | /* check blocks count against device size */ |
2512 | blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; | 2577 | blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; |
2513 | if (blocks_count && ext4_blocks_count(es) > blocks_count) { | 2578 | if (blocks_count && ext4_blocks_count(es) > blocks_count) { |
2514 | printk(KERN_WARNING "EXT4-fs: bad geometry: block count %llu " | 2579 | ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu " |
2515 | "exceeds size of device (%llu blocks)\n", | 2580 | "exceeds size of device (%llu blocks)", |
2516 | ext4_blocks_count(es), blocks_count); | 2581 | ext4_blocks_count(es), blocks_count); |
2517 | goto failed_mount; | 2582 | goto failed_mount; |
2518 | } | 2583 | } |
2519 | 2584 | ||
2520 | /* | 2585 | /* |
2521 | * It makes no sense for the first data block to be beyond the end | 2586 | * It makes no sense for the first data block to be beyond the end |
2522 | * of the filesystem. | 2587 | * of the filesystem. |
2523 | */ | 2588 | */ |
2524 | if (le32_to_cpu(es->s_first_data_block) >= ext4_blocks_count(es)) { | 2589 | if (le32_to_cpu(es->s_first_data_block) >= ext4_blocks_count(es)) { |
2525 | printk(KERN_WARNING "EXT4-fs: bad geometry: first data" | 2590 | ext4_msg(sb, KERN_WARNING, "bad geometry: first data" |
2526 | "block %u is beyond end of filesystem (%llu)\n", | 2591 | "block %u is beyond end of filesystem (%llu)", |
2527 | le32_to_cpu(es->s_first_data_block), | 2592 | le32_to_cpu(es->s_first_data_block), |
2528 | ext4_blocks_count(es)); | 2593 | ext4_blocks_count(es)); |
2529 | goto failed_mount; | 2594 | goto failed_mount; |
2530 | } | 2595 | } |
2531 | blocks_count = (ext4_blocks_count(es) - | 2596 | blocks_count = (ext4_blocks_count(es) - |
@@ -2533,9 +2598,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2533 | EXT4_BLOCKS_PER_GROUP(sb) - 1); | 2598 | EXT4_BLOCKS_PER_GROUP(sb) - 1); |
2534 | do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb)); | 2599 | do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb)); |
2535 | if (blocks_count > ((uint64_t)1<<32) - EXT4_DESC_PER_BLOCK(sb)) { | 2600 | if (blocks_count > ((uint64_t)1<<32) - EXT4_DESC_PER_BLOCK(sb)) { |
2536 | printk(KERN_WARNING "EXT4-fs: groups count too large: %u " | 2601 | ext4_msg(sb, KERN_WARNING, "groups count too large: %u " |
2537 | "(block count %llu, first data block %u, " | 2602 | "(block count %llu, first data block %u, " |
2538 | "blocks per group %lu)\n", sbi->s_groups_count, | 2603 | "blocks per group %lu)", sbi->s_groups_count, |
2539 | ext4_blocks_count(es), | 2604 | ext4_blocks_count(es), |
2540 | le32_to_cpu(es->s_first_data_block), | 2605 | le32_to_cpu(es->s_first_data_block), |
2541 | EXT4_BLOCKS_PER_GROUP(sb)); | 2606 | EXT4_BLOCKS_PER_GROUP(sb)); |
@@ -2547,7 +2612,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2547 | sbi->s_group_desc = kmalloc(db_count * sizeof(struct buffer_head *), | 2612 | sbi->s_group_desc = kmalloc(db_count * sizeof(struct buffer_head *), |
2548 | GFP_KERNEL); | 2613 | GFP_KERNEL); |
2549 | if (sbi->s_group_desc == NULL) { | 2614 | if (sbi->s_group_desc == NULL) { |
2550 | printk(KERN_ERR "EXT4-fs: not enough memory\n"); | 2615 | ext4_msg(sb, KERN_ERR, "not enough memory"); |
2551 | goto failed_mount; | 2616 | goto failed_mount; |
2552 | } | 2617 | } |
2553 | 2618 | ||
@@ -2562,21 +2627,21 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2562 | block = descriptor_loc(sb, logical_sb_block, i); | 2627 | block = descriptor_loc(sb, logical_sb_block, i); |
2563 | sbi->s_group_desc[i] = sb_bread(sb, block); | 2628 | sbi->s_group_desc[i] = sb_bread(sb, block); |
2564 | if (!sbi->s_group_desc[i]) { | 2629 | if (!sbi->s_group_desc[i]) { |
2565 | printk(KERN_ERR "EXT4-fs: " | 2630 | ext4_msg(sb, KERN_ERR, |
2566 | "can't read group descriptor %d\n", i); | 2631 | "can't read group descriptor %d", i); |
2567 | db_count = i; | 2632 | db_count = i; |
2568 | goto failed_mount2; | 2633 | goto failed_mount2; |
2569 | } | 2634 | } |
2570 | } | 2635 | } |
2571 | if (!ext4_check_descriptors(sb)) { | 2636 | if (!ext4_check_descriptors(sb)) { |
2572 | printk(KERN_ERR "EXT4-fs: group descriptors corrupted!\n"); | 2637 | ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); |
2573 | goto failed_mount2; | 2638 | goto failed_mount2; |
2574 | } | 2639 | } |
2575 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) | 2640 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) |
2576 | if (!ext4_fill_flex_info(sb)) { | 2641 | if (!ext4_fill_flex_info(sb)) { |
2577 | printk(KERN_ERR | 2642 | ext4_msg(sb, KERN_ERR, |
2578 | "EXT4-fs: unable to initialize " | 2643 | "unable to initialize " |
2579 | "flex_bg meta info!\n"); | 2644 | "flex_bg meta info!"); |
2580 | goto failed_mount2; | 2645 | goto failed_mount2; |
2581 | } | 2646 | } |
2582 | 2647 | ||
@@ -2598,7 +2663,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2598 | err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); | 2663 | err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); |
2599 | } | 2664 | } |
2600 | if (err) { | 2665 | if (err) { |
2601 | printk(KERN_ERR "EXT4-fs: insufficient memory\n"); | 2666 | ext4_msg(sb, KERN_ERR, "insufficient memory"); |
2602 | goto failed_mount3; | 2667 | goto failed_mount3; |
2603 | } | 2668 | } |
2604 | 2669 | ||
@@ -2607,7 +2672,11 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2607 | /* | 2672 | /* |
2608 | * set up enough so that it can read an inode | 2673 | * set up enough so that it can read an inode |
2609 | */ | 2674 | */ |
2610 | sb->s_op = &ext4_sops; | 2675 | if (!test_opt(sb, NOLOAD) && |
2676 | EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) | ||
2677 | sb->s_op = &ext4_sops; | ||
2678 | else | ||
2679 | sb->s_op = &ext4_nojournal_sops; | ||
2611 | sb->s_export_op = &ext4_export_ops; | 2680 | sb->s_export_op = &ext4_export_ops; |
2612 | sb->s_xattr = ext4_xattr_handlers; | 2681 | sb->s_xattr = ext4_xattr_handlers; |
2613 | #ifdef CONFIG_QUOTA | 2682 | #ifdef CONFIG_QUOTA |
@@ -2615,6 +2684,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2615 | sb->dq_op = &ext4_quota_operations; | 2684 | sb->dq_op = &ext4_quota_operations; |
2616 | #endif | 2685 | #endif |
2617 | INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ | 2686 | INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ |
2687 | mutex_init(&sbi->s_orphan_lock); | ||
2688 | mutex_init(&sbi->s_resize_lock); | ||
2618 | 2689 | ||
2619 | sb->s_root = NULL; | 2690 | sb->s_root = NULL; |
2620 | 2691 | ||
@@ -2632,13 +2703,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2632 | goto failed_mount3; | 2703 | goto failed_mount3; |
2633 | if (!(sb->s_flags & MS_RDONLY) && | 2704 | if (!(sb->s_flags & MS_RDONLY) && |
2634 | EXT4_SB(sb)->s_journal->j_failed_commit) { | 2705 | EXT4_SB(sb)->s_journal->j_failed_commit) { |
2635 | printk(KERN_CRIT "EXT4-fs error (device %s): " | 2706 | ext4_msg(sb, KERN_CRIT, "error: " |
2636 | "ext4_fill_super: Journal transaction " | 2707 | "ext4_fill_super: Journal transaction " |
2637 | "%u is corrupt\n", sb->s_id, | 2708 | "%u is corrupt", |
2638 | EXT4_SB(sb)->s_journal->j_failed_commit); | 2709 | EXT4_SB(sb)->s_journal->j_failed_commit); |
2639 | if (test_opt(sb, ERRORS_RO)) { | 2710 | if (test_opt(sb, ERRORS_RO)) { |
2640 | printk(KERN_CRIT | 2711 | ext4_msg(sb, KERN_CRIT, |
2641 | "Mounting filesystem read-only\n"); | 2712 | "Mounting filesystem read-only"); |
2642 | sb->s_flags |= MS_RDONLY; | 2713 | sb->s_flags |= MS_RDONLY; |
2643 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | 2714 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; |
2644 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | 2715 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); |
@@ -2646,14 +2717,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2646 | if (test_opt(sb, ERRORS_PANIC)) { | 2717 | if (test_opt(sb, ERRORS_PANIC)) { |
2647 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | 2718 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; |
2648 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | 2719 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); |
2649 | ext4_commit_super(sb, es, 1); | 2720 | ext4_commit_super(sb, 1); |
2650 | goto failed_mount4; | 2721 | goto failed_mount4; |
2651 | } | 2722 | } |
2652 | } | 2723 | } |
2653 | } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) && | 2724 | } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) && |
2654 | EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { | 2725 | EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { |
2655 | printk(KERN_ERR "EXT4-fs: required journal recovery " | 2726 | ext4_msg(sb, KERN_ERR, "required journal recovery " |
2656 | "suppressed and not mounted read-only\n"); | 2727 | "suppressed and not mounted read-only"); |
2657 | goto failed_mount4; | 2728 | goto failed_mount4; |
2658 | } else { | 2729 | } else { |
2659 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); | 2730 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); |
@@ -2666,7 +2737,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2666 | if (ext4_blocks_count(es) > 0xffffffffULL && | 2737 | if (ext4_blocks_count(es) > 0xffffffffULL && |
2667 | !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, | 2738 | !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, |
2668 | JBD2_FEATURE_INCOMPAT_64BIT)) { | 2739 | JBD2_FEATURE_INCOMPAT_64BIT)) { |
2669 | printk(KERN_ERR "EXT4-fs: Failed to set 64-bit journal feature\n"); | 2740 | ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature"); |
2670 | goto failed_mount4; | 2741 | goto failed_mount4; |
2671 | } | 2742 | } |
2672 | 2743 | ||
@@ -2704,8 +2775,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2704 | case EXT4_MOUNT_WRITEBACK_DATA: | 2775 | case EXT4_MOUNT_WRITEBACK_DATA: |
2705 | if (!jbd2_journal_check_available_features | 2776 | if (!jbd2_journal_check_available_features |
2706 | (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) { | 2777 | (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) { |
2707 | printk(KERN_ERR "EXT4-fs: Journal does not support " | 2778 | ext4_msg(sb, KERN_ERR, "Journal does not support " |
2708 | "requested data journaling mode\n"); | 2779 | "requested data journaling mode"); |
2709 | goto failed_mount4; | 2780 | goto failed_mount4; |
2710 | } | 2781 | } |
2711 | default: | 2782 | default: |
@@ -2717,8 +2788,8 @@ no_journal: | |||
2717 | 2788 | ||
2718 | if (test_opt(sb, NOBH)) { | 2789 | if (test_opt(sb, NOBH)) { |
2719 | if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { | 2790 | if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { |
2720 | printk(KERN_WARNING "EXT4-fs: Ignoring nobh option - " | 2791 | ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - " |
2721 | "its supported only with writeback mode\n"); | 2792 | "its supported only with writeback mode"); |
2722 | clear_opt(sbi->s_mount_opt, NOBH); | 2793 | clear_opt(sbi->s_mount_opt, NOBH); |
2723 | } | 2794 | } |
2724 | } | 2795 | } |
@@ -2729,18 +2800,18 @@ no_journal: | |||
2729 | 2800 | ||
2730 | root = ext4_iget(sb, EXT4_ROOT_INO); | 2801 | root = ext4_iget(sb, EXT4_ROOT_INO); |
2731 | if (IS_ERR(root)) { | 2802 | if (IS_ERR(root)) { |
2732 | printk(KERN_ERR "EXT4-fs: get root inode failed\n"); | 2803 | ext4_msg(sb, KERN_ERR, "get root inode failed"); |
2733 | ret = PTR_ERR(root); | 2804 | ret = PTR_ERR(root); |
2734 | goto failed_mount4; | 2805 | goto failed_mount4; |
2735 | } | 2806 | } |
2736 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { | 2807 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { |
2737 | iput(root); | 2808 | iput(root); |
2738 | printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n"); | 2809 | ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck"); |
2739 | goto failed_mount4; | 2810 | goto failed_mount4; |
2740 | } | 2811 | } |
2741 | sb->s_root = d_alloc_root(root); | 2812 | sb->s_root = d_alloc_root(root); |
2742 | if (!sb->s_root) { | 2813 | if (!sb->s_root) { |
2743 | printk(KERN_ERR "EXT4-fs: get root dentry failed\n"); | 2814 | ext4_msg(sb, KERN_ERR, "get root dentry failed"); |
2744 | iput(root); | 2815 | iput(root); |
2745 | ret = -ENOMEM; | 2816 | ret = -ENOMEM; |
2746 | goto failed_mount4; | 2817 | goto failed_mount4; |
@@ -2769,22 +2840,29 @@ no_journal: | |||
2769 | sbi->s_inode_size) { | 2840 | sbi->s_inode_size) { |
2770 | sbi->s_want_extra_isize = sizeof(struct ext4_inode) - | 2841 | sbi->s_want_extra_isize = sizeof(struct ext4_inode) - |
2771 | EXT4_GOOD_OLD_INODE_SIZE; | 2842 | EXT4_GOOD_OLD_INODE_SIZE; |
2772 | printk(KERN_INFO "EXT4-fs: required extra inode space not" | 2843 | ext4_msg(sb, KERN_INFO, "required extra inode space not" |
2773 | "available.\n"); | 2844 | "available"); |
2774 | } | 2845 | } |
2775 | 2846 | ||
2776 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { | 2847 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { |
2777 | printk(KERN_WARNING "EXT4-fs: Ignoring delalloc option - " | 2848 | ext4_msg(sb, KERN_WARNING, "Ignoring delalloc option - " |
2778 | "requested data journaling mode\n"); | 2849 | "requested data journaling mode"); |
2779 | clear_opt(sbi->s_mount_opt, DELALLOC); | 2850 | clear_opt(sbi->s_mount_opt, DELALLOC); |
2780 | } else if (test_opt(sb, DELALLOC)) | 2851 | } else if (test_opt(sb, DELALLOC)) |
2781 | printk(KERN_INFO "EXT4-fs: delayed allocation enabled\n"); | 2852 | ext4_msg(sb, KERN_INFO, "delayed allocation enabled"); |
2853 | |||
2854 | err = ext4_setup_system_zone(sb); | ||
2855 | if (err) { | ||
2856 | ext4_msg(sb, KERN_ERR, "failed to initialize system " | ||
2857 | "zone (%d)\n", err); | ||
2858 | goto failed_mount4; | ||
2859 | } | ||
2782 | 2860 | ||
2783 | ext4_ext_init(sb); | 2861 | ext4_ext_init(sb); |
2784 | err = ext4_mb_init(sb, needs_recovery); | 2862 | err = ext4_mb_init(sb, needs_recovery); |
2785 | if (err) { | 2863 | if (err) { |
2786 | printk(KERN_ERR "EXT4-fs: failed to initalize mballoc (%d)\n", | 2864 | ext4_msg(sb, KERN_ERR, "failed to initalize mballoc (%d)", |
2787 | err); | 2865 | err); |
2788 | goto failed_mount4; | 2866 | goto failed_mount4; |
2789 | } | 2867 | } |
2790 | 2868 | ||
@@ -2798,19 +2876,11 @@ no_journal: | |||
2798 | goto failed_mount4; | 2876 | goto failed_mount4; |
2799 | }; | 2877 | }; |
2800 | 2878 | ||
2801 | /* | ||
2802 | * akpm: core read_super() calls in here with the superblock locked. | ||
2803 | * That deadlocks, because orphan cleanup needs to lock the superblock | ||
2804 | * in numerous places. Here we just pop the lock - it's relatively | ||
2805 | * harmless, because we are now ready to accept write_super() requests, | ||
2806 | * and aviro says that's the only reason for hanging onto the | ||
2807 | * superblock lock. | ||
2808 | */ | ||
2809 | EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS; | 2879 | EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS; |
2810 | ext4_orphan_cleanup(sb, es); | 2880 | ext4_orphan_cleanup(sb, es); |
2811 | EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; | 2881 | EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; |
2812 | if (needs_recovery) { | 2882 | if (needs_recovery) { |
2813 | printk(KERN_INFO "EXT4-fs: recovery complete.\n"); | 2883 | ext4_msg(sb, KERN_INFO, "recovery complete"); |
2814 | ext4_mark_recovery_complete(sb, es); | 2884 | ext4_mark_recovery_complete(sb, es); |
2815 | } | 2885 | } |
2816 | if (EXT4_SB(sb)->s_journal) { | 2886 | if (EXT4_SB(sb)->s_journal) { |
@@ -2823,25 +2893,30 @@ no_journal: | |||
2823 | } else | 2893 | } else |
2824 | descr = "out journal"; | 2894 | descr = "out journal"; |
2825 | 2895 | ||
2826 | printk(KERN_INFO "EXT4-fs: mounted filesystem %s with%s\n", | 2896 | ext4_msg(sb, KERN_INFO, "mounted filesystem with%s", descr); |
2827 | sb->s_id, descr); | ||
2828 | 2897 | ||
2829 | lock_kernel(); | 2898 | lock_kernel(); |
2830 | return 0; | 2899 | return 0; |
2831 | 2900 | ||
2832 | cantfind_ext4: | 2901 | cantfind_ext4: |
2833 | if (!silent) | 2902 | if (!silent) |
2834 | printk(KERN_ERR "VFS: Can't find ext4 filesystem on dev %s.\n", | 2903 | ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem"); |
2835 | sb->s_id); | ||
2836 | goto failed_mount; | 2904 | goto failed_mount; |
2837 | 2905 | ||
2838 | failed_mount4: | 2906 | failed_mount4: |
2839 | printk(KERN_ERR "EXT4-fs (device %s): mount failed\n", sb->s_id); | 2907 | ext4_msg(sb, KERN_ERR, "mount failed"); |
2908 | ext4_release_system_zone(sb); | ||
2840 | if (sbi->s_journal) { | 2909 | if (sbi->s_journal) { |
2841 | jbd2_journal_destroy(sbi->s_journal); | 2910 | jbd2_journal_destroy(sbi->s_journal); |
2842 | sbi->s_journal = NULL; | 2911 | sbi->s_journal = NULL; |
2843 | } | 2912 | } |
2844 | failed_mount3: | 2913 | failed_mount3: |
2914 | if (sbi->s_flex_groups) { | ||
2915 | if (is_vmalloc_addr(sbi->s_flex_groups)) | ||
2916 | vfree(sbi->s_flex_groups); | ||
2917 | else | ||
2918 | kfree(sbi->s_flex_groups); | ||
2919 | } | ||
2845 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | 2920 | percpu_counter_destroy(&sbi->s_freeblocks_counter); |
2846 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | 2921 | percpu_counter_destroy(&sbi->s_freeinodes_counter); |
2847 | percpu_counter_destroy(&sbi->s_dirs_counter); | 2922 | percpu_counter_destroy(&sbi->s_dirs_counter); |
@@ -2862,6 +2937,7 @@ failed_mount: | |||
2862 | brelse(bh); | 2937 | brelse(bh); |
2863 | out_fail: | 2938 | out_fail: |
2864 | sb->s_fs_info = NULL; | 2939 | sb->s_fs_info = NULL; |
2940 | kfree(sbi->s_blockgroup_lock); | ||
2865 | kfree(sbi); | 2941 | kfree(sbi); |
2866 | lock_kernel(); | 2942 | lock_kernel(); |
2867 | return ret; | 2943 | return ret; |
@@ -2906,27 +2982,27 @@ static journal_t *ext4_get_journal(struct super_block *sb, | |||
2906 | 2982 | ||
2907 | journal_inode = ext4_iget(sb, journal_inum); | 2983 | journal_inode = ext4_iget(sb, journal_inum); |
2908 | if (IS_ERR(journal_inode)) { | 2984 | if (IS_ERR(journal_inode)) { |
2909 | printk(KERN_ERR "EXT4-fs: no journal found.\n"); | 2985 | ext4_msg(sb, KERN_ERR, "no journal found"); |
2910 | return NULL; | 2986 | return NULL; |
2911 | } | 2987 | } |
2912 | if (!journal_inode->i_nlink) { | 2988 | if (!journal_inode->i_nlink) { |
2913 | make_bad_inode(journal_inode); | 2989 | make_bad_inode(journal_inode); |
2914 | iput(journal_inode); | 2990 | iput(journal_inode); |
2915 | printk(KERN_ERR "EXT4-fs: journal inode is deleted.\n"); | 2991 | ext4_msg(sb, KERN_ERR, "journal inode is deleted"); |
2916 | return NULL; | 2992 | return NULL; |
2917 | } | 2993 | } |
2918 | 2994 | ||
2919 | jbd_debug(2, "Journal inode found at %p: %lld bytes\n", | 2995 | jbd_debug(2, "Journal inode found at %p: %lld bytes\n", |
2920 | journal_inode, journal_inode->i_size); | 2996 | journal_inode, journal_inode->i_size); |
2921 | if (!S_ISREG(journal_inode->i_mode)) { | 2997 | if (!S_ISREG(journal_inode->i_mode)) { |
2922 | printk(KERN_ERR "EXT4-fs: invalid journal inode.\n"); | 2998 | ext4_msg(sb, KERN_ERR, "invalid journal inode"); |
2923 | iput(journal_inode); | 2999 | iput(journal_inode); |
2924 | return NULL; | 3000 | return NULL; |
2925 | } | 3001 | } |
2926 | 3002 | ||
2927 | journal = jbd2_journal_init_inode(journal_inode); | 3003 | journal = jbd2_journal_init_inode(journal_inode); |
2928 | if (!journal) { | 3004 | if (!journal) { |
2929 | printk(KERN_ERR "EXT4-fs: Could not load journal inode\n"); | 3005 | ext4_msg(sb, KERN_ERR, "Could not load journal inode"); |
2930 | iput(journal_inode); | 3006 | iput(journal_inode); |
2931 | return NULL; | 3007 | return NULL; |
2932 | } | 3008 | } |
@@ -2950,22 +3026,22 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, | |||
2950 | 3026 | ||
2951 | BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); | 3027 | BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); |
2952 | 3028 | ||
2953 | bdev = ext4_blkdev_get(j_dev); | 3029 | bdev = ext4_blkdev_get(j_dev, sb); |
2954 | if (bdev == NULL) | 3030 | if (bdev == NULL) |
2955 | return NULL; | 3031 | return NULL; |
2956 | 3032 | ||
2957 | if (bd_claim(bdev, sb)) { | 3033 | if (bd_claim(bdev, sb)) { |
2958 | printk(KERN_ERR | 3034 | ext4_msg(sb, KERN_ERR, |
2959 | "EXT4-fs: failed to claim external journal device.\n"); | 3035 | "failed to claim external journal device"); |
2960 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE); | 3036 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE); |
2961 | return NULL; | 3037 | return NULL; |
2962 | } | 3038 | } |
2963 | 3039 | ||
2964 | blocksize = sb->s_blocksize; | 3040 | blocksize = sb->s_blocksize; |
2965 | hblock = bdev_hardsect_size(bdev); | 3041 | hblock = bdev_logical_block_size(bdev); |
2966 | if (blocksize < hblock) { | 3042 | if (blocksize < hblock) { |
2967 | printk(KERN_ERR | 3043 | ext4_msg(sb, KERN_ERR, |
2968 | "EXT4-fs: blocksize too small for journal device.\n"); | 3044 | "blocksize too small for journal device"); |
2969 | goto out_bdev; | 3045 | goto out_bdev; |
2970 | } | 3046 | } |
2971 | 3047 | ||
@@ -2973,8 +3049,8 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, | |||
2973 | offset = EXT4_MIN_BLOCK_SIZE % blocksize; | 3049 | offset = EXT4_MIN_BLOCK_SIZE % blocksize; |
2974 | set_blocksize(bdev, blocksize); | 3050 | set_blocksize(bdev, blocksize); |
2975 | if (!(bh = __bread(bdev, sb_block, blocksize))) { | 3051 | if (!(bh = __bread(bdev, sb_block, blocksize))) { |
2976 | printk(KERN_ERR "EXT4-fs: couldn't read superblock of " | 3052 | ext4_msg(sb, KERN_ERR, "couldn't read superblock of " |
2977 | "external journal\n"); | 3053 | "external journal"); |
2978 | goto out_bdev; | 3054 | goto out_bdev; |
2979 | } | 3055 | } |
2980 | 3056 | ||
@@ -2982,14 +3058,14 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, | |||
2982 | if ((le16_to_cpu(es->s_magic) != EXT4_SUPER_MAGIC) || | 3058 | if ((le16_to_cpu(es->s_magic) != EXT4_SUPER_MAGIC) || |
2983 | !(le32_to_cpu(es->s_feature_incompat) & | 3059 | !(le32_to_cpu(es->s_feature_incompat) & |
2984 | EXT4_FEATURE_INCOMPAT_JOURNAL_DEV)) { | 3060 | EXT4_FEATURE_INCOMPAT_JOURNAL_DEV)) { |
2985 | printk(KERN_ERR "EXT4-fs: external journal has " | 3061 | ext4_msg(sb, KERN_ERR, "external journal has " |
2986 | "bad superblock\n"); | 3062 | "bad superblock"); |
2987 | brelse(bh); | 3063 | brelse(bh); |
2988 | goto out_bdev; | 3064 | goto out_bdev; |
2989 | } | 3065 | } |
2990 | 3066 | ||
2991 | if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { | 3067 | if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { |
2992 | printk(KERN_ERR "EXT4-fs: journal UUID does not match\n"); | 3068 | ext4_msg(sb, KERN_ERR, "journal UUID does not match"); |
2993 | brelse(bh); | 3069 | brelse(bh); |
2994 | goto out_bdev; | 3070 | goto out_bdev; |
2995 | } | 3071 | } |
@@ -3001,25 +3077,26 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, | |||
3001 | journal = jbd2_journal_init_dev(bdev, sb->s_bdev, | 3077 | journal = jbd2_journal_init_dev(bdev, sb->s_bdev, |
3002 | start, len, blocksize); | 3078 | start, len, blocksize); |
3003 | if (!journal) { | 3079 | if (!journal) { |
3004 | printk(KERN_ERR "EXT4-fs: failed to create device journal\n"); | 3080 | ext4_msg(sb, KERN_ERR, "failed to create device journal"); |
3005 | goto out_bdev; | 3081 | goto out_bdev; |
3006 | } | 3082 | } |
3007 | journal->j_private = sb; | 3083 | journal->j_private = sb; |
3008 | ll_rw_block(READ, 1, &journal->j_sb_buffer); | 3084 | ll_rw_block(READ, 1, &journal->j_sb_buffer); |
3009 | wait_on_buffer(journal->j_sb_buffer); | 3085 | wait_on_buffer(journal->j_sb_buffer); |
3010 | if (!buffer_uptodate(journal->j_sb_buffer)) { | 3086 | if (!buffer_uptodate(journal->j_sb_buffer)) { |
3011 | printk(KERN_ERR "EXT4-fs: I/O error on journal device\n"); | 3087 | ext4_msg(sb, KERN_ERR, "I/O error on journal device"); |
3012 | goto out_journal; | 3088 | goto out_journal; |
3013 | } | 3089 | } |
3014 | if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { | 3090 | if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { |
3015 | printk(KERN_ERR "EXT4-fs: External journal has more than one " | 3091 | ext4_msg(sb, KERN_ERR, "External journal has more than one " |
3016 | "user (unsupported) - %d\n", | 3092 | "user (unsupported) - %d", |
3017 | be32_to_cpu(journal->j_superblock->s_nr_users)); | 3093 | be32_to_cpu(journal->j_superblock->s_nr_users)); |
3018 | goto out_journal; | 3094 | goto out_journal; |
3019 | } | 3095 | } |
3020 | EXT4_SB(sb)->journal_bdev = bdev; | 3096 | EXT4_SB(sb)->journal_bdev = bdev; |
3021 | ext4_init_journal_params(sb, journal); | 3097 | ext4_init_journal_params(sb, journal); |
3022 | return journal; | 3098 | return journal; |
3099 | |||
3023 | out_journal: | 3100 | out_journal: |
3024 | jbd2_journal_destroy(journal); | 3101 | jbd2_journal_destroy(journal); |
3025 | out_bdev: | 3102 | out_bdev: |
@@ -3041,8 +3118,8 @@ static int ext4_load_journal(struct super_block *sb, | |||
3041 | 3118 | ||
3042 | if (journal_devnum && | 3119 | if (journal_devnum && |
3043 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { | 3120 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { |
3044 | printk(KERN_INFO "EXT4-fs: external journal device major/minor " | 3121 | ext4_msg(sb, KERN_INFO, "external journal device major/minor " |
3045 | "numbers have changed\n"); | 3122 | "numbers have changed"); |
3046 | journal_dev = new_decode_dev(journal_devnum); | 3123 | journal_dev = new_decode_dev(journal_devnum); |
3047 | } else | 3124 | } else |
3048 | journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev)); | 3125 | journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev)); |
@@ -3054,24 +3131,23 @@ static int ext4_load_journal(struct super_block *sb, | |||
3054 | * crash? For recovery, we need to check in advance whether we | 3131 | * crash? For recovery, we need to check in advance whether we |
3055 | * can get read-write access to the device. | 3132 | * can get read-write access to the device. |
3056 | */ | 3133 | */ |
3057 | |||
3058 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { | 3134 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { |
3059 | if (sb->s_flags & MS_RDONLY) { | 3135 | if (sb->s_flags & MS_RDONLY) { |
3060 | printk(KERN_INFO "EXT4-fs: INFO: recovery " | 3136 | ext4_msg(sb, KERN_INFO, "INFO: recovery " |
3061 | "required on readonly filesystem.\n"); | 3137 | "required on readonly filesystem"); |
3062 | if (really_read_only) { | 3138 | if (really_read_only) { |
3063 | printk(KERN_ERR "EXT4-fs: write access " | 3139 | ext4_msg(sb, KERN_ERR, "write access " |
3064 | "unavailable, cannot proceed.\n"); | 3140 | "unavailable, cannot proceed"); |
3065 | return -EROFS; | 3141 | return -EROFS; |
3066 | } | 3142 | } |
3067 | printk(KERN_INFO "EXT4-fs: write access will " | 3143 | ext4_msg(sb, KERN_INFO, "write access will " |
3068 | "be enabled during recovery.\n"); | 3144 | "be enabled during recovery"); |
3069 | } | 3145 | } |
3070 | } | 3146 | } |
3071 | 3147 | ||
3072 | if (journal_inum && journal_dev) { | 3148 | if (journal_inum && journal_dev) { |
3073 | printk(KERN_ERR "EXT4-fs: filesystem has both journal " | 3149 | ext4_msg(sb, KERN_ERR, "filesystem has both journal " |
3074 | "and inode journals!\n"); | 3150 | "and inode journals!"); |
3075 | return -EINVAL; | 3151 | return -EINVAL; |
3076 | } | 3152 | } |
3077 | 3153 | ||
@@ -3084,14 +3160,14 @@ static int ext4_load_journal(struct super_block *sb, | |||
3084 | } | 3160 | } |
3085 | 3161 | ||
3086 | if (journal->j_flags & JBD2_BARRIER) | 3162 | if (journal->j_flags & JBD2_BARRIER) |
3087 | printk(KERN_INFO "EXT4-fs: barriers enabled\n"); | 3163 | ext4_msg(sb, KERN_INFO, "barriers enabled"); |
3088 | else | 3164 | else |
3089 | printk(KERN_INFO "EXT4-fs: barriers disabled\n"); | 3165 | ext4_msg(sb, KERN_INFO, "barriers disabled"); |
3090 | 3166 | ||
3091 | if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { | 3167 | if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { |
3092 | err = jbd2_journal_update_format(journal); | 3168 | err = jbd2_journal_update_format(journal); |
3093 | if (err) { | 3169 | if (err) { |
3094 | printk(KERN_ERR "EXT4-fs: error updating journal.\n"); | 3170 | ext4_msg(sb, KERN_ERR, "error updating journal"); |
3095 | jbd2_journal_destroy(journal); | 3171 | jbd2_journal_destroy(journal); |
3096 | return err; | 3172 | return err; |
3097 | } | 3173 | } |
@@ -3103,7 +3179,7 @@ static int ext4_load_journal(struct super_block *sb, | |||
3103 | err = jbd2_journal_load(journal); | 3179 | err = jbd2_journal_load(journal); |
3104 | 3180 | ||
3105 | if (err) { | 3181 | if (err) { |
3106 | printk(KERN_ERR "EXT4-fs: error loading journal.\n"); | 3182 | ext4_msg(sb, KERN_ERR, "error loading journal"); |
3107 | jbd2_journal_destroy(journal); | 3183 | jbd2_journal_destroy(journal); |
3108 | return err; | 3184 | return err; |
3109 | } | 3185 | } |
@@ -3114,18 +3190,17 @@ static int ext4_load_journal(struct super_block *sb, | |||
3114 | if (journal_devnum && | 3190 | if (journal_devnum && |
3115 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { | 3191 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { |
3116 | es->s_journal_dev = cpu_to_le32(journal_devnum); | 3192 | es->s_journal_dev = cpu_to_le32(journal_devnum); |
3117 | sb->s_dirt = 1; | ||
3118 | 3193 | ||
3119 | /* Make sure we flush the recovery flag to disk. */ | 3194 | /* Make sure we flush the recovery flag to disk. */ |
3120 | ext4_commit_super(sb, es, 1); | 3195 | ext4_commit_super(sb, 1); |
3121 | } | 3196 | } |
3122 | 3197 | ||
3123 | return 0; | 3198 | return 0; |
3124 | } | 3199 | } |
3125 | 3200 | ||
3126 | static int ext4_commit_super(struct super_block *sb, | 3201 | static int ext4_commit_super(struct super_block *sb, int sync) |
3127 | struct ext4_super_block *es, int sync) | ||
3128 | { | 3202 | { |
3203 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | ||
3129 | struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; | 3204 | struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; |
3130 | int error = 0; | 3205 | int error = 0; |
3131 | 3206 | ||
@@ -3140,8 +3215,8 @@ static int ext4_commit_super(struct super_block *sb, | |||
3140 | * be remapped. Nothing we can do but to retry the | 3215 | * be remapped. Nothing we can do but to retry the |
3141 | * write and hope for the best. | 3216 | * write and hope for the best. |
3142 | */ | 3217 | */ |
3143 | printk(KERN_ERR "EXT4-fs: previous I/O error to " | 3218 | ext4_msg(sb, KERN_ERR, "previous I/O error to " |
3144 | "superblock detected for %s.\n", sb->s_id); | 3219 | "superblock detected"); |
3145 | clear_buffer_write_io_error(sbh); | 3220 | clear_buffer_write_io_error(sbh); |
3146 | set_buffer_uptodate(sbh); | 3221 | set_buffer_uptodate(sbh); |
3147 | } | 3222 | } |
@@ -3154,7 +3229,7 @@ static int ext4_commit_super(struct super_block *sb, | |||
3154 | &EXT4_SB(sb)->s_freeblocks_counter)); | 3229 | &EXT4_SB(sb)->s_freeblocks_counter)); |
3155 | es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive( | 3230 | es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive( |
3156 | &EXT4_SB(sb)->s_freeinodes_counter)); | 3231 | &EXT4_SB(sb)->s_freeinodes_counter)); |
3157 | 3232 | sb->s_dirt = 0; | |
3158 | BUFFER_TRACE(sbh, "marking dirty"); | 3233 | BUFFER_TRACE(sbh, "marking dirty"); |
3159 | mark_buffer_dirty(sbh); | 3234 | mark_buffer_dirty(sbh); |
3160 | if (sync) { | 3235 | if (sync) { |
@@ -3164,8 +3239,8 @@ static int ext4_commit_super(struct super_block *sb, | |||
3164 | 3239 | ||
3165 | error = buffer_write_io_error(sbh); | 3240 | error = buffer_write_io_error(sbh); |
3166 | if (error) { | 3241 | if (error) { |
3167 | printk(KERN_ERR "EXT4-fs: I/O error while writing " | 3242 | ext4_msg(sb, KERN_ERR, "I/O error while writing " |
3168 | "superblock for %s.\n", sb->s_id); | 3243 | "superblock"); |
3169 | clear_buffer_write_io_error(sbh); | 3244 | clear_buffer_write_io_error(sbh); |
3170 | set_buffer_uptodate(sbh); | 3245 | set_buffer_uptodate(sbh); |
3171 | } | 3246 | } |
@@ -3173,7 +3248,6 @@ static int ext4_commit_super(struct super_block *sb, | |||
3173 | return error; | 3248 | return error; |
3174 | } | 3249 | } |
3175 | 3250 | ||
3176 | |||
3177 | /* | 3251 | /* |
3178 | * Have we just finished recovery? If so, and if we are mounting (or | 3252 | * Have we just finished recovery? If so, and if we are mounting (or |
3179 | * remounting) the filesystem readonly, then we will end up with a | 3253 | * remounting) the filesystem readonly, then we will end up with a |
@@ -3192,14 +3266,11 @@ static void ext4_mark_recovery_complete(struct super_block *sb, | |||
3192 | if (jbd2_journal_flush(journal) < 0) | 3266 | if (jbd2_journal_flush(journal) < 0) |
3193 | goto out; | 3267 | goto out; |
3194 | 3268 | ||
3195 | lock_super(sb); | ||
3196 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) && | 3269 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) && |
3197 | sb->s_flags & MS_RDONLY) { | 3270 | sb->s_flags & MS_RDONLY) { |
3198 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 3271 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
3199 | sb->s_dirt = 0; | 3272 | ext4_commit_super(sb, 1); |
3200 | ext4_commit_super(sb, es, 1); | ||
3201 | } | 3273 | } |
3202 | unlock_super(sb); | ||
3203 | 3274 | ||
3204 | out: | 3275 | out: |
3205 | jbd2_journal_unlock_updates(journal); | 3276 | jbd2_journal_unlock_updates(journal); |
@@ -3238,7 +3309,7 @@ static void ext4_clear_journal_err(struct super_block *sb, | |||
3238 | 3309 | ||
3239 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | 3310 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; |
3240 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | 3311 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); |
3241 | ext4_commit_super(sb, es, 1); | 3312 | ext4_commit_super(sb, 1); |
3242 | 3313 | ||
3243 | jbd2_journal_clear_err(journal); | 3314 | jbd2_journal_clear_err(journal); |
3244 | } | 3315 | } |
@@ -3257,29 +3328,17 @@ int ext4_force_commit(struct super_block *sb) | |||
3257 | return 0; | 3328 | return 0; |
3258 | 3329 | ||
3259 | journal = EXT4_SB(sb)->s_journal; | 3330 | journal = EXT4_SB(sb)->s_journal; |
3260 | if (journal) { | 3331 | if (journal) |
3261 | sb->s_dirt = 0; | ||
3262 | ret = ext4_journal_force_commit(journal); | 3332 | ret = ext4_journal_force_commit(journal); |
3263 | } | ||
3264 | 3333 | ||
3265 | return ret; | 3334 | return ret; |
3266 | } | 3335 | } |
3267 | 3336 | ||
3268 | /* | ||
3269 | * Ext4 always journals updates to the superblock itself, so we don't | ||
3270 | * have to propagate any other updates to the superblock on disk at this | ||
3271 | * point. (We can probably nuke this function altogether, and remove | ||
3272 | * any mention to sb->s_dirt in all of fs/ext4; eventual cleanup...) | ||
3273 | */ | ||
3274 | static void ext4_write_super(struct super_block *sb) | 3337 | static void ext4_write_super(struct super_block *sb) |
3275 | { | 3338 | { |
3276 | if (EXT4_SB(sb)->s_journal) { | 3339 | lock_super(sb); |
3277 | if (mutex_trylock(&sb->s_lock) != 0) | 3340 | ext4_commit_super(sb, 1); |
3278 | BUG(); | 3341 | unlock_super(sb); |
3279 | sb->s_dirt = 0; | ||
3280 | } else { | ||
3281 | ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); | ||
3282 | } | ||
3283 | } | 3342 | } |
3284 | 3343 | ||
3285 | static int ext4_sync_fs(struct super_block *sb, int wait) | 3344 | static int ext4_sync_fs(struct super_block *sb, int wait) |
@@ -3288,16 +3347,9 @@ static int ext4_sync_fs(struct super_block *sb, int wait) | |||
3288 | tid_t target; | 3347 | tid_t target; |
3289 | 3348 | ||
3290 | trace_mark(ext4_sync_fs, "dev %s wait %d", sb->s_id, wait); | 3349 | trace_mark(ext4_sync_fs, "dev %s wait %d", sb->s_id, wait); |
3291 | sb->s_dirt = 0; | 3350 | if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, &target)) { |
3292 | if (EXT4_SB(sb)->s_journal) { | 3351 | if (wait) |
3293 | if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, | 3352 | jbd2_log_wait_commit(EXT4_SB(sb)->s_journal, target); |
3294 | &target)) { | ||
3295 | if (wait) | ||
3296 | jbd2_log_wait_commit(EXT4_SB(sb)->s_journal, | ||
3297 | target); | ||
3298 | } | ||
3299 | } else { | ||
3300 | ext4_commit_super(sb, EXT4_SB(sb)->s_es, wait); | ||
3301 | } | 3353 | } |
3302 | return ret; | 3354 | return ret; |
3303 | } | 3355 | } |
@@ -3310,34 +3362,32 @@ static int ext4_freeze(struct super_block *sb) | |||
3310 | { | 3362 | { |
3311 | int error = 0; | 3363 | int error = 0; |
3312 | journal_t *journal; | 3364 | journal_t *journal; |
3313 | sb->s_dirt = 0; | ||
3314 | 3365 | ||
3315 | if (!(sb->s_flags & MS_RDONLY)) { | 3366 | if (sb->s_flags & MS_RDONLY) |
3316 | journal = EXT4_SB(sb)->s_journal; | 3367 | return 0; |
3317 | 3368 | ||
3318 | if (journal) { | 3369 | journal = EXT4_SB(sb)->s_journal; |
3319 | /* Now we set up the journal barrier. */ | ||
3320 | jbd2_journal_lock_updates(journal); | ||
3321 | 3370 | ||
3322 | /* | 3371 | /* Now we set up the journal barrier. */ |
3323 | * We don't want to clear needs_recovery flag when we | 3372 | jbd2_journal_lock_updates(journal); |
3324 | * failed to flush the journal. | ||
3325 | */ | ||
3326 | error = jbd2_journal_flush(journal); | ||
3327 | if (error < 0) | ||
3328 | goto out; | ||
3329 | } | ||
3330 | 3373 | ||
3331 | /* Journal blocked and flushed, clear needs_recovery flag. */ | 3374 | /* |
3332 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 3375 | * Don't clear the needs_recovery flag if we failed to flush |
3333 | error = ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); | 3376 | * the journal. |
3334 | if (error) | 3377 | */ |
3335 | goto out; | 3378 | error = jbd2_journal_flush(journal); |
3379 | if (error < 0) { | ||
3380 | out: | ||
3381 | jbd2_journal_unlock_updates(journal); | ||
3382 | return error; | ||
3336 | } | 3383 | } |
3384 | |||
3385 | /* Journal blocked and flushed, clear needs_recovery flag. */ | ||
3386 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | ||
3387 | error = ext4_commit_super(sb, 1); | ||
3388 | if (error) | ||
3389 | goto out; | ||
3337 | return 0; | 3390 | return 0; |
3338 | out: | ||
3339 | jbd2_journal_unlock_updates(journal); | ||
3340 | return error; | ||
3341 | } | 3391 | } |
3342 | 3392 | ||
3343 | /* | 3393 | /* |
@@ -3346,14 +3396,15 @@ out: | |||
3346 | */ | 3396 | */ |
3347 | static int ext4_unfreeze(struct super_block *sb) | 3397 | static int ext4_unfreeze(struct super_block *sb) |
3348 | { | 3398 | { |
3349 | if (EXT4_SB(sb)->s_journal && !(sb->s_flags & MS_RDONLY)) { | 3399 | if (sb->s_flags & MS_RDONLY) |
3350 | lock_super(sb); | 3400 | return 0; |
3351 | /* Reser the needs_recovery flag before the fs is unlocked. */ | 3401 | |
3352 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 3402 | lock_super(sb); |
3353 | ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); | 3403 | /* Reset the needs_recovery flag before the fs is unlocked. */ |
3354 | unlock_super(sb); | 3404 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
3355 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | 3405 | ext4_commit_super(sb, 1); |
3356 | } | 3406 | unlock_super(sb); |
3407 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | ||
3357 | return 0; | 3408 | return 0; |
3358 | } | 3409 | } |
3359 | 3410 | ||
@@ -3371,7 +3422,10 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3371 | int i; | 3422 | int i; |
3372 | #endif | 3423 | #endif |
3373 | 3424 | ||
3425 | lock_kernel(); | ||
3426 | |||
3374 | /* Store the original options */ | 3427 | /* Store the original options */ |
3428 | lock_super(sb); | ||
3375 | old_sb_flags = sb->s_flags; | 3429 | old_sb_flags = sb->s_flags; |
3376 | old_opts.s_mount_opt = sbi->s_mount_opt; | 3430 | old_opts.s_mount_opt = sbi->s_mount_opt; |
3377 | old_opts.s_resuid = sbi->s_resuid; | 3431 | old_opts.s_resuid = sbi->s_resuid; |
@@ -3432,22 +3486,15 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3432 | (sbi->s_mount_state & EXT4_VALID_FS)) | 3486 | (sbi->s_mount_state & EXT4_VALID_FS)) |
3433 | es->s_state = cpu_to_le16(sbi->s_mount_state); | 3487 | es->s_state = cpu_to_le16(sbi->s_mount_state); |
3434 | 3488 | ||
3435 | /* | 3489 | if (sbi->s_journal) |
3436 | * We have to unlock super so that we can wait for | ||
3437 | * transactions. | ||
3438 | */ | ||
3439 | if (sbi->s_journal) { | ||
3440 | unlock_super(sb); | ||
3441 | ext4_mark_recovery_complete(sb, es); | 3490 | ext4_mark_recovery_complete(sb, es); |
3442 | lock_super(sb); | ||
3443 | } | ||
3444 | } else { | 3491 | } else { |
3445 | int ret; | 3492 | int ret; |
3446 | if ((ret = EXT4_HAS_RO_COMPAT_FEATURE(sb, | 3493 | if ((ret = EXT4_HAS_RO_COMPAT_FEATURE(sb, |
3447 | ~EXT4_FEATURE_RO_COMPAT_SUPP))) { | 3494 | ~EXT4_FEATURE_RO_COMPAT_SUPP))) { |
3448 | printk(KERN_WARNING "EXT4-fs: %s: couldn't " | 3495 | ext4_msg(sb, KERN_WARNING, "couldn't " |
3449 | "remount RDWR because of unsupported " | 3496 | "remount RDWR because of unsupported " |
3450 | "optional features (%x).\n", sb->s_id, | 3497 | "optional features (%x)", |
3451 | (le32_to_cpu(sbi->s_es->s_feature_ro_compat) & | 3498 | (le32_to_cpu(sbi->s_es->s_feature_ro_compat) & |
3452 | ~EXT4_FEATURE_RO_COMPAT_SUPP)); | 3499 | ~EXT4_FEATURE_RO_COMPAT_SUPP)); |
3453 | err = -EROFS; | 3500 | err = -EROFS; |
@@ -3456,17 +3503,15 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3456 | 3503 | ||
3457 | /* | 3504 | /* |
3458 | * Make sure the group descriptor checksums | 3505 | * Make sure the group descriptor checksums |
3459 | * are sane. If they aren't, refuse to | 3506 | * are sane. If they aren't, refuse to remount r/w. |
3460 | * remount r/w. | ||
3461 | */ | 3507 | */ |
3462 | for (g = 0; g < sbi->s_groups_count; g++) { | 3508 | for (g = 0; g < sbi->s_groups_count; g++) { |
3463 | struct ext4_group_desc *gdp = | 3509 | struct ext4_group_desc *gdp = |
3464 | ext4_get_group_desc(sb, g, NULL); | 3510 | ext4_get_group_desc(sb, g, NULL); |
3465 | 3511 | ||
3466 | if (!ext4_group_desc_csum_verify(sbi, g, gdp)) { | 3512 | if (!ext4_group_desc_csum_verify(sbi, g, gdp)) { |
3467 | printk(KERN_ERR | 3513 | ext4_msg(sb, KERN_ERR, |
3468 | "EXT4-fs: ext4_remount: " | 3514 | "ext4_remount: Checksum for group %u failed (%u!=%u)", |
3469 | "Checksum for group %u failed (%u!=%u)\n", | ||
3470 | g, le16_to_cpu(ext4_group_desc_csum(sbi, g, gdp)), | 3515 | g, le16_to_cpu(ext4_group_desc_csum(sbi, g, gdp)), |
3471 | le16_to_cpu(gdp->bg_checksum)); | 3516 | le16_to_cpu(gdp->bg_checksum)); |
3472 | err = -EINVAL; | 3517 | err = -EINVAL; |
@@ -3480,11 +3525,10 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3480 | * require a full umount/remount for now. | 3525 | * require a full umount/remount for now. |
3481 | */ | 3526 | */ |
3482 | if (es->s_last_orphan) { | 3527 | if (es->s_last_orphan) { |
3483 | printk(KERN_WARNING "EXT4-fs: %s: couldn't " | 3528 | ext4_msg(sb, KERN_WARNING, "Couldn't " |
3484 | "remount RDWR because of unprocessed " | 3529 | "remount RDWR because of unprocessed " |
3485 | "orphan inode list. Please " | 3530 | "orphan inode list. Please " |
3486 | "umount/remount instead.\n", | 3531 | "umount/remount instead"); |
3487 | sb->s_id); | ||
3488 | err = -EINVAL; | 3532 | err = -EINVAL; |
3489 | goto restore_opts; | 3533 | goto restore_opts; |
3490 | } | 3534 | } |
@@ -3504,8 +3548,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3504 | sb->s_flags &= ~MS_RDONLY; | 3548 | sb->s_flags &= ~MS_RDONLY; |
3505 | } | 3549 | } |
3506 | } | 3550 | } |
3551 | ext4_setup_system_zone(sb); | ||
3507 | if (sbi->s_journal == NULL) | 3552 | if (sbi->s_journal == NULL) |
3508 | ext4_commit_super(sb, es, 1); | 3553 | ext4_commit_super(sb, 1); |
3509 | 3554 | ||
3510 | #ifdef CONFIG_QUOTA | 3555 | #ifdef CONFIG_QUOTA |
3511 | /* Release old quota file names */ | 3556 | /* Release old quota file names */ |
@@ -3514,7 +3559,10 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3514 | old_opts.s_qf_names[i] != sbi->s_qf_names[i]) | 3559 | old_opts.s_qf_names[i] != sbi->s_qf_names[i]) |
3515 | kfree(old_opts.s_qf_names[i]); | 3560 | kfree(old_opts.s_qf_names[i]); |
3516 | #endif | 3561 | #endif |
3562 | unlock_super(sb); | ||
3563 | unlock_kernel(); | ||
3517 | return 0; | 3564 | return 0; |
3565 | |||
3518 | restore_opts: | 3566 | restore_opts: |
3519 | sb->s_flags = old_sb_flags; | 3567 | sb->s_flags = old_sb_flags; |
3520 | sbi->s_mount_opt = old_opts.s_mount_opt; | 3568 | sbi->s_mount_opt = old_opts.s_mount_opt; |
@@ -3532,6 +3580,8 @@ restore_opts: | |||
3532 | sbi->s_qf_names[i] = old_opts.s_qf_names[i]; | 3580 | sbi->s_qf_names[i] = old_opts.s_qf_names[i]; |
3533 | } | 3581 | } |
3534 | #endif | 3582 | #endif |
3583 | unlock_super(sb); | ||
3584 | unlock_kernel(); | ||
3535 | return err; | 3585 | return err; |
3536 | } | 3586 | } |
3537 | 3587 | ||
@@ -3545,9 +3595,8 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
3545 | if (test_opt(sb, MINIX_DF)) { | 3595 | if (test_opt(sb, MINIX_DF)) { |
3546 | sbi->s_overhead_last = 0; | 3596 | sbi->s_overhead_last = 0; |
3547 | } else if (sbi->s_blocks_last != ext4_blocks_count(es)) { | 3597 | } else if (sbi->s_blocks_last != ext4_blocks_count(es)) { |
3548 | ext4_group_t ngroups = sbi->s_groups_count, i; | 3598 | ext4_group_t i, ngroups = ext4_get_groups_count(sb); |
3549 | ext4_fsblk_t overhead = 0; | 3599 | ext4_fsblk_t overhead = 0; |
3550 | smp_rmb(); | ||
3551 | 3600 | ||
3552 | /* | 3601 | /* |
3553 | * Compute the overhead (FS structures). This is constant | 3602 | * Compute the overhead (FS structures). This is constant |
@@ -3599,11 +3648,12 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
3599 | le64_to_cpup((void *)es->s_uuid + sizeof(u64)); | 3648 | le64_to_cpup((void *)es->s_uuid + sizeof(u64)); |
3600 | buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL; | 3649 | buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL; |
3601 | buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL; | 3650 | buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL; |
3651 | |||
3602 | return 0; | 3652 | return 0; |
3603 | } | 3653 | } |
3604 | 3654 | ||
3605 | /* Helper function for writing quotas on sync - we need to start transaction before quota file | 3655 | /* Helper function for writing quotas on sync - we need to start transaction |
3606 | * is locked for write. Otherwise the are possible deadlocks: | 3656 | * before quota file is locked for write. Otherwise the are possible deadlocks: |
3607 | * Process 1 Process 2 | 3657 | * Process 1 Process 2 |
3608 | * ext4_create() quota_sync() | 3658 | * ext4_create() quota_sync() |
3609 | * jbd2_journal_start() write_dquot() | 3659 | * jbd2_journal_start() write_dquot() |
@@ -3627,7 +3677,7 @@ static int ext4_write_dquot(struct dquot *dquot) | |||
3627 | 3677 | ||
3628 | inode = dquot_to_inode(dquot); | 3678 | inode = dquot_to_inode(dquot); |
3629 | handle = ext4_journal_start(inode, | 3679 | handle = ext4_journal_start(inode, |
3630 | EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); | 3680 | EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); |
3631 | if (IS_ERR(handle)) | 3681 | if (IS_ERR(handle)) |
3632 | return PTR_ERR(handle); | 3682 | return PTR_ERR(handle); |
3633 | ret = dquot_commit(dquot); | 3683 | ret = dquot_commit(dquot); |
@@ -3643,7 +3693,7 @@ static int ext4_acquire_dquot(struct dquot *dquot) | |||
3643 | handle_t *handle; | 3693 | handle_t *handle; |
3644 | 3694 | ||
3645 | handle = ext4_journal_start(dquot_to_inode(dquot), | 3695 | handle = ext4_journal_start(dquot_to_inode(dquot), |
3646 | EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb)); | 3696 | EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb)); |
3647 | if (IS_ERR(handle)) | 3697 | if (IS_ERR(handle)) |
3648 | return PTR_ERR(handle); | 3698 | return PTR_ERR(handle); |
3649 | ret = dquot_acquire(dquot); | 3699 | ret = dquot_acquire(dquot); |
@@ -3659,7 +3709,7 @@ static int ext4_release_dquot(struct dquot *dquot) | |||
3659 | handle_t *handle; | 3709 | handle_t *handle; |
3660 | 3710 | ||
3661 | handle = ext4_journal_start(dquot_to_inode(dquot), | 3711 | handle = ext4_journal_start(dquot_to_inode(dquot), |
3662 | EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb)); | 3712 | EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb)); |
3663 | if (IS_ERR(handle)) { | 3713 | if (IS_ERR(handle)) { |
3664 | /* Release dquot anyway to avoid endless cycle in dqput() */ | 3714 | /* Release dquot anyway to avoid endless cycle in dqput() */ |
3665 | dquot_release(dquot); | 3715 | dquot_release(dquot); |
@@ -3707,7 +3757,7 @@ static int ext4_write_info(struct super_block *sb, int type) | |||
3707 | static int ext4_quota_on_mount(struct super_block *sb, int type) | 3757 | static int ext4_quota_on_mount(struct super_block *sb, int type) |
3708 | { | 3758 | { |
3709 | return vfs_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type], | 3759 | return vfs_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type], |
3710 | EXT4_SB(sb)->s_jquota_fmt, type); | 3760 | EXT4_SB(sb)->s_jquota_fmt, type); |
3711 | } | 3761 | } |
3712 | 3762 | ||
3713 | /* | 3763 | /* |
@@ -3738,9 +3788,9 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, | |||
3738 | if (EXT4_SB(sb)->s_qf_names[type]) { | 3788 | if (EXT4_SB(sb)->s_qf_names[type]) { |
3739 | /* Quotafile not in fs root? */ | 3789 | /* Quotafile not in fs root? */ |
3740 | if (path.dentry->d_parent != sb->s_root) | 3790 | if (path.dentry->d_parent != sb->s_root) |
3741 | printk(KERN_WARNING | 3791 | ext4_msg(sb, KERN_WARNING, |
3742 | "EXT4-fs: Quota file not on filesystem root. " | 3792 | "Quota file not on filesystem root. " |
3743 | "Journaled quota will not work.\n"); | 3793 | "Journaled quota will not work"); |
3744 | } | 3794 | } |
3745 | 3795 | ||
3746 | /* | 3796 | /* |
@@ -3823,8 +3873,8 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
3823 | handle_t *handle = journal_current_handle(); | 3873 | handle_t *handle = journal_current_handle(); |
3824 | 3874 | ||
3825 | if (EXT4_SB(sb)->s_journal && !handle) { | 3875 | if (EXT4_SB(sb)->s_journal && !handle) { |
3826 | printk(KERN_WARNING "EXT4-fs: Quota write (off=%llu, len=%llu)" | 3876 | ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" |
3827 | " cancelled because transaction is not started.\n", | 3877 | " cancelled because transaction is not started", |
3828 | (unsigned long long)off, (unsigned long long)len); | 3878 | (unsigned long long)off, (unsigned long long)len); |
3829 | return -EIO; | 3879 | return -EIO; |
3830 | } | 3880 | } |
@@ -3878,10 +3928,10 @@ out: | |||
3878 | 3928 | ||
3879 | #endif | 3929 | #endif |
3880 | 3930 | ||
3881 | static int ext4_get_sb(struct file_system_type *fs_type, | 3931 | static int ext4_get_sb(struct file_system_type *fs_type, int flags, |
3882 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | 3932 | const char *dev_name, void *data, struct vfsmount *mnt) |
3883 | { | 3933 | { |
3884 | return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super, mnt); | 3934 | return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt); |
3885 | } | 3935 | } |
3886 | 3936 | ||
3887 | static struct file_system_type ext4_fs_type = { | 3937 | static struct file_system_type ext4_fs_type = { |
@@ -3893,14 +3943,14 @@ static struct file_system_type ext4_fs_type = { | |||
3893 | }; | 3943 | }; |
3894 | 3944 | ||
3895 | #ifdef CONFIG_EXT4DEV_COMPAT | 3945 | #ifdef CONFIG_EXT4DEV_COMPAT |
3896 | static int ext4dev_get_sb(struct file_system_type *fs_type, | 3946 | static int ext4dev_get_sb(struct file_system_type *fs_type, int flags, |
3897 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | 3947 | const char *dev_name, void *data,struct vfsmount *mnt) |
3898 | { | 3948 | { |
3899 | printk(KERN_WARNING "EXT4-fs: Update your userspace programs " | 3949 | printk(KERN_WARNING "EXT4-fs (%s): Update your userspace programs " |
3900 | "to mount using ext4\n"); | 3950 | "to mount using ext4\n", dev_name); |
3901 | printk(KERN_WARNING "EXT4-fs: ext4dev backwards compatibility " | 3951 | printk(KERN_WARNING "EXT4-fs (%s): ext4dev backwards compatibility " |
3902 | "will go away by 2.6.31\n"); | 3952 | "will go away by 2.6.31\n", dev_name); |
3903 | return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super, mnt); | 3953 | return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt); |
3904 | } | 3954 | } |
3905 | 3955 | ||
3906 | static struct file_system_type ext4dev_fs_type = { | 3956 | static struct file_system_type ext4dev_fs_type = { |
@@ -3917,13 +3967,16 @@ static int __init init_ext4_fs(void) | |||
3917 | { | 3967 | { |
3918 | int err; | 3968 | int err; |
3919 | 3969 | ||
3970 | err = init_ext4_system_zone(); | ||
3971 | if (err) | ||
3972 | return err; | ||
3920 | ext4_kset = kset_create_and_add("ext4", NULL, fs_kobj); | 3973 | ext4_kset = kset_create_and_add("ext4", NULL, fs_kobj); |
3921 | if (!ext4_kset) | 3974 | if (!ext4_kset) |
3922 | return -ENOMEM; | 3975 | goto out4; |
3923 | ext4_proc_root = proc_mkdir("fs/ext4", NULL); | 3976 | ext4_proc_root = proc_mkdir("fs/ext4", NULL); |
3924 | err = init_ext4_mballoc(); | 3977 | err = init_ext4_mballoc(); |
3925 | if (err) | 3978 | if (err) |
3926 | return err; | 3979 | goto out3; |
3927 | 3980 | ||
3928 | err = init_ext4_xattr(); | 3981 | err = init_ext4_xattr(); |
3929 | if (err) | 3982 | if (err) |
@@ -3948,6 +4001,11 @@ out1: | |||
3948 | exit_ext4_xattr(); | 4001 | exit_ext4_xattr(); |
3949 | out2: | 4002 | out2: |
3950 | exit_ext4_mballoc(); | 4003 | exit_ext4_mballoc(); |
4004 | out3: | ||
4005 | remove_proc_entry("fs/ext4", NULL); | ||
4006 | kset_unregister(ext4_kset); | ||
4007 | out4: | ||
4008 | exit_ext4_system_zone(); | ||
3951 | return err; | 4009 | return err; |
3952 | } | 4010 | } |
3953 | 4011 | ||
@@ -3962,6 +4020,7 @@ static void __exit exit_ext4_fs(void) | |||
3962 | exit_ext4_mballoc(); | 4020 | exit_ext4_mballoc(); |
3963 | remove_proc_entry("fs/ext4", NULL); | 4021 | remove_proc_entry("fs/ext4", NULL); |
3964 | kset_unregister(ext4_kset); | 4022 | kset_unregister(ext4_kset); |
4023 | exit_ext4_system_zone(); | ||
3965 | } | 4024 | } |
3966 | 4025 | ||
3967 | MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); | 4026 | MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); |