[1/2] gfs2: factor out __gfs2_ail1_empty() and gfs2_ail1_withdraw()

Message ID 20230206095543.539186-2-chenxiaosong2@huawei.com
State New
Headers
Series gfs2: fix sleep from invalid context bug in gfs2_glock_wait() |

Commit Message

ChenXiaoSong Feb. 6, 2023, 9:55 a.m. UTC
  Factor out __gfs2_ail1_empty() and gfs2_ail1_withdraw() from
gfs2_ail1_empty(). No functional change.

Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
---
 fs/gfs2/log.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)
  

Patch

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 61323deb80bc..c62c914702ba 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -347,15 +347,7 @@  static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
 	return active_count;
 }
 
-/**
- * gfs2_ail1_empty - Try to empty the ail1 lists
- * @sdp: The superblock
- * @max_revokes: If non-zero, add revokes where appropriate
- *
- * Tries to empty the ail1 lists, starting with the oldest first
- */
-
-static int gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes)
+static int __gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes)
 {
 	struct gfs2_trans *tr, *s;
 	int oldest_tr = 1;
@@ -372,10 +364,31 @@  static int gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes)
 	ret = list_empty(&sdp->sd_ail1_list);
 	spin_unlock(&sdp->sd_ail_lock);
 
+	return ret;
+}
+
+static void gfs2_ail1_withdraw(struct gfs2_sbd *sdp)
+{
 	if (test_bit(SDF_WITHDRAWING, &sdp->sd_flags)) {
 		gfs2_lm(sdp, "fatal: I/O error(s)\n");
 		gfs2_withdraw(sdp);
 	}
+}
+
+/**
+ * gfs2_ail1_empty - Try to empty the ail1 lists
+ * @sdp: The superblock
+ * @max_revokes: If non-zero, add revokes where appropriate
+ *
+ * Tries to empty the ail1 lists, starting with the oldest first
+ */
+
+static int gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes)
+{
+	int ret;
+
+	ret = __gfs2_ail1_empty(sdp, max_revokes);
+	gfs2_ail1_withdraw(sdp);
 
 	return ret;
 }