* [PATCH] aio: Adjust the position of get_reqs_available() in aio_get_req()
@ 2022-01-20 6:42 chenxiang
2022-01-20 9:03 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: chenxiang @ 2022-01-20 6:42 UTC (permalink / raw)
To: bcrl, viro; +Cc: linux-aio, linux-fsdevel, linuxarm, Xiang Chen
From: Xiang Chen <chenxiang66@hisilicon.com>
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.
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
fs/aio.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/aio.c b/fs/aio.c
index 9c81cf611d65..79f8ea31a696 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -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;
--
2.33.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] aio: Adjust the position of get_reqs_available() in aio_get_req()
2022-01-20 6:42 [PATCH] aio: Adjust the position of get_reqs_available() in aio_get_req() chenxiang
@ 2022-01-20 9:03 ` Christoph Hellwig
2022-01-20 11:33 ` chenxiang (M)
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2022-01-20 9:03 UTC (permalink / raw)
To: chenxiang; +Cc: bcrl, viro, linux-aio, linux-fsdevel, linuxarm
On Thu, Jan 20, 2022 at 02:42:26PM +0800, chenxiang wrote:
> From: Xiang Chen <chenxiang66@hisilicon.com>
>
> 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.
Except for the fact that this completely missed undoing
get_reqs_available, how is that order any better?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] aio: Adjust the position of get_reqs_available() in aio_get_req()
2022-01-20 9:03 ` Christoph Hellwig
@ 2022-01-20 11:33 ` chenxiang (M)
0 siblings, 0 replies; 3+ messages in thread
From: chenxiang (M) @ 2022-01-20 11:33 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: bcrl, viro, linux-aio, linux-fsdevel, linuxarm
在 2022/1/20 17:03, Christoph Hellwig 写道:
> On Thu, Jan 20, 2022 at 02:42:26PM +0800, chenxiang wrote:
>> From: Xiang Chen <chenxiang66@hisilicon.com>
>>
>> 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.
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-20 11:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 6:42 [PATCH] aio: Adjust the position of get_reqs_available() in aio_get_req() chenxiang
2022-01-20 9:03 ` Christoph Hellwig
2022-01-20 11:33 ` chenxiang (M)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.