summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2026-03-19 17:35:03 +0300
committerAndreas Gruenbacher <agruenba@redhat.com>2026-03-23 22:55:28 +0300
commit9e34adb1cc582bbcf1d74b23f1e6d9d71fb99fa1 (patch)
treeefabe421e015302add198465771f672e1be0f737
parent10866892c79159168459289a1288df4163e94d67 (diff)
downloadlinux-9e34adb1cc582bbcf1d74b23f1e6d9d71fb99fa1.tar.xz
gfs2: Remove trans_drain code duplication
Rename trans_drain() to gfs2_trans_drain(). Add a new gfs2_trans_drain_list() helper and use it in gfs2_trans_drain() to reduce code duplication. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
-rw-r--r--fs/gfs2/log.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index dde65f7d7437..8397d34527a4 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -983,38 +983,33 @@ static void empty_ail1_list(struct gfs2_sbd *sdp)
}
}
+static void gfs2_trans_drain_list(struct list_head *list)
+{
+ struct gfs2_bufdata *bd;
+
+ while (!list_empty(list)) {
+ bd = list_first_entry(list, struct gfs2_bufdata, bd_list);
+ list_del_init(&bd->bd_list);
+ if (!list_empty(&bd->bd_ail_st_list))
+ gfs2_remove_from_ail(bd);
+ kmem_cache_free(gfs2_bufdata_cachep, bd);
+ }
+}
+
/**
- * trans_drain - drain the buf and databuf queue for a failed transaction
+ * gfs2_trans_drain - drain the buf and databuf queue for a failed transaction
* @tr: the transaction to drain
*
* When this is called, we're taking an error exit for a log write that failed
* but since we bypassed the after_commit functions, we need to remove the
* items from the buf and databuf queue.
*/
-static void trans_drain(struct gfs2_trans *tr)
+static void gfs2_trans_drain(struct gfs2_trans *tr)
{
- struct gfs2_bufdata *bd;
- struct list_head *head;
-
if (!tr)
return;
-
- head = &tr->tr_buf;
- while (!list_empty(head)) {
- bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
- list_del_init(&bd->bd_list);
- if (!list_empty(&bd->bd_ail_st_list))
- gfs2_remove_from_ail(bd);
- kmem_cache_free(gfs2_bufdata_cachep, bd);
- }
- head = &tr->tr_databuf;
- while (!list_empty(head)) {
- bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
- list_del_init(&bd->bd_list);
- if (!list_empty(&bd->bd_ail_st_list))
- gfs2_remove_from_ail(bd);
- kmem_cache_free(gfs2_bufdata_cachep, bd);
- }
+ gfs2_trans_drain_list(&tr->tr_buf);
+ gfs2_trans_drain_list(&tr->tr_databuf);
}
void gfs2_remove_from_journal(struct buffer_head *bh, int meta)
@@ -1186,7 +1181,7 @@ out:
return;
out_withdraw:
- trans_drain(tr);
+ gfs2_trans_drain(tr);
/**
* If the tr_list is empty, we're withdrawing during a log
* flush that targets a transaction, but the transaction was