From: Christoph Hellwig <hch@lst.de>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Miklos Szeredi <mszeredi@suse.cz>,
linux-aio@kvack.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 2/5] fs: saner aio_complete prototype
Date: Tue, 27 Jan 2015 18:55:10 +0100 [thread overview]
Message-ID: <1422381313-24034-3-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1422381313-24034-1-git-send-email-hch@lst.de>
Pass the result as a ssize_t, which is what we use for these returns
all over the kernel. Remove the res2 argument that all relevant
callers always pass as '0'.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/usb/gadget/function/f_fs.c | 2 +-
drivers/usb/gadget/legacy/inode.c | 5 ++---
fs/aio.c | 11 +++++------
fs/direct-io.c | 2 +-
fs/fuse/file.c | 2 +-
fs/nfs/direct.c | 6 ++----
include/linux/aio.h | 4 ++--
7 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index debd78b..c30d125 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -671,7 +671,7 @@ static void ffs_user_copy_worker(struct work_struct *work)
unuse_mm(io_data->mm);
}
- aio_complete(io_data->kiocb, ret, ret);
+ aio_complete(io_data->kiocb, ret);
usb_ep_free_request(io_data->ep, io_data->req);
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index db49ec4..987a461 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -582,7 +582,7 @@ static void ep_user_copy_worker(struct work_struct *work)
unuse_mm(mm);
/* completing the iocb can drop the ctx and mm, don't touch mm after */
- aio_complete(iocb, ret, ret);
+ aio_complete(iocb, ret);
kfree(priv->buf);
kfree(priv);
@@ -608,8 +608,7 @@ static void ep_aio_complete(struct usb_ep *ep, struct usb_request *req)
kfree(priv);
iocb->private = NULL;
/* aio_complete() reports bytes-transferred _and_ faults */
- aio_complete(iocb, req->actual ? req->actual : req->status,
- req->status);
+ aio_complete(iocb, req->actual ? req->actual : req->status);
} else {
/* ep_copy_to_user() won't report both; we hide some faults */
if (unlikely(0 != req->status))
diff --git a/fs/aio.c b/fs/aio.c
index 0ee25d6..52f36ee 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1007,7 +1007,7 @@ out:
/* aio_complete
* Called when the io request on the given iocb is complete.
*/
-void aio_complete(struct kiocb *iocb, long res, long res2)
+void aio_complete(struct kiocb *iocb, ssize_t res)
{
struct kioctx *ctx = iocb->ki_ctx;
struct aio_ring *ring;
@@ -1051,14 +1051,13 @@ void aio_complete(struct kiocb *iocb, long res, long res2)
event->obj = (u64)(unsigned long)iocb->ki_obj.user;
event->data = iocb->ki_user_data;
event->res = res;
- event->res2 = res2;
+ event->res2 = 0;
kunmap_atomic(ev_page);
flush_dcache_page(ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE]);
- pr_debug("%p[%u]: %p: %p %Lx %lx %lx\n",
- ctx, tail, iocb, iocb->ki_obj.user, iocb->ki_user_data,
- res, res2);
+ pr_debug("%p[%u]: %p: %p %Lx %zx\n",
+ ctx, tail, iocb, iocb->ki_obj.user, iocb->ki_user_data, res);
/* after flagging the request as done, we
* must never even look at it again
@@ -1475,7 +1474,7 @@ rw_common:
ret == -ERESTARTNOHAND ||
ret == -ERESTART_RESTARTBLOCK))
ret = -EINTR;
- aio_complete(req, ret, 0);
+ aio_complete(req, ret);
}
return 0;
diff --git a/fs/direct-io.c b/fs/direct-io.c
index e181b6b..10bea2b 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -265,7 +265,7 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret,
ret = err;
}
- aio_complete(dio->iocb, ret, 0);
+ aio_complete(dio->iocb, ret);
}
kmem_cache_free(dio_cache, dio);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 9c27312..b670e30 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -578,7 +578,7 @@ static void fuse_aio_complete(struct fuse_io_priv *io, int err, ssize_t pos)
}
}
- aio_complete(io->iocb, res, 0);
+ aio_complete(io->iocb, res);
kfree(io);
}
}
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 10bf072..9441c4c 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -330,10 +330,8 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write)
inode_dio_done(inode);
if (dreq->iocb) {
- long res = (long) dreq->error;
- if (!res)
- res = (long) dreq->count;
- aio_complete(dreq->iocb, res, 0);
+ aio_complete(dreq->iocb,
+ dreq->error ? dreq->error : dreq->count);
}
complete_all(&dreq->completion);
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 57c86c0..5657bd2 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -68,14 +68,14 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
/* prototypes */
#ifdef CONFIG_AIO
-extern void aio_complete(struct kiocb *iocb, long res, long res2);
+extern void aio_complete(struct kiocb *iocb, ssize_t ret);
struct mm_struct;
extern void exit_aio(struct mm_struct *mm);
extern long do_io_submit(aio_context_t ctx_id, long nr,
struct iocb __user *__user *iocbpp, bool compat);
void kiocb_set_cancel_fn(struct kiocb *req, kiocb_cancel_fn *cancel);
#else
-static inline void aio_complete(struct kiocb *iocb, long res, long res2) { }
+static inline void aio_complete(struct kiocb *iocb, ssize_t ret) { }
struct mm_struct;
static inline void exit_aio(struct mm_struct *mm) { }
static inline long do_io_submit(aio_context_t ctx_id, long nr,
--
1.9.1
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>
next prev parent reply other threads:[~2015-01-27 17:55 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-27 17:55 [RFC] split struct kiocb Christoph Hellwig
2015-01-27 17:55 ` [PATCH 1/5] fs: don't allow to complete sync iocbs through aio_complete Christoph Hellwig
2015-01-28 15:30 ` Miklos Szeredi
2015-01-28 16:57 ` Christoph Hellwig
2015-01-31 3:01 ` Maxim Patlasov
2015-01-27 17:55 ` Christoph Hellwig [this message]
2015-01-31 10:04 ` [PATCH 2/5] fs: saner aio_complete prototype Al Viro
2015-01-27 17:55 ` [PATCH 3/5] fs: remove ki_nbytes Christoph Hellwig
2015-01-31 6:08 ` Al Viro
2015-02-02 8:07 ` Christoph Hellwig
2015-02-02 8:11 ` Al Viro
2015-02-02 8:14 ` Al Viro
2015-02-02 14:26 ` Christoph Hellwig
2015-02-04 8:34 ` Al Viro
2015-02-04 18:17 ` Alan Stern
2015-02-04 19:06 ` Al Viro
2015-02-04 20:30 ` Alan Stern
2015-02-04 23:07 ` Al Viro
2015-02-05 8:24 ` Robert Baldyga
2015-02-05 8:47 ` Al Viro
2015-02-05 9:03 ` Al Viro
2015-02-05 9:15 ` Robert Baldyga
[not found] ` <20150204230733.GK29656-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2015-02-05 15:29 ` Alan Stern
2015-02-06 7:03 ` Al Viro
[not found] ` <20150206070350.GX29656-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2015-02-06 8:44 ` Robert Baldyga
2015-02-07 5:44 ` Al Viro
2015-02-07 5:48 ` [PATCH 1/6] new helper: dup_iter() Al Viro
2015-02-07 5:48 ` [PATCH 2/6] gadget/function/f_fs.c: close leaks Al Viro
2015-02-07 5:48 ` [PATCH 3/6] gadget/function/f_fs.c: use put iov_iter into io_data Al Viro
2015-02-07 5:48 ` [PATCH 4/6] gadget/function/f_fs.c: switch to ->{read,write}_iter() Al Viro
2015-02-07 5:48 ` [PATCH 5/6] gadgetfs: use-after-free in ->aio_read() Al Viro
2015-02-07 5:48 ` [PATCH 6/6] gadget: switch ep_io_operations to ->read_iter/->write_iter Al Viro
2015-02-02 14:20 ` [PATCH 3/5] fs: remove ki_nbytes Christoph Hellwig
2015-01-27 17:55 ` [PATCH 4/5] fs: split generic and aio kiocb Christoph Hellwig
2015-01-27 17:55 ` [PATCH 5/5] fs: add async read/write interfaces Christoph Hellwig
2015-01-31 6:29 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1422381313-24034-3-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mszeredi@suse.cz \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).