Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: Fix ext4_show_options to show the correct mount options.

We need to look at the default value and make sure
the mount options are not set via default value
before showing them via ext4_show_options

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

authored by

Aneesh Kumar K.V and committed by
Theodore Ts'o
aa22df2c c14c6fd5

+15 -11
+15 -11
fs/ext4/super.c
··· 665 665 */ 666 666 static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) 667 667 { 668 + int def_errors; 669 + unsigned long def_mount_opts; 668 670 struct super_block *sb = vfs->mnt_sb; 669 671 struct ext4_sb_info *sbi = EXT4_SB(sb); 670 672 struct ext4_super_block *es = sbi->s_es; 671 - unsigned long def_mount_opts; 672 673 673 674 def_mount_opts = le32_to_cpu(es->s_default_mount_opts); 675 + def_errors = le16_to_cpu(es->s_errors); 674 676 675 677 if (sbi->s_sb_block != 1) 676 678 seq_printf(seq, ",sb=%llu", sbi->s_sb_block); 677 679 if (test_opt(sb, MINIX_DF)) 678 680 seq_puts(seq, ",minixdf"); 679 - if (test_opt(sb, GRPID)) 681 + if (test_opt(sb, GRPID) && !(def_mount_opts & EXT4_DEFM_BSDGROUPS)) 680 682 seq_puts(seq, ",grpid"); 681 683 if (!test_opt(sb, GRPID) && (def_mount_opts & EXT4_DEFM_BSDGROUPS)) 682 684 seq_puts(seq, ",nogrpid"); ··· 691 689 seq_printf(seq, ",resgid=%u", sbi->s_resgid); 692 690 } 693 691 if (test_opt(sb, ERRORS_RO)) { 694 - int def_errors = le16_to_cpu(es->s_errors); 695 - 696 692 if (def_errors == EXT4_ERRORS_PANIC || 697 693 def_errors == EXT4_ERRORS_CONTINUE) { 698 694 seq_puts(seq, ",errors=remount-ro"); 699 695 } 700 696 } 701 - if (test_opt(sb, ERRORS_CONT)) 697 + if (test_opt(sb, ERRORS_CONT) && def_errors != EXT4_ERRORS_CONTINUE) 702 698 seq_puts(seq, ",errors=continue"); 703 - if (test_opt(sb, ERRORS_PANIC)) 699 + if (test_opt(sb, ERRORS_PANIC) && def_errors != EXT4_ERRORS_PANIC) 704 700 seq_puts(seq, ",errors=panic"); 705 - if (test_opt(sb, NO_UID32)) 701 + if (test_opt(sb, NO_UID32) && !(def_mount_opts & EXT4_DEFM_UID16)) 706 702 seq_puts(seq, ",nouid32"); 707 - if (test_opt(sb, DEBUG)) 703 + if (test_opt(sb, DEBUG) && !(def_mount_opts & EXT4_DEFM_DEBUG)) 708 704 seq_puts(seq, ",debug"); 709 705 if (test_opt(sb, OLDALLOC)) 710 706 seq_puts(seq, ",oldalloc"); 711 707 #ifdef CONFIG_EXT4DEV_FS_XATTR 712 - if (test_opt(sb, XATTR_USER)) 708 + if (test_opt(sb, XATTR_USER) && 709 + !(def_mount_opts & EXT4_DEFM_XATTR_USER)) 713 710 seq_puts(seq, ",user_xattr"); 714 711 if (!test_opt(sb, XATTR_USER) && 715 712 (def_mount_opts & EXT4_DEFM_XATTR_USER)) { ··· 716 715 } 717 716 #endif 718 717 #ifdef CONFIG_EXT4DEV_FS_POSIX_ACL 719 - if (test_opt(sb, POSIX_ACL)) 718 + if (test_opt(sb, POSIX_ACL) && !(def_mount_opts & EXT4_DEFM_ACL)) 720 719 seq_puts(seq, ",acl"); 721 720 if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT4_DEFM_ACL)) 722 721 seq_puts(seq, ",noacl"); ··· 736 735 if (test_opt(sb, I_VERSION)) 737 736 seq_puts(seq, ",i_version"); 738 737 738 + /* 739 + * journal mode get enabled in different ways 740 + * So just print the value even if we didn't specify it 741 + */ 739 742 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) 740 743 seq_puts(seq, ",data=journal"); 741 744 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) ··· 748 743 seq_puts(seq, ",data=writeback"); 749 744 750 745 ext4_show_quota_options(seq, sb); 751 - 752 746 return 0; 753 747 } 754 748