public inbox for linux-bcachefs@vger.kernel.org
 help / color / mirror / Atom feed
From: Kent Overstreet <kent.overstreet@linux.dev>
To: linux-bcachefs@vger.kernel.org
Cc: mmpgouride@gmail.com, Kent Overstreet <kent.overstreet@linux.dev>
Subject: [PATCH] bcachefs: Re-add seemingly duplicate bch2_trans_begin()
Date: Sat,  7 Jun 2025 20:28:47 -0400	[thread overview]
Message-ID: <20250608002847.1871960-1-kent.overstreet@linux.dev> (raw)

Include a comment this time - we can't call iter_init() in a transaction
restart, and write bufer flush doesn't guarantee that we aren't in a
restart when it returns.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
 fs/bcachefs/movinggc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c
index 6d7b1d5f7697..697d58b0bf91 100644
--- a/fs/bcachefs/movinggc.c
+++ b/fs/bcachefs/movinggc.c
@@ -154,6 +154,12 @@ static int bch2_copygc_get_buckets(struct moving_context *ctxt,
 	if (bch2_fs_fatal_err_on(ret, c, "%s: from bch2_btree_write_buffer_tryflush()", bch2_err_str(ret)))
 		return ret;
 
+	/*
+	 * we might be in a transaction restart from write buffer flush, start a
+	 * new transaction before iter_init -> path_get
+	 */
+	bch2_trans_begin(trans);
+
 	ret = for_each_btree_key_max(trans, iter, BTREE_ID_lru,
 				  lru_pos(BCH_LRU_BUCKET_FRAGMENTATION, 0, 0),
 				  lru_pos(BCH_LRU_BUCKET_FRAGMENTATION, U64_MAX, LRU_TIME_MAX),
-- 
2.49.0


             reply	other threads:[~2025-06-08  0:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-08  0:28 Kent Overstreet [this message]
2025-06-08 10:05 ` [PATCH] bcachefs: Re-add seemingly duplicate bch2_trans_begin() Alan Huang
2025-06-08 12:08   ` Kent Overstreet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250608002847.1871960-1-kent.overstreet@linux.dev \
    --to=kent.overstreet@linux.dev \
    --cc=linux-bcachefs@vger.kernel.org \
    --cc=mmpgouride@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox