[PATCH 14/22] aio: pass in user index to __io_submit_one()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is used for the user iocb pointer right now, but in preparation
for having iocbs not reside in userspace, unionize with a ki_index
and pass that in instead.

Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
 fs/aio.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index 4895b971150c..bec5df2108b2 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -207,7 +207,11 @@ struct aio_kiocb {
 	struct kioctx		*ki_ctx;
 	kiocb_cancel_fn		*ki_cancel;
 
-	struct iocb __user	*ki_user_iocb;	/* user's aiocb */
+	union {
+		struct iocb __user	*ki_user_iocb;	/* user's aiocb */
+		unsigned long		ki_index;
+	};
+
 	__u64			ki_user_data;	/* user's data for completion */
 
 	struct list_head	ki_list;	/* the aio core uses this
@@ -1201,7 +1205,7 @@ static void iocb_put_many(struct kioctx *ctx, void **iocbs, int *nr)
 static void aio_fill_event(struct io_event *ev, struct aio_kiocb *iocb,
 			   long res, long res2)
 {
-	ev->obj = (u64)(unsigned long)iocb->ki_user_iocb;
+	ev->obj = iocb->ki_index;
 	ev->data = iocb->ki_user_data;
 	ev->res = res;
 	ev->res2 = res2;
@@ -2303,7 +2307,7 @@ static ssize_t aio_poll(struct aio_kiocb *aiocb, const struct iocb *iocb)
 }
 
 static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
-			   struct iocb __user *user_iocb,
+			   unsigned long ki_index,
 			   struct aio_submit_state *state, bool compat)
 {
 	struct aio_kiocb *req;
@@ -2350,14 +2354,17 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
 	}
 
 	if (aio_ctx_supports_cancel(ctx)) {
+		struct iocb __user *user_iocb = (struct iocb __user *) ki_index;
+
 		ret = put_user(KIOCB_KEY, &user_iocb->aio_key);
 		if (unlikely(ret)) {
 			pr_debug("EFAULT: aio_key\n");
 			goto out_put_req;
 		}
-	}
+		req->ki_user_iocb = user_iocb;
+	} else
+		req->ki_index = ki_index;
 
-	req->ki_user_iocb = user_iocb;
 	req->ki_user_data = iocb->aio_data;
 
 	ret = -EINVAL;
@@ -2423,12 +2430,13 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
 static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
 			 struct aio_submit_state *state, bool compat)
 {
+	unsigned long ki_index = (unsigned long) user_iocb;
 	struct iocb iocb;
 
 	if (unlikely(copy_from_user(&iocb, user_iocb, sizeof(iocb))))
 		return -EFAULT;
 
-	return __io_submit_one(ctx, &iocb, user_iocb, state, compat);
+	return __io_submit_one(ctx, &iocb, ki_index, state, compat);
 }
 
 #ifdef CONFIG_BLOCK
-- 
2.17.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux