aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2012-03-04 19:27:31 -0500
committerTheodore Ts'o <tytso@mit.edu>2012-03-04 19:27:31 -0500
commit5a916be1b31de9e833aa764de6faf27bb79f9b83 (patch)
tree62cf0697a0edef5ab44870cbc81cf07451f232ef /fs/ext4/super.c
parent2adf6da8379b68838aa1002e11efd66916689a9b (diff)
ext4: make ext4_show_options() be table-driven
Consistently show mount options which are the non-default, so that /proc/mounts accurately shows the mount options that would be necessary to mount the file system in its current mode of operation. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c172
1 files changed, 61 insertions, 111 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 7e3a319ec402..70828699fa89 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1198,8 +1198,8 @@ static const match_table_t tokens = {
1198 {Opt_nouser_xattr, "nouser_xattr"}, 1198 {Opt_nouser_xattr, "nouser_xattr"},
1199 {Opt_acl, "acl"}, 1199 {Opt_acl, "acl"},
1200 {Opt_noacl, "noacl"}, 1200 {Opt_noacl, "noacl"},
1201 {Opt_noload, "noload"},
1202 {Opt_noload, "norecovery"}, 1201 {Opt_noload, "norecovery"},
1202 {Opt_noload, "noload"},
1203 {Opt_removed, "nobh"}, 1203 {Opt_removed, "nobh"},
1204 {Opt_removed, "bh"}, 1204 {Opt_removed, "bh"},
1205 {Opt_commit, "commit=%u"}, 1205 {Opt_commit, "commit=%u"},
@@ -1668,6 +1668,16 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
1668#endif 1668#endif
1669} 1669}
1670 1670
1671static const char *token2str(int token)
1672{
1673 static const struct match_token *t;
1674
1675 for (t = tokens; t->token != Opt_err; t++)
1676 if (t->token == token && !strchr(t->pattern, '='))
1677 break;
1678 return t->pattern;
1679}
1680
1671/* 1681/*
1672 * Show an option if 1682 * Show an option if
1673 * - it's set to a non-default value OR 1683 * - it's set to a non-default value OR
@@ -1676,132 +1686,71 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
1676static int ext4_show_options(struct seq_file *seq, struct dentry *root) 1686static int ext4_show_options(struct seq_file *seq, struct dentry *root)
1677{ 1687{
1678 int def_errors; 1688 int def_errors;
1679 unsigned long def_mount_opts;
1680 struct super_block *sb = root->d_sb; 1689 struct super_block *sb = root->d_sb;
1681 struct ext4_sb_info *sbi = EXT4_SB(sb); 1690 struct ext4_sb_info *sbi = EXT4_SB(sb);
1682 struct ext4_super_block *es = sbi->s_es; 1691 struct ext4_super_block *es = sbi->s_es;
1692 const struct mount_opts *m;
1683 1693
1684 def_mount_opts = le32_to_cpu(es->s_default_mount_opts); 1694#define SEQ_OPTS_PUTS(str) seq_printf(seq, "," str)
1685 def_errors = le16_to_cpu(es->s_errors); 1695#define SEQ_OPTS_PRINT(str, arg) seq_printf(seq, "," str, arg)
1686 1696
1687 if (sbi->s_sb_block != 1) 1697 if (sbi->s_sb_block != 1)
1688 seq_printf(seq, ",sb=%llu", sbi->s_sb_block); 1698 SEQ_OPTS_PRINT("sb=%llu", sbi->s_sb_block);
1689 if (test_opt(sb, MINIX_DF)) 1699
1690 seq_puts(seq, ",minixdf"); 1700 for (m = ext4_mount_opts; m->token != Opt_err; m++) {
1691 if (test_opt(sb, GRPID) && !(def_mount_opts & EXT4_DEFM_BSDGROUPS)) 1701 int want_set = m->flags & MOPT_SET;
1692 seq_puts(seq, ",grpid"); 1702 if (((m->flags & (MOPT_SET|MOPT_CLEAR)) == 0) ||
1693 if (!test_opt(sb, GRPID) && (def_mount_opts & EXT4_DEFM_BSDGROUPS)) 1703 (m->flags & MOPT_CLEAR_ERR))
1694 seq_puts(seq, ",nogrpid"); 1704 continue;
1695 if (sbi->s_resuid != EXT4_DEF_RESUID || 1705 if (!(m->mount_opt & (sbi->s_mount_opt ^ sbi->s_def_mount_opt)))
1696 le16_to_cpu(es->s_def_resuid) != EXT4_DEF_RESUID) { 1706 continue; /* skip if same as the default */
1697 seq_printf(seq, ",resuid=%u", sbi->s_resuid); 1707 if ((want_set &&
1708 (sbi->s_mount_opt & m->mount_opt) != m->mount_opt) ||
1709 (!want_set && (sbi->s_mount_opt & m->mount_opt)))
1710 continue; /* select Opt_noFoo vs Opt_Foo */
1711 SEQ_OPTS_PRINT("%s", token2str(m->token));
1698 } 1712 }
1713
1714 if (sbi->s_resuid != EXT4_DEF_RESUID ||
1715 le16_to_cpu(es->s_def_resuid) != EXT4_DEF_RESUID)
1716 SEQ_OPTS_PRINT("resuid=%u", sbi->s_resuid);
1699 if (sbi->s_resgid != EXT4_DEF_RESGID || 1717 if (sbi->s_resgid != EXT4_DEF_RESGID ||
1700 le16_to_cpu(es->s_def_resgid) != EXT4_DEF_RESGID) { 1718 le16_to_cpu(es->s_def_resgid) != EXT4_DEF_RESGID)
1701 seq_printf(seq, ",resgid=%u", sbi->s_resgid); 1719 SEQ_OPTS_PRINT("resgid=%u", sbi->s_resgid);
1702 } 1720 def_errors = le16_to_cpu(es->s_errors);
1703 if (test_opt(sb, ERRORS_RO)) { 1721 if (test_opt(sb, ERRORS_RO) && def_errors != EXT4_ERRORS_RO)
1704 if (def_errors == EXT4_ERRORS_PANIC || 1722 SEQ_OPTS_PUTS("errors=remount-ro");
1705 def_errors == EXT4_ERRORS_CONTINUE) {
1706 seq_puts(seq, ",errors=remount-ro");
1707 }
1708 }
1709 if (test_opt(sb, ERRORS_CONT) && def_errors != EXT4_ERRORS_CONTINUE) 1723 if (test_opt(sb, ERRORS_CONT) && def_errors != EXT4_ERRORS_CONTINUE)
1710 seq_puts(seq, ",errors=continue"); 1724 SEQ_OPTS_PUTS("errors=continue");
1711 if (test_opt(sb, ERRORS_PANIC) && def_errors != EXT4_ERRORS_PANIC) 1725 if (test_opt(sb, ERRORS_PANIC) && def_errors != EXT4_ERRORS_PANIC)
1712 seq_puts(seq, ",errors=panic"); 1726 SEQ_OPTS_PUTS("errors=panic");
1713 if (test_opt(sb, NO_UID32) && !(def_mount_opts & EXT4_DEFM_UID16)) 1727 if (sbi->s_commit_interval != JBD2_DEFAULT_MAX_COMMIT_AGE*HZ)
1714 seq_puts(seq, ",nouid32"); 1728 SEQ_OPTS_PRINT("commit=%lu", sbi->s_commit_interval / HZ);
1715 if (test_opt(sb, DEBUG) && !(def_mount_opts & EXT4_DEFM_DEBUG)) 1729 if (sbi->s_min_batch_time != EXT4_DEF_MIN_BATCH_TIME)
1716 seq_puts(seq, ",debug"); 1730 SEQ_OPTS_PRINT("min_batch_time=%u", sbi->s_min_batch_time);
1717#ifdef CONFIG_EXT4_FS_XATTR 1731 if (sbi->s_max_batch_time != EXT4_DEF_MAX_BATCH_TIME)
1718 if (test_opt(sb, XATTR_USER)) 1732 SEQ_OPTS_PRINT("max_batch_time=%u", sbi->s_max_batch_time);
1719 seq_puts(seq, ",user_xattr");
1720 if (!test_opt(sb, XATTR_USER))
1721 seq_puts(seq, ",nouser_xattr");
1722#endif
1723#ifdef CONFIG_EXT4_FS_POSIX_ACL
1724 if (test_opt(sb, POSIX_ACL) && !(def_mount_opts & EXT4_DEFM_ACL))
1725 seq_puts(seq, ",acl");
1726 if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT4_DEFM_ACL))
1727 seq_puts(seq, ",noacl");
1728#endif
1729 if (sbi->s_commit_interval != JBD2_DEFAULT_MAX_COMMIT_AGE*HZ) {
1730 seq_printf(seq, ",commit=%u",
1731 (unsigned) (sbi->s_commit_interval / HZ));
1732 }
1733 if (sbi->s_min_batch_time != EXT4_DEF_MIN_BATCH_TIME) {
1734 seq_printf(seq, ",min_batch_time=%u",
1735 (unsigned) sbi->s_min_batch_time);
1736 }
1737 if (sbi->s_max_batch_time != EXT4_DEF_MAX_BATCH_TIME) {
1738 seq_printf(seq, ",max_batch_time=%u",
1739 (unsigned) sbi->s_max_batch_time);
1740 }
1741
1742 /*
1743 * We're changing the default of barrier mount option, so
1744 * let's always display its mount state so it's clear what its
1745 * status is.
1746 */
1747 seq_puts(seq, ",barrier=");
1748 seq_puts(seq, test_opt(sb, BARRIER) ? "1" : "0");
1749 if (test_opt(sb, JOURNAL_ASYNC_COMMIT))
1750 seq_puts(seq, ",journal_async_commit");
1751 else if (test_opt(sb, JOURNAL_CHECKSUM))
1752 seq_puts(seq, ",journal_checksum");
1753 if (sb->s_flags & MS_I_VERSION) 1733 if (sb->s_flags & MS_I_VERSION)
1754 seq_puts(seq, ",i_version"); 1734 SEQ_OPTS_PUTS("i_version");
1755 if (!test_opt(sb, DELALLOC) &&
1756 !(def_mount_opts & EXT4_DEFM_NODELALLOC))
1757 seq_puts(seq, ",nodelalloc");
1758
1759 if (!test_opt(sb, MBLK_IO_SUBMIT))
1760 seq_puts(seq, ",nomblk_io_submit");
1761 if (sbi->s_stripe) 1735 if (sbi->s_stripe)
1762 seq_printf(seq, ",stripe=%lu", sbi->s_stripe); 1736 SEQ_OPTS_PRINT("stripe=%lu", sbi->s_stripe);
1763 /* 1737 if (EXT4_MOUNT_DATA_FLAGS & (sbi->s_mount_opt ^ sbi->s_def_mount_opt)) {
1764 * journal mode get enabled in different ways 1738 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
1765 * So just print the value even if we didn't specify it 1739 SEQ_OPTS_PUTS("data=journal");
1766 */ 1740 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA)
1767 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) 1741 SEQ_OPTS_PUTS("data=ordered");
1768 seq_puts(seq, ",data=journal"); 1742 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
1769 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) 1743 SEQ_OPTS_PUTS("data=writeback");
1770 seq_puts(seq, ",data=ordered"); 1744 }
1771 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
1772 seq_puts(seq, ",data=writeback");
1773
1774 if (sbi->s_inode_readahead_blks != EXT4_DEF_INODE_READAHEAD_BLKS) 1745 if (sbi->s_inode_readahead_blks != EXT4_DEF_INODE_READAHEAD_BLKS)
1775 seq_printf(seq, ",inode_readahead_blks=%u", 1746 SEQ_OPTS_PRINT("inode_readahead_blks=%u",
1776 sbi->s_inode_readahead_blks); 1747 sbi->s_inode_readahead_blks);
1777
1778 if (test_opt(sb, DATA_ERR_ABORT))
1779 seq_puts(seq, ",data_err=abort");
1780
1781 if (test_opt(sb, NO_AUTO_DA_ALLOC))
1782 seq_puts(seq, ",noauto_da_alloc");
1783 1748
1784 if (test_opt(sb, DISCARD) && !(def_mount_opts & EXT4_DEFM_DISCARD)) 1749 if (test_opt(sb, INIT_INODE_TABLE) &&
1785 seq_puts(seq, ",discard"); 1750 (sbi->s_li_wait_mult != EXT4_DEF_LI_WAIT_MULT))
1786 1751 SEQ_OPTS_PRINT("init_itable=%u", sbi->s_li_wait_mult);
1787 if (test_opt(sb, NOLOAD))
1788 seq_puts(seq, ",norecovery");
1789
1790 if (test_opt(sb, DIOREAD_NOLOCK))
1791 seq_puts(seq, ",dioread_nolock");
1792
1793 if (test_opt(sb, BLOCK_VALIDITY) &&
1794 !(def_mount_opts & EXT4_DEFM_BLOCK_VALIDITY))
1795 seq_puts(seq, ",block_validity");
1796
1797 if (!test_opt(sb, INIT_INODE_TABLE))
1798 seq_puts(seq, ",noinit_itable");
1799 else if (sbi->s_li_wait_mult != EXT4_DEF_LI_WAIT_MULT)
1800 seq_printf(seq, ",init_itable=%u",
1801 (unsigned) sbi->s_li_wait_mult);
1802 1752
1803 ext4_show_quota_options(seq, sb); 1753 ext4_show_quota_options(seq, sb);
1804
1805 return 0; 1754 return 0;
1806} 1755}
1807 1756
@@ -3105,6 +3054,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3105 "failed to parse options in superblock: %s", 3054 "failed to parse options in superblock: %s",
3106 sbi->s_es->s_mount_opts); 3055 sbi->s_es->s_mount_opts);
3107 } 3056 }
3057 sbi->s_def_mount_opt = sbi->s_mount_opt;
3108 if (!parse_options((char *) data, sb, &journal_devnum, 3058 if (!parse_options((char *) data, sb, &journal_devnum,
3109 &journal_ioprio, 0)) 3059 &journal_ioprio, 0))
3110 goto failed_mount; 3060 goto failed_mount;