From: Wu Bo <wubo40@xxxxxxxxxx>
This patch adds helpers functions for s_mount_state.
Signed-off-by: Wu Bo <wubo40@xxxxxxxxxx>
---
fs/ext4/balloc.c | 2 +-
fs/ext4/ext4.h | 14 ++++++++++++++
fs/ext4/ext4_jbd2.c | 2 +-
fs/ext4/extents_status.c | 16 ++++++++--------
fs/ext4/fast_commit.c | 6 +++---
fs/ext4/ialloc.c | 14 +++++++-------
fs/ext4/inode.c | 12 ++++++------
fs/ext4/mballoc.c | 8 ++++----
fs/ext4/namei.c | 4 ++--
fs/ext4/orphan.c | 7 ++++---
fs/ext4/resize.c | 4 ++--
fs/ext4/super.c | 20 ++++++++++----------
12 files changed, 62 insertions(+), 47 deletions(-)
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 1f72f977c6db..9baa88cacbe0 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -402,7 +402,7 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
ext4_fsblk_t blk;
struct ext4_group_info *grp;
- if (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)
+ if (ext4_test_mount_state(sb, EXT4_FC_REPLAY))
return 0;
grp = ext4_get_group_info(sb, block_group);
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 0a2d55faa095..5b1995986704 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1817,6 +1817,20 @@ static inline int ext4_test_mount_flag(struct super_block *sb, int bit)
return test_bit(bit, &EXT4_SB(sb)->s_mount_flags);
}
+static inline void ext4_set_mount_state(struct super_block *sb, int state)
+{
+ EXT4_SB(sb)->s_mount_state |= state;
+}
+
+static inline void ext4_clear_mount_state(struct super_block *sb, int state)
+{
+ EXT4_SB(sb)->s_mount_state &= ~state;
+}
+
+static inline int ext4_test_mount_state(struct super_block *sb, int state)
+{
+ return EXT4_SB(sb)->s_mount_state & state;
+}
/*
* Simulate_fail codes
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index 77f318ec8abb..6ba75ae2c188 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -106,7 +106,7 @@ handle_t *__ext4_journal_start_sb(struct inode *inode,
return ERR_PTR(err);
journal = EXT4_SB(sb)->s_journal;
- if (!journal || (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))
+ if (!journal || ext4_test_mount_state(sb, EXT4_FC_REPLAY))
return ext4_get_nojournal();
return jbd2__journal_start(journal, blocks, rsv_blocks, revoke_creds,
GFP_NOFS, type, line);
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 9b5b8951afb4..b37b9c29c9fa 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -309,7 +309,7 @@ void ext4_es_find_extent_range(struct inode *inode,
ext4_lblk_t lblk, ext4_lblk_t end,
struct extent_status *es)
{
- if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
+ if (ext4_test_mount_state(inode->i_sb, EXT4_FC_REPLAY))
return;
trace_ext4_es_find_extent_range_enter(inode, lblk);
@@ -362,7 +362,7 @@ bool ext4_es_scan_range(struct inode *inode,
{
bool ret;
- if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
+ if (ext4_test_mount_state(inode->i_sb, EXT4_FC_REPLAY))
return false;
read_lock(&EXT4_I(inode)->i_es_lock);
@@ -408,7 +408,7 @@ bool ext4_es_scan_clu(struct inode *inode,
{
bool ret;
- if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
+ if (ext4_test_mount_state(inode->i_sb, EXT4_FC_REPLAY))
return false;
read_lock(&EXT4_I(inode)->i_es_lock);
@@ -842,7 +842,7 @@ void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
struct extent_status *es1 = NULL;
struct extent_status *es2 = NULL;
- if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
+ if (ext4_test_mount_state(inode->i_sb, EXT4_FC_REPLAY))
return;
es_debug("add [%u/%u) %llu %x to extent status tree of inode %lu\n",
@@ -917,7 +917,7 @@ void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk,
struct extent_status newes;
ext4_lblk_t end = lblk + len - 1;
- if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
+ if (ext4_test_mount_state(inode->i_sb, EXT4_FC_REPLAY))
return;
newes.es_lblk = lblk;
@@ -955,7 +955,7 @@ int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk,
struct rb_node *node;
int found = 0;
- if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
+ if (ext4_test_mount_state(inode->i_sb, EXT4_FC_REPLAY))
return 0;
trace_ext4_es_lookup_extent_enter(inode, lblk);
@@ -1468,7 +1468,7 @@ void ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
int reserved = 0;
struct extent_status *es = NULL;
- if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
+ if (ext4_test_mount_state(inode->i_sb, EXT4_FC_REPLAY))
return;
trace_ext4_es_remove_extent(inode, lblk, len);
@@ -2024,7 +2024,7 @@ void ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
struct extent_status *es1 = NULL;
struct extent_status *es2 = NULL;
- if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
+ if (ext4_test_mount_state(inode->i_sb, EXT4_FC_REPLAY))
return;
es_debug("add [%u/1) delayed to extent status tree of inode %lu\n",
diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
index b06de728b3b6..023e13ec9fdc 100644
--- a/fs/ext4/fast_commit.c
+++ b/fs/ext4/fast_commit.c
@@ -232,7 +232,7 @@ __releases(&EXT4_SB(inode->i_sb)->s_fc_lock)
static bool ext4_fc_disabled(struct super_block *sb)
{
return (!test_opt2(sb, JOURNAL_FAST_COMMIT) ||
- (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY));
+ ext4_test_mount_state(sb, EXT4_FC_REPLAY));
}
/*
@@ -1975,7 +1975,7 @@ void ext4_fc_replay_cleanup(struct super_block *sb)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
- sbi->s_mount_state &= ~EXT4_FC_REPLAY;
+ ext4_clear_mount_state(sb, EXT4_FC_REPLAY);
kfree(sbi->s_fc_replay_state.fc_regions);
kfree(sbi->s_fc_replay_state.fc_modified_inodes);
}
@@ -2165,7 +2165,7 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
if (state->fc_current_pass != pass) {
state->fc_current_pass = pass;
- sbi->s_mount_state |= EXT4_FC_REPLAY;
+ ext4_set_mount_state(sb, EXT4_FC_REPLAY);
}
if (!sbi->s_fc_replay_state.fc_replay_num_tags) {
ext4_debug("Replay stops\n");
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 754f961cd9fd..09ec20b2e761 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -84,7 +84,7 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
ext4_fsblk_t blk;
struct ext4_group_info *grp;
- if (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)
+ if (ext4_test_mount_state(sb, EXT4_FC_REPLAY))
return 0;
grp = ext4_get_group_info(sb, block_group);
@@ -291,7 +291,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
bitmap_bh = NULL;
goto error_return;
}
- if (!(sbi->s_mount_state & EXT4_FC_REPLAY)) {
+ if (!ext4_test_mount_state(sb, EXT4_FC_REPLAY)) {
grp = ext4_get_group_info(sb, block_group);
if (!grp || unlikely(EXT4_MB_GRP_IBITMAP_CORRUPT(grp))) {
fatal = -EFSCORRUPTED;
@@ -1040,7 +1040,7 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
if (ext4_free_inodes_count(sb, gdp) == 0)
goto next_group;
- if (!(sbi->s_mount_state & EXT4_FC_REPLAY)) {
+ if (!ext4_test_mount_state(sb, EXT4_FC_REPLAY)) {
grp = ext4_get_group_info(sb, group);
/*
* Skip groups with already-known suspicious inode
@@ -1053,7 +1053,7 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
brelse(inode_bitmap_bh);
inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
/* Skip groups with suspicious inode tables */
- if (((!(sbi->s_mount_state & EXT4_FC_REPLAY))
+ if (((ext4_test_mount_state(sb, EXT4_FC_REPLAY))