ext4: use s_mount_flags instead of s_mount_state for fast commit state
authorHarshad Shirwadkar <harshadshirwadkar@gmail.com>
Tue, 27 Oct 2020 04:49:15 +0000 (21:49 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 28 Oct 2020 17:42:10 +0000 (13:42 -0400)
Ext4's fast commit related transient states should use
sb->s_mount_flags instead of persistent sb->s_mount_state.

Fixes: 8016e29f4362 ("ext4: fast commit recovery path")
Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Link: https://lore.kernel.org/r/20201027044915.2553163-3-harshadshirwadkar@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ext4.h
fs/ext4/fast_commit.c
fs/ext4/super.c

index 254d1c26bea8a80228ace0c1dbe330b535cfe845..2337e443fa30f700fb983c3ff42ec0d378fbe529 100644 (file)
@@ -1166,10 +1166,6 @@ struct ext4_inode_info {
 #define        EXT4_VALID_FS                   0x0001  /* Unmounted cleanly */
 #define        EXT4_ERROR_FS                   0x0002  /* Errors detected */
 #define        EXT4_ORPHAN_FS                  0x0004  /* Orphans being recovered */
-#define EXT4_FC_INELIGIBLE             0x0008  /* Fast commit ineligible */
-#define EXT4_FC_COMMITTING             0x0010  /* File system underoing a fast
-                                                * commit.
-                                                */
 #define EXT4_FC_REPLAY                 0x0020  /* Fast commit replay ongoing */
 
 /*
@@ -1431,6 +1427,10 @@ struct ext4_super_block {
  */
 #define EXT4_MF_MNTDIR_SAMPLED         0x0001
 #define EXT4_MF_FS_ABORTED             0x0002  /* Fatal error detected */
+#define EXT4_MF_FC_INELIGIBLE          0x0004  /* Fast commit ineligible */
+#define EXT4_MF_FC_COMMITTING          0x0008  /* File system underoing a fast
+                                                * commit.
+                                                */
 
 #ifdef CONFIG_FS_ENCRYPTION
 #define DUMMY_ENCRYPTION_ENABLED(sbi) ((sbi)->s_dummy_enc_policy.policy != NULL)
index dd7931400474a283ead3370b2eeda19432e8029d..3ee43fd6d5aa7056e3b74ba0e9e152ad61dc0d53 100644 (file)
@@ -269,7 +269,7 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason)
            (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))
                return;
 
-       sbi->s_mount_state |= EXT4_FC_INELIGIBLE;
+       sbi->s_mount_flags |= EXT4_MF_FC_INELIGIBLE;
        WARN_ON(reason >= EXT4_FC_REASON_MAX);
        sbi->s_fc_stats.fc_ineligible_reason_count[reason]++;
 }
@@ -292,7 +292,7 @@ void ext4_fc_start_ineligible(struct super_block *sb, int reason)
 }
 
 /*
- * Stop a fast commit ineligible update. We set EXT4_FC_INELIGIBLE flag here
+ * Stop a fast commit ineligible update. We set EXT4_MF_FC_INELIGIBLE flag here
  * to ensure that after stopping the ineligible update, at least one full
  * commit takes place.
  */
@@ -302,13 +302,13 @@ void ext4_fc_stop_ineligible(struct super_block *sb)
            (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))
                return;
 
-       EXT4_SB(sb)->s_mount_state |= EXT4_FC_INELIGIBLE;
+       EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FC_INELIGIBLE;
        atomic_dec(&EXT4_SB(sb)->s_fc_ineligible_updates);
 }
 
 static inline int ext4_fc_is_ineligible(struct super_block *sb)
 {
-       return (EXT4_SB(sb)->s_mount_state & EXT4_FC_INELIGIBLE) ||
+       return (EXT4_SB(sb)->s_mount_flags & EXT4_MF_FC_INELIGIBLE) ||
                atomic_read(&EXT4_SB(sb)->s_fc_ineligible_updates);
 }
 
@@ -358,7 +358,7 @@ static int ext4_fc_track_template(
        spin_lock(&sbi->s_fc_lock);
        if (list_empty(&EXT4_I(inode)->i_fc_list))
                list_add_tail(&EXT4_I(inode)->i_fc_list,
-                               (sbi->s_mount_state & EXT4_FC_COMMITTING) ?
+                               (sbi->s_mount_flags & EXT4_MF_FC_COMMITTING) ?
                                &sbi->s_fc_q[FC_Q_STAGING] :
                                &sbi->s_fc_q[FC_Q_MAIN]);
        spin_unlock(&sbi->s_fc_lock);
@@ -411,7 +411,7 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update)
        node->fcd_name.len = dentry->d_name.len;
 
        spin_lock(&sbi->s_fc_lock);
-       if (sbi->s_mount_state & EXT4_FC_COMMITTING)
+       if (sbi->s_mount_flags & EXT4_MF_FC_COMMITTING)
                list_add_tail(&node->fcd_list,
                                &sbi->s_fc_dentry_q[FC_Q_STAGING]);
        else
@@ -846,7 +846,7 @@ static int ext4_fc_submit_inode_data_all(journal_t *journal)
        int ret = 0;
 
        spin_lock(&sbi->s_fc_lock);
-       sbi->s_mount_state |= EXT4_FC_COMMITTING;
+       sbi->s_mount_flags |= EXT4_MF_FC_COMMITTING;
        list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
                ei = list_entry(pos, struct ext4_inode_info, i_fc_list);
                ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING);
@@ -1190,8 +1190,8 @@ static void ext4_fc_cleanup(journal_t *journal, int full)
        list_splice_init(&sbi->s_fc_q[FC_Q_STAGING],
                                &sbi->s_fc_q[FC_Q_STAGING]);
 
-       sbi->s_mount_state &= ~EXT4_FC_COMMITTING;
-       sbi->s_mount_state &= ~EXT4_FC_INELIGIBLE;
+       sbi->s_mount_flags &= ~EXT4_MF_FC_COMMITTING;
+       sbi->s_mount_flags &= ~EXT4_MF_FC_INELIGIBLE;
 
        if (full)
                sbi->s_fc_bytes = 0;
index 03373471131cdf23c6b7965cfe3535e00d414767..d92de21212e937d45dee9716723574028ba17201 100644 (file)
@@ -4777,8 +4777,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
        INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]);
        INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]);
        sbi->s_fc_bytes = 0;
-       sbi->s_mount_state &= ~EXT4_FC_INELIGIBLE;
-       sbi->s_mount_state &= ~EXT4_FC_COMMITTING;
+       sbi->s_mount_flags &= ~EXT4_MF_FC_INELIGIBLE;
+       sbi->s_mount_flags &= ~EXT4_MF_FC_COMMITTING;
        spin_lock_init(&sbi->s_fc_lock);
        memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats));
        sbi->s_fc_replay_state.fc_regions = NULL;