add patch fix-duplicate-label-for-phase-2-commit
[ext4-patch-queue.git] / introduce-own-superblock-dirty-flag
blobdb928e42fa99007b291edd62dad68eb969a05fd3
1 ext4: introduce own superblock dirty flag
3 From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
5 We finally do not need VFS's 's_dirt' flag in ext4 - introduce our own
6 's_dirty' flag instead.
8 Note: the final goal is to get rid of the 'sync_supers()' kernel
9 thread which wakes up every 5 seconds and even if there is nothing to
10 do.  Thus, we are pushing superblock management from VFS down to
11 file-systems.
13 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
14 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
15 ---
16  fs/ext4/ext4.h  |    1 +
17  fs/ext4/super.c |   12 ++++++------
18  2 files changed, 7 insertions(+), 6 deletions(-)
20 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
21 index 87e8376..be15b2d 100644
22 --- a/fs/ext4/ext4.h
23 +++ b/fs/ext4/ext4.h
24 @@ -1158,6 +1158,7 @@ struct ext4_sb_info {
25         u32 s_hash_seed[4];
26         int s_def_hash_version;
27         int s_hash_unsigned;    /* 3 if hash should be signed, 0 if not */
28 +       int s_dirty;
29         struct percpu_counter s_freeclusters_counter;
30         struct percpu_counter s_freeinodes_counter;
31         struct percpu_counter s_dirs_counter;
32 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
33 index 64f3a6a..e24dec2 100644
34 --- a/fs/ext4/super.c
35 +++ b/fs/ext4/super.c
36 @@ -824,7 +824,7 @@ static void ext4_put_super(struct super_block *sb)
37                 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
38                 es->s_state = cpu_to_le16(sbi->s_mount_state);
39         }
40 -       if (sb->s_dirt || !(sb->s_flags & MS_RDONLY))
41 +       if (sbi->s_dirty || !(sb->s_flags & MS_RDONLY))
42                 ext4_commit_super(sb, 1);
44         if (sbi->s_proc) {
45 @@ -4140,7 +4140,7 @@ static int ext4_commit_super(struct super_block *sb, int sync)
46         if (!sbh || block_device_ejected(sb))
47                 return error;
49 -       sb->s_dirt = 0;
50 +       sbi->s_dirty = 0;
51         /*
52          * Make sure we first mark the superblock as clean and then start
53          * writing it out.
54 @@ -4225,7 +4225,7 @@ static void write_super(struct work_struct *work)
55         kfree(sbwork);
57         smp_rmb();
58 -       if (!sb->s_dirt)
59 +       if (!EXT4_SB(sb)->s_dirty)
60                 return;
62         lock_super(sb);
63 @@ -4241,9 +4241,9 @@ void __ext4_mark_super_dirty(struct super_block *sb)
65         /* Make sure we see 's_dirt' changes ASAP */
66         smp_rmb();
67 -       if (sb->s_dirt == 1)
68 +       if (sbi->s_dirty == 1)
69                 return;
70 -       sb->s_dirt = 1;
71 +       sbi->s_dirty = 1;
72         /* Make other CPUs see the 's_dirt' change as soon as possible */
73         smp_wmb();
75 @@ -4254,7 +4254,7 @@ void __ext4_mark_super_dirty(struct super_block *sb)
76                  * trouble anyway, and the SB will be written out on unmount or
77                  * we may be luckier next time it is marked as dirty.
78                  */
79 -               sb->s_dirt = 2;
80 +               sbi->s_dirty = 2;
81                 return;
82         }
84 -- 
85 1.7.7.6