Skip to content

Commit 7425970

Browse files
author
Al Viro
committed
aio: move dropping ->ki_eventfd into iocb_destroy()
no reason to duplicate that... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 958c13c commit 7425970

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

fs/aio.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,8 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id)
10711071

10721072
static inline void iocb_destroy(struct aio_kiocb *iocb)
10731073
{
1074+
if (iocb->ki_eventfd)
1075+
eventfd_ctx_put(iocb->ki_eventfd);
10741076
if (iocb->ki_filp)
10751077
fput(iocb->ki_filp);
10761078
percpu_ref_put(&iocb->ki_ctx->reqs);
@@ -1138,10 +1140,8 @@ static void aio_complete(struct aio_kiocb *iocb)
11381140
* eventfd. The eventfd_signal() function is safe to be called
11391141
* from IRQ context.
11401142
*/
1141-
if (iocb->ki_eventfd) {
1143+
if (iocb->ki_eventfd)
11421144
eventfd_signal(iocb->ki_eventfd, 1);
1143-
eventfd_ctx_put(iocb->ki_eventfd);
1144-
}
11451145

11461146
/*
11471147
* We have to order our ring_info tail store above and test
@@ -1807,18 +1807,19 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
18071807
goto out_put_req;
18081808

18091809
if (iocb->aio_flags & IOCB_FLAG_RESFD) {
1810+
struct eventfd_ctx *eventfd;
18101811
/*
18111812
* If the IOCB_FLAG_RESFD flag of aio_flags is set, get an
18121813
* instance of the file* now. The file descriptor must be
18131814
* an eventfd() fd, and will be signaled for each completed
18141815
* event using the eventfd_signal() function.
18151816
*/
1816-
req->ki_eventfd = eventfd_ctx_fdget((int) iocb->aio_resfd);
1817-
if (IS_ERR(req->ki_eventfd)) {
1818-
ret = PTR_ERR(req->ki_eventfd);
1819-
req->ki_eventfd = NULL;
1817+
eventfd = eventfd_ctx_fdget(iocb->aio_resfd);
1818+
if (IS_ERR(eventfd)) {
1819+
ret = PTR_ERR(eventfd);
18201820
goto out_put_req;
18211821
}
1822+
req->ki_eventfd = eventfd;
18221823
}
18231824

18241825
ret = put_user(KIOCB_KEY, &user_iocb->aio_key);
@@ -1872,8 +1873,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
18721873
return 0;
18731874

18741875
out_put_req:
1875-
if (req->ki_eventfd)
1876-
eventfd_ctx_put(req->ki_eventfd);
18771876
iocb_destroy(req);
18781877
out_put_reqs_available:
18791878
put_reqs_available(ctx, 1);

0 commit comments

Comments
 (0)