* [PATCH] bcachefs: Re-add seemingly duplicate bch2_trans_begin()
@ 2025-06-08 0:28 Kent Overstreet
2025-06-08 10:05 ` Alan Huang
0 siblings, 1 reply; 3+ messages in thread
From: Kent Overstreet @ 2025-06-08 0:28 UTC (permalink / raw)
To: linux-bcachefs; +Cc: mmpgouride, Kent Overstreet
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bcachefs: Re-add seemingly duplicate bch2_trans_begin()
2025-06-08 0:28 [PATCH] bcachefs: Re-add seemingly duplicate bch2_trans_begin() Kent Overstreet
@ 2025-06-08 10:05 ` Alan Huang
2025-06-08 12:08 ` Kent Overstreet
0 siblings, 1 reply; 3+ messages in thread
From: Alan Huang @ 2025-06-08 10:05 UTC (permalink / raw)
To: Kent Overstreet; +Cc: linux-bcachefs
On Jun 8, 2025, at 08:28, Kent Overstreet <kent.overstreet@linux.dev> wrote:
>
> 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.
Why would it related to iter_init(), bch2_trans_begin(trans) is at the top of for_each_btree_key_max
>
> 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bcachefs: Re-add seemingly duplicate bch2_trans_begin()
2025-06-08 10:05 ` Alan Huang
@ 2025-06-08 12:08 ` Kent Overstreet
0 siblings, 0 replies; 3+ messages in thread
From: Kent Overstreet @ 2025-06-08 12:08 UTC (permalink / raw)
To: Alan Huang; +Cc: linux-bcachefs
On Sun, Jun 08, 2025 at 06:05:11PM +0800, Alan Huang wrote:
> On Jun 8, 2025, at 08:28, Kent Overstreet <kent.overstreet@linux.dev> wrote:
> >
> > 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.
>
> Why would it related to iter_init(), bch2_trans_begin(trans) is at the top of for_each_btree_key_max
Ok never mind :)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-08 12:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-08 0:28 [PATCH] bcachefs: Re-add seemingly duplicate bch2_trans_begin() Kent Overstreet
2025-06-08 10:05 ` Alan Huang
2025-06-08 12:08 ` Kent Overstreet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox