提交 aab66dfb 编写于 作者: A Al Viro 提交者: Greg Kroah-Hartman

aio: store event at final iocb_put()

commit 2bb874c0d873d13bd9b9b9c6d7b7c4edab18c8b4 upstream.

Instead of having aio_complete() set ->ki_res.{res,res2}, do that
explicitly in its callers, drop the reference (as aio_complete()
used to do) and delay the rest until the final iocb_put().
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 c20202c5
...@@ -1071,16 +1071,10 @@ static inline void iocb_destroy(struct aio_kiocb *iocb) ...@@ -1071,16 +1071,10 @@ static inline void iocb_destroy(struct aio_kiocb *iocb)
kmem_cache_free(kiocb_cachep, iocb); kmem_cache_free(kiocb_cachep, iocb);
} }
static inline void iocb_put(struct aio_kiocb *iocb)
{
if (refcount_dec_and_test(&iocb->ki_refcnt))
iocb_destroy(iocb);
}
/* aio_complete /* aio_complete
* Called when the io request on the given iocb is complete. * Called when the io request on the given iocb is complete.
*/ */
static void aio_complete(struct aio_kiocb *iocb, long res, long res2) static void aio_complete(struct aio_kiocb *iocb)
{ {
struct kioctx *ctx = iocb->ki_ctx; struct kioctx *ctx = iocb->ki_ctx;
struct aio_ring *ring; struct aio_ring *ring;
...@@ -1088,8 +1082,6 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2) ...@@ -1088,8 +1082,6 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2)
unsigned tail, pos, head; unsigned tail, pos, head;
unsigned long flags; unsigned long flags;
iocb->ki_res.res = res;
iocb->ki_res.res2 = res2;
/* /*
* Add a completion event to the ring buffer. Must be done holding * Add a completion event to the ring buffer. Must be done holding
* ctx->completion_lock to prevent other code from messing with the tail * ctx->completion_lock to prevent other code from messing with the tail
...@@ -1155,7 +1147,14 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2) ...@@ -1155,7 +1147,14 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2)
if (waitqueue_active(&ctx->wait)) if (waitqueue_active(&ctx->wait))
wake_up(&ctx->wait); wake_up(&ctx->wait);
iocb_put(iocb); }
static inline void iocb_put(struct aio_kiocb *iocb)
{
if (refcount_dec_and_test(&iocb->ki_refcnt)) {
aio_complete(iocb);
iocb_destroy(iocb);
}
} }
/* aio_read_events_ring /* aio_read_events_ring
...@@ -1429,7 +1428,9 @@ static void aio_complete_rw(struct kiocb *kiocb, long res, long res2) ...@@ -1429,7 +1428,9 @@ static void aio_complete_rw(struct kiocb *kiocb, long res, long res2)
file_end_write(kiocb->ki_filp); file_end_write(kiocb->ki_filp);
} }
aio_complete(iocb, res, res2); iocb->ki_res.res = res;
iocb->ki_res.res2 = res2;
iocb_put(iocb);
} }
static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb) static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb)
...@@ -1577,11 +1578,10 @@ static ssize_t aio_write(struct kiocb *req, const struct iocb *iocb, ...@@ -1577,11 +1578,10 @@ static ssize_t aio_write(struct kiocb *req, const struct iocb *iocb,
static void aio_fsync_work(struct work_struct *work) static void aio_fsync_work(struct work_struct *work)
{ {
struct fsync_iocb *req = container_of(work, struct fsync_iocb, work); struct aio_kiocb *iocb = container_of(work, struct aio_kiocb, fsync.work);
int ret;
ret = vfs_fsync(req->file, req->datasync); iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync);
aio_complete(container_of(req, struct aio_kiocb, fsync), ret, 0); iocb_put(iocb);
} }
static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb, static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb,
...@@ -1602,7 +1602,8 @@ static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb, ...@@ -1602,7 +1602,8 @@ static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb,
static inline void aio_poll_complete(struct aio_kiocb *iocb, __poll_t mask) static inline void aio_poll_complete(struct aio_kiocb *iocb, __poll_t mask)
{ {
aio_complete(iocb, mangle_poll(mask), 0); iocb->ki_res.res = mangle_poll(mask);
iocb_put(iocb);
} }
static void aio_poll_complete_work(struct work_struct *work) static void aio_poll_complete_work(struct work_struct *work)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册