net: socket: add support for async operations
authortadeusz.struk@intel.com <tadeusz.struk@intel.com>
Thu, 19 Mar 2015 19:31:25 +0000 (12:31 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 23 Mar 2015 20:41:36 +0000 (16:41 -0400)
Add support for async operations.

Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/socket.h
net/compat.c
net/socket.c

index fab4d0ddf4eda67ff416bb10a1e7b545639462fd..c9852ef7e317a6167675f68e7948b6aebea85947 100644 (file)
@@ -51,6 +51,7 @@ struct msghdr {
        void            *msg_control;   /* ancillary data */
        __kernel_size_t msg_controllen; /* ancillary data buffer length */
        unsigned int    msg_flags;      /* flags on received message */
+       struct kiocb    *msg_iocb;      /* ptr to iocb for async requests */
 };
  
 struct user_msghdr {
index 13c0c9a25cd99e8e868dc71c23246d45aeaa7c8b..c4b6b0f43d5d4243d8c35274a4669333bd9f5f25 100644 (file)
@@ -79,6 +79,8 @@ ssize_t get_compat_msghdr(struct msghdr *kmsg,
        if (nr_segs > UIO_MAXIOV)
                return -EMSGSIZE;
 
+       kmsg->msg_iocb = NULL;
+
        err = compat_rw_copy_check_uvector(save_addr ? READ : WRITE,
                                           compat_ptr(uiov), nr_segs,
                                           UIO_FASTIOV, *iov, iov);
index 3e776776f42c1015f0e989e8302dcd519ca6dc1c..073809f4125f276799418342f9c60519a3da82e9 100644 (file)
@@ -798,7 +798,8 @@ static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
        struct file *file = iocb->ki_filp;
        struct socket *sock = file->private_data;
-       struct msghdr msg = {.msg_iter = *to};
+       struct msghdr msg = {.msg_iter = *to,
+                            .msg_iocb = iocb};
        ssize_t res;
 
        if (file->f_flags & O_NONBLOCK)
@@ -819,7 +820,8 @@ static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
        struct file *file = iocb->ki_filp;
        struct socket *sock = file->private_data;
-       struct msghdr msg = {.msg_iter = *from};
+       struct msghdr msg = {.msg_iter = *from,
+                            .msg_iocb = iocb};
        ssize_t res;
 
        if (iocb->ki_pos != 0)
@@ -1894,6 +1896,8 @@ static ssize_t copy_msghdr_from_user(struct msghdr *kmsg,
        if (nr_segs > UIO_MAXIOV)
                return -EMSGSIZE;
 
+       kmsg->msg_iocb = NULL;
+
        err = rw_copy_check_uvector(save_addr ? READ : WRITE,
                                    uiov, nr_segs,
                                    UIO_FASTIOV, *iov, iov);