[PATCH] aio: Adjust the position of get_reqs_available() in aio_get_req()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Xiang Chen <chenxiang66@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux