Commit ababea77 authored by Harshad Shirwadkar's avatar Harshad Shirwadkar Committed by Theodore Ts'o

ext4: use s_mount_flags instead of s_mount_state for fast commit state

Ext4's fast commit related transient states should use
sb->s_mount_flags instead of persistent sb->s_mount_state.

Fixes: 8016e29f ("ext4: fast commit recovery path")
Signed-off-by: default avatarHarshad Shirwadkar <harshadshirwadkar@gmail.com>
Link: https://lore.kernel.org/r/20201027044915.2553163-3-harshadshirwadkar@gmail.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent e029c5f2
...@@ -1166,10 +1166,6 @@ struct ext4_inode_info { ...@@ -1166,10 +1166,6 @@ struct ext4_inode_info {
#define EXT4_VALID_FS 0x0001 /* Unmounted cleanly */ #define EXT4_VALID_FS 0x0001 /* Unmounted cleanly */
#define EXT4_ERROR_FS 0x0002 /* Errors detected */ #define EXT4_ERROR_FS 0x0002 /* Errors detected */
#define EXT4_ORPHAN_FS 0x0004 /* Orphans being recovered */ #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 */ #define EXT4_FC_REPLAY 0x0020 /* Fast commit replay ongoing */
/* /*
...@@ -1431,6 +1427,10 @@ struct ext4_super_block { ...@@ -1431,6 +1427,10 @@ struct ext4_super_block {
*/ */
#define EXT4_MF_MNTDIR_SAMPLED 0x0001 #define EXT4_MF_MNTDIR_SAMPLED 0x0001
#define EXT4_MF_FS_ABORTED 0x0002 /* Fatal error detected */ #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 #ifdef CONFIG_FS_ENCRYPTION
#define DUMMY_ENCRYPTION_ENABLED(sbi) ((sbi)->s_dummy_enc_policy.policy != NULL) #define DUMMY_ENCRYPTION_ENABLED(sbi) ((sbi)->s_dummy_enc_policy.policy != NULL)
......
...@@ -269,7 +269,7 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason) ...@@ -269,7 +269,7 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason)
(EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))
return; return;
sbi->s_mount_state |= EXT4_FC_INELIGIBLE; sbi->s_mount_flags |= EXT4_MF_FC_INELIGIBLE;
WARN_ON(reason >= EXT4_FC_REASON_MAX); WARN_ON(reason >= EXT4_FC_REASON_MAX);
sbi->s_fc_stats.fc_ineligible_reason_count[reason]++; sbi->s_fc_stats.fc_ineligible_reason_count[reason]++;
} }
...@@ -292,7 +292,7 @@ void ext4_fc_start_ineligible(struct super_block *sb, int 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 * to ensure that after stopping the ineligible update, at least one full
* commit takes place. * commit takes place.
*/ */
...@@ -302,13 +302,13 @@ void ext4_fc_stop_ineligible(struct super_block *sb) ...@@ -302,13 +302,13 @@ void ext4_fc_stop_ineligible(struct super_block *sb)
(EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))
return; 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); atomic_dec(&EXT4_SB(sb)->s_fc_ineligible_updates);
} }
static inline int ext4_fc_is_ineligible(struct super_block *sb) 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); atomic_read(&EXT4_SB(sb)->s_fc_ineligible_updates);
} }
...@@ -358,7 +358,7 @@ static int ext4_fc_track_template( ...@@ -358,7 +358,7 @@ static int ext4_fc_track_template(
spin_lock(&sbi->s_fc_lock); spin_lock(&sbi->s_fc_lock);
if (list_empty(&EXT4_I(inode)->i_fc_list)) if (list_empty(&EXT4_I(inode)->i_fc_list))
list_add_tail(&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_STAGING] :
&sbi->s_fc_q[FC_Q_MAIN]); &sbi->s_fc_q[FC_Q_MAIN]);
spin_unlock(&sbi->s_fc_lock); spin_unlock(&sbi->s_fc_lock);
...@@ -411,7 +411,7 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update) ...@@ -411,7 +411,7 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update)
node->fcd_name.len = dentry->d_name.len; node->fcd_name.len = dentry->d_name.len;
spin_lock(&sbi->s_fc_lock); 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, list_add_tail(&node->fcd_list,
&sbi->s_fc_dentry_q[FC_Q_STAGING]); &sbi->s_fc_dentry_q[FC_Q_STAGING]);
else else
...@@ -846,7 +846,7 @@ static int ext4_fc_submit_inode_data_all(journal_t *journal) ...@@ -846,7 +846,7 @@ static int ext4_fc_submit_inode_data_all(journal_t *journal)
int ret = 0; int ret = 0;
spin_lock(&sbi->s_fc_lock); 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]) { list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
ei = list_entry(pos, struct ext4_inode_info, i_fc_list); ei = list_entry(pos, struct ext4_inode_info, i_fc_list);
ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING); 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) ...@@ -1190,8 +1190,8 @@ static void ext4_fc_cleanup(journal_t *journal, int full)
list_splice_init(&sbi->s_fc_q[FC_Q_STAGING], list_splice_init(&sbi->s_fc_q[FC_Q_STAGING],
&sbi->s_fc_q[FC_Q_STAGING]); &sbi->s_fc_q[FC_Q_STAGING]);
sbi->s_mount_state &= ~EXT4_FC_COMMITTING; sbi->s_mount_flags &= ~EXT4_MF_FC_COMMITTING;
sbi->s_mount_state &= ~EXT4_FC_INELIGIBLE; sbi->s_mount_flags &= ~EXT4_MF_FC_INELIGIBLE;
if (full) if (full)
sbi->s_fc_bytes = 0; sbi->s_fc_bytes = 0;
......
...@@ -4777,8 +4777,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -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_MAIN]);
INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]); INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]);
sbi->s_fc_bytes = 0; sbi->s_fc_bytes = 0;
sbi->s_mount_state &= ~EXT4_FC_INELIGIBLE; sbi->s_mount_flags &= ~EXT4_MF_FC_INELIGIBLE;
sbi->s_mount_state &= ~EXT4_FC_COMMITTING; sbi->s_mount_flags &= ~EXT4_MF_FC_COMMITTING;
spin_lock_init(&sbi->s_fc_lock); spin_lock_init(&sbi->s_fc_lock);
memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats)); memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats));
sbi->s_fc_replay_state.fc_regions = NULL; sbi->s_fc_replay_state.fc_regions = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment