add patch dont-show-jbd-data-option-if-defaulted
[ext4-patch-queue.git] / dont-show-jbd-data-option-if-defaulted
blobcf60f6ddeca0c0ad87cd130e09fc9e03110dce72
1 ext4: don't show data=<mode> option if defaulted
3 From: Tyson Nottingham <tgnottingham@gmail.com>
5 Previously, mount -l would show data=<mode> even if the ext4 default
6 journaling mode was being used. Change this to be consistent with the
7 rest of the options.
9 Ext4 already did the right thing when the journaling mode being used
10 matched the one specified in the superblock's default mount options. The
11 reason it failed to do the right thing for the ext4 defaults is that,
12 when set, they were never included in sbi->s_def_mount_opt (unlike the
13 superblock's defaults, which were).
15 Signed-off-by: Tyson Nottingham <tgnottingham@gmail.com>
16 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
17 ---
19 Before:
21 (Without any default journaling mode configured in superblock or mount
22 option, ext4 will use its own default, which is ordered in this case.)
24 $ sudo mount -o loop=$(losetup -f) image.ext4 mnt
25 $ grep data /proc/fs/ext4/loop0/options
26 data=ordered
27 $ mount -l | grep image
28 /home/tgnottingham/image.ext4 on /home/tgnottingham/mnt type ext4 (rw,relatime,data=ordered)
30 data=ordered is still displayed, even though the ext4 default was used.
33 After:
35 $ sudo mount -o loop=$(losetup -f) image.ext4 mnt
36 $ grep data /proc/fs/ext4/loop0/options
37 data=ordered
38 $ mount -l | grep image
39 /home/tgnottingham/image.ext4 on /home/tgnottingham/mnt type ext4 (rw,relatime)
41 data=ordered is not displayed, since it was the default.
43 tgnottingham@kernel-dev:~$ sudo mount -o loop=$(losetup -f),data=journal image.ext4 mnt
44 $ grep data /proc/fs/ext4/loop0/options
45 data=journal
46 $ mount -l | grep image
47 /home/tgnottingham/image.ext4 on /home/tgnottingham/mnt type ext4 (rw,relatime,nodelalloc,data=journal)
49 data=journal is displayed, since it was not the default.
52 Default mount options stored in superblock were tested but not shown.
54 ---
55  fs/ext4/super.c | 7 +++++--
56  1 file changed, 5 insertions(+), 2 deletions(-)
58 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
59 index 7437ed0..7fbe7f4 100644
60 --- a/fs/ext4/super.c
61 +++ b/fs/ext4/super.c
62 @@ -4091,10 +4091,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
63                  * cope, else JOURNAL_DATA
64                  */
65                 if (jbd2_journal_check_available_features
66 -                   (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE))
67 +                   (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) {
68                         set_opt(sb, ORDERED_DATA);
69 -               else
70 +                       sbi->s_def_mount_opt |= EXT4_MOUNT_ORDERED_DATA;
71 +               } else {
72                         set_opt(sb, JOURNAL_DATA);
73 +                       sbi->s_def_mount_opt |= EXT4_MOUNT_JOURNAL_DATA;
74 +               }
75                 break;
77         case EXT4_MOUNT_ORDERED_DATA:
78 -- 
79 2.7.4