From d95dd378c207ddec7551cce2e047e6067c3c27ab Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 28 May 2023 03:44:38 -0400 Subject: bcachefs: allocate_dropping_locks() Add two new helpers for allocating memory with btree locks held: The idea is to first try the allocation with GFP_NOWAIT|__GFP_NOWARN, then if that fails - unlock, retry with GFP_KERNEL, and then call trans_relock(). Signed-off-by: Kent Overstreet --- fs/bcachefs/ec.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'fs/bcachefs/ec.c') diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 1c35fa1fedd3..dfc0a61afa51 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -578,15 +578,8 @@ static int __ec_stripe_mem_alloc(struct bch_fs *c, size_t idx, gfp_t gfp) static int ec_stripe_mem_alloc(struct btree_trans *trans, struct btree_iter *iter) { - size_t idx = iter->pos.offset; - - if (!__ec_stripe_mem_alloc(trans->c, idx, GFP_NOWAIT|__GFP_NOWARN)) - return 0; - - bch2_trans_unlock(trans); - - return __ec_stripe_mem_alloc(trans->c, idx, GFP_KERNEL) ?: - bch2_trans_relock(trans); + return allocate_dropping_locks_errcode(trans, + __ec_stripe_mem_alloc(trans->c, iter->pos.offset, _gfp)); } /* -- cgit v1.2.3