aboutsummaryrefslogtreecommitdiff
path: root/net/rds/send.c
diff options
context:
space:
mode:
authorAndy Grover <andy.grover@oracle.com>2010-01-12 14:13:15 -0800
committerAndy Grover <andy.grover@oracle.com>2010-09-08 18:11:38 -0700
commitff87e97a9d70c9ae133d3d3d7792b26ab85f4297 (patch)
tree32de73cdf5e4353e89b3351eaae695f69faa868b /net/rds/send.c
parent21f79afa5fda2820671a8f64c3d0e43bb118053b (diff)
RDS: make m_rdma_op a member of rds_message
This eliminates a separate memory alloc, although it is now necessary to add an "r_active" flag, since it is no longer to use the m_rdma_op pointer as an indicator of if an rdma op is present. rdma SGs allocated from rm sg pool. rds_rm_size also gets bigger. It's a little inefficient to run through CMSGs twice, but it makes later steps a lot smoother. Signed-off-by: Andy Grover <andy.grover@oracle.com>
Diffstat (limited to 'net/rds/send.c')
-rw-r--r--net/rds/send.c59
1 files changed, 44 insertions, 15 deletions
diff --git a/net/rds/send.c b/net/rds/send.c
index 89e26ffdc81..72dbe7fc4f5 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -235,7 +235,7 @@ int rds_send_xmit(struct rds_connection *conn)
* connection.
* Therefore, we never retransmit messages with RDMA ops.
*/
- if (rm->rdma.m_rdma_op &&
+ if (rm->rdma.m_rdma_op.r_active &&
test_bit(RDS_MSG_RETRANSMITTED, &rm->m_flags)) {
spin_lock_irqsave(&conn->c_lock, flags);
if (test_and_clear_bit(RDS_MSG_ON_CONN, &rm->m_flags))
@@ -267,8 +267,8 @@ int rds_send_xmit(struct rds_connection *conn)
* keep this simple and require that the transport either
* send the whole rdma or none of it.
*/
- if (rm->rdma.m_rdma_op && !conn->c_xmit_rdma_sent) {
- ret = conn->c_trans->xmit_rdma(conn, rm->rdma.m_rdma_op);
+ if (rm->rdma.m_rdma_op.r_active && !conn->c_xmit_rdma_sent) {
+ ret = conn->c_trans->xmit_rdma(conn, &rm->rdma.m_rdma_op);
if (ret)
break;
conn->c_xmit_rdma_sent = 1;
@@ -418,9 +418,9 @@ void rds_rdma_send_complete(struct rds_message *rm, int status)
spin_lock_irqsave(&rm->m_rs_lock, flags);
- ro = rm->rdma.m_rdma_op;
+ ro = &rm->rdma.m_rdma_op;
if (test_bit(RDS_MSG_ON_SOCK, &rm->m_flags) &&
- ro && ro->r_notify && ro->r_notifier) {
+ ro->r_active && ro->r_notify && ro->r_notifier) {
notifier = ro->r_notifier;
rs = rm->m_rs;
sock_hold(rds_rs_to_sk(rs));
@@ -452,8 +452,8 @@ __rds_rdma_send_complete(struct rds_sock *rs, struct rds_message *rm, int status
{
struct rds_rdma_op *ro;
- ro = rm->rdma.m_rdma_op;
- if (ro && ro->r_notify && ro->r_notifier) {
+ ro = &rm->rdma.m_rdma_op;
+ if (ro->r_active && ro->r_notify && ro->r_notifier) {
ro->r_notifier->n_status = status;
list_add_tail(&ro->r_notifier->n_list, &rs->rs_notify_queue);
ro->r_notifier = NULL;
@@ -476,7 +476,7 @@ struct rds_message *rds_send_get_message(struct rds_connection *conn,
spin_lock_irqsave(&conn->c_lock, flags);
list_for_each_entry_safe(rm, tmp, &conn->c_retrans, m_conn_item) {
- if (rm->rdma.m_rdma_op == op) {
+ if (&rm->rdma.m_rdma_op == op) {
atomic_inc(&rm->m_refcount);
found = rm;
goto out;
@@ -484,7 +484,7 @@ struct rds_message *rds_send_get_message(struct rds_connection *conn,
}
list_for_each_entry_safe(rm, tmp, &conn->c_send_queue, m_conn_item) {
- if (rm->rdma.m_rdma_op == op) {
+ if (&rm->rdma.m_rdma_op == op) {
atomic_inc(&rm->m_refcount);
found = rm;
break;
@@ -544,19 +544,20 @@ void rds_send_remove_from_sock(struct list_head *messages, int status)
spin_lock(&rs->rs_lock);
if (test_and_clear_bit(RDS_MSG_ON_SOCK, &rm->m_flags)) {
- struct rds_rdma_op *ro = rm->rdma.m_rdma_op;
+ struct rds_rdma_op *ro = &rm->rdma.m_rdma_op;
struct rds_notifier *notifier;
list_del_init(&rm->m_sock_item);
rds_send_sndbuf_remove(rs, rm);
- if (ro && ro->r_notifier && (status || ro->r_notify)) {
+ if (ro->r_active && ro->r_notifier &&
+ (status || ro->r_notify)) {
notifier = ro->r_notifier;
list_add_tail(&notifier->n_list,
&rs->rs_notify_queue);
if (!notifier->n_status)
notifier->n_status = status;
- rm->rdma.m_rdma_op->r_notifier = NULL;
+ rm->rdma.m_rdma_op.r_notifier = NULL;
}
was_on_sock = 1;
rm->m_rs = NULL;
@@ -763,9 +764,37 @@ out:
*/
static int rds_rm_size(struct msghdr *msg, int data_len)
{
+ struct cmsghdr *cmsg;
int size = 0;
+ int retval;
+
+ for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
+ if (!CMSG_OK(msg, cmsg))
+ return -EINVAL;
+
+ if (cmsg->cmsg_level != SOL_RDS)
+ continue;
+
+ switch (cmsg->cmsg_type) {
+ case RDS_CMSG_RDMA_ARGS:
+ retval = rds_rdma_extra_size(CMSG_DATA(cmsg));
+ if (retval < 0)
+ return retval;
+ size += retval;
+ break;
+
+ case RDS_CMSG_RDMA_DEST:
+ case RDS_CMSG_RDMA_MAP:
+ /* these are valid but do no add any size */
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ }
- size += ceil(data_len, PAGE_SIZE) * sizeof(struct scatterlist);
+ size += ceil(data_len, PAGE_SIZE) * sizeof(struct scatterlist);
return size;
}
@@ -896,11 +925,11 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
if (ret)
goto out;
- if ((rm->m_rdma_cookie || rm->rdma.m_rdma_op) &&
+ if ((rm->m_rdma_cookie || rm->rdma.m_rdma_op.r_active) &&
!conn->c_trans->xmit_rdma) {
if (printk_ratelimit())
printk(KERN_NOTICE "rdma_op %p conn xmit_rdma %p\n",
- rm->rdma.m_rdma_op, conn->c_trans->xmit_rdma);
+ &rm->rdma.m_rdma_op, conn->c_trans->xmit_rdma);
ret = -EOPNOTSUPP;
goto out;
}