diff options
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 833 |
1 files changed, 440 insertions, 393 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 2958f4e6f222..f016707597a7 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,7 @@ 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 | ext4_release_system_zone(sb); | ||
566 | ext4_mb_release(sb); | 580 | ext4_mb_release(sb); |
567 | ext4_ext_release(sb); | 581 | ext4_ext_release(sb); |
568 | ext4_xattr_put_super(sb); | 582 | ext4_xattr_put_super(sb); |
@@ -576,7 +590,7 @@ static void ext4_put_super(struct super_block *sb) | |||
576 | if (!(sb->s_flags & MS_RDONLY)) { | 590 | if (!(sb->s_flags & MS_RDONLY)) { |
577 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 591 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
578 | es->s_state = cpu_to_le16(sbi->s_mount_state); | 592 | es->s_state = cpu_to_le16(sbi->s_mount_state); |
579 | ext4_commit_super(sb, es, 1); | 593 | ext4_commit_super(sb, 1); |
580 | } | 594 | } |
581 | if (sbi->s_proc) { | 595 | if (sbi->s_proc) { |
582 | remove_proc_entry(sb->s_id, ext4_proc_root); | 596 | remove_proc_entry(sb->s_id, ext4_proc_root); |
@@ -586,7 +600,10 @@ static void ext4_put_super(struct super_block *sb) | |||
586 | for (i = 0; i < sbi->s_gdb_count; i++) | 600 | for (i = 0; i < sbi->s_gdb_count; i++) |
587 | brelse(sbi->s_group_desc[i]); | 601 | brelse(sbi->s_group_desc[i]); |
588 | kfree(sbi->s_group_desc); | 602 | kfree(sbi->s_group_desc); |
589 | kfree(sbi->s_flex_groups); | 603 | if (is_vmalloc_addr(sbi->s_flex_groups)) |
604 | vfree(sbi->s_flex_groups); | ||
605 | else | ||
606 | kfree(sbi->s_flex_groups); | ||
590 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | 607 | percpu_counter_destroy(&sbi->s_freeblocks_counter); |
591 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | 608 | percpu_counter_destroy(&sbi->s_freeinodes_counter); |
592 | percpu_counter_destroy(&sbi->s_dirs_counter); | 609 | percpu_counter_destroy(&sbi->s_dirs_counter); |
@@ -629,7 +646,6 @@ static void ext4_put_super(struct super_block *sb) | |||
629 | lock_kernel(); | 646 | lock_kernel(); |
630 | kfree(sbi->s_blockgroup_lock); | 647 | kfree(sbi->s_blockgroup_lock); |
631 | kfree(sbi); | 648 | kfree(sbi); |
632 | return; | ||
633 | } | 649 | } |
634 | 650 | ||
635 | static struct kmem_cache *ext4_inode_cachep; | 651 | static struct kmem_cache *ext4_inode_cachep; |
@@ -644,6 +660,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
644 | ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS); | 660 | ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS); |
645 | if (!ei) | 661 | if (!ei) |
646 | return NULL; | 662 | return NULL; |
663 | |||
647 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 664 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
648 | ei->i_acl = EXT4_ACL_NOT_CACHED; | 665 | ei->i_acl = EXT4_ACL_NOT_CACHED; |
649 | ei->i_default_acl = EXT4_ACL_NOT_CACHED; | 666 | ei->i_default_acl = EXT4_ACL_NOT_CACHED; |
@@ -664,14 +681,16 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
664 | ei->i_allocated_meta_blocks = 0; | 681 | ei->i_allocated_meta_blocks = 0; |
665 | ei->i_delalloc_reserved_flag = 0; | 682 | ei->i_delalloc_reserved_flag = 0; |
666 | spin_lock_init(&(ei->i_block_reservation_lock)); | 683 | spin_lock_init(&(ei->i_block_reservation_lock)); |
684 | |||
667 | return &ei->vfs_inode; | 685 | return &ei->vfs_inode; |
668 | } | 686 | } |
669 | 687 | ||
670 | static void ext4_destroy_inode(struct inode *inode) | 688 | static void ext4_destroy_inode(struct inode *inode) |
671 | { | 689 | { |
672 | if (!list_empty(&(EXT4_I(inode)->i_orphan))) { | 690 | if (!list_empty(&(EXT4_I(inode)->i_orphan))) { |
673 | printk("EXT4 Inode %p: orphan list check failed!\n", | 691 | ext4_msg(inode->i_sb, KERN_ERR, |
674 | EXT4_I(inode)); | 692 | "Inode %lu (%p): orphan list check failed!", |
693 | inode->i_ino, EXT4_I(inode)); | ||
675 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 16, 4, | 694 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 16, 4, |
676 | EXT4_I(inode), sizeof(struct ext4_inode_info), | 695 | EXT4_I(inode), sizeof(struct ext4_inode_info), |
677 | true); | 696 | true); |
@@ -870,12 +889,12 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
870 | seq_puts(seq, ",noauto_da_alloc"); | 889 | seq_puts(seq, ",noauto_da_alloc"); |
871 | 890 | ||
872 | ext4_show_quota_options(seq, sb); | 891 | ext4_show_quota_options(seq, sb); |
892 | |||
873 | return 0; | 893 | return 0; |
874 | } | 894 | } |
875 | 895 | ||
876 | |||
877 | static struct inode *ext4_nfs_get_inode(struct super_block *sb, | 896 | static struct inode *ext4_nfs_get_inode(struct super_block *sb, |
878 | u64 ino, u32 generation) | 897 | u64 ino, u32 generation) |
879 | { | 898 | { |
880 | struct inode *inode; | 899 | struct inode *inode; |
881 | 900 | ||
@@ -904,14 +923,14 @@ static struct inode *ext4_nfs_get_inode(struct super_block *sb, | |||
904 | } | 923 | } |
905 | 924 | ||
906 | static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid, | 925 | static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid, |
907 | int fh_len, int fh_type) | 926 | int fh_len, int fh_type) |
908 | { | 927 | { |
909 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, | 928 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, |
910 | ext4_nfs_get_inode); | 929 | ext4_nfs_get_inode); |
911 | } | 930 | } |
912 | 931 | ||
913 | static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, | 932 | static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, |
914 | int fh_len, int fh_type) | 933 | int fh_len, int fh_type) |
915 | { | 934 | { |
916 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, | 935 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, |
917 | ext4_nfs_get_inode); | 936 | ext4_nfs_get_inode); |
@@ -923,7 +942,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 | 942 | * 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. | 943 | * jbd2 layer's try_to_free_buffers() function to release them. |
925 | */ | 944 | */ |
926 | static int bdev_try_to_free_page(struct super_block *sb, struct page *page, gfp_t wait) | 945 | static int bdev_try_to_free_page(struct super_block *sb, struct page *page, |
946 | gfp_t wait) | ||
927 | { | 947 | { |
928 | journal_t *journal = EXT4_SB(sb)->s_journal; | 948 | journal_t *journal = EXT4_SB(sb)->s_journal; |
929 | 949 | ||
@@ -992,7 +1012,6 @@ static const struct super_operations ext4_sops = { | |||
992 | .dirty_inode = ext4_dirty_inode, | 1012 | .dirty_inode = ext4_dirty_inode, |
993 | .delete_inode = ext4_delete_inode, | 1013 | .delete_inode = ext4_delete_inode, |
994 | .put_super = ext4_put_super, | 1014 | .put_super = ext4_put_super, |
995 | .write_super = ext4_write_super, | ||
996 | .sync_fs = ext4_sync_fs, | 1015 | .sync_fs = ext4_sync_fs, |
997 | .freeze_fs = ext4_freeze, | 1016 | .freeze_fs = ext4_freeze, |
998 | .unfreeze_fs = ext4_unfreeze, | 1017 | .unfreeze_fs = ext4_unfreeze, |
@@ -1007,6 +1026,25 @@ static const struct super_operations ext4_sops = { | |||
1007 | .bdev_try_to_free_page = bdev_try_to_free_page, | 1026 | .bdev_try_to_free_page = bdev_try_to_free_page, |
1008 | }; | 1027 | }; |
1009 | 1028 | ||
1029 | static const struct super_operations ext4_nojournal_sops = { | ||
1030 | .alloc_inode = ext4_alloc_inode, | ||
1031 | .destroy_inode = ext4_destroy_inode, | ||
1032 | .write_inode = ext4_write_inode, | ||
1033 | .dirty_inode = ext4_dirty_inode, | ||
1034 | .delete_inode = ext4_delete_inode, | ||
1035 | .write_super = ext4_write_super, | ||
1036 | .put_super = ext4_put_super, | ||
1037 | .statfs = ext4_statfs, | ||
1038 | .remount_fs = ext4_remount, | ||
1039 | .clear_inode = ext4_clear_inode, | ||
1040 | .show_options = ext4_show_options, | ||
1041 | #ifdef CONFIG_QUOTA | ||
1042 | .quota_read = ext4_quota_read, | ||
1043 | .quota_write = ext4_quota_write, | ||
1044 | #endif | ||
1045 | .bdev_try_to_free_page = bdev_try_to_free_page, | ||
1046 | }; | ||
1047 | |||
1010 | static const struct export_operations ext4_export_ops = { | 1048 | static const struct export_operations ext4_export_ops = { |
1011 | .fh_to_dentry = ext4_fh_to_dentry, | 1049 | .fh_to_dentry = ext4_fh_to_dentry, |
1012 | .fh_to_parent = ext4_fh_to_parent, | 1050 | .fh_to_parent = ext4_fh_to_parent, |
@@ -1023,12 +1061,13 @@ enum { | |||
1023 | Opt_journal_update, Opt_journal_dev, | 1061 | Opt_journal_update, Opt_journal_dev, |
1024 | Opt_journal_checksum, Opt_journal_async_commit, | 1062 | Opt_journal_checksum, Opt_journal_async_commit, |
1025 | Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, | 1063 | Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, |
1026 | Opt_data_err_abort, Opt_data_err_ignore, | 1064 | Opt_data_err_abort, Opt_data_err_ignore, Opt_mb_history_length, |
1027 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, | 1065 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, |
1028 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, | 1066 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, |
1029 | Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize, | 1067 | Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize, |
1030 | Opt_usrquota, Opt_grpquota, Opt_i_version, | 1068 | Opt_usrquota, Opt_grpquota, Opt_i_version, |
1031 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, | 1069 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, |
1070 | Opt_block_validity, Opt_noblock_validity, | ||
1032 | Opt_inode_readahead_blks, Opt_journal_ioprio | 1071 | Opt_inode_readahead_blks, Opt_journal_ioprio |
1033 | }; | 1072 | }; |
1034 | 1073 | ||
@@ -1069,6 +1108,7 @@ static const match_table_t tokens = { | |||
1069 | {Opt_data_writeback, "data=writeback"}, | 1108 | {Opt_data_writeback, "data=writeback"}, |
1070 | {Opt_data_err_abort, "data_err=abort"}, | 1109 | {Opt_data_err_abort, "data_err=abort"}, |
1071 | {Opt_data_err_ignore, "data_err=ignore"}, | 1110 | {Opt_data_err_ignore, "data_err=ignore"}, |
1111 | {Opt_mb_history_length, "mb_history_length=%u"}, | ||
1072 | {Opt_offusrjquota, "usrjquota="}, | 1112 | {Opt_offusrjquota, "usrjquota="}, |
1073 | {Opt_usrjquota, "usrjquota=%s"}, | 1113 | {Opt_usrjquota, "usrjquota=%s"}, |
1074 | {Opt_offgrpjquota, "grpjquota="}, | 1114 | {Opt_offgrpjquota, "grpjquota="}, |
@@ -1087,6 +1127,8 @@ static const match_table_t tokens = { | |||
1087 | {Opt_resize, "resize"}, | 1127 | {Opt_resize, "resize"}, |
1088 | {Opt_delalloc, "delalloc"}, | 1128 | {Opt_delalloc, "delalloc"}, |
1089 | {Opt_nodelalloc, "nodelalloc"}, | 1129 | {Opt_nodelalloc, "nodelalloc"}, |
1130 | {Opt_block_validity, "block_validity"}, | ||
1131 | {Opt_noblock_validity, "noblock_validity"}, | ||
1090 | {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, | 1132 | {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, |
1091 | {Opt_journal_ioprio, "journal_ioprio=%u"}, | 1133 | {Opt_journal_ioprio, "journal_ioprio=%u"}, |
1092 | {Opt_auto_da_alloc, "auto_da_alloc=%u"}, | 1134 | {Opt_auto_da_alloc, "auto_da_alloc=%u"}, |
@@ -1102,8 +1144,9 @@ static ext4_fsblk_t get_sb_block(void **data) | |||
1102 | 1144 | ||
1103 | if (!options || strncmp(options, "sb=", 3) != 0) | 1145 | if (!options || strncmp(options, "sb=", 3) != 0) |
1104 | return 1; /* Default location */ | 1146 | return 1; /* Default location */ |
1147 | |||
1105 | options += 3; | 1148 | options += 3; |
1106 | /*todo: use simple_strtoll with >32bit ext4 */ | 1149 | /* TODO: use simple_strtoll with >32bit ext4 */ |
1107 | sb_block = simple_strtoul(options, &options, 0); | 1150 | sb_block = simple_strtoul(options, &options, 0); |
1108 | if (*options && *options != ',') { | 1151 | if (*options && *options != ',') { |
1109 | printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n", | 1152 | printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n", |
@@ -1113,6 +1156,7 @@ static ext4_fsblk_t get_sb_block(void **data) | |||
1113 | if (*options == ',') | 1156 | if (*options == ',') |
1114 | options++; | 1157 | options++; |
1115 | *data = (void *) options; | 1158 | *data = (void *) options; |
1159 | |||
1116 | return sb_block; | 1160 | return sb_block; |
1117 | } | 1161 | } |
1118 | 1162 | ||
@@ -1206,8 +1250,7 @@ static int parse_options(char *options, struct super_block *sb, | |||
1206 | #else | 1250 | #else |
1207 | case Opt_user_xattr: | 1251 | case Opt_user_xattr: |
1208 | case Opt_nouser_xattr: | 1252 | case Opt_nouser_xattr: |
1209 | printk(KERN_ERR "EXT4 (no)user_xattr options " | 1253 | ext4_msg(sb, KERN_ERR, "(no)user_xattr options not supported"); |
1210 | "not supported\n"); | ||
1211 | break; | 1254 | break; |
1212 | #endif | 1255 | #endif |
1213 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 1256 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
@@ -1220,8 +1263,7 @@ static int parse_options(char *options, struct super_block *sb, | |||
1220 | #else | 1263 | #else |
1221 | case Opt_acl: | 1264 | case Opt_acl: |
1222 | case Opt_noacl: | 1265 | case Opt_noacl: |
1223 | printk(KERN_ERR "EXT4 (no)acl options " | 1266 | ext4_msg(sb, KERN_ERR, "(no)acl options not supported"); |
1224 | "not supported\n"); | ||
1225 | break; | 1267 | break; |
1226 | #endif | 1268 | #endif |
1227 | case Opt_journal_update: | 1269 | case Opt_journal_update: |
@@ -1231,16 +1273,16 @@ static int parse_options(char *options, struct super_block *sb, | |||
1231 | user to specify an existing inode to be the | 1273 | user to specify an existing inode to be the |
1232 | journal file. */ | 1274 | journal file. */ |
1233 | if (is_remount) { | 1275 | if (is_remount) { |
1234 | printk(KERN_ERR "EXT4-fs: cannot specify " | 1276 | ext4_msg(sb, KERN_ERR, |
1235 | "journal on remount\n"); | 1277 | "Cannot specify journal on remount"); |
1236 | return 0; | 1278 | return 0; |
1237 | } | 1279 | } |
1238 | set_opt(sbi->s_mount_opt, UPDATE_JOURNAL); | 1280 | set_opt(sbi->s_mount_opt, UPDATE_JOURNAL); |
1239 | break; | 1281 | break; |
1240 | case Opt_journal_dev: | 1282 | case Opt_journal_dev: |
1241 | if (is_remount) { | 1283 | if (is_remount) { |
1242 | printk(KERN_ERR "EXT4-fs: cannot specify " | 1284 | ext4_msg(sb, KERN_ERR, |
1243 | "journal on remount\n"); | 1285 | "Cannot specify journal on remount"); |
1244 | return 0; | 1286 | return 0; |
1245 | } | 1287 | } |
1246 | if (match_int(&args[0], &option)) | 1288 | if (match_int(&args[0], &option)) |
@@ -1294,9 +1336,8 @@ static int parse_options(char *options, struct super_block *sb, | |||
1294 | if (is_remount) { | 1336 | if (is_remount) { |
1295 | if ((sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS) | 1337 | if ((sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS) |
1296 | != data_opt) { | 1338 | != data_opt) { |
1297 | printk(KERN_ERR | 1339 | ext4_msg(sb, KERN_ERR, |
1298 | "EXT4-fs: cannot change data " | 1340 | "Cannot change data mode on remount"); |
1299 | "mode on remount\n"); | ||
1300 | return 0; | 1341 | return 0; |
1301 | } | 1342 | } |
1302 | } else { | 1343 | } else { |
@@ -1310,6 +1351,13 @@ static int parse_options(char *options, struct super_block *sb, | |||
1310 | case Opt_data_err_ignore: | 1351 | case Opt_data_err_ignore: |
1311 | clear_opt(sbi->s_mount_opt, DATA_ERR_ABORT); | 1352 | clear_opt(sbi->s_mount_opt, DATA_ERR_ABORT); |
1312 | break; | 1353 | break; |
1354 | case Opt_mb_history_length: | ||
1355 | if (match_int(&args[0], &option)) | ||
1356 | return 0; | ||
1357 | if (option < 0) | ||
1358 | return 0; | ||
1359 | sbi->s_mb_history_max = option; | ||
1360 | break; | ||
1313 | #ifdef CONFIG_QUOTA | 1361 | #ifdef CONFIG_QUOTA |
1314 | case Opt_usrjquota: | 1362 | case Opt_usrjquota: |
1315 | qtype = USRQUOTA; | 1363 | qtype = USRQUOTA; |
@@ -1319,31 +1367,31 @@ static int parse_options(char *options, struct super_block *sb, | |||
1319 | set_qf_name: | 1367 | set_qf_name: |
1320 | if (sb_any_quota_loaded(sb) && | 1368 | if (sb_any_quota_loaded(sb) && |
1321 | !sbi->s_qf_names[qtype]) { | 1369 | !sbi->s_qf_names[qtype]) { |
1322 | printk(KERN_ERR | 1370 | ext4_msg(sb, KERN_ERR, |
1323 | "EXT4-fs: Cannot change journaled " | 1371 | "Cannot change journaled " |
1324 | "quota options when quota turned on.\n"); | 1372 | "quota options when quota turned on"); |
1325 | return 0; | 1373 | return 0; |
1326 | } | 1374 | } |
1327 | qname = match_strdup(&args[0]); | 1375 | qname = match_strdup(&args[0]); |
1328 | if (!qname) { | 1376 | if (!qname) { |
1329 | printk(KERN_ERR | 1377 | ext4_msg(sb, KERN_ERR, |
1330 | "EXT4-fs: not enough memory for " | 1378 | "Not enough memory for " |
1331 | "storing quotafile name.\n"); | 1379 | "storing quotafile name"); |
1332 | return 0; | 1380 | return 0; |
1333 | } | 1381 | } |
1334 | if (sbi->s_qf_names[qtype] && | 1382 | if (sbi->s_qf_names[qtype] && |
1335 | strcmp(sbi->s_qf_names[qtype], qname)) { | 1383 | strcmp(sbi->s_qf_names[qtype], qname)) { |
1336 | printk(KERN_ERR | 1384 | ext4_msg(sb, KERN_ERR, |
1337 | "EXT4-fs: %s quota file already " | 1385 | "%s quota file already " |
1338 | "specified.\n", QTYPE2NAME(qtype)); | 1386 | "specified", QTYPE2NAME(qtype)); |
1339 | kfree(qname); | 1387 | kfree(qname); |
1340 | return 0; | 1388 | return 0; |
1341 | } | 1389 | } |
1342 | sbi->s_qf_names[qtype] = qname; | 1390 | sbi->s_qf_names[qtype] = qname; |
1343 | if (strchr(sbi->s_qf_names[qtype], '/')) { | 1391 | if (strchr(sbi->s_qf_names[qtype], '/')) { |
1344 | printk(KERN_ERR | 1392 | ext4_msg(sb, KERN_ERR, |
1345 | "EXT4-fs: quotafile must be on " | 1393 | "quotafile must be on " |
1346 | "filesystem root.\n"); | 1394 | "filesystem root"); |
1347 | kfree(sbi->s_qf_names[qtype]); | 1395 | kfree(sbi->s_qf_names[qtype]); |
1348 | sbi->s_qf_names[qtype] = NULL; | 1396 | sbi->s_qf_names[qtype] = NULL; |
1349 | return 0; | 1397 | return 0; |
@@ -1358,9 +1406,9 @@ set_qf_name: | |||
1358 | clear_qf_name: | 1406 | clear_qf_name: |
1359 | if (sb_any_quota_loaded(sb) && | 1407 | if (sb_any_quota_loaded(sb) && |
1360 | sbi->s_qf_names[qtype]) { | 1408 | sbi->s_qf_names[qtype]) { |
1361 | printk(KERN_ERR "EXT4-fs: Cannot change " | 1409 | ext4_msg(sb, KERN_ERR, "Cannot change " |
1362 | "journaled quota options when " | 1410 | "journaled quota options when " |
1363 | "quota turned on.\n"); | 1411 | "quota turned on"); |
1364 | return 0; | 1412 | return 0; |
1365 | } | 1413 | } |
1366 | /* | 1414 | /* |
@@ -1377,9 +1425,9 @@ clear_qf_name: | |||
1377 | set_qf_format: | 1425 | set_qf_format: |
1378 | if (sb_any_quota_loaded(sb) && | 1426 | if (sb_any_quota_loaded(sb) && |
1379 | sbi->s_jquota_fmt != qfmt) { | 1427 | sbi->s_jquota_fmt != qfmt) { |
1380 | printk(KERN_ERR "EXT4-fs: Cannot change " | 1428 | ext4_msg(sb, KERN_ERR, "Cannot change " |
1381 | "journaled quota options when " | 1429 | "journaled quota options when " |
1382 | "quota turned on.\n"); | 1430 | "quota turned on"); |
1383 | return 0; | 1431 | return 0; |
1384 | } | 1432 | } |
1385 | sbi->s_jquota_fmt = qfmt; | 1433 | sbi->s_jquota_fmt = qfmt; |
@@ -1395,8 +1443,8 @@ set_qf_format: | |||
1395 | break; | 1443 | break; |
1396 | case Opt_noquota: | 1444 | case Opt_noquota: |
1397 | if (sb_any_quota_loaded(sb)) { | 1445 | if (sb_any_quota_loaded(sb)) { |
1398 | printk(KERN_ERR "EXT4-fs: Cannot change quota " | 1446 | ext4_msg(sb, KERN_ERR, "Cannot change quota " |
1399 | "options when quota turned on.\n"); | 1447 | "options when quota turned on"); |
1400 | return 0; | 1448 | return 0; |
1401 | } | 1449 | } |
1402 | clear_opt(sbi->s_mount_opt, QUOTA); | 1450 | clear_opt(sbi->s_mount_opt, QUOTA); |
@@ -1407,8 +1455,8 @@ set_qf_format: | |||
1407 | case Opt_quota: | 1455 | case Opt_quota: |
1408 | case Opt_usrquota: | 1456 | case Opt_usrquota: |
1409 | case Opt_grpquota: | 1457 | case Opt_grpquota: |
1410 | printk(KERN_ERR | 1458 | ext4_msg(sb, KERN_ERR, |
1411 | "EXT4-fs: quota options not supported.\n"); | 1459 | "quota options not supported"); |
1412 | break; | 1460 | break; |
1413 | case Opt_usrjquota: | 1461 | case Opt_usrjquota: |
1414 | case Opt_grpjquota: | 1462 | case Opt_grpjquota: |
@@ -1416,9 +1464,8 @@ set_qf_format: | |||
1416 | case Opt_offgrpjquota: | 1464 | case Opt_offgrpjquota: |
1417 | case Opt_jqfmt_vfsold: | 1465 | case Opt_jqfmt_vfsold: |
1418 | case Opt_jqfmt_vfsv0: | 1466 | case Opt_jqfmt_vfsv0: |
1419 | printk(KERN_ERR | 1467 | ext4_msg(sb, KERN_ERR, |
1420 | "EXT4-fs: journaled quota options not " | 1468 | "journaled quota options not supported"); |
1421 | "supported.\n"); | ||
1422 | break; | 1469 | break; |
1423 | case Opt_noquota: | 1470 | case Opt_noquota: |
1424 | break; | 1471 | break; |
@@ -1443,8 +1490,9 @@ set_qf_format: | |||
1443 | break; | 1490 | break; |
1444 | case Opt_resize: | 1491 | case Opt_resize: |
1445 | if (!is_remount) { | 1492 | if (!is_remount) { |
1446 | printk("EXT4-fs: resize option only available " | 1493 | ext4_msg(sb, KERN_ERR, |
1447 | "for remount\n"); | 1494 | "resize option only available " |
1495 | "for remount"); | ||
1448 | return 0; | 1496 | return 0; |
1449 | } | 1497 | } |
1450 | if (match_int(&args[0], &option) != 0) | 1498 | if (match_int(&args[0], &option) != 0) |
@@ -1474,14 +1522,21 @@ set_qf_format: | |||
1474 | case Opt_delalloc: | 1522 | case Opt_delalloc: |
1475 | set_opt(sbi->s_mount_opt, DELALLOC); | 1523 | set_opt(sbi->s_mount_opt, DELALLOC); |
1476 | break; | 1524 | break; |
1525 | case Opt_block_validity: | ||
1526 | set_opt(sbi->s_mount_opt, BLOCK_VALIDITY); | ||
1527 | break; | ||
1528 | case Opt_noblock_validity: | ||
1529 | clear_opt(sbi->s_mount_opt, BLOCK_VALIDITY); | ||
1530 | break; | ||
1477 | case Opt_inode_readahead_blks: | 1531 | case Opt_inode_readahead_blks: |
1478 | if (match_int(&args[0], &option)) | 1532 | if (match_int(&args[0], &option)) |
1479 | return 0; | 1533 | return 0; |
1480 | if (option < 0 || option > (1 << 30)) | 1534 | if (option < 0 || option > (1 << 30)) |
1481 | return 0; | 1535 | return 0; |
1482 | if (option & (option - 1)) { | 1536 | if (!is_power_of_2(option)) { |
1483 | printk(KERN_ERR "EXT4-fs: inode_readahead_blks" | 1537 | ext4_msg(sb, KERN_ERR, |
1484 | " must be a power of 2\n"); | 1538 | "EXT4-fs: inode_readahead_blks" |
1539 | " must be a power of 2"); | ||
1485 | return 0; | 1540 | return 0; |
1486 | } | 1541 | } |
1487 | sbi->s_inode_readahead_blks = option; | 1542 | sbi->s_inode_readahead_blks = option; |
@@ -1508,9 +1563,9 @@ set_qf_format: | |||
1508 | set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); | 1563 | set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); |
1509 | break; | 1564 | break; |
1510 | default: | 1565 | default: |
1511 | printk(KERN_ERR | 1566 | ext4_msg(sb, KERN_ERR, |
1512 | "EXT4-fs: Unrecognized mount option \"%s\" " | 1567 | "Unrecognized mount option \"%s\" " |
1513 | "or missing value\n", p); | 1568 | "or missing value", p); |
1514 | return 0; | 1569 | return 0; |
1515 | } | 1570 | } |
1516 | } | 1571 | } |
@@ -1528,21 +1583,21 @@ set_qf_format: | |||
1528 | (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA)) || | 1583 | (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA)) || |
1529 | (sbi->s_qf_names[GRPQUOTA] && | 1584 | (sbi->s_qf_names[GRPQUOTA] && |
1530 | (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA))) { | 1585 | (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA))) { |
1531 | printk(KERN_ERR "EXT4-fs: old and new quota " | 1586 | ext4_msg(sb, KERN_ERR, "old and new quota " |
1532 | "format mixing.\n"); | 1587 | "format mixing"); |
1533 | return 0; | 1588 | return 0; |
1534 | } | 1589 | } |
1535 | 1590 | ||
1536 | if (!sbi->s_jquota_fmt) { | 1591 | if (!sbi->s_jquota_fmt) { |
1537 | printk(KERN_ERR "EXT4-fs: journaled quota format " | 1592 | ext4_msg(sb, KERN_ERR, "journaled quota format " |
1538 | "not specified.\n"); | 1593 | "not specified"); |
1539 | return 0; | 1594 | return 0; |
1540 | } | 1595 | } |
1541 | } else { | 1596 | } else { |
1542 | if (sbi->s_jquota_fmt) { | 1597 | if (sbi->s_jquota_fmt) { |
1543 | printk(KERN_ERR "EXT4-fs: journaled quota format " | 1598 | ext4_msg(sb, KERN_ERR, "journaled quota format " |
1544 | "specified with no journaling " | 1599 | "specified with no journaling " |
1545 | "enabled.\n"); | 1600 | "enabled"); |
1546 | return 0; | 1601 | return 0; |
1547 | } | 1602 | } |
1548 | } | 1603 | } |
@@ -1557,32 +1612,32 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, | |||
1557 | int res = 0; | 1612 | int res = 0; |
1558 | 1613 | ||
1559 | if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) { | 1614 | if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) { |
1560 | printk(KERN_ERR "EXT4-fs warning: revision level too high, " | 1615 | ext4_msg(sb, KERN_ERR, "revision level too high, " |
1561 | "forcing read-only mode\n"); | 1616 | "forcing read-only mode"); |
1562 | res = MS_RDONLY; | 1617 | res = MS_RDONLY; |
1563 | } | 1618 | } |
1564 | if (read_only) | 1619 | if (read_only) |
1565 | return res; | 1620 | return res; |
1566 | if (!(sbi->s_mount_state & EXT4_VALID_FS)) | 1621 | if (!(sbi->s_mount_state & EXT4_VALID_FS)) |
1567 | printk(KERN_WARNING "EXT4-fs warning: mounting unchecked fs, " | 1622 | ext4_msg(sb, KERN_WARNING, "warning: mounting unchecked fs, " |
1568 | "running e2fsck is recommended\n"); | 1623 | "running e2fsck is recommended"); |
1569 | else if ((sbi->s_mount_state & EXT4_ERROR_FS)) | 1624 | else if ((sbi->s_mount_state & EXT4_ERROR_FS)) |
1570 | printk(KERN_WARNING | 1625 | ext4_msg(sb, KERN_WARNING, |
1571 | "EXT4-fs warning: mounting fs with errors, " | 1626 | "warning: mounting fs with errors, " |
1572 | "running e2fsck is recommended\n"); | 1627 | "running e2fsck is recommended"); |
1573 | else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && | 1628 | else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && |
1574 | le16_to_cpu(es->s_mnt_count) >= | 1629 | le16_to_cpu(es->s_mnt_count) >= |
1575 | (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) | 1630 | (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) |
1576 | printk(KERN_WARNING | 1631 | ext4_msg(sb, KERN_WARNING, |
1577 | "EXT4-fs warning: maximal mount count reached, " | 1632 | "warning: maximal mount count reached, " |
1578 | "running e2fsck is recommended\n"); | 1633 | "running e2fsck is recommended"); |
1579 | else if (le32_to_cpu(es->s_checkinterval) && | 1634 | else if (le32_to_cpu(es->s_checkinterval) && |
1580 | (le32_to_cpu(es->s_lastcheck) + | 1635 | (le32_to_cpu(es->s_lastcheck) + |
1581 | le32_to_cpu(es->s_checkinterval) <= get_seconds())) | 1636 | le32_to_cpu(es->s_checkinterval) <= get_seconds())) |
1582 | printk(KERN_WARNING | 1637 | ext4_msg(sb, KERN_WARNING, |
1583 | "EXT4-fs warning: checktime reached, " | 1638 | "warning: checktime reached, " |
1584 | "running e2fsck is recommended\n"); | 1639 | "running e2fsck is recommended"); |
1585 | if (!sbi->s_journal) | 1640 | if (!sbi->s_journal) |
1586 | es->s_state &= cpu_to_le16(~EXT4_VALID_FS); | 1641 | es->s_state &= cpu_to_le16(~EXT4_VALID_FS); |
1587 | if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) | 1642 | if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) |
1588 | es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT); | 1643 | es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT); |
@@ -1592,7 +1647,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, | |||
1592 | if (sbi->s_journal) | 1647 | if (sbi->s_journal) |
1593 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 1648 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
1594 | 1649 | ||
1595 | ext4_commit_super(sb, es, 1); | 1650 | ext4_commit_super(sb, 1); |
1596 | if (test_opt(sb, DEBUG)) | 1651 | if (test_opt(sb, DEBUG)) |
1597 | printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, " | 1652 | printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, " |
1598 | "bpg=%lu, ipg=%lu, mo=%04lx]\n", | 1653 | "bpg=%lu, ipg=%lu, mo=%04lx]\n", |
@@ -1603,11 +1658,11 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, | |||
1603 | sbi->s_mount_opt); | 1658 | sbi->s_mount_opt); |
1604 | 1659 | ||
1605 | if (EXT4_SB(sb)->s_journal) { | 1660 | if (EXT4_SB(sb)->s_journal) { |
1606 | printk(KERN_INFO "EXT4 FS on %s, %s journal on %s\n", | 1661 | ext4_msg(sb, KERN_INFO, "%s journal on %s", |
1607 | sb->s_id, EXT4_SB(sb)->s_journal->j_inode ? "internal" : | 1662 | EXT4_SB(sb)->s_journal->j_inode ? "internal" : |
1608 | "external", EXT4_SB(sb)->s_journal->j_devname); | 1663 | "external", EXT4_SB(sb)->s_journal->j_devname); |
1609 | } else { | 1664 | } else { |
1610 | printk(KERN_INFO "EXT4 FS on %s, no journal\n", sb->s_id); | 1665 | ext4_msg(sb, KERN_INFO, "no journal"); |
1611 | } | 1666 | } |
1612 | return res; | 1667 | return res; |
1613 | } | 1668 | } |
@@ -1616,10 +1671,10 @@ static int ext4_fill_flex_info(struct super_block *sb) | |||
1616 | { | 1671 | { |
1617 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 1672 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
1618 | struct ext4_group_desc *gdp = NULL; | 1673 | struct ext4_group_desc *gdp = NULL; |
1619 | struct buffer_head *bh; | ||
1620 | ext4_group_t flex_group_count; | 1674 | ext4_group_t flex_group_count; |
1621 | ext4_group_t flex_group; | 1675 | ext4_group_t flex_group; |
1622 | int groups_per_flex = 0; | 1676 | int groups_per_flex = 0; |
1677 | size_t size; | ||
1623 | int i; | 1678 | int i; |
1624 | 1679 | ||
1625 | if (!sbi->s_es->s_log_groups_per_flex) { | 1680 | if (!sbi->s_es->s_log_groups_per_flex) { |
@@ -1634,16 +1689,21 @@ static int ext4_fill_flex_info(struct super_block *sb) | |||
1634 | flex_group_count = ((sbi->s_groups_count + groups_per_flex - 1) + | 1689 | flex_group_count = ((sbi->s_groups_count + groups_per_flex - 1) + |
1635 | ((le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) + 1) << | 1690 | ((le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) + 1) << |
1636 | EXT4_DESC_PER_BLOCK_BITS(sb))) / groups_per_flex; | 1691 | EXT4_DESC_PER_BLOCK_BITS(sb))) / groups_per_flex; |
1637 | sbi->s_flex_groups = kzalloc(flex_group_count * | 1692 | size = flex_group_count * sizeof(struct flex_groups); |
1638 | sizeof(struct flex_groups), GFP_KERNEL); | 1693 | sbi->s_flex_groups = kzalloc(size, GFP_KERNEL); |
1694 | if (sbi->s_flex_groups == NULL) { | ||
1695 | sbi->s_flex_groups = vmalloc(size); | ||
1696 | if (sbi->s_flex_groups) | ||
1697 | memset(sbi->s_flex_groups, 0, size); | ||
1698 | } | ||
1639 | if (sbi->s_flex_groups == NULL) { | 1699 | if (sbi->s_flex_groups == NULL) { |
1640 | printk(KERN_ERR "EXT4-fs: not enough memory for " | 1700 | ext4_msg(sb, KERN_ERR, "not enough memory for " |
1641 | "%u flex groups\n", flex_group_count); | 1701 | "%u flex groups", flex_group_count); |
1642 | goto failed; | 1702 | goto failed; |
1643 | } | 1703 | } |
1644 | 1704 | ||
1645 | for (i = 0; i < sbi->s_groups_count; i++) { | 1705 | for (i = 0; i < sbi->s_groups_count; i++) { |
1646 | gdp = ext4_get_group_desc(sb, i, &bh); | 1706 | gdp = ext4_get_group_desc(sb, i, NULL); |
1647 | 1707 | ||
1648 | flex_group = ext4_flex_group(sbi, i); | 1708 | flex_group = ext4_flex_group(sbi, i); |
1649 | atomic_set(&sbi->s_flex_groups[flex_group].free_inodes, | 1709 | atomic_set(&sbi->s_flex_groups[flex_group].free_inodes, |
@@ -1724,44 +1784,44 @@ static int ext4_check_descriptors(struct super_block *sb) | |||
1724 | 1784 | ||
1725 | block_bitmap = ext4_block_bitmap(sb, gdp); | 1785 | block_bitmap = ext4_block_bitmap(sb, gdp); |
1726 | if (block_bitmap < first_block || block_bitmap > last_block) { | 1786 | if (block_bitmap < first_block || block_bitmap > last_block) { |
1727 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1787 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
1728 | "Block bitmap for group %u not in group " | 1788 | "Block bitmap for group %u not in group " |
1729 | "(block %llu)!\n", i, block_bitmap); | 1789 | "(block %llu)!", i, block_bitmap); |
1730 | return 0; | 1790 | return 0; |
1731 | } | 1791 | } |
1732 | inode_bitmap = ext4_inode_bitmap(sb, gdp); | 1792 | inode_bitmap = ext4_inode_bitmap(sb, gdp); |
1733 | if (inode_bitmap < first_block || inode_bitmap > last_block) { | 1793 | if (inode_bitmap < first_block || inode_bitmap > last_block) { |
1734 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1794 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
1735 | "Inode bitmap for group %u not in group " | 1795 | "Inode bitmap for group %u not in group " |
1736 | "(block %llu)!\n", i, inode_bitmap); | 1796 | "(block %llu)!", i, inode_bitmap); |
1737 | return 0; | 1797 | return 0; |
1738 | } | 1798 | } |
1739 | inode_table = ext4_inode_table(sb, gdp); | 1799 | inode_table = ext4_inode_table(sb, gdp); |
1740 | if (inode_table < first_block || | 1800 | if (inode_table < first_block || |
1741 | inode_table + sbi->s_itb_per_group - 1 > last_block) { | 1801 | inode_table + sbi->s_itb_per_group - 1 > last_block) { |
1742 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1802 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
1743 | "Inode table for group %u not in group " | 1803 | "Inode table for group %u not in group " |
1744 | "(block %llu)!\n", i, inode_table); | 1804 | "(block %llu)!", i, inode_table); |
1745 | return 0; | 1805 | return 0; |
1746 | } | 1806 | } |
1747 | spin_lock(sb_bgl_lock(sbi, i)); | 1807 | ext4_lock_group(sb, i); |
1748 | if (!ext4_group_desc_csum_verify(sbi, i, gdp)) { | 1808 | if (!ext4_group_desc_csum_verify(sbi, i, gdp)) { |
1749 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1809 | ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " |
1750 | "Checksum for group %u failed (%u!=%u)\n", | 1810 | "Checksum for group %u failed (%u!=%u)", |
1751 | i, le16_to_cpu(ext4_group_desc_csum(sbi, i, | 1811 | i, le16_to_cpu(ext4_group_desc_csum(sbi, i, |
1752 | gdp)), le16_to_cpu(gdp->bg_checksum)); | 1812 | gdp)), le16_to_cpu(gdp->bg_checksum)); |
1753 | if (!(sb->s_flags & MS_RDONLY)) { | 1813 | if (!(sb->s_flags & MS_RDONLY)) { |
1754 | spin_unlock(sb_bgl_lock(sbi, i)); | 1814 | ext4_unlock_group(sb, i); |
1755 | return 0; | 1815 | return 0; |
1756 | } | 1816 | } |
1757 | } | 1817 | } |
1758 | spin_unlock(sb_bgl_lock(sbi, i)); | 1818 | ext4_unlock_group(sb, i); |
1759 | if (!flexbg_flag) | 1819 | if (!flexbg_flag) |
1760 | first_block += EXT4_BLOCKS_PER_GROUP(sb); | 1820 | first_block += EXT4_BLOCKS_PER_GROUP(sb); |
1761 | } | 1821 | } |
1762 | 1822 | ||
1763 | ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb)); | 1823 | 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)); | 1824 | sbi->s_es->s_free_inodes_count =cpu_to_le32(ext4_count_free_inodes(sb)); |
1765 | return 1; | 1825 | return 1; |
1766 | } | 1826 | } |
1767 | 1827 | ||
@@ -1796,8 +1856,8 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1796 | } | 1856 | } |
1797 | 1857 | ||
1798 | if (bdev_read_only(sb->s_bdev)) { | 1858 | if (bdev_read_only(sb->s_bdev)) { |
1799 | printk(KERN_ERR "EXT4-fs: write access " | 1859 | ext4_msg(sb, KERN_ERR, "write access " |
1800 | "unavailable, skipping orphan cleanup.\n"); | 1860 | "unavailable, skipping orphan cleanup"); |
1801 | return; | 1861 | return; |
1802 | } | 1862 | } |
1803 | 1863 | ||
@@ -1811,8 +1871,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1811 | } | 1871 | } |
1812 | 1872 | ||
1813 | if (s_flags & MS_RDONLY) { | 1873 | if (s_flags & MS_RDONLY) { |
1814 | printk(KERN_INFO "EXT4-fs: %s: orphan cleanup on readonly fs\n", | 1874 | ext4_msg(sb, KERN_INFO, "orphan cleanup on readonly fs"); |
1815 | sb->s_id); | ||
1816 | sb->s_flags &= ~MS_RDONLY; | 1875 | sb->s_flags &= ~MS_RDONLY; |
1817 | } | 1876 | } |
1818 | #ifdef CONFIG_QUOTA | 1877 | #ifdef CONFIG_QUOTA |
@@ -1823,9 +1882,9 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1823 | if (EXT4_SB(sb)->s_qf_names[i]) { | 1882 | if (EXT4_SB(sb)->s_qf_names[i]) { |
1824 | int ret = ext4_quota_on_mount(sb, i); | 1883 | int ret = ext4_quota_on_mount(sb, i); |
1825 | if (ret < 0) | 1884 | if (ret < 0) |
1826 | printk(KERN_ERR | 1885 | ext4_msg(sb, KERN_ERR, |
1827 | "EXT4-fs: Cannot turn on journaled " | 1886 | "Cannot turn on journaled " |
1828 | "quota: error %d\n", ret); | 1887 | "quota: error %d", ret); |
1829 | } | 1888 | } |
1830 | } | 1889 | } |
1831 | #endif | 1890 | #endif |
@@ -1842,16 +1901,16 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1842 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); | 1901 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); |
1843 | vfs_dq_init(inode); | 1902 | vfs_dq_init(inode); |
1844 | if (inode->i_nlink) { | 1903 | if (inode->i_nlink) { |
1845 | printk(KERN_DEBUG | 1904 | ext4_msg(sb, KERN_DEBUG, |
1846 | "%s: truncating inode %lu to %lld bytes\n", | 1905 | "%s: truncating inode %lu to %lld bytes", |
1847 | __func__, inode->i_ino, inode->i_size); | 1906 | __func__, inode->i_ino, inode->i_size); |
1848 | jbd_debug(2, "truncating inode %lu to %lld bytes\n", | 1907 | jbd_debug(2, "truncating inode %lu to %lld bytes\n", |
1849 | inode->i_ino, inode->i_size); | 1908 | inode->i_ino, inode->i_size); |
1850 | ext4_truncate(inode); | 1909 | ext4_truncate(inode); |
1851 | nr_truncates++; | 1910 | nr_truncates++; |
1852 | } else { | 1911 | } else { |
1853 | printk(KERN_DEBUG | 1912 | ext4_msg(sb, KERN_DEBUG, |
1854 | "%s: deleting unreferenced inode %lu\n", | 1913 | "%s: deleting unreferenced inode %lu", |
1855 | __func__, inode->i_ino); | 1914 | __func__, inode->i_ino); |
1856 | jbd_debug(2, "deleting unreferenced inode %lu\n", | 1915 | jbd_debug(2, "deleting unreferenced inode %lu\n", |
1857 | inode->i_ino); | 1916 | inode->i_ino); |
@@ -1863,11 +1922,11 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1863 | #define PLURAL(x) (x), ((x) == 1) ? "" : "s" | 1922 | #define PLURAL(x) (x), ((x) == 1) ? "" : "s" |
1864 | 1923 | ||
1865 | if (nr_orphans) | 1924 | if (nr_orphans) |
1866 | printk(KERN_INFO "EXT4-fs: %s: %d orphan inode%s deleted\n", | 1925 | ext4_msg(sb, KERN_INFO, "%d orphan inode%s deleted", |
1867 | sb->s_id, PLURAL(nr_orphans)); | 1926 | PLURAL(nr_orphans)); |
1868 | if (nr_truncates) | 1927 | if (nr_truncates) |
1869 | printk(KERN_INFO "EXT4-fs: %s: %d truncate%s cleaned up\n", | 1928 | ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up", |
1870 | sb->s_id, PLURAL(nr_truncates)); | 1929 | PLURAL(nr_truncates)); |
1871 | #ifdef CONFIG_QUOTA | 1930 | #ifdef CONFIG_QUOTA |
1872 | /* Turn quotas off */ | 1931 | /* Turn quotas off */ |
1873 | for (i = 0; i < MAXQUOTAS; i++) { | 1932 | for (i = 0; i < MAXQUOTAS; i++) { |
@@ -1877,6 +1936,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1877 | #endif | 1936 | #endif |
1878 | sb->s_flags = s_flags; /* Restore MS_RDONLY status */ | 1937 | sb->s_flags = s_flags; /* Restore MS_RDONLY status */ |
1879 | } | 1938 | } |
1939 | |||
1880 | /* | 1940 | /* |
1881 | * Maximal extent format file size. | 1941 | * Maximal extent format file size. |
1882 | * Resulting logical blkno at s_maxbytes must fit in our on-disk | 1942 | * Resulting logical blkno at s_maxbytes must fit in our on-disk |
@@ -1927,19 +1987,19 @@ static loff_t ext4_max_bitmap_size(int bits, int has_huge_files) | |||
1927 | loff_t res = EXT4_NDIR_BLOCKS; | 1987 | loff_t res = EXT4_NDIR_BLOCKS; |
1928 | int meta_blocks; | 1988 | int meta_blocks; |
1929 | loff_t upper_limit; | 1989 | loff_t upper_limit; |
1930 | /* This is calculated to be the largest file size for a | 1990 | /* This is calculated to be the largest file size for a dense, block |
1931 | * dense, bitmapped file such that the total number of | 1991 | * mapped file such that the file's total number of 512-byte sectors, |
1932 | * sectors in the file, including data and all indirect blocks, | 1992 | * including data and all indirect blocks, does not exceed (2^48 - 1). |
1933 | * does not exceed 2^48 -1 | 1993 | * |
1934 | * __u32 i_blocks_lo and _u16 i_blocks_high representing the | 1994 | * __u32 i_blocks_lo and _u16 i_blocks_high represent the total |
1935 | * total number of 512 bytes blocks of the file | 1995 | * number of 512-byte sectors of the file. |
1936 | */ | 1996 | */ |
1937 | 1997 | ||
1938 | if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { | 1998 | if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { |
1939 | /* | 1999 | /* |
1940 | * !has_huge_files or CONFIG_LBD is not enabled | 2000 | * !has_huge_files or CONFIG_LBD not enabled implies that |
1941 | * implies the inode i_block represent total blocks in | 2001 | * the inode i_block field represents total file blocks in |
1942 | * 512 bytes 32 == size of vfs inode i_blocks * 8 | 2002 | * 2^32 512-byte sectors == size of vfs inode i_blocks * 8 |
1943 | */ | 2003 | */ |
1944 | upper_limit = (1LL << 32) - 1; | 2004 | upper_limit = (1LL << 32) - 1; |
1945 | 2005 | ||
@@ -1981,7 +2041,7 @@ static loff_t ext4_max_bitmap_size(int bits, int has_huge_files) | |||
1981 | } | 2041 | } |
1982 | 2042 | ||
1983 | static ext4_fsblk_t descriptor_loc(struct super_block *sb, | 2043 | static ext4_fsblk_t descriptor_loc(struct super_block *sb, |
1984 | ext4_fsblk_t logical_sb_block, int nr) | 2044 | ext4_fsblk_t logical_sb_block, int nr) |
1985 | { | 2045 | { |
1986 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 2046 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
1987 | ext4_group_t bg, first_meta_bg; | 2047 | ext4_group_t bg, first_meta_bg; |
@@ -1995,6 +2055,7 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb, | |||
1995 | bg = sbi->s_desc_per_block * nr; | 2055 | bg = sbi->s_desc_per_block * nr; |
1996 | if (ext4_bg_has_super(sb, bg)) | 2056 | if (ext4_bg_has_super(sb, bg)) |
1997 | has_super = 1; | 2057 | has_super = 1; |
2058 | |||
1998 | return (has_super + ext4_group_first_block_no(sb, bg)); | 2059 | return (has_super + ext4_group_first_block_no(sb, bg)); |
1999 | } | 2060 | } |
2000 | 2061 | ||
@@ -2091,8 +2152,7 @@ static ssize_t inode_readahead_blks_store(struct ext4_attr *a, | |||
2091 | if (parse_strtoul(buf, 0x40000000, &t)) | 2152 | if (parse_strtoul(buf, 0x40000000, &t)) |
2092 | return -EINVAL; | 2153 | return -EINVAL; |
2093 | 2154 | ||
2094 | /* inode_readahead_blks must be a power of 2 */ | 2155 | if (!is_power_of_2(t)) |
2095 | if (t & (t-1)) | ||
2096 | return -EINVAL; | 2156 | return -EINVAL; |
2097 | 2157 | ||
2098 | sbi->s_inode_readahead_blks = t; | 2158 | sbi->s_inode_readahead_blks = t; |
@@ -2100,7 +2160,7 @@ static ssize_t inode_readahead_blks_store(struct ext4_attr *a, | |||
2100 | } | 2160 | } |
2101 | 2161 | ||
2102 | static ssize_t sbi_ui_show(struct ext4_attr *a, | 2162 | static ssize_t sbi_ui_show(struct ext4_attr *a, |
2103 | struct ext4_sb_info *sbi, char *buf) | 2163 | struct ext4_sb_info *sbi, char *buf) |
2104 | { | 2164 | { |
2105 | unsigned int *ui = (unsigned int *) (((char *) sbi) + a->offset); | 2165 | unsigned int *ui = (unsigned int *) (((char *) sbi) + a->offset); |
2106 | 2166 | ||
@@ -2205,7 +2265,6 @@ static struct kobj_type ext4_ktype = { | |||
2205 | static int ext4_fill_super(struct super_block *sb, void *data, int silent) | 2265 | static int ext4_fill_super(struct super_block *sb, void *data, int silent) |
2206 | __releases(kernel_lock) | 2266 | __releases(kernel_lock) |
2207 | __acquires(kernel_lock) | 2267 | __acquires(kernel_lock) |
2208 | |||
2209 | { | 2268 | { |
2210 | struct buffer_head *bh; | 2269 | struct buffer_head *bh; |
2211 | struct ext4_super_block *es = NULL; | 2270 | struct ext4_super_block *es = NULL; |
@@ -2256,7 +2315,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2256 | 2315 | ||
2257 | blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); | 2316 | blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); |
2258 | if (!blocksize) { | 2317 | if (!blocksize) { |
2259 | printk(KERN_ERR "EXT4-fs: unable to set blocksize\n"); | 2318 | ext4_msg(sb, KERN_ERR, "unable to set blocksize"); |
2260 | goto out_fail; | 2319 | goto out_fail; |
2261 | } | 2320 | } |
2262 | 2321 | ||
@@ -2272,7 +2331,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2272 | } | 2331 | } |
2273 | 2332 | ||
2274 | if (!(bh = sb_bread(sb, logical_sb_block))) { | 2333 | if (!(bh = sb_bread(sb, logical_sb_block))) { |
2275 | printk(KERN_ERR "EXT4-fs: unable to read superblock\n"); | 2334 | ext4_msg(sb, KERN_ERR, "unable to read superblock"); |
2276 | goto out_fail; | 2335 | goto out_fail; |
2277 | } | 2336 | } |
2278 | /* | 2337 | /* |
@@ -2321,6 +2380,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; | 2380 | sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ; |
2322 | sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; | 2381 | sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; |
2323 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; | 2382 | sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; |
2383 | sbi->s_mb_history_max = default_mb_history_length; | ||
2324 | 2384 | ||
2325 | set_opt(sbi->s_mount_opt, BARRIER); | 2385 | set_opt(sbi->s_mount_opt, BARRIER); |
2326 | 2386 | ||
@@ -2330,7 +2390,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2330 | */ | 2390 | */ |
2331 | set_opt(sbi->s_mount_opt, DELALLOC); | 2391 | set_opt(sbi->s_mount_opt, DELALLOC); |
2332 | 2392 | ||
2333 | |||
2334 | if (!parse_options((char *) data, sb, &journal_devnum, | 2393 | if (!parse_options((char *) data, sb, &journal_devnum, |
2335 | &journal_ioprio, NULL, 0)) | 2394 | &journal_ioprio, NULL, 0)) |
2336 | goto failed_mount; | 2395 | goto failed_mount; |
@@ -2342,9 +2401,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2342 | (EXT4_HAS_COMPAT_FEATURE(sb, ~0U) || | 2401 | (EXT4_HAS_COMPAT_FEATURE(sb, ~0U) || |
2343 | EXT4_HAS_RO_COMPAT_FEATURE(sb, ~0U) || | 2402 | EXT4_HAS_RO_COMPAT_FEATURE(sb, ~0U) || |
2344 | EXT4_HAS_INCOMPAT_FEATURE(sb, ~0U))) | 2403 | EXT4_HAS_INCOMPAT_FEATURE(sb, ~0U))) |
2345 | printk(KERN_WARNING | 2404 | ext4_msg(sb, KERN_WARNING, |
2346 | "EXT4-fs warning: feature flags set on rev 0 fs, " | 2405 | "feature flags set on rev 0 fs, " |
2347 | "running e2fsck is recommended\n"); | 2406 | "running e2fsck is recommended"); |
2348 | 2407 | ||
2349 | /* | 2408 | /* |
2350 | * Check feature flags regardless of the revision level, since we | 2409 | * Check feature flags regardless of the revision level, since we |
@@ -2353,16 +2412,18 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2353 | */ | 2412 | */ |
2354 | features = EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP); | 2413 | features = EXT4_HAS_INCOMPAT_FEATURE(sb, ~EXT4_FEATURE_INCOMPAT_SUPP); |
2355 | if (features) { | 2414 | if (features) { |
2356 | printk(KERN_ERR "EXT4-fs: %s: couldn't mount because of " | 2415 | ext4_msg(sb, KERN_ERR, |
2357 | "unsupported optional features (%x).\n", sb->s_id, | 2416 | "Couldn't mount because of " |
2417 | "unsupported optional features (%x)", | ||
2358 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) & | 2418 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) & |
2359 | ~EXT4_FEATURE_INCOMPAT_SUPP)); | 2419 | ~EXT4_FEATURE_INCOMPAT_SUPP)); |
2360 | goto failed_mount; | 2420 | goto failed_mount; |
2361 | } | 2421 | } |
2362 | features = EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP); | 2422 | features = EXT4_HAS_RO_COMPAT_FEATURE(sb, ~EXT4_FEATURE_RO_COMPAT_SUPP); |
2363 | if (!(sb->s_flags & MS_RDONLY) && features) { | 2423 | if (!(sb->s_flags & MS_RDONLY) && features) { |
2364 | printk(KERN_ERR "EXT4-fs: %s: couldn't mount RDWR because of " | 2424 | ext4_msg(sb, KERN_ERR, |
2365 | "unsupported optional features (%x).\n", sb->s_id, | 2425 | "Couldn't mount RDWR because of " |
2426 | "unsupported optional features (%x)", | ||
2366 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) & | 2427 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) & |
2367 | ~EXT4_FEATURE_RO_COMPAT_SUPP)); | 2428 | ~EXT4_FEATURE_RO_COMPAT_SUPP)); |
2368 | goto failed_mount; | 2429 | goto failed_mount; |
@@ -2376,9 +2437,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2376 | */ | 2437 | */ |
2377 | if (sizeof(root->i_blocks) < sizeof(u64) && | 2438 | if (sizeof(root->i_blocks) < sizeof(u64) && |
2378 | !(sb->s_flags & MS_RDONLY)) { | 2439 | !(sb->s_flags & MS_RDONLY)) { |
2379 | printk(KERN_ERR "EXT4-fs: %s: Filesystem with huge " | 2440 | ext4_msg(sb, KERN_ERR, "Filesystem with huge " |
2380 | "files cannot be mounted read-write " | 2441 | "files cannot be mounted read-write " |
2381 | "without CONFIG_LBD.\n", sb->s_id); | 2442 | "without CONFIG_LBD"); |
2382 | goto failed_mount; | 2443 | goto failed_mount; |
2383 | } | 2444 | } |
2384 | } | 2445 | } |
@@ -2386,17 +2447,15 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2386 | 2447 | ||
2387 | if (blocksize < EXT4_MIN_BLOCK_SIZE || | 2448 | if (blocksize < EXT4_MIN_BLOCK_SIZE || |
2388 | blocksize > EXT4_MAX_BLOCK_SIZE) { | 2449 | blocksize > EXT4_MAX_BLOCK_SIZE) { |
2389 | printk(KERN_ERR | 2450 | ext4_msg(sb, KERN_ERR, |
2390 | "EXT4-fs: Unsupported filesystem blocksize %d on %s.\n", | 2451 | "Unsupported filesystem blocksize %d", blocksize); |
2391 | blocksize, sb->s_id); | ||
2392 | goto failed_mount; | 2452 | goto failed_mount; |
2393 | } | 2453 | } |
2394 | 2454 | ||
2395 | if (sb->s_blocksize != blocksize) { | 2455 | if (sb->s_blocksize != blocksize) { |
2396 | |||
2397 | /* Validate the filesystem blocksize */ | 2456 | /* Validate the filesystem blocksize */ |
2398 | if (!sb_set_blocksize(sb, blocksize)) { | 2457 | if (!sb_set_blocksize(sb, blocksize)) { |
2399 | printk(KERN_ERR "EXT4-fs: bad block size %d.\n", | 2458 | ext4_msg(sb, KERN_ERR, "bad block size %d", |
2400 | blocksize); | 2459 | blocksize); |
2401 | goto failed_mount; | 2460 | goto failed_mount; |
2402 | } | 2461 | } |
@@ -2406,15 +2465,15 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2406 | offset = do_div(logical_sb_block, blocksize); | 2465 | offset = do_div(logical_sb_block, blocksize); |
2407 | bh = sb_bread(sb, logical_sb_block); | 2466 | bh = sb_bread(sb, logical_sb_block); |
2408 | if (!bh) { | 2467 | if (!bh) { |
2409 | printk(KERN_ERR | 2468 | ext4_msg(sb, KERN_ERR, |
2410 | "EXT4-fs: Can't read superblock on 2nd try.\n"); | 2469 | "Can't read superblock on 2nd try"); |
2411 | goto failed_mount; | 2470 | goto failed_mount; |
2412 | } | 2471 | } |
2413 | es = (struct ext4_super_block *)(((char *)bh->b_data) + offset); | 2472 | es = (struct ext4_super_block *)(((char *)bh->b_data) + offset); |
2414 | sbi->s_es = es; | 2473 | sbi->s_es = es; |
2415 | if (es->s_magic != cpu_to_le16(EXT4_SUPER_MAGIC)) { | 2474 | if (es->s_magic != cpu_to_le16(EXT4_SUPER_MAGIC)) { |
2416 | printk(KERN_ERR | 2475 | ext4_msg(sb, KERN_ERR, |
2417 | "EXT4-fs: Magic mismatch, very weird !\n"); | 2476 | "Magic mismatch, very weird!"); |
2418 | goto failed_mount; | 2477 | goto failed_mount; |
2419 | } | 2478 | } |
2420 | } | 2479 | } |
@@ -2432,30 +2491,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) || | 2491 | if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) || |
2433 | (!is_power_of_2(sbi->s_inode_size)) || | 2492 | (!is_power_of_2(sbi->s_inode_size)) || |
2434 | (sbi->s_inode_size > blocksize)) { | 2493 | (sbi->s_inode_size > blocksize)) { |
2435 | printk(KERN_ERR | 2494 | ext4_msg(sb, KERN_ERR, |
2436 | "EXT4-fs: unsupported inode size: %d\n", | 2495 | "unsupported inode size: %d", |
2437 | sbi->s_inode_size); | 2496 | sbi->s_inode_size); |
2438 | goto failed_mount; | 2497 | goto failed_mount; |
2439 | } | 2498 | } |
2440 | if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) | 2499 | if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) |
2441 | sb->s_time_gran = 1 << (EXT4_EPOCH_BITS - 2); | 2500 | sb->s_time_gran = 1 << (EXT4_EPOCH_BITS - 2); |
2442 | } | 2501 | } |
2502 | |||
2443 | sbi->s_desc_size = le16_to_cpu(es->s_desc_size); | 2503 | sbi->s_desc_size = le16_to_cpu(es->s_desc_size); |
2444 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) { | 2504 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) { |
2445 | if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT || | 2505 | if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT || |
2446 | sbi->s_desc_size > EXT4_MAX_DESC_SIZE || | 2506 | sbi->s_desc_size > EXT4_MAX_DESC_SIZE || |
2447 | !is_power_of_2(sbi->s_desc_size)) { | 2507 | !is_power_of_2(sbi->s_desc_size)) { |
2448 | printk(KERN_ERR | 2508 | ext4_msg(sb, KERN_ERR, |
2449 | "EXT4-fs: unsupported descriptor size %lu\n", | 2509 | "unsupported descriptor size %lu", |
2450 | sbi->s_desc_size); | 2510 | sbi->s_desc_size); |
2451 | goto failed_mount; | 2511 | goto failed_mount; |
2452 | } | 2512 | } |
2453 | } else | 2513 | } else |
2454 | sbi->s_desc_size = EXT4_MIN_DESC_SIZE; | 2514 | sbi->s_desc_size = EXT4_MIN_DESC_SIZE; |
2515 | |||
2455 | sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group); | 2516 | 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); | 2517 | 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) | 2518 | if (EXT4_INODE_SIZE(sb) == 0 || EXT4_INODES_PER_GROUP(sb) == 0) |
2458 | goto cantfind_ext4; | 2519 | goto cantfind_ext4; |
2520 | |||
2459 | sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb); | 2521 | sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb); |
2460 | if (sbi->s_inodes_per_block == 0) | 2522 | if (sbi->s_inodes_per_block == 0) |
2461 | goto cantfind_ext4; | 2523 | goto cantfind_ext4; |
@@ -2466,6 +2528,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); | 2528 | sbi->s_mount_state = le16_to_cpu(es->s_state); |
2467 | sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); | 2529 | 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)); | 2530 | sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); |
2531 | |||
2469 | for (i = 0; i < 4; i++) | 2532 | for (i = 0; i < 4; i++) |
2470 | sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); | 2533 | sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); |
2471 | sbi->s_def_hash_version = es->s_def_hash_version; | 2534 | sbi->s_def_hash_version = es->s_def_hash_version; |
@@ -2483,25 +2546,24 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2483 | } | 2546 | } |
2484 | 2547 | ||
2485 | if (sbi->s_blocks_per_group > blocksize * 8) { | 2548 | if (sbi->s_blocks_per_group > blocksize * 8) { |
2486 | printk(KERN_ERR | 2549 | ext4_msg(sb, KERN_ERR, |
2487 | "EXT4-fs: #blocks per group too big: %lu\n", | 2550 | "#blocks per group too big: %lu", |
2488 | sbi->s_blocks_per_group); | 2551 | sbi->s_blocks_per_group); |
2489 | goto failed_mount; | 2552 | goto failed_mount; |
2490 | } | 2553 | } |
2491 | if (sbi->s_inodes_per_group > blocksize * 8) { | 2554 | if (sbi->s_inodes_per_group > blocksize * 8) { |
2492 | printk(KERN_ERR | 2555 | ext4_msg(sb, KERN_ERR, |
2493 | "EXT4-fs: #inodes per group too big: %lu\n", | 2556 | "#inodes per group too big: %lu", |
2494 | sbi->s_inodes_per_group); | 2557 | sbi->s_inodes_per_group); |
2495 | goto failed_mount; | 2558 | goto failed_mount; |
2496 | } | 2559 | } |
2497 | 2560 | ||
2498 | if (ext4_blocks_count(es) > | 2561 | if (ext4_blocks_count(es) > |
2499 | (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { | 2562 | (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { |
2500 | printk(KERN_ERR "EXT4-fs: filesystem on %s:" | 2563 | ext4_msg(sb, KERN_ERR, "filesystem" |
2501 | " too large to mount safely\n", sb->s_id); | 2564 | " too large to mount safely"); |
2502 | if (sizeof(sector_t) < 8) | 2565 | if (sizeof(sector_t) < 8) |
2503 | printk(KERN_WARNING "EXT4-fs: CONFIG_LBD not " | 2566 | ext4_msg(sb, KERN_WARNING, "CONFIG_LBD not enabled"); |
2504 | "enabled\n"); | ||
2505 | goto failed_mount; | 2567 | goto failed_mount; |
2506 | } | 2568 | } |
2507 | 2569 | ||
@@ -2511,21 +2573,21 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2511 | /* check blocks count against device size */ | 2573 | /* check blocks count against device size */ |
2512 | blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; | 2574 | blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; |
2513 | if (blocks_count && ext4_blocks_count(es) > blocks_count) { | 2575 | if (blocks_count && ext4_blocks_count(es) > blocks_count) { |
2514 | printk(KERN_WARNING "EXT4-fs: bad geometry: block count %llu " | 2576 | ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu " |
2515 | "exceeds size of device (%llu blocks)\n", | 2577 | "exceeds size of device (%llu blocks)", |
2516 | ext4_blocks_count(es), blocks_count); | 2578 | ext4_blocks_count(es), blocks_count); |
2517 | goto failed_mount; | 2579 | goto failed_mount; |
2518 | } | 2580 | } |
2519 | 2581 | ||
2520 | /* | 2582 | /* |
2521 | * It makes no sense for the first data block to be beyond the end | 2583 | * It makes no sense for the first data block to be beyond the end |
2522 | * of the filesystem. | 2584 | * of the filesystem. |
2523 | */ | 2585 | */ |
2524 | if (le32_to_cpu(es->s_first_data_block) >= ext4_blocks_count(es)) { | 2586 | if (le32_to_cpu(es->s_first_data_block) >= ext4_blocks_count(es)) { |
2525 | printk(KERN_WARNING "EXT4-fs: bad geometry: first data" | 2587 | ext4_msg(sb, KERN_WARNING, "bad geometry: first data" |
2526 | "block %u is beyond end of filesystem (%llu)\n", | 2588 | "block %u is beyond end of filesystem (%llu)", |
2527 | le32_to_cpu(es->s_first_data_block), | 2589 | le32_to_cpu(es->s_first_data_block), |
2528 | ext4_blocks_count(es)); | 2590 | ext4_blocks_count(es)); |
2529 | goto failed_mount; | 2591 | goto failed_mount; |
2530 | } | 2592 | } |
2531 | blocks_count = (ext4_blocks_count(es) - | 2593 | blocks_count = (ext4_blocks_count(es) - |
@@ -2533,9 +2595,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2533 | EXT4_BLOCKS_PER_GROUP(sb) - 1); | 2595 | EXT4_BLOCKS_PER_GROUP(sb) - 1); |
2534 | do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb)); | 2596 | do_div(blocks_count, EXT4_BLOCKS_PER_GROUP(sb)); |
2535 | if (blocks_count > ((uint64_t)1<<32) - EXT4_DESC_PER_BLOCK(sb)) { | 2597 | if (blocks_count > ((uint64_t)1<<32) - EXT4_DESC_PER_BLOCK(sb)) { |
2536 | printk(KERN_WARNING "EXT4-fs: groups count too large: %u " | 2598 | ext4_msg(sb, KERN_WARNING, "groups count too large: %u " |
2537 | "(block count %llu, first data block %u, " | 2599 | "(block count %llu, first data block %u, " |
2538 | "blocks per group %lu)\n", sbi->s_groups_count, | 2600 | "blocks per group %lu)", sbi->s_groups_count, |
2539 | ext4_blocks_count(es), | 2601 | ext4_blocks_count(es), |
2540 | le32_to_cpu(es->s_first_data_block), | 2602 | le32_to_cpu(es->s_first_data_block), |
2541 | EXT4_BLOCKS_PER_GROUP(sb)); | 2603 | EXT4_BLOCKS_PER_GROUP(sb)); |
@@ -2547,7 +2609,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 *), | 2609 | sbi->s_group_desc = kmalloc(db_count * sizeof(struct buffer_head *), |
2548 | GFP_KERNEL); | 2610 | GFP_KERNEL); |
2549 | if (sbi->s_group_desc == NULL) { | 2611 | if (sbi->s_group_desc == NULL) { |
2550 | printk(KERN_ERR "EXT4-fs: not enough memory\n"); | 2612 | ext4_msg(sb, KERN_ERR, "not enough memory"); |
2551 | goto failed_mount; | 2613 | goto failed_mount; |
2552 | } | 2614 | } |
2553 | 2615 | ||
@@ -2562,21 +2624,21 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2562 | block = descriptor_loc(sb, logical_sb_block, i); | 2624 | block = descriptor_loc(sb, logical_sb_block, i); |
2563 | sbi->s_group_desc[i] = sb_bread(sb, block); | 2625 | sbi->s_group_desc[i] = sb_bread(sb, block); |
2564 | if (!sbi->s_group_desc[i]) { | 2626 | if (!sbi->s_group_desc[i]) { |
2565 | printk(KERN_ERR "EXT4-fs: " | 2627 | ext4_msg(sb, KERN_ERR, |
2566 | "can't read group descriptor %d\n", i); | 2628 | "can't read group descriptor %d", i); |
2567 | db_count = i; | 2629 | db_count = i; |
2568 | goto failed_mount2; | 2630 | goto failed_mount2; |
2569 | } | 2631 | } |
2570 | } | 2632 | } |
2571 | if (!ext4_check_descriptors(sb)) { | 2633 | if (!ext4_check_descriptors(sb)) { |
2572 | printk(KERN_ERR "EXT4-fs: group descriptors corrupted!\n"); | 2634 | ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); |
2573 | goto failed_mount2; | 2635 | goto failed_mount2; |
2574 | } | 2636 | } |
2575 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) | 2637 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) |
2576 | if (!ext4_fill_flex_info(sb)) { | 2638 | if (!ext4_fill_flex_info(sb)) { |
2577 | printk(KERN_ERR | 2639 | ext4_msg(sb, KERN_ERR, |
2578 | "EXT4-fs: unable to initialize " | 2640 | "unable to initialize " |
2579 | "flex_bg meta info!\n"); | 2641 | "flex_bg meta info!"); |
2580 | goto failed_mount2; | 2642 | goto failed_mount2; |
2581 | } | 2643 | } |
2582 | 2644 | ||
@@ -2598,7 +2660,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2598 | err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); | 2660 | err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); |
2599 | } | 2661 | } |
2600 | if (err) { | 2662 | if (err) { |
2601 | printk(KERN_ERR "EXT4-fs: insufficient memory\n"); | 2663 | ext4_msg(sb, KERN_ERR, "insufficient memory"); |
2602 | goto failed_mount3; | 2664 | goto failed_mount3; |
2603 | } | 2665 | } |
2604 | 2666 | ||
@@ -2607,7 +2669,11 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2607 | /* | 2669 | /* |
2608 | * set up enough so that it can read an inode | 2670 | * set up enough so that it can read an inode |
2609 | */ | 2671 | */ |
2610 | sb->s_op = &ext4_sops; | 2672 | if (!test_opt(sb, NOLOAD) && |
2673 | EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) | ||
2674 | sb->s_op = &ext4_sops; | ||
2675 | else | ||
2676 | sb->s_op = &ext4_nojournal_sops; | ||
2611 | sb->s_export_op = &ext4_export_ops; | 2677 | sb->s_export_op = &ext4_export_ops; |
2612 | sb->s_xattr = ext4_xattr_handlers; | 2678 | sb->s_xattr = ext4_xattr_handlers; |
2613 | #ifdef CONFIG_QUOTA | 2679 | #ifdef CONFIG_QUOTA |
@@ -2615,6 +2681,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2615 | sb->dq_op = &ext4_quota_operations; | 2681 | sb->dq_op = &ext4_quota_operations; |
2616 | #endif | 2682 | #endif |
2617 | INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ | 2683 | INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ |
2684 | mutex_init(&sbi->s_orphan_lock); | ||
2685 | mutex_init(&sbi->s_resize_lock); | ||
2618 | 2686 | ||
2619 | sb->s_root = NULL; | 2687 | sb->s_root = NULL; |
2620 | 2688 | ||
@@ -2632,13 +2700,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2632 | goto failed_mount3; | 2700 | goto failed_mount3; |
2633 | if (!(sb->s_flags & MS_RDONLY) && | 2701 | if (!(sb->s_flags & MS_RDONLY) && |
2634 | EXT4_SB(sb)->s_journal->j_failed_commit) { | 2702 | EXT4_SB(sb)->s_journal->j_failed_commit) { |
2635 | printk(KERN_CRIT "EXT4-fs error (device %s): " | 2703 | ext4_msg(sb, KERN_CRIT, "error: " |
2636 | "ext4_fill_super: Journal transaction " | 2704 | "ext4_fill_super: Journal transaction " |
2637 | "%u is corrupt\n", sb->s_id, | 2705 | "%u is corrupt", |
2638 | EXT4_SB(sb)->s_journal->j_failed_commit); | 2706 | EXT4_SB(sb)->s_journal->j_failed_commit); |
2639 | if (test_opt(sb, ERRORS_RO)) { | 2707 | if (test_opt(sb, ERRORS_RO)) { |
2640 | printk(KERN_CRIT | 2708 | ext4_msg(sb, KERN_CRIT, |
2641 | "Mounting filesystem read-only\n"); | 2709 | "Mounting filesystem read-only"); |
2642 | sb->s_flags |= MS_RDONLY; | 2710 | sb->s_flags |= MS_RDONLY; |
2643 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | 2711 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; |
2644 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | 2712 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); |
@@ -2646,14 +2714,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2646 | if (test_opt(sb, ERRORS_PANIC)) { | 2714 | if (test_opt(sb, ERRORS_PANIC)) { |
2647 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | 2715 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; |
2648 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | 2716 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); |
2649 | ext4_commit_super(sb, es, 1); | 2717 | ext4_commit_super(sb, 1); |
2650 | goto failed_mount4; | 2718 | goto failed_mount4; |
2651 | } | 2719 | } |
2652 | } | 2720 | } |
2653 | } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) && | 2721 | } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) && |
2654 | EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { | 2722 | EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { |
2655 | printk(KERN_ERR "EXT4-fs: required journal recovery " | 2723 | ext4_msg(sb, KERN_ERR, "required journal recovery " |
2656 | "suppressed and not mounted read-only\n"); | 2724 | "suppressed and not mounted read-only"); |
2657 | goto failed_mount4; | 2725 | goto failed_mount4; |
2658 | } else { | 2726 | } else { |
2659 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); | 2727 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); |
@@ -2666,7 +2734,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2666 | if (ext4_blocks_count(es) > 0xffffffffULL && | 2734 | if (ext4_blocks_count(es) > 0xffffffffULL && |
2667 | !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, | 2735 | !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, |
2668 | JBD2_FEATURE_INCOMPAT_64BIT)) { | 2736 | JBD2_FEATURE_INCOMPAT_64BIT)) { |
2669 | printk(KERN_ERR "EXT4-fs: Failed to set 64-bit journal feature\n"); | 2737 | ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature"); |
2670 | goto failed_mount4; | 2738 | goto failed_mount4; |
2671 | } | 2739 | } |
2672 | 2740 | ||
@@ -2704,8 +2772,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2704 | case EXT4_MOUNT_WRITEBACK_DATA: | 2772 | case EXT4_MOUNT_WRITEBACK_DATA: |
2705 | if (!jbd2_journal_check_available_features | 2773 | if (!jbd2_journal_check_available_features |
2706 | (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) { | 2774 | (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) { |
2707 | printk(KERN_ERR "EXT4-fs: Journal does not support " | 2775 | ext4_msg(sb, KERN_ERR, "Journal does not support " |
2708 | "requested data journaling mode\n"); | 2776 | "requested data journaling mode"); |
2709 | goto failed_mount4; | 2777 | goto failed_mount4; |
2710 | } | 2778 | } |
2711 | default: | 2779 | default: |
@@ -2717,8 +2785,8 @@ no_journal: | |||
2717 | 2785 | ||
2718 | if (test_opt(sb, NOBH)) { | 2786 | if (test_opt(sb, NOBH)) { |
2719 | if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { | 2787 | if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { |
2720 | printk(KERN_WARNING "EXT4-fs: Ignoring nobh option - " | 2788 | ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - " |
2721 | "its supported only with writeback mode\n"); | 2789 | "its supported only with writeback mode"); |
2722 | clear_opt(sbi->s_mount_opt, NOBH); | 2790 | clear_opt(sbi->s_mount_opt, NOBH); |
2723 | } | 2791 | } |
2724 | } | 2792 | } |
@@ -2729,18 +2797,18 @@ no_journal: | |||
2729 | 2797 | ||
2730 | root = ext4_iget(sb, EXT4_ROOT_INO); | 2798 | root = ext4_iget(sb, EXT4_ROOT_INO); |
2731 | if (IS_ERR(root)) { | 2799 | if (IS_ERR(root)) { |
2732 | printk(KERN_ERR "EXT4-fs: get root inode failed\n"); | 2800 | ext4_msg(sb, KERN_ERR, "get root inode failed"); |
2733 | ret = PTR_ERR(root); | 2801 | ret = PTR_ERR(root); |
2734 | goto failed_mount4; | 2802 | goto failed_mount4; |
2735 | } | 2803 | } |
2736 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { | 2804 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { |
2737 | iput(root); | 2805 | iput(root); |
2738 | printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n"); | 2806 | ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck"); |
2739 | goto failed_mount4; | 2807 | goto failed_mount4; |
2740 | } | 2808 | } |
2741 | sb->s_root = d_alloc_root(root); | 2809 | sb->s_root = d_alloc_root(root); |
2742 | if (!sb->s_root) { | 2810 | if (!sb->s_root) { |
2743 | printk(KERN_ERR "EXT4-fs: get root dentry failed\n"); | 2811 | ext4_msg(sb, KERN_ERR, "get root dentry failed"); |
2744 | iput(root); | 2812 | iput(root); |
2745 | ret = -ENOMEM; | 2813 | ret = -ENOMEM; |
2746 | goto failed_mount4; | 2814 | goto failed_mount4; |
@@ -2769,22 +2837,29 @@ no_journal: | |||
2769 | sbi->s_inode_size) { | 2837 | sbi->s_inode_size) { |
2770 | sbi->s_want_extra_isize = sizeof(struct ext4_inode) - | 2838 | sbi->s_want_extra_isize = sizeof(struct ext4_inode) - |
2771 | EXT4_GOOD_OLD_INODE_SIZE; | 2839 | EXT4_GOOD_OLD_INODE_SIZE; |
2772 | printk(KERN_INFO "EXT4-fs: required extra inode space not" | 2840 | ext4_msg(sb, KERN_INFO, "required extra inode space not" |
2773 | "available.\n"); | 2841 | "available"); |
2774 | } | 2842 | } |
2775 | 2843 | ||
2776 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { | 2844 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { |
2777 | printk(KERN_WARNING "EXT4-fs: Ignoring delalloc option - " | 2845 | ext4_msg(sb, KERN_WARNING, "Ignoring delalloc option - " |
2778 | "requested data journaling mode\n"); | 2846 | "requested data journaling mode"); |
2779 | clear_opt(sbi->s_mount_opt, DELALLOC); | 2847 | clear_opt(sbi->s_mount_opt, DELALLOC); |
2780 | } else if (test_opt(sb, DELALLOC)) | 2848 | } else if (test_opt(sb, DELALLOC)) |
2781 | printk(KERN_INFO "EXT4-fs: delayed allocation enabled\n"); | 2849 | ext4_msg(sb, KERN_INFO, "delayed allocation enabled"); |
2850 | |||
2851 | err = ext4_setup_system_zone(sb); | ||
2852 | if (err) { | ||
2853 | ext4_msg(sb, KERN_ERR, "failed to initialize system " | ||
2854 | "zone (%d)\n", err); | ||
2855 | goto failed_mount4; | ||
2856 | } | ||
2782 | 2857 | ||
2783 | ext4_ext_init(sb); | 2858 | ext4_ext_init(sb); |
2784 | err = ext4_mb_init(sb, needs_recovery); | 2859 | err = ext4_mb_init(sb, needs_recovery); |
2785 | if (err) { | 2860 | if (err) { |
2786 | printk(KERN_ERR "EXT4-fs: failed to initalize mballoc (%d)\n", | 2861 | ext4_msg(sb, KERN_ERR, "failed to initalize mballoc (%d)", |
2787 | err); | 2862 | err); |
2788 | goto failed_mount4; | 2863 | goto failed_mount4; |
2789 | } | 2864 | } |
2790 | 2865 | ||
@@ -2798,19 +2873,11 @@ no_journal: | |||
2798 | goto failed_mount4; | 2873 | goto failed_mount4; |
2799 | }; | 2874 | }; |
2800 | 2875 | ||
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; | 2876 | EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS; |
2810 | ext4_orphan_cleanup(sb, es); | 2877 | ext4_orphan_cleanup(sb, es); |
2811 | EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; | 2878 | EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; |
2812 | if (needs_recovery) { | 2879 | if (needs_recovery) { |
2813 | printk(KERN_INFO "EXT4-fs: recovery complete.\n"); | 2880 | ext4_msg(sb, KERN_INFO, "recovery complete"); |
2814 | ext4_mark_recovery_complete(sb, es); | 2881 | ext4_mark_recovery_complete(sb, es); |
2815 | } | 2882 | } |
2816 | if (EXT4_SB(sb)->s_journal) { | 2883 | if (EXT4_SB(sb)->s_journal) { |
@@ -2823,25 +2890,30 @@ no_journal: | |||
2823 | } else | 2890 | } else |
2824 | descr = "out journal"; | 2891 | descr = "out journal"; |
2825 | 2892 | ||
2826 | printk(KERN_INFO "EXT4-fs: mounted filesystem %s with%s\n", | 2893 | ext4_msg(sb, KERN_INFO, "mounted filesystem with%s", descr); |
2827 | sb->s_id, descr); | ||
2828 | 2894 | ||
2829 | lock_kernel(); | 2895 | lock_kernel(); |
2830 | return 0; | 2896 | return 0; |
2831 | 2897 | ||
2832 | cantfind_ext4: | 2898 | cantfind_ext4: |
2833 | if (!silent) | 2899 | if (!silent) |
2834 | printk(KERN_ERR "VFS: Can't find ext4 filesystem on dev %s.\n", | 2900 | ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem"); |
2835 | sb->s_id); | ||
2836 | goto failed_mount; | 2901 | goto failed_mount; |
2837 | 2902 | ||
2838 | failed_mount4: | 2903 | failed_mount4: |
2839 | printk(KERN_ERR "EXT4-fs (device %s): mount failed\n", sb->s_id); | 2904 | ext4_msg(sb, KERN_ERR, "mount failed"); |
2905 | ext4_release_system_zone(sb); | ||
2840 | if (sbi->s_journal) { | 2906 | if (sbi->s_journal) { |
2841 | jbd2_journal_destroy(sbi->s_journal); | 2907 | jbd2_journal_destroy(sbi->s_journal); |
2842 | sbi->s_journal = NULL; | 2908 | sbi->s_journal = NULL; |
2843 | } | 2909 | } |
2844 | failed_mount3: | 2910 | failed_mount3: |
2911 | if (sbi->s_flex_groups) { | ||
2912 | if (is_vmalloc_addr(sbi->s_flex_groups)) | ||
2913 | vfree(sbi->s_flex_groups); | ||
2914 | else | ||
2915 | kfree(sbi->s_flex_groups); | ||
2916 | } | ||
2845 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | 2917 | percpu_counter_destroy(&sbi->s_freeblocks_counter); |
2846 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | 2918 | percpu_counter_destroy(&sbi->s_freeinodes_counter); |
2847 | percpu_counter_destroy(&sbi->s_dirs_counter); | 2919 | percpu_counter_destroy(&sbi->s_dirs_counter); |
@@ -2862,6 +2934,7 @@ failed_mount: | |||
2862 | brelse(bh); | 2934 | brelse(bh); |
2863 | out_fail: | 2935 | out_fail: |
2864 | sb->s_fs_info = NULL; | 2936 | sb->s_fs_info = NULL; |
2937 | kfree(sbi->s_blockgroup_lock); | ||
2865 | kfree(sbi); | 2938 | kfree(sbi); |
2866 | lock_kernel(); | 2939 | lock_kernel(); |
2867 | return ret; | 2940 | return ret; |
@@ -2906,27 +2979,27 @@ static journal_t *ext4_get_journal(struct super_block *sb, | |||
2906 | 2979 | ||
2907 | journal_inode = ext4_iget(sb, journal_inum); | 2980 | journal_inode = ext4_iget(sb, journal_inum); |
2908 | if (IS_ERR(journal_inode)) { | 2981 | if (IS_ERR(journal_inode)) { |
2909 | printk(KERN_ERR "EXT4-fs: no journal found.\n"); | 2982 | ext4_msg(sb, KERN_ERR, "no journal found"); |
2910 | return NULL; | 2983 | return NULL; |
2911 | } | 2984 | } |
2912 | if (!journal_inode->i_nlink) { | 2985 | if (!journal_inode->i_nlink) { |
2913 | make_bad_inode(journal_inode); | 2986 | make_bad_inode(journal_inode); |
2914 | iput(journal_inode); | 2987 | iput(journal_inode); |
2915 | printk(KERN_ERR "EXT4-fs: journal inode is deleted.\n"); | 2988 | ext4_msg(sb, KERN_ERR, "journal inode is deleted"); |
2916 | return NULL; | 2989 | return NULL; |
2917 | } | 2990 | } |
2918 | 2991 | ||
2919 | jbd_debug(2, "Journal inode found at %p: %lld bytes\n", | 2992 | jbd_debug(2, "Journal inode found at %p: %lld bytes\n", |
2920 | journal_inode, journal_inode->i_size); | 2993 | journal_inode, journal_inode->i_size); |
2921 | if (!S_ISREG(journal_inode->i_mode)) { | 2994 | if (!S_ISREG(journal_inode->i_mode)) { |
2922 | printk(KERN_ERR "EXT4-fs: invalid journal inode.\n"); | 2995 | ext4_msg(sb, KERN_ERR, "invalid journal inode"); |
2923 | iput(journal_inode); | 2996 | iput(journal_inode); |
2924 | return NULL; | 2997 | return NULL; |
2925 | } | 2998 | } |
2926 | 2999 | ||
2927 | journal = jbd2_journal_init_inode(journal_inode); | 3000 | journal = jbd2_journal_init_inode(journal_inode); |
2928 | if (!journal) { | 3001 | if (!journal) { |
2929 | printk(KERN_ERR "EXT4-fs: Could not load journal inode\n"); | 3002 | ext4_msg(sb, KERN_ERR, "Could not load journal inode"); |
2930 | iput(journal_inode); | 3003 | iput(journal_inode); |
2931 | return NULL; | 3004 | return NULL; |
2932 | } | 3005 | } |
@@ -2950,22 +3023,22 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, | |||
2950 | 3023 | ||
2951 | BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); | 3024 | BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)); |
2952 | 3025 | ||
2953 | bdev = ext4_blkdev_get(j_dev); | 3026 | bdev = ext4_blkdev_get(j_dev, sb); |
2954 | if (bdev == NULL) | 3027 | if (bdev == NULL) |
2955 | return NULL; | 3028 | return NULL; |
2956 | 3029 | ||
2957 | if (bd_claim(bdev, sb)) { | 3030 | if (bd_claim(bdev, sb)) { |
2958 | printk(KERN_ERR | 3031 | ext4_msg(sb, KERN_ERR, |
2959 | "EXT4-fs: failed to claim external journal device.\n"); | 3032 | "failed to claim external journal device"); |
2960 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE); | 3033 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE); |
2961 | return NULL; | 3034 | return NULL; |
2962 | } | 3035 | } |
2963 | 3036 | ||
2964 | blocksize = sb->s_blocksize; | 3037 | blocksize = sb->s_blocksize; |
2965 | hblock = bdev_hardsect_size(bdev); | 3038 | hblock = bdev_logical_block_size(bdev); |
2966 | if (blocksize < hblock) { | 3039 | if (blocksize < hblock) { |
2967 | printk(KERN_ERR | 3040 | ext4_msg(sb, KERN_ERR, |
2968 | "EXT4-fs: blocksize too small for journal device.\n"); | 3041 | "blocksize too small for journal device"); |
2969 | goto out_bdev; | 3042 | goto out_bdev; |
2970 | } | 3043 | } |
2971 | 3044 | ||
@@ -2973,8 +3046,8 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, | |||
2973 | offset = EXT4_MIN_BLOCK_SIZE % blocksize; | 3046 | offset = EXT4_MIN_BLOCK_SIZE % blocksize; |
2974 | set_blocksize(bdev, blocksize); | 3047 | set_blocksize(bdev, blocksize); |
2975 | if (!(bh = __bread(bdev, sb_block, blocksize))) { | 3048 | if (!(bh = __bread(bdev, sb_block, blocksize))) { |
2976 | printk(KERN_ERR "EXT4-fs: couldn't read superblock of " | 3049 | ext4_msg(sb, KERN_ERR, "couldn't read superblock of " |
2977 | "external journal\n"); | 3050 | "external journal"); |
2978 | goto out_bdev; | 3051 | goto out_bdev; |
2979 | } | 3052 | } |
2980 | 3053 | ||
@@ -2982,14 +3055,14 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, | |||
2982 | if ((le16_to_cpu(es->s_magic) != EXT4_SUPER_MAGIC) || | 3055 | if ((le16_to_cpu(es->s_magic) != EXT4_SUPER_MAGIC) || |
2983 | !(le32_to_cpu(es->s_feature_incompat) & | 3056 | !(le32_to_cpu(es->s_feature_incompat) & |
2984 | EXT4_FEATURE_INCOMPAT_JOURNAL_DEV)) { | 3057 | EXT4_FEATURE_INCOMPAT_JOURNAL_DEV)) { |
2985 | printk(KERN_ERR "EXT4-fs: external journal has " | 3058 | ext4_msg(sb, KERN_ERR, "external journal has " |
2986 | "bad superblock\n"); | 3059 | "bad superblock"); |
2987 | brelse(bh); | 3060 | brelse(bh); |
2988 | goto out_bdev; | 3061 | goto out_bdev; |
2989 | } | 3062 | } |
2990 | 3063 | ||
2991 | if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { | 3064 | 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"); | 3065 | ext4_msg(sb, KERN_ERR, "journal UUID does not match"); |
2993 | brelse(bh); | 3066 | brelse(bh); |
2994 | goto out_bdev; | 3067 | goto out_bdev; |
2995 | } | 3068 | } |
@@ -3001,25 +3074,26 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, | |||
3001 | journal = jbd2_journal_init_dev(bdev, sb->s_bdev, | 3074 | journal = jbd2_journal_init_dev(bdev, sb->s_bdev, |
3002 | start, len, blocksize); | 3075 | start, len, blocksize); |
3003 | if (!journal) { | 3076 | if (!journal) { |
3004 | printk(KERN_ERR "EXT4-fs: failed to create device journal\n"); | 3077 | ext4_msg(sb, KERN_ERR, "failed to create device journal"); |
3005 | goto out_bdev; | 3078 | goto out_bdev; |
3006 | } | 3079 | } |
3007 | journal->j_private = sb; | 3080 | journal->j_private = sb; |
3008 | ll_rw_block(READ, 1, &journal->j_sb_buffer); | 3081 | ll_rw_block(READ, 1, &journal->j_sb_buffer); |
3009 | wait_on_buffer(journal->j_sb_buffer); | 3082 | wait_on_buffer(journal->j_sb_buffer); |
3010 | if (!buffer_uptodate(journal->j_sb_buffer)) { | 3083 | if (!buffer_uptodate(journal->j_sb_buffer)) { |
3011 | printk(KERN_ERR "EXT4-fs: I/O error on journal device\n"); | 3084 | ext4_msg(sb, KERN_ERR, "I/O error on journal device"); |
3012 | goto out_journal; | 3085 | goto out_journal; |
3013 | } | 3086 | } |
3014 | if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { | 3087 | if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { |
3015 | printk(KERN_ERR "EXT4-fs: External journal has more than one " | 3088 | ext4_msg(sb, KERN_ERR, "External journal has more than one " |
3016 | "user (unsupported) - %d\n", | 3089 | "user (unsupported) - %d", |
3017 | be32_to_cpu(journal->j_superblock->s_nr_users)); | 3090 | be32_to_cpu(journal->j_superblock->s_nr_users)); |
3018 | goto out_journal; | 3091 | goto out_journal; |
3019 | } | 3092 | } |
3020 | EXT4_SB(sb)->journal_bdev = bdev; | 3093 | EXT4_SB(sb)->journal_bdev = bdev; |
3021 | ext4_init_journal_params(sb, journal); | 3094 | ext4_init_journal_params(sb, journal); |
3022 | return journal; | 3095 | return journal; |
3096 | |||
3023 | out_journal: | 3097 | out_journal: |
3024 | jbd2_journal_destroy(journal); | 3098 | jbd2_journal_destroy(journal); |
3025 | out_bdev: | 3099 | out_bdev: |
@@ -3041,8 +3115,8 @@ static int ext4_load_journal(struct super_block *sb, | |||
3041 | 3115 | ||
3042 | if (journal_devnum && | 3116 | if (journal_devnum && |
3043 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { | 3117 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { |
3044 | printk(KERN_INFO "EXT4-fs: external journal device major/minor " | 3118 | ext4_msg(sb, KERN_INFO, "external journal device major/minor " |
3045 | "numbers have changed\n"); | 3119 | "numbers have changed"); |
3046 | journal_dev = new_decode_dev(journal_devnum); | 3120 | journal_dev = new_decode_dev(journal_devnum); |
3047 | } else | 3121 | } else |
3048 | journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev)); | 3122 | journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev)); |
@@ -3054,24 +3128,23 @@ static int ext4_load_journal(struct super_block *sb, | |||
3054 | * crash? For recovery, we need to check in advance whether we | 3128 | * crash? For recovery, we need to check in advance whether we |
3055 | * can get read-write access to the device. | 3129 | * can get read-write access to the device. |
3056 | */ | 3130 | */ |
3057 | |||
3058 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { | 3131 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { |
3059 | if (sb->s_flags & MS_RDONLY) { | 3132 | if (sb->s_flags & MS_RDONLY) { |
3060 | printk(KERN_INFO "EXT4-fs: INFO: recovery " | 3133 | ext4_msg(sb, KERN_INFO, "INFO: recovery " |
3061 | "required on readonly filesystem.\n"); | 3134 | "required on readonly filesystem"); |
3062 | if (really_read_only) { | 3135 | if (really_read_only) { |
3063 | printk(KERN_ERR "EXT4-fs: write access " | 3136 | ext4_msg(sb, KERN_ERR, "write access " |
3064 | "unavailable, cannot proceed.\n"); | 3137 | "unavailable, cannot proceed"); |
3065 | return -EROFS; | 3138 | return -EROFS; |
3066 | } | 3139 | } |
3067 | printk(KERN_INFO "EXT4-fs: write access will " | 3140 | ext4_msg(sb, KERN_INFO, "write access will " |
3068 | "be enabled during recovery.\n"); | 3141 | "be enabled during recovery"); |
3069 | } | 3142 | } |
3070 | } | 3143 | } |
3071 | 3144 | ||
3072 | if (journal_inum && journal_dev) { | 3145 | if (journal_inum && journal_dev) { |
3073 | printk(KERN_ERR "EXT4-fs: filesystem has both journal " | 3146 | ext4_msg(sb, KERN_ERR, "filesystem has both journal " |
3074 | "and inode journals!\n"); | 3147 | "and inode journals!"); |
3075 | return -EINVAL; | 3148 | return -EINVAL; |
3076 | } | 3149 | } |
3077 | 3150 | ||
@@ -3084,14 +3157,14 @@ static int ext4_load_journal(struct super_block *sb, | |||
3084 | } | 3157 | } |
3085 | 3158 | ||
3086 | if (journal->j_flags & JBD2_BARRIER) | 3159 | if (journal->j_flags & JBD2_BARRIER) |
3087 | printk(KERN_INFO "EXT4-fs: barriers enabled\n"); | 3160 | ext4_msg(sb, KERN_INFO, "barriers enabled"); |
3088 | else | 3161 | else |
3089 | printk(KERN_INFO "EXT4-fs: barriers disabled\n"); | 3162 | ext4_msg(sb, KERN_INFO, "barriers disabled"); |
3090 | 3163 | ||
3091 | if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { | 3164 | if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { |
3092 | err = jbd2_journal_update_format(journal); | 3165 | err = jbd2_journal_update_format(journal); |
3093 | if (err) { | 3166 | if (err) { |
3094 | printk(KERN_ERR "EXT4-fs: error updating journal.\n"); | 3167 | ext4_msg(sb, KERN_ERR, "error updating journal"); |
3095 | jbd2_journal_destroy(journal); | 3168 | jbd2_journal_destroy(journal); |
3096 | return err; | 3169 | return err; |
3097 | } | 3170 | } |
@@ -3103,7 +3176,7 @@ static int ext4_load_journal(struct super_block *sb, | |||
3103 | err = jbd2_journal_load(journal); | 3176 | err = jbd2_journal_load(journal); |
3104 | 3177 | ||
3105 | if (err) { | 3178 | if (err) { |
3106 | printk(KERN_ERR "EXT4-fs: error loading journal.\n"); | 3179 | ext4_msg(sb, KERN_ERR, "error loading journal"); |
3107 | jbd2_journal_destroy(journal); | 3180 | jbd2_journal_destroy(journal); |
3108 | return err; | 3181 | return err; |
3109 | } | 3182 | } |
@@ -3114,18 +3187,17 @@ static int ext4_load_journal(struct super_block *sb, | |||
3114 | if (journal_devnum && | 3187 | if (journal_devnum && |
3115 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { | 3188 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { |
3116 | es->s_journal_dev = cpu_to_le32(journal_devnum); | 3189 | es->s_journal_dev = cpu_to_le32(journal_devnum); |
3117 | sb->s_dirt = 1; | ||
3118 | 3190 | ||
3119 | /* Make sure we flush the recovery flag to disk. */ | 3191 | /* Make sure we flush the recovery flag to disk. */ |
3120 | ext4_commit_super(sb, es, 1); | 3192 | ext4_commit_super(sb, 1); |
3121 | } | 3193 | } |
3122 | 3194 | ||
3123 | return 0; | 3195 | return 0; |
3124 | } | 3196 | } |
3125 | 3197 | ||
3126 | static int ext4_commit_super(struct super_block *sb, | 3198 | static int ext4_commit_super(struct super_block *sb, int sync) |
3127 | struct ext4_super_block *es, int sync) | ||
3128 | { | 3199 | { |
3200 | struct ext4_super_block *es = EXT4_SB(sb)->s_es; | ||
3129 | struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; | 3201 | struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; |
3130 | int error = 0; | 3202 | int error = 0; |
3131 | 3203 | ||
@@ -3140,8 +3212,8 @@ static int ext4_commit_super(struct super_block *sb, | |||
3140 | * be remapped. Nothing we can do but to retry the | 3212 | * be remapped. Nothing we can do but to retry the |
3141 | * write and hope for the best. | 3213 | * write and hope for the best. |
3142 | */ | 3214 | */ |
3143 | printk(KERN_ERR "EXT4-fs: previous I/O error to " | 3215 | ext4_msg(sb, KERN_ERR, "previous I/O error to " |
3144 | "superblock detected for %s.\n", sb->s_id); | 3216 | "superblock detected"); |
3145 | clear_buffer_write_io_error(sbh); | 3217 | clear_buffer_write_io_error(sbh); |
3146 | set_buffer_uptodate(sbh); | 3218 | set_buffer_uptodate(sbh); |
3147 | } | 3219 | } |
@@ -3154,7 +3226,7 @@ static int ext4_commit_super(struct super_block *sb, | |||
3154 | &EXT4_SB(sb)->s_freeblocks_counter)); | 3226 | &EXT4_SB(sb)->s_freeblocks_counter)); |
3155 | es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive( | 3227 | es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive( |
3156 | &EXT4_SB(sb)->s_freeinodes_counter)); | 3228 | &EXT4_SB(sb)->s_freeinodes_counter)); |
3157 | 3229 | sb->s_dirt = 0; | |
3158 | BUFFER_TRACE(sbh, "marking dirty"); | 3230 | BUFFER_TRACE(sbh, "marking dirty"); |
3159 | mark_buffer_dirty(sbh); | 3231 | mark_buffer_dirty(sbh); |
3160 | if (sync) { | 3232 | if (sync) { |
@@ -3164,8 +3236,8 @@ static int ext4_commit_super(struct super_block *sb, | |||
3164 | 3236 | ||
3165 | error = buffer_write_io_error(sbh); | 3237 | error = buffer_write_io_error(sbh); |
3166 | if (error) { | 3238 | if (error) { |
3167 | printk(KERN_ERR "EXT4-fs: I/O error while writing " | 3239 | ext4_msg(sb, KERN_ERR, "I/O error while writing " |
3168 | "superblock for %s.\n", sb->s_id); | 3240 | "superblock"); |
3169 | clear_buffer_write_io_error(sbh); | 3241 | clear_buffer_write_io_error(sbh); |
3170 | set_buffer_uptodate(sbh); | 3242 | set_buffer_uptodate(sbh); |
3171 | } | 3243 | } |
@@ -3173,7 +3245,6 @@ static int ext4_commit_super(struct super_block *sb, | |||
3173 | return error; | 3245 | return error; |
3174 | } | 3246 | } |
3175 | 3247 | ||
3176 | |||
3177 | /* | 3248 | /* |
3178 | * Have we just finished recovery? If so, and if we are mounting (or | 3249 | * 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 | 3250 | * remounting) the filesystem readonly, then we will end up with a |
@@ -3192,14 +3263,11 @@ static void ext4_mark_recovery_complete(struct super_block *sb, | |||
3192 | if (jbd2_journal_flush(journal) < 0) | 3263 | if (jbd2_journal_flush(journal) < 0) |
3193 | goto out; | 3264 | goto out; |
3194 | 3265 | ||
3195 | lock_super(sb); | ||
3196 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) && | 3266 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) && |
3197 | sb->s_flags & MS_RDONLY) { | 3267 | sb->s_flags & MS_RDONLY) { |
3198 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 3268 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
3199 | sb->s_dirt = 0; | 3269 | ext4_commit_super(sb, 1); |
3200 | ext4_commit_super(sb, es, 1); | ||
3201 | } | 3270 | } |
3202 | unlock_super(sb); | ||
3203 | 3271 | ||
3204 | out: | 3272 | out: |
3205 | jbd2_journal_unlock_updates(journal); | 3273 | jbd2_journal_unlock_updates(journal); |
@@ -3238,7 +3306,7 @@ static void ext4_clear_journal_err(struct super_block *sb, | |||
3238 | 3306 | ||
3239 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | 3307 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; |
3240 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | 3308 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); |
3241 | ext4_commit_super(sb, es, 1); | 3309 | ext4_commit_super(sb, 1); |
3242 | 3310 | ||
3243 | jbd2_journal_clear_err(journal); | 3311 | jbd2_journal_clear_err(journal); |
3244 | } | 3312 | } |
@@ -3257,29 +3325,15 @@ int ext4_force_commit(struct super_block *sb) | |||
3257 | return 0; | 3325 | return 0; |
3258 | 3326 | ||
3259 | journal = EXT4_SB(sb)->s_journal; | 3327 | journal = EXT4_SB(sb)->s_journal; |
3260 | if (journal) { | 3328 | if (journal) |
3261 | sb->s_dirt = 0; | ||
3262 | ret = ext4_journal_force_commit(journal); | 3329 | ret = ext4_journal_force_commit(journal); |
3263 | } | ||
3264 | 3330 | ||
3265 | return ret; | 3331 | return ret; |
3266 | } | 3332 | } |
3267 | 3333 | ||
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) | 3334 | static void ext4_write_super(struct super_block *sb) |
3275 | { | 3335 | { |
3276 | if (EXT4_SB(sb)->s_journal) { | 3336 | ext4_commit_super(sb, 1); |
3277 | if (mutex_trylock(&sb->s_lock) != 0) | ||
3278 | BUG(); | ||
3279 | sb->s_dirt = 0; | ||
3280 | } else { | ||
3281 | ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); | ||
3282 | } | ||
3283 | } | 3337 | } |
3284 | 3338 | ||
3285 | static int ext4_sync_fs(struct super_block *sb, int wait) | 3339 | static int ext4_sync_fs(struct super_block *sb, int wait) |
@@ -3288,16 +3342,9 @@ static int ext4_sync_fs(struct super_block *sb, int wait) | |||
3288 | tid_t target; | 3342 | tid_t target; |
3289 | 3343 | ||
3290 | trace_mark(ext4_sync_fs, "dev %s wait %d", sb->s_id, wait); | 3344 | trace_mark(ext4_sync_fs, "dev %s wait %d", sb->s_id, wait); |
3291 | sb->s_dirt = 0; | 3345 | if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, &target)) { |
3292 | if (EXT4_SB(sb)->s_journal) { | 3346 | if (wait) |
3293 | if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, | 3347 | 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 | } | 3348 | } |
3302 | return ret; | 3349 | return ret; |
3303 | } | 3350 | } |
@@ -3310,34 +3357,32 @@ static int ext4_freeze(struct super_block *sb) | |||
3310 | { | 3357 | { |
3311 | int error = 0; | 3358 | int error = 0; |
3312 | journal_t *journal; | 3359 | journal_t *journal; |
3313 | sb->s_dirt = 0; | ||
3314 | 3360 | ||
3315 | if (!(sb->s_flags & MS_RDONLY)) { | 3361 | if (sb->s_flags & MS_RDONLY) |
3316 | journal = EXT4_SB(sb)->s_journal; | 3362 | return 0; |
3317 | 3363 | ||
3318 | if (journal) { | 3364 | journal = EXT4_SB(sb)->s_journal; |
3319 | /* Now we set up the journal barrier. */ | ||
3320 | jbd2_journal_lock_updates(journal); | ||
3321 | 3365 | ||
3322 | /* | 3366 | /* Now we set up the journal barrier. */ |
3323 | * We don't want to clear needs_recovery flag when we | 3367 | 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 | 3368 | ||
3331 | /* Journal blocked and flushed, clear needs_recovery flag. */ | 3369 | /* |
3332 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 3370 | * Don't clear the needs_recovery flag if we failed to flush |
3333 | error = ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); | 3371 | * the journal. |
3334 | if (error) | 3372 | */ |
3335 | goto out; | 3373 | error = jbd2_journal_flush(journal); |
3374 | if (error < 0) { | ||
3375 | out: | ||
3376 | jbd2_journal_unlock_updates(journal); | ||
3377 | return error; | ||
3336 | } | 3378 | } |
3379 | |||
3380 | /* Journal blocked and flushed, clear needs_recovery flag. */ | ||
3381 | EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | ||
3382 | error = ext4_commit_super(sb, 1); | ||
3383 | if (error) | ||
3384 | goto out; | ||
3337 | return 0; | 3385 | return 0; |
3338 | out: | ||
3339 | jbd2_journal_unlock_updates(journal); | ||
3340 | return error; | ||
3341 | } | 3386 | } |
3342 | 3387 | ||
3343 | /* | 3388 | /* |
@@ -3346,14 +3391,15 @@ out: | |||
3346 | */ | 3391 | */ |
3347 | static int ext4_unfreeze(struct super_block *sb) | 3392 | static int ext4_unfreeze(struct super_block *sb) |
3348 | { | 3393 | { |
3349 | if (EXT4_SB(sb)->s_journal && !(sb->s_flags & MS_RDONLY)) { | 3394 | if (sb->s_flags & MS_RDONLY) |
3350 | lock_super(sb); | 3395 | return 0; |
3351 | /* Reser the needs_recovery flag before the fs is unlocked. */ | 3396 | |
3352 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); | 3397 | lock_super(sb); |
3353 | ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); | 3398 | /* Reset the needs_recovery flag before the fs is unlocked. */ |
3354 | unlock_super(sb); | 3399 | EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); |
3355 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | 3400 | ext4_commit_super(sb, 1); |
3356 | } | 3401 | unlock_super(sb); |
3402 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | ||
3357 | return 0; | 3403 | return 0; |
3358 | } | 3404 | } |
3359 | 3405 | ||
@@ -3432,22 +3478,15 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3432 | (sbi->s_mount_state & EXT4_VALID_FS)) | 3478 | (sbi->s_mount_state & EXT4_VALID_FS)) |
3433 | es->s_state = cpu_to_le16(sbi->s_mount_state); | 3479 | es->s_state = cpu_to_le16(sbi->s_mount_state); |
3434 | 3480 | ||
3435 | /* | 3481 | 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); | 3482 | ext4_mark_recovery_complete(sb, es); |
3442 | lock_super(sb); | ||
3443 | } | ||
3444 | } else { | 3483 | } else { |
3445 | int ret; | 3484 | int ret; |
3446 | if ((ret = EXT4_HAS_RO_COMPAT_FEATURE(sb, | 3485 | if ((ret = EXT4_HAS_RO_COMPAT_FEATURE(sb, |
3447 | ~EXT4_FEATURE_RO_COMPAT_SUPP))) { | 3486 | ~EXT4_FEATURE_RO_COMPAT_SUPP))) { |
3448 | printk(KERN_WARNING "EXT4-fs: %s: couldn't " | 3487 | ext4_msg(sb, KERN_WARNING, "couldn't " |
3449 | "remount RDWR because of unsupported " | 3488 | "remount RDWR because of unsupported " |
3450 | "optional features (%x).\n", sb->s_id, | 3489 | "optional features (%x)", |
3451 | (le32_to_cpu(sbi->s_es->s_feature_ro_compat) & | 3490 | (le32_to_cpu(sbi->s_es->s_feature_ro_compat) & |
3452 | ~EXT4_FEATURE_RO_COMPAT_SUPP)); | 3491 | ~EXT4_FEATURE_RO_COMPAT_SUPP)); |
3453 | err = -EROFS; | 3492 | err = -EROFS; |
@@ -3456,17 +3495,15 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3456 | 3495 | ||
3457 | /* | 3496 | /* |
3458 | * Make sure the group descriptor checksums | 3497 | * Make sure the group descriptor checksums |
3459 | * are sane. If they aren't, refuse to | 3498 | * are sane. If they aren't, refuse to remount r/w. |
3460 | * remount r/w. | ||
3461 | */ | 3499 | */ |
3462 | for (g = 0; g < sbi->s_groups_count; g++) { | 3500 | for (g = 0; g < sbi->s_groups_count; g++) { |
3463 | struct ext4_group_desc *gdp = | 3501 | struct ext4_group_desc *gdp = |
3464 | ext4_get_group_desc(sb, g, NULL); | 3502 | ext4_get_group_desc(sb, g, NULL); |
3465 | 3503 | ||
3466 | if (!ext4_group_desc_csum_verify(sbi, g, gdp)) { | 3504 | if (!ext4_group_desc_csum_verify(sbi, g, gdp)) { |
3467 | printk(KERN_ERR | 3505 | ext4_msg(sb, KERN_ERR, |
3468 | "EXT4-fs: ext4_remount: " | 3506 | "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)), | 3507 | g, le16_to_cpu(ext4_group_desc_csum(sbi, g, gdp)), |
3471 | le16_to_cpu(gdp->bg_checksum)); | 3508 | le16_to_cpu(gdp->bg_checksum)); |
3472 | err = -EINVAL; | 3509 | err = -EINVAL; |
@@ -3480,11 +3517,10 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3480 | * require a full umount/remount for now. | 3517 | * require a full umount/remount for now. |
3481 | */ | 3518 | */ |
3482 | if (es->s_last_orphan) { | 3519 | if (es->s_last_orphan) { |
3483 | printk(KERN_WARNING "EXT4-fs: %s: couldn't " | 3520 | ext4_msg(sb, KERN_WARNING, "Couldn't " |
3484 | "remount RDWR because of unprocessed " | 3521 | "remount RDWR because of unprocessed " |
3485 | "orphan inode list. Please " | 3522 | "orphan inode list. Please " |
3486 | "umount/remount instead.\n", | 3523 | "umount/remount instead"); |
3487 | sb->s_id); | ||
3488 | err = -EINVAL; | 3524 | err = -EINVAL; |
3489 | goto restore_opts; | 3525 | goto restore_opts; |
3490 | } | 3526 | } |
@@ -3504,8 +3540,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3504 | sb->s_flags &= ~MS_RDONLY; | 3540 | sb->s_flags &= ~MS_RDONLY; |
3505 | } | 3541 | } |
3506 | } | 3542 | } |
3543 | ext4_setup_system_zone(sb); | ||
3507 | if (sbi->s_journal == NULL) | 3544 | if (sbi->s_journal == NULL) |
3508 | ext4_commit_super(sb, es, 1); | 3545 | ext4_commit_super(sb, 1); |
3509 | 3546 | ||
3510 | #ifdef CONFIG_QUOTA | 3547 | #ifdef CONFIG_QUOTA |
3511 | /* Release old quota file names */ | 3548 | /* Release old quota file names */ |
@@ -3515,6 +3552,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3515 | kfree(old_opts.s_qf_names[i]); | 3552 | kfree(old_opts.s_qf_names[i]); |
3516 | #endif | 3553 | #endif |
3517 | return 0; | 3554 | return 0; |
3555 | |||
3518 | restore_opts: | 3556 | restore_opts: |
3519 | sb->s_flags = old_sb_flags; | 3557 | sb->s_flags = old_sb_flags; |
3520 | sbi->s_mount_opt = old_opts.s_mount_opt; | 3558 | sbi->s_mount_opt = old_opts.s_mount_opt; |
@@ -3545,9 +3583,8 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
3545 | if (test_opt(sb, MINIX_DF)) { | 3583 | if (test_opt(sb, MINIX_DF)) { |
3546 | sbi->s_overhead_last = 0; | 3584 | sbi->s_overhead_last = 0; |
3547 | } else if (sbi->s_blocks_last != ext4_blocks_count(es)) { | 3585 | } else if (sbi->s_blocks_last != ext4_blocks_count(es)) { |
3548 | ext4_group_t ngroups = sbi->s_groups_count, i; | 3586 | ext4_group_t i, ngroups = ext4_get_groups_count(sb); |
3549 | ext4_fsblk_t overhead = 0; | 3587 | ext4_fsblk_t overhead = 0; |
3550 | smp_rmb(); | ||
3551 | 3588 | ||
3552 | /* | 3589 | /* |
3553 | * Compute the overhead (FS structures). This is constant | 3590 | * Compute the overhead (FS structures). This is constant |
@@ -3599,11 +3636,12 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
3599 | le64_to_cpup((void *)es->s_uuid + sizeof(u64)); | 3636 | le64_to_cpup((void *)es->s_uuid + sizeof(u64)); |
3600 | buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL; | 3637 | buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL; |
3601 | buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL; | 3638 | buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL; |
3639 | |||
3602 | return 0; | 3640 | return 0; |
3603 | } | 3641 | } |
3604 | 3642 | ||
3605 | /* Helper function for writing quotas on sync - we need to start transaction before quota file | 3643 | /* Helper function for writing quotas on sync - we need to start transaction |
3606 | * is locked for write. Otherwise the are possible deadlocks: | 3644 | * before quota file is locked for write. Otherwise the are possible deadlocks: |
3607 | * Process 1 Process 2 | 3645 | * Process 1 Process 2 |
3608 | * ext4_create() quota_sync() | 3646 | * ext4_create() quota_sync() |
3609 | * jbd2_journal_start() write_dquot() | 3647 | * jbd2_journal_start() write_dquot() |
@@ -3627,7 +3665,7 @@ static int ext4_write_dquot(struct dquot *dquot) | |||
3627 | 3665 | ||
3628 | inode = dquot_to_inode(dquot); | 3666 | inode = dquot_to_inode(dquot); |
3629 | handle = ext4_journal_start(inode, | 3667 | handle = ext4_journal_start(inode, |
3630 | EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); | 3668 | EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); |
3631 | if (IS_ERR(handle)) | 3669 | if (IS_ERR(handle)) |
3632 | return PTR_ERR(handle); | 3670 | return PTR_ERR(handle); |
3633 | ret = dquot_commit(dquot); | 3671 | ret = dquot_commit(dquot); |
@@ -3643,7 +3681,7 @@ static int ext4_acquire_dquot(struct dquot *dquot) | |||
3643 | handle_t *handle; | 3681 | handle_t *handle; |
3644 | 3682 | ||
3645 | handle = ext4_journal_start(dquot_to_inode(dquot), | 3683 | handle = ext4_journal_start(dquot_to_inode(dquot), |
3646 | EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb)); | 3684 | EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb)); |
3647 | if (IS_ERR(handle)) | 3685 | if (IS_ERR(handle)) |
3648 | return PTR_ERR(handle); | 3686 | return PTR_ERR(handle); |
3649 | ret = dquot_acquire(dquot); | 3687 | ret = dquot_acquire(dquot); |
@@ -3659,7 +3697,7 @@ static int ext4_release_dquot(struct dquot *dquot) | |||
3659 | handle_t *handle; | 3697 | handle_t *handle; |
3660 | 3698 | ||
3661 | handle = ext4_journal_start(dquot_to_inode(dquot), | 3699 | handle = ext4_journal_start(dquot_to_inode(dquot), |
3662 | EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb)); | 3700 | EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb)); |
3663 | if (IS_ERR(handle)) { | 3701 | if (IS_ERR(handle)) { |
3664 | /* Release dquot anyway to avoid endless cycle in dqput() */ | 3702 | /* Release dquot anyway to avoid endless cycle in dqput() */ |
3665 | dquot_release(dquot); | 3703 | dquot_release(dquot); |
@@ -3707,7 +3745,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) | 3745 | static int ext4_quota_on_mount(struct super_block *sb, int type) |
3708 | { | 3746 | { |
3709 | return vfs_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type], | 3747 | return vfs_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type], |
3710 | EXT4_SB(sb)->s_jquota_fmt, type); | 3748 | EXT4_SB(sb)->s_jquota_fmt, type); |
3711 | } | 3749 | } |
3712 | 3750 | ||
3713 | /* | 3751 | /* |
@@ -3738,9 +3776,9 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, | |||
3738 | if (EXT4_SB(sb)->s_qf_names[type]) { | 3776 | if (EXT4_SB(sb)->s_qf_names[type]) { |
3739 | /* Quotafile not in fs root? */ | 3777 | /* Quotafile not in fs root? */ |
3740 | if (path.dentry->d_parent != sb->s_root) | 3778 | if (path.dentry->d_parent != sb->s_root) |
3741 | printk(KERN_WARNING | 3779 | ext4_msg(sb, KERN_WARNING, |
3742 | "EXT4-fs: Quota file not on filesystem root. " | 3780 | "Quota file not on filesystem root. " |
3743 | "Journaled quota will not work.\n"); | 3781 | "Journaled quota will not work"); |
3744 | } | 3782 | } |
3745 | 3783 | ||
3746 | /* | 3784 | /* |
@@ -3823,8 +3861,8 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
3823 | handle_t *handle = journal_current_handle(); | 3861 | handle_t *handle = journal_current_handle(); |
3824 | 3862 | ||
3825 | if (EXT4_SB(sb)->s_journal && !handle) { | 3863 | if (EXT4_SB(sb)->s_journal && !handle) { |
3826 | printk(KERN_WARNING "EXT4-fs: Quota write (off=%llu, len=%llu)" | 3864 | ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" |
3827 | " cancelled because transaction is not started.\n", | 3865 | " cancelled because transaction is not started", |
3828 | (unsigned long long)off, (unsigned long long)len); | 3866 | (unsigned long long)off, (unsigned long long)len); |
3829 | return -EIO; | 3867 | return -EIO; |
3830 | } | 3868 | } |
@@ -3878,10 +3916,10 @@ out: | |||
3878 | 3916 | ||
3879 | #endif | 3917 | #endif |
3880 | 3918 | ||
3881 | static int ext4_get_sb(struct file_system_type *fs_type, | 3919 | 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) | 3920 | const char *dev_name, void *data, struct vfsmount *mnt) |
3883 | { | 3921 | { |
3884 | return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super, mnt); | 3922 | return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt); |
3885 | } | 3923 | } |
3886 | 3924 | ||
3887 | static struct file_system_type ext4_fs_type = { | 3925 | static struct file_system_type ext4_fs_type = { |
@@ -3893,14 +3931,14 @@ static struct file_system_type ext4_fs_type = { | |||
3893 | }; | 3931 | }; |
3894 | 3932 | ||
3895 | #ifdef CONFIG_EXT4DEV_COMPAT | 3933 | #ifdef CONFIG_EXT4DEV_COMPAT |
3896 | static int ext4dev_get_sb(struct file_system_type *fs_type, | 3934 | 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) | 3935 | const char *dev_name, void *data,struct vfsmount *mnt) |
3898 | { | 3936 | { |
3899 | printk(KERN_WARNING "EXT4-fs: Update your userspace programs " | 3937 | printk(KERN_WARNING "EXT4-fs (%s): Update your userspace programs " |
3900 | "to mount using ext4\n"); | 3938 | "to mount using ext4\n", dev_name); |
3901 | printk(KERN_WARNING "EXT4-fs: ext4dev backwards compatibility " | 3939 | printk(KERN_WARNING "EXT4-fs (%s): ext4dev backwards compatibility " |
3902 | "will go away by 2.6.31\n"); | 3940 | "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); | 3941 | return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt); |
3904 | } | 3942 | } |
3905 | 3943 | ||
3906 | static struct file_system_type ext4dev_fs_type = { | 3944 | static struct file_system_type ext4dev_fs_type = { |
@@ -3917,13 +3955,16 @@ static int __init init_ext4_fs(void) | |||
3917 | { | 3955 | { |
3918 | int err; | 3956 | int err; |
3919 | 3957 | ||
3958 | err = init_ext4_system_zone(); | ||
3959 | if (err) | ||
3960 | return err; | ||
3920 | ext4_kset = kset_create_and_add("ext4", NULL, fs_kobj); | 3961 | ext4_kset = kset_create_and_add("ext4", NULL, fs_kobj); |
3921 | if (!ext4_kset) | 3962 | if (!ext4_kset) |
3922 | return -ENOMEM; | 3963 | goto out4; |
3923 | ext4_proc_root = proc_mkdir("fs/ext4", NULL); | 3964 | ext4_proc_root = proc_mkdir("fs/ext4", NULL); |
3924 | err = init_ext4_mballoc(); | 3965 | err = init_ext4_mballoc(); |
3925 | if (err) | 3966 | if (err) |
3926 | return err; | 3967 | goto out3; |
3927 | 3968 | ||
3928 | err = init_ext4_xattr(); | 3969 | err = init_ext4_xattr(); |
3929 | if (err) | 3970 | if (err) |
@@ -3948,6 +3989,11 @@ out1: | |||
3948 | exit_ext4_xattr(); | 3989 | exit_ext4_xattr(); |
3949 | out2: | 3990 | out2: |
3950 | exit_ext4_mballoc(); | 3991 | exit_ext4_mballoc(); |
3992 | out3: | ||
3993 | remove_proc_entry("fs/ext4", NULL); | ||
3994 | kset_unregister(ext4_kset); | ||
3995 | out4: | ||
3996 | exit_ext4_system_zone(); | ||
3951 | return err; | 3997 | return err; |
3952 | } | 3998 | } |
3953 | 3999 | ||
@@ -3962,6 +4008,7 @@ static void __exit exit_ext4_fs(void) | |||
3962 | exit_ext4_mballoc(); | 4008 | exit_ext4_mballoc(); |
3963 | remove_proc_entry("fs/ext4", NULL); | 4009 | remove_proc_entry("fs/ext4", NULL); |
3964 | kset_unregister(ext4_kset); | 4010 | kset_unregister(ext4_kset); |
4011 | exit_ext4_system_zone(); | ||
3965 | } | 4012 | } |
3966 | 4013 | ||
3967 | MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); | 4014 | MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); |