From: Kent Overstreet Date: Wed, 28 May 2025 20:06:07 +0000 (-0400) Subject: bcachefs: Don't unlock trans before data_update_init() X-Git-Tag: v6.16-rc1~48^2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f02d15327455822ed80e0b7d70b2ab3568a0389e;p=thirdparty%2Flinux.git bcachefs: Don't unlock trans before data_update_init() data_update_init() does need to do btree operations, delay doing the unlock-before-io. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index 1216729c20e8f..63a10ea83c974 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -980,6 +980,8 @@ int bch2_data_update_init(struct btree_trans *trans, goto out_nocow_unlock; } + bch2_trans_unlock(trans); + ret = __bch2_data_update_bios_init(m, c, io_opts, buf_bytes); if (ret) goto out_nocow_unlock; diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index 857519cdac4ee..fc1a7a04cb15e 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -359,16 +359,14 @@ int bch2_move_extent(struct moving_context *ctxt, return 0; } - /* - * Before memory allocations & taking nocow locks in - * bch2_data_update_init(): - */ - bch2_trans_unlock(trans); - - struct moving_io *io = kzalloc(sizeof(struct moving_io), GFP_KERNEL); + struct moving_io *io = allocate_dropping_locks(trans, ret, + kzalloc(sizeof(struct moving_io), _gfp)); if (!io) goto err; + if (ret) + goto err_free; + INIT_LIST_HEAD(&io->io_list); io->write.ctxt = ctxt; io->read_sectors = k.k->size; @@ -388,6 +386,8 @@ int bch2_move_extent(struct moving_context *ctxt, io->write.op.c = c; io->write.data_opts = data_opts; + bch2_trans_unlock(trans); + ret = bch2_data_update_bios_init(&io->write, c, &io_opts); if (ret) goto err_free;