aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c107
1 files changed, 93 insertions, 14 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 3c1397fa83df..4c8d31c61454 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -523,7 +523,7 @@ static void ext4_destroy_inode(struct inode *inode)
523 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); 523 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
524} 524}
525 525
526static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags) 526static void init_once(struct kmem_cache *cachep, void *foo)
527{ 527{
528 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; 528 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
529 529
@@ -596,9 +596,80 @@ static inline void ext4_show_quota_options(struct seq_file *seq, struct super_bl
596#endif 596#endif
597} 597}
598 598
599/*
600 * Show an option if
601 * - it's set to a non-default value OR
602 * - if the per-sb default is different from the global default
603 */
599static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) 604static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
600{ 605{
601 struct super_block *sb = vfs->mnt_sb; 606 struct super_block *sb = vfs->mnt_sb;
607 struct ext4_sb_info *sbi = EXT4_SB(sb);
608 struct ext4_super_block *es = sbi->s_es;
609 unsigned long def_mount_opts;
610
611 def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
612
613 if (sbi->s_sb_block != 1)
614 seq_printf(seq, ",sb=%llu", sbi->s_sb_block);
615 if (test_opt(sb, MINIX_DF))
616 seq_puts(seq, ",minixdf");
617 if (test_opt(sb, GRPID))
618 seq_puts(seq, ",grpid");
619 if (!test_opt(sb, GRPID) && (def_mount_opts & EXT4_DEFM_BSDGROUPS))
620 seq_puts(seq, ",nogrpid");
621 if (sbi->s_resuid != EXT4_DEF_RESUID ||
622 le16_to_cpu(es->s_def_resuid) != EXT4_DEF_RESUID) {
623 seq_printf(seq, ",resuid=%u", sbi->s_resuid);
624 }
625 if (sbi->s_resgid != EXT4_DEF_RESGID ||
626 le16_to_cpu(es->s_def_resgid) != EXT4_DEF_RESGID) {
627 seq_printf(seq, ",resgid=%u", sbi->s_resgid);
628 }
629 if (test_opt(sb, ERRORS_CONT)) {
630 int def_errors = le16_to_cpu(es->s_errors);
631
632 if (def_errors == EXT4_ERRORS_PANIC ||
633 def_errors == EXT4_ERRORS_RO) {
634 seq_puts(seq, ",errors=continue");
635 }
636 }
637 if (test_opt(sb, ERRORS_RO))
638 seq_puts(seq, ",errors=remount-ro");
639 if (test_opt(sb, ERRORS_PANIC))
640 seq_puts(seq, ",errors=panic");
641 if (test_opt(sb, NO_UID32))
642 seq_puts(seq, ",nouid32");
643 if (test_opt(sb, DEBUG))
644 seq_puts(seq, ",debug");
645 if (test_opt(sb, OLDALLOC))
646 seq_puts(seq, ",oldalloc");
647#ifdef CONFIG_EXT4_FS_XATTR
648 if (test_opt(sb, XATTR_USER))
649 seq_puts(seq, ",user_xattr");
650 if (!test_opt(sb, XATTR_USER) &&
651 (def_mount_opts & EXT4_DEFM_XATTR_USER)) {
652 seq_puts(seq, ",nouser_xattr");
653 }
654#endif
655#ifdef CONFIG_EXT4_FS_POSIX_ACL
656 if (test_opt(sb, POSIX_ACL))
657 seq_puts(seq, ",acl");
658 if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT4_DEFM_ACL))
659 seq_puts(seq, ",noacl");
660#endif
661 if (!test_opt(sb, RESERVATION))
662 seq_puts(seq, ",noreservation");
663 if (sbi->s_commit_interval) {
664 seq_printf(seq, ",commit=%u",
665 (unsigned) (sbi->s_commit_interval / HZ));
666 }
667 if (test_opt(sb, BARRIER))
668 seq_puts(seq, ",barrier=1");
669 if (test_opt(sb, NOBH))
670 seq_puts(seq, ",nobh");
671 if (!test_opt(sb, EXTENTS))
672 seq_puts(seq, ",noextents");
602 673
603 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) 674 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
604 seq_puts(seq, ",data=journal"); 675 seq_puts(seq, ",data=journal");
@@ -1415,8 +1486,6 @@ static void ext4_orphan_cleanup (struct super_block * sb,
1415 sb->s_flags = s_flags; /* Restore MS_RDONLY status */ 1486 sb->s_flags = s_flags; /* Restore MS_RDONLY status */
1416} 1487}
1417 1488
1418#define log2(n) ffz(~(n))
1419
1420/* 1489/*
1421 * Maximal file size. There is a direct, and {,double-,triple-}indirect 1490 * Maximal file size. There is a direct, and {,double-,triple-}indirect
1422 * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks. 1491 * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
@@ -1479,6 +1548,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1479 int needs_recovery; 1548 int needs_recovery;
1480 __le32 features; 1549 __le32 features;
1481 __u64 blocks_count; 1550 __u64 blocks_count;
1551 int err;
1482 1552
1483 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 1553 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
1484 if (!sbi) 1554 if (!sbi)
@@ -1487,6 +1557,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1487 sbi->s_mount_opt = 0; 1557 sbi->s_mount_opt = 0;
1488 sbi->s_resuid = EXT4_DEF_RESUID; 1558 sbi->s_resuid = EXT4_DEF_RESUID;
1489 sbi->s_resgid = EXT4_DEF_RESGID; 1559 sbi->s_resgid = EXT4_DEF_RESGID;
1560 sbi->s_sb_block = sb_block;
1490 1561
1491 unlock_kernel(); 1562 unlock_kernel();
1492 1563
@@ -1667,7 +1738,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1667 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) { 1738 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) {
1668 if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT || 1739 if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT ||
1669 sbi->s_desc_size > EXT4_MAX_DESC_SIZE || 1740 sbi->s_desc_size > EXT4_MAX_DESC_SIZE ||
1670 sbi->s_desc_size & (sbi->s_desc_size - 1)) { 1741 !is_power_of_2(sbi->s_desc_size)) {
1671 printk(KERN_ERR 1742 printk(KERN_ERR
1672 "EXT4-fs: unsupported descriptor size %lu\n", 1743 "EXT4-fs: unsupported descriptor size %lu\n",
1673 sbi->s_desc_size); 1744 sbi->s_desc_size);
@@ -1688,8 +1759,8 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1688 sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb); 1759 sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb);
1689 sbi->s_sbh = bh; 1760 sbi->s_sbh = bh;
1690 sbi->s_mount_state = le16_to_cpu(es->s_state); 1761 sbi->s_mount_state = le16_to_cpu(es->s_state);
1691 sbi->s_addr_per_block_bits = log2(EXT4_ADDR_PER_BLOCK(sb)); 1762 sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb));
1692 sbi->s_desc_per_block_bits = log2(EXT4_DESC_PER_BLOCK(sb)); 1763 sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb));
1693 for (i=0; i < 4; i++) 1764 for (i=0; i < 4; i++)
1694 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); 1765 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
1695 sbi->s_def_hash_version = es->s_def_hash_version; 1766 sbi->s_def_hash_version = es->s_def_hash_version;
@@ -1759,12 +1830,20 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1759 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); 1830 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
1760 spin_lock_init(&sbi->s_next_gen_lock); 1831 spin_lock_init(&sbi->s_next_gen_lock);
1761 1832
1762 percpu_counter_init(&sbi->s_freeblocks_counter, 1833 err = percpu_counter_init(&sbi->s_freeblocks_counter,
1763 ext4_count_free_blocks(sb)); 1834 ext4_count_free_blocks(sb));
1764 percpu_counter_init(&sbi->s_freeinodes_counter, 1835 if (!err) {
1765 ext4_count_free_inodes(sb)); 1836 err = percpu_counter_init(&sbi->s_freeinodes_counter,
1766 percpu_counter_init(&sbi->s_dirs_counter, 1837 ext4_count_free_inodes(sb));
1767 ext4_count_dirs(sb)); 1838 }
1839 if (!err) {
1840 err = percpu_counter_init(&sbi->s_dirs_counter,
1841 ext4_count_dirs(sb));
1842 }
1843 if (err) {
1844 printk(KERN_ERR "EXT4-fs: insufficient memory\n");
1845 goto failed_mount3;
1846 }
1768 1847
1769 /* per fileystem reservation list head & lock */ 1848 /* per fileystem reservation list head & lock */
1770 spin_lock_init(&sbi->s_rsv_window_lock); 1849 spin_lock_init(&sbi->s_rsv_window_lock);
@@ -2592,13 +2671,13 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
2592 buf->f_type = EXT4_SUPER_MAGIC; 2671 buf->f_type = EXT4_SUPER_MAGIC;
2593 buf->f_bsize = sb->s_blocksize; 2672 buf->f_bsize = sb->s_blocksize;
2594 buf->f_blocks = ext4_blocks_count(es) - sbi->s_overhead_last; 2673 buf->f_blocks = ext4_blocks_count(es) - sbi->s_overhead_last;
2595 buf->f_bfree = percpu_counter_sum(&sbi->s_freeblocks_counter); 2674 buf->f_bfree = percpu_counter_sum_positive(&sbi->s_freeblocks_counter);
2596 es->s_free_blocks_count = cpu_to_le32(buf->f_bfree); 2675 es->s_free_blocks_count = cpu_to_le32(buf->f_bfree);
2597 buf->f_bavail = buf->f_bfree - ext4_r_blocks_count(es); 2676 buf->f_bavail = buf->f_bfree - ext4_r_blocks_count(es);
2598 if (buf->f_bfree < ext4_r_blocks_count(es)) 2677 if (buf->f_bfree < ext4_r_blocks_count(es))
2599 buf->f_bavail = 0; 2678 buf->f_bavail = 0;
2600 buf->f_files = le32_to_cpu(es->s_inodes_count); 2679 buf->f_files = le32_to_cpu(es->s_inodes_count);
2601 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter); 2680 buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter);
2602 es->s_free_inodes_count = cpu_to_le32(buf->f_ffree); 2681 es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
2603 buf->f_namelen = EXT4_NAME_LEN; 2682 buf->f_namelen = EXT4_NAME_LEN;
2604 fsid = le64_to_cpup((void *)es->s_uuid) ^ 2683 fsid = le64_to_cpup((void *)es->s_uuid) ^