gfs2: Minor gfs2_ail1_empty cleanup
authorAndreas Gruenbacher <agruenba@redhat.com>
Wed, 20 Dec 2023 15:38:21 +0000 (16:38 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Wed, 20 Dec 2023 20:29:40 +0000 (21:29 +0100)
Change gfs2_ail1_empty() to return %true when the ail1 list is empty.

Based on that, make the loop in empty_ail1_list() more obvious.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/log.c

index e5271ae87d1c43997322ee1e585b2e13ca21c1cf..61cd52a579d9b29a89e931a516e8920d693c6203 100644 (file)
@@ -352,14 +352,15 @@ static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
  * @sdp: The superblock
  * @max_revokes: If non-zero, add revokes where appropriate
  *
- * Tries to empty the ail1 lists, starting with the oldest first
+ * Tries to empty the ail1 lists, starting with the oldest first.
+ * Returns %true if the ail1 list is now empty.
  */
 
-static int gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes)
+static bool gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes)
 {
        struct gfs2_trans *tr, *s;
        int oldest_tr = 1;
-       int ret;
+       bool empty;
 
        spin_lock(&sdp->sd_ail_lock);
        list_for_each_entry_safe_reverse(tr, s, &sdp->sd_ail1_list, tr_list) {
@@ -369,7 +370,7 @@ static int gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes)
                        oldest_tr = 0;
        }
        gfs2_log_update_flush_tail(sdp);
-       ret = list_empty(&sdp->sd_ail1_list);
+       empty = list_empty(&sdp->sd_ail1_list);
        spin_unlock(&sdp->sd_ail_lock);
 
        if (test_bit(SDF_WITHDRAWING, &sdp->sd_flags)) {
@@ -377,7 +378,7 @@ static int gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes)
                gfs2_withdraw(sdp);
        }
 
-       return ret;
+       return empty;
 }
 
 static void gfs2_ail1_wait(struct gfs2_sbd *sdp)
@@ -974,8 +975,9 @@ void gfs2_ail_drain(struct gfs2_sbd *sdp)
 static void empty_ail1_list(struct gfs2_sbd *sdp)
 {
        unsigned long start = jiffies;
+       bool empty = false;
 
-       for (;;) {
+       while (!empty) {
                if (time_after(jiffies, start + (HZ * 600))) {
                        fs_err(sdp, "Error: In %s for 10 minutes! t=%d\n",
                               __func__, current->journal_info ? 1 : 0);
@@ -984,8 +986,7 @@ static void empty_ail1_list(struct gfs2_sbd *sdp)
                }
                gfs2_ail1_start(sdp);
                gfs2_ail1_wait(sdp);
-               if (gfs2_ail1_empty(sdp, 0))
-                       return;
+               empty = gfs2_ail1_empty(sdp, 0);
        }
 }