RDS: Do not set op_active in r_m_copy_from_user().
authorAndy Grover <andy.grover@oracle.com>
Thu, 4 Feb 2010 03:40:32 +0000 (19:40 -0800)
committerAndy Grover <andy.grover@oracle.com>
Thu, 9 Sep 2010 01:12:02 +0000 (18:12 -0700)
Do not allocate sgs for data for 0-length datagrams

Set data.op_active in rds_sendmsg() instead of
rds_message_copy_from_user().

Signed-off-by: Andy Grover <andy.grover@oracle.com>
net/rds/message.c
net/rds/send.c

index 4bd9504ca048762884d4be662fdf675cc6d21565..f4c3be0878e97226d1b2d28d8504f8374274d169 100644 (file)
@@ -330,8 +330,6 @@ int rds_message_copy_from_user(struct rds_message *rm, struct iovec *first_iov,
                        sg++;
        }
 
-       rm->data.op_active = 1;
-
 out:
        return ret;
 }
index 66dc6b04526165c040b718a468762ed0885c872c..ad89a63c430480277359acaef2c7d7b2fb6cf68d 100644 (file)
@@ -970,11 +970,14 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
                goto out;
        }
 
-       rm->data.op_sg = rds_message_alloc_sgs(rm, ceil(payload_len, PAGE_SIZE));
-       /* XXX fix this to not allocate memory */
-       ret = rds_message_copy_from_user(rm, msg->msg_iov, payload_len);
-       if (ret)
-               goto out;
+       /* Attach data to the rm */
+       if (payload_len) {
+               rm->data.op_sg = rds_message_alloc_sgs(rm, ceil(payload_len, PAGE_SIZE));
+               ret = rds_message_copy_from_user(rm, msg->msg_iov, payload_len);
+               if (ret)
+                       goto out;
+       }
+       rm->data.op_active = 1;
 
        rm->m_daddr = daddr;