[PATCH 09/21] aio: Kill unneeded kiocb members

2013-05-13 Thread Kent Overstreet
The old aio retry infrastucture needed to save the various arguments to
to aio operations. But with the retry infrastructure gone, we can trim
struct kiocb quite a bit.

Signed-off-by: Kent Overstreet 
Cc: Zach Brown 
Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: Mark Fasheh 
Cc: Joel Becker 
Cc: Rusty Russell 
Cc: Jens Axboe 
Cc: Asai Thambi S P 
Cc: Selvan Mani 
Cc: Sam Bradshaw 
Cc: Jeff Moyer 
Cc: Al Viro 
Cc: Benjamin LaHaise 
Cc: Theodore Ts'o 
---
 fs/aio.c| 69 +++--
 include/linux/aio.h | 11 ++---
 2 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index 73ec062..280b014 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -637,8 +637,6 @@ static void kiocb_free(struct kiocb *req)
eventfd_ctx_put(req->ki_eventfd);
if (req->ki_dtor)
req->ki_dtor(req);
-   if (req->ki_iovec != >ki_inline_vec)
-   kfree(req->ki_iovec);
kmem_cache_free(kiocb_cachep, req);
 }
 
@@ -968,24 +966,26 @@ SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx)
 typedef ssize_t (aio_rw_op)(struct kiocb *, const struct iovec *,
unsigned long, loff_t);
 
-static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
+static ssize_t aio_setup_vectored_rw(struct kiocb *kiocb,
+int rw, char __user *buf,
+unsigned long *nr_segs,
+struct iovec **iovec,
+bool compat)
 {
ssize_t ret;
 
-   kiocb->ki_nr_segs = kiocb->ki_nbytes;
+   *nr_segs = kiocb->ki_nbytes;
 
 #ifdef CONFIG_COMPAT
if (compat)
ret = compat_rw_copy_check_uvector(rw,
-   (struct compat_iovec __user *)kiocb->ki_buf,
-   kiocb->ki_nr_segs, 1, >ki_inline_vec,
-   >ki_iovec);
+   (struct compat_iovec __user *)buf,
+   *nr_segs, 1, *iovec, iovec);
else
 #endif
ret = rw_copy_check_uvector(rw,
-   (struct iovec __user *)kiocb->ki_buf,
-   kiocb->ki_nr_segs, 1, >ki_inline_vec,
-   >ki_iovec);
+   (struct iovec __user *)buf,
+   *nr_segs, 1, *iovec, iovec);
if (ret < 0)
return ret;
 
@@ -994,15 +994,17 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb 
*kiocb, bool compat)
return 0;
 }
 
-static ssize_t aio_setup_single_vector(int rw, struct kiocb *kiocb)
+static ssize_t aio_setup_single_vector(struct kiocb *kiocb,
+  int rw, char __user *buf,
+  unsigned long *nr_segs,
+  struct iovec *iovec)
 {
-   if (unlikely(!access_ok(!rw, kiocb->ki_buf, kiocb->ki_nbytes)))
+   if (unlikely(!access_ok(!rw, buf, kiocb->ki_nbytes)))
return -EFAULT;
 
-   kiocb->ki_iovec = >ki_inline_vec;
-   kiocb->ki_iovec->iov_base = kiocb->ki_buf;
-   kiocb->ki_iovec->iov_len = kiocb->ki_nbytes;
-   kiocb->ki_nr_segs = 1;
+   iovec->iov_base = buf;
+   iovec->iov_len = kiocb->ki_nbytes;
+   *nr_segs = 1;
return 0;
 }
 
@@ -1011,15 +1013,18 @@ static ssize_t aio_setup_single_vector(int rw, struct 
kiocb *kiocb)
  * Performs the initial checks and aio retry method
  * setup for the kiocb at the time of io submission.
  */
-static ssize_t aio_run_iocb(struct kiocb *req, bool compat)
+static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
+   char __user *buf, bool compat)
 {
struct file *file = req->ki_filp;
ssize_t ret;
+   unsigned long nr_segs;
int rw;
fmode_t mode;
aio_rw_op *rw_op;
+   struct iovec inline_vec, *iovec = _vec;
 
-   switch (req->ki_opcode) {
+   switch (opcode) {
case IOCB_CMD_PREAD:
case IOCB_CMD_PREADV:
mode= FMODE_READ;
@@ -1040,16 +1045,21 @@ rw_common:
if (!rw_op)
return -EINVAL;
 
-   ret = (req->ki_opcode == IOCB_CMD_PREADV ||
-  req->ki_opcode == IOCB_CMD_PWRITEV)
-   ? aio_setup_vectored_rw(rw, req, compat)
-   : aio_setup_single_vector(rw, req);
+   ret = (opcode == IOCB_CMD_PREADV ||
+  opcode == IOCB_CMD_PWRITEV)
+   ? aio_setup_vectored_rw(req, rw, buf, _segs,
+   , compat)
+   : aio_setup_single_vector(req, rw, buf, _segs,
+ iovec);
if (ret)
return ret;
 
   

[PATCH 09/21] aio: Kill unneeded kiocb members

2013-05-13 Thread Kent Overstreet
The old aio retry infrastucture needed to save the various arguments to
to aio operations. But with the retry infrastructure gone, we can trim
struct kiocb quite a bit.

Signed-off-by: Kent Overstreet koverstr...@google.com
Cc: Zach Brown z...@redhat.com
Cc: Felipe Balbi ba...@ti.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Mark Fasheh mfas...@suse.com
Cc: Joel Becker jl...@evilplan.org
Cc: Rusty Russell ru...@rustcorp.com.au
Cc: Jens Axboe ax...@kernel.dk
Cc: Asai Thambi S P asamymuth...@micron.com
Cc: Selvan Mani sm...@micron.com
Cc: Sam Bradshaw sbrads...@micron.com
Cc: Jeff Moyer jmo...@redhat.com
Cc: Al Viro v...@zeniv.linux.org.uk
Cc: Benjamin LaHaise b...@kvack.org
Cc: Theodore Ts'o ty...@mit.edu
---
 fs/aio.c| 69 +++--
 include/linux/aio.h | 11 ++---
 2 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index 73ec062..280b014 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -637,8 +637,6 @@ static void kiocb_free(struct kiocb *req)
eventfd_ctx_put(req-ki_eventfd);
if (req-ki_dtor)
req-ki_dtor(req);
-   if (req-ki_iovec != req-ki_inline_vec)
-   kfree(req-ki_iovec);
kmem_cache_free(kiocb_cachep, req);
 }
 
@@ -968,24 +966,26 @@ SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx)
 typedef ssize_t (aio_rw_op)(struct kiocb *, const struct iovec *,
unsigned long, loff_t);
 
-static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
+static ssize_t aio_setup_vectored_rw(struct kiocb *kiocb,
+int rw, char __user *buf,
+unsigned long *nr_segs,
+struct iovec **iovec,
+bool compat)
 {
ssize_t ret;
 
-   kiocb-ki_nr_segs = kiocb-ki_nbytes;
+   *nr_segs = kiocb-ki_nbytes;
 
 #ifdef CONFIG_COMPAT
if (compat)
ret = compat_rw_copy_check_uvector(rw,
-   (struct compat_iovec __user *)kiocb-ki_buf,
-   kiocb-ki_nr_segs, 1, kiocb-ki_inline_vec,
-   kiocb-ki_iovec);
+   (struct compat_iovec __user *)buf,
+   *nr_segs, 1, *iovec, iovec);
else
 #endif
ret = rw_copy_check_uvector(rw,
-   (struct iovec __user *)kiocb-ki_buf,
-   kiocb-ki_nr_segs, 1, kiocb-ki_inline_vec,
-   kiocb-ki_iovec);
+   (struct iovec __user *)buf,
+   *nr_segs, 1, *iovec, iovec);
if (ret  0)
return ret;
 
@@ -994,15 +994,17 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb 
*kiocb, bool compat)
return 0;
 }
 
-static ssize_t aio_setup_single_vector(int rw, struct kiocb *kiocb)
+static ssize_t aio_setup_single_vector(struct kiocb *kiocb,
+  int rw, char __user *buf,
+  unsigned long *nr_segs,
+  struct iovec *iovec)
 {
-   if (unlikely(!access_ok(!rw, kiocb-ki_buf, kiocb-ki_nbytes)))
+   if (unlikely(!access_ok(!rw, buf, kiocb-ki_nbytes)))
return -EFAULT;
 
-   kiocb-ki_iovec = kiocb-ki_inline_vec;
-   kiocb-ki_iovec-iov_base = kiocb-ki_buf;
-   kiocb-ki_iovec-iov_len = kiocb-ki_nbytes;
-   kiocb-ki_nr_segs = 1;
+   iovec-iov_base = buf;
+   iovec-iov_len = kiocb-ki_nbytes;
+   *nr_segs = 1;
return 0;
 }
 
@@ -1011,15 +1013,18 @@ static ssize_t aio_setup_single_vector(int rw, struct 
kiocb *kiocb)
  * Performs the initial checks and aio retry method
  * setup for the kiocb at the time of io submission.
  */
-static ssize_t aio_run_iocb(struct kiocb *req, bool compat)
+static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
+   char __user *buf, bool compat)
 {
struct file *file = req-ki_filp;
ssize_t ret;
+   unsigned long nr_segs;
int rw;
fmode_t mode;
aio_rw_op *rw_op;
+   struct iovec inline_vec, *iovec = inline_vec;
 
-   switch (req-ki_opcode) {
+   switch (opcode) {
case IOCB_CMD_PREAD:
case IOCB_CMD_PREADV:
mode= FMODE_READ;
@@ -1040,16 +1045,21 @@ rw_common:
if (!rw_op)
return -EINVAL;
 
-   ret = (req-ki_opcode == IOCB_CMD_PREADV ||
-  req-ki_opcode == IOCB_CMD_PWRITEV)
-   ? aio_setup_vectored_rw(rw, req, compat)
-   : aio_setup_single_vector(rw, req);
+   ret = (opcode == IOCB_CMD_PREADV ||
+  opcode == IOCB_CMD_PWRITEV)
+   ? aio_setup_vectored_rw(req,