Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4529413imb; Wed, 6 Mar 2019 16:04:23 -0800 (PST) X-Google-Smtp-Source: APXvYqwDJLe0GW3dYZNud6A8j7KcsHrHiHzoUFDlMQemiwqKBXcSac9HkiRuXPJqCMhkNrxeay9u X-Received: by 2002:a63:6f09:: with SMTP id k9mr8741329pgc.326.1551917063064; Wed, 06 Mar 2019 16:04:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551917063; cv=none; d=google.com; s=arc-20160816; b=EXt4Jt95BMiohgmlG/9xb7vkUcU8fL6z4BDW90fC5PinZ9D4Nh3+urG6mJI0EkvEvk PKEkWJIs+0UmBQGe7jx1m4G/MBq1O6oFEieQjl4ON0B7aUL6/QPSGeWahMKBXr+deZN/ xJwH5xC4vk9lpiZ/O335BLHZ4tdv7FOVtMnz67Gbw/JCT7E+7FsSEqEm2LIwXS5BFuCi BaVslgdEKiAEjWLR5D+YUY2qGxW1K1Tn4zTAQdNXaH9/LYGWREu7hGX1sBEfaGUbNAzh eN6r4noYuFKUjv/RXtem0Bq+8AWCK6NYIlRdWrBjf9sD1XSMS4GeI5CDYUpWUeJOe7Ts v/NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ng0DJ31SBRpPXOb3GpsrnwGjnp7Xeo9QLxLZ17DKcAI=; b=y/3vM8BUEbe5kT/rq7HbTi583A7j0tXxLkQeFovzbCrj+QunsUWpgUln9MCaE3TqLF xy+0hN52h/oeWZlG8kNNZvdeh9Ywh+D6lRCIkpbgvDXoxnqTn+DPThFlYdIqOzdxsI9X kejBu3gOcoyIUg1ChKht5T2oqXRcPRPQ6xtUgGp9LfAOWphLQDdMbk+Pn0ciWccYqJuu /kjGUIoJUofwu+F+vMCprUMCRKhKV+ZLcLoP6pyMhdaKM5DgDJWwn/DQ5F2lTbOytymE SbLsWci6Fe6bec3y5w7IDxChJKqWsFCnwLt4QfgpL7jboAAH37ZdOpdD3n/+dxcTq2UQ zVjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z186si2489391pgd.477.2019.03.06.16.04.07; Wed, 06 Mar 2019 16:04:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726768AbfCGADg (ORCPT + 99 others); Wed, 6 Mar 2019 19:03:36 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:40004 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726422AbfCGADf (ORCPT ); Wed, 6 Mar 2019 19:03:35 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1h1gVJ-000874-He; Thu, 07 Mar 2019 00:03:17 +0000 From: Al Viro To: Linus Torvalds Cc: Eric Dumazet , David Miller , Jason Baron , kgraul@linux.ibm.com, ktkhai@virtuozzo.com, kyeongdon.kim@lge.com, Linux List Kernel Mailing , Netdev , pabeni@redhat.com, syzkaller-bugs@googlegroups.com, xiyou.wangcong@gmail.com, Christoph Hellwig , zhengbin , bcrl@kvack.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, houtao1@huawei.com, yi.zhang@huawei.com Subject: [PATCH 6/8] move dropping ->ki_eventfd into iocb_put() Date: Thu, 7 Mar 2019 00:03:14 +0000 Message-Id: <20190307000316.31133-6-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190307000316.31133-1-viro@ZenIV.linux.org.uk> References: <20190307000316.31133-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro Signed-off-by: Al Viro --- fs/aio.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 5dd5f35d054c..5837a29e63fe 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1066,6 +1066,8 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id) static inline void iocb_put(struct aio_kiocb *iocb) { + if (iocb->ki_eventfd) + eventfd_ctx_put(iocb->ki_eventfd); if (iocb->ki_filp) fput(iocb->ki_filp); percpu_ref_put(&iocb->ki_ctx->reqs); @@ -1142,10 +1144,8 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2) * eventfd. The eventfd_signal() function is safe to be called * from IRQ context. */ - if (iocb->ki_eventfd) { + if (iocb->ki_eventfd) eventfd_signal(iocb->ki_eventfd, 1); - eventfd_ctx_put(iocb->ki_eventfd); - } /* * We have to order our ring_info tail store above and test @@ -1819,18 +1819,19 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, goto out_put_req; if (iocb->aio_flags & IOCB_FLAG_RESFD) { + struct eventfd_ctx *eventfd; /* * If the IOCB_FLAG_RESFD flag of aio_flags is set, get an * instance of the file* now. The file descriptor must be * an eventfd() fd, and will be signaled for each completed * event using the eventfd_signal() function. */ - req->ki_eventfd = eventfd_ctx_fdget((int) iocb->aio_resfd); - if (IS_ERR(req->ki_eventfd)) { - ret = PTR_ERR(req->ki_eventfd); - req->ki_eventfd = NULL; + eventfd = eventfd_ctx_fdget((int) iocb->aio_resfd); + if (IS_ERR(eventfd)) { + ret = PTR_ERR(eventfd); goto out_put_req; } + req->ki_eventfd = eventfd; } ret = put_user(KIOCB_KEY, &user_iocb->aio_key); @@ -1881,8 +1882,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, goto out_put_req; return 0; out_put_req: - if (req->ki_eventfd) - eventfd_ctx_put(req->ki_eventfd); iocb_put(req); out_put_reqs_available: put_reqs_available(ctx, 1); -- 2.11.0