aio: Adjust the position of get_reqs_available() in aio_get_req()
PATCH 1/1 aio: Adjust the position of get_reqs_available() in aio_get_req()
From: Xiang Chen <[email protected]>
Right now allocating aio_kiocb is in front of get_reqs_available(), then need to free aio_kiocb if get_reqs_available() is failed. Put get_reqs_availabe() in front of allocating aio_kiocb to avoid freeing aio_kiocb if get_reqs_available() is failed.
--- fs/aio.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
fs/aio.c +3 -5
@@ -1025,14 +1025,12 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx) {struct aio_kiocb *req; - req =kmem_cache_alloc (kiocb_cachep,GFP_KERNEL ); -if (unlikely (!req)) +if (unlikely (!get_reqs_available (ctx)))return NULL ; -if (unlikely (!get_reqs_available (ctx))) { -kmem_cache_free (kiocb_cachep, req); + req =kmem_cache_alloc (kiocb_cachep,GFP_KERNEL ); +if (unlikely (!req))return NULL ; - }percpu_ref_get (&ctx->reqs); req->ki_ctx = ctx;
Signature · 1 line
2.33.0
Quoted 6 lines · chenxiang
From: Xiang Chen <[email protected]>
Right now allocating
aio_kiocbis in front ofget_reqs_available(), then need to freeaio_kiocbifget_reqs_available()is failed. Putget_reqs_availabe()in front of allocatingaio_kiocbto avoid freeingaio_kiocbifget_reqs_available()is failed.
Except for the fact that this completely missed undoing get_reqs_available, how is that order any better?
Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · chenxiang
From: Xiang Chen <[email protected]>
Right now allocating
aio_kiocbis in front ofget_reqs_available(), then need to freeaio_kiocbifget_reqs_available()is failed. Putget_reqs_availabe()in front of allocatingaio_kiocbto avoid freeingaio_kiocbifget_reqs_available()is failed.Except for the fact that this completely missed undoing
get_reqs_available, how is that order any better?
Forgot that put_reqs_avaiable() is required if so, and please ignore the patch.