diff mbox

[2/5] fs: saner aio_complete prototype

Message ID 1422381313-24034-3-git-send-email-hch@lst.de (mailing list archive)
State New, archived
Headers show

Commit Message

Christoph Hellwig Jan. 27, 2015, 5:55 p.m. UTC
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(-)

Comments

Al Viro Jan. 31, 2015, 10:04 a.m. UTC | #1
On Tue, Jan 27, 2015 at 06:55:10PM +0100, Christoph Hellwig wrote:
> 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'.

AFAICS, ->res2 is a part of user-visible ABI and drivers/usb/gadget ones
sure as hell don't look like as if it was 0:

> -	aio_complete(io_data->kiocb, ret, ret);
> -	aio_complete(iocb, ret, ret);
> -		aio_complete(iocb, req->actual ? req->actual : req->status,
> -				req->status);

What am I missing here?
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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,