diff options
author | Andy Grover <andy.grover@oracle.com> | 2010-01-12 17:13:15 -0500 |
---|---|---|
committer | Andy Grover <andy.grover@oracle.com> | 2010-09-08 21:11:38 -0400 |
commit | ff87e97a9d70c9ae133d3d3d7792b26ab85f4297 (patch) | |
tree | 32de73cdf5e4353e89b3351eaae695f69faa868b /net/rds/send.c | |
parent | 21f79afa5fda2820671a8f64c3d0e43bb118053b (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.c | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/net/rds/send.c b/net/rds/send.c index 89e26ffdc812..72dbe7fc4f54 100644 --- a/net/rds/send.c +++ b/net/rds/send.c | |||
@@ -235,7 +235,7 @@ int rds_send_xmit(struct rds_connection *conn) | |||
235 | * connection. | 235 | * connection. |
236 | * Therefore, we never retransmit messages with RDMA ops. | 236 | * Therefore, we never retransmit messages with RDMA ops. |
237 | */ | 237 | */ |
238 | if (rm->rdma.m_rdma_op && | 238 | if (rm->rdma.m_rdma_op.r_active && |
239 | test_bit(RDS_MSG_RETRANSMITTED, &rm->m_flags)) { | 239 | test_bit(RDS_MSG_RETRANSMITTED, &rm->m_flags)) { |
240 | spin_lock_irqsave(&conn->c_lock, flags); | 240 | spin_lock_irqsave(&conn->c_lock, flags); |
241 | if (test_and_clear_bit(RDS_MSG_ON_CONN, &rm->m_flags)) | 241 | if (test_and_clear_bit(RDS_MSG_ON_CONN, &rm->m_flags)) |
@@ -267,8 +267,8 @@ int rds_send_xmit(struct rds_connection *conn) | |||
267 | * keep this simple and require that the transport either | 267 | * keep this simple and require that the transport either |
268 | * send the whole rdma or none of it. | 268 | * send the whole rdma or none of it. |
269 | */ | 269 | */ |
270 | if (rm->rdma.m_rdma_op && !conn->c_xmit_rdma_sent) { | 270 | if (rm->rdma.m_rdma_op.r_active && !conn->c_xmit_rdma_sent) { |
271 | ret = conn->c_trans->xmit_rdma(conn, rm->rdma.m_rdma_op); | 271 | ret = conn->c_trans->xmit_rdma(conn, &rm->rdma.m_rdma_op); |
272 | if (ret) | 272 | if (ret) |
273 | break; | 273 | break; |
274 | conn->c_xmit_rdma_sent = 1; | 274 | conn->c_xmit_rdma_sent = 1; |
@@ -418,9 +418,9 @@ void rds_rdma_send_complete(struct rds_message *rm, int status) | |||
418 | 418 | ||
419 | spin_lock_irqsave(&rm->m_rs_lock, flags); | 419 | spin_lock_irqsave(&rm->m_rs_lock, flags); |
420 | 420 | ||
421 | ro = rm->rdma.m_rdma_op; | 421 | ro = &rm->rdma.m_rdma_op; |
422 | if (test_bit(RDS_MSG_ON_SOCK, &rm->m_flags) && | 422 | if (test_bit(RDS_MSG_ON_SOCK, &rm->m_flags) && |
423 | ro && ro->r_notify && ro->r_notifier) { | 423 | ro->r_active && ro->r_notify && ro->r_notifier) { |
424 | notifier = ro->r_notifier; | 424 | notifier = ro->r_notifier; |
425 | rs = rm->m_rs; | 425 | rs = rm->m_rs; |
426 | sock_hold(rds_rs_to_sk(rs)); | 426 | 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 | |||
452 | { | 452 | { |
453 | struct rds_rdma_op *ro; | 453 | struct rds_rdma_op *ro; |
454 | 454 | ||
455 | ro = rm->rdma.m_rdma_op; | 455 | ro = &rm->rdma.m_rdma_op; |
456 | if (ro && ro->r_notify && ro->r_notifier) { | 456 | if (ro->r_active && ro->r_notify && ro->r_notifier) { |
457 | ro->r_notifier->n_status = status; | 457 | ro->r_notifier->n_status = status; |
458 | list_add_tail(&ro->r_notifier->n_list, &rs->rs_notify_queue); | 458 | list_add_tail(&ro->r_notifier->n_list, &rs->rs_notify_queue); |
459 | ro->r_notifier = NULL; | 459 | ro->r_notifier = NULL; |
@@ -476,7 +476,7 @@ struct rds_message *rds_send_get_message(struct rds_connection *conn, | |||
476 | spin_lock_irqsave(&conn->c_lock, flags); | 476 | spin_lock_irqsave(&conn->c_lock, flags); |
477 | 477 | ||
478 | list_for_each_entry_safe(rm, tmp, &conn->c_retrans, m_conn_item) { | 478 | list_for_each_entry_safe(rm, tmp, &conn->c_retrans, m_conn_item) { |
479 | if (rm->rdma.m_rdma_op == op) { | 479 | if (&rm->rdma.m_rdma_op == op) { |
480 | atomic_inc(&rm->m_refcount); | 480 | atomic_inc(&rm->m_refcount); |
481 | found = rm; | 481 | found = rm; |
482 | goto out; | 482 | goto out; |
@@ -484,7 +484,7 @@ struct rds_message *rds_send_get_message(struct rds_connection *conn, | |||
484 | } | 484 | } |
485 | 485 | ||
486 | list_for_each_entry_safe(rm, tmp, &conn->c_send_queue, m_conn_item) { | 486 | list_for_each_entry_safe(rm, tmp, &conn->c_send_queue, m_conn_item) { |
487 | if (rm->rdma.m_rdma_op == op) { | 487 | if (&rm->rdma.m_rdma_op == op) { |
488 | atomic_inc(&rm->m_refcount); | 488 | atomic_inc(&rm->m_refcount); |
489 | found = rm; | 489 | found = rm; |
490 | break; | 490 | break; |
@@ -544,19 +544,20 @@ void rds_send_remove_from_sock(struct list_head *messages, int status) | |||
544 | spin_lock(&rs->rs_lock); | 544 | spin_lock(&rs->rs_lock); |
545 | 545 | ||
546 | if (test_and_clear_bit(RDS_MSG_ON_SOCK, &rm->m_flags)) { | 546 | if (test_and_clear_bit(RDS_MSG_ON_SOCK, &rm->m_flags)) { |
547 | struct rds_rdma_op *ro = rm->rdma.m_rdma_op; | 547 | struct rds_rdma_op *ro = &rm->rdma.m_rdma_op; |
548 | struct rds_notifier *notifier; | 548 | struct rds_notifier *notifier; |
549 | 549 | ||
550 | list_del_init(&rm->m_sock_item); | 550 | list_del_init(&rm->m_sock_item); |
551 | rds_send_sndbuf_remove(rs, rm); | 551 | rds_send_sndbuf_remove(rs, rm); |
552 | 552 | ||
553 | if (ro && ro->r_notifier && (status || ro->r_notify)) { | 553 | if (ro->r_active && ro->r_notifier && |
554 | (status || ro->r_notify)) { | ||
554 | notifier = ro->r_notifier; | 555 | notifier = ro->r_notifier; |
555 | list_add_tail(¬ifier->n_list, | 556 | list_add_tail(¬ifier->n_list, |
556 | &rs->rs_notify_queue); | 557 | &rs->rs_notify_queue); |
557 | if (!notifier->n_status) | 558 | if (!notifier->n_status) |
558 | notifier->n_status = status; | 559 | notifier->n_status = status; |
559 | rm->rdma.m_rdma_op->r_notifier = NULL; | 560 | rm->rdma.m_rdma_op.r_notifier = NULL; |
560 | } | 561 | } |
561 | was_on_sock = 1; | 562 | was_on_sock = 1; |
562 | rm->m_rs = NULL; | 563 | rm->m_rs = NULL; |
@@ -763,9 +764,37 @@ out: | |||
763 | */ | 764 | */ |
764 | static int rds_rm_size(struct msghdr *msg, int data_len) | 765 | static int rds_rm_size(struct msghdr *msg, int data_len) |
765 | { | 766 | { |
767 | struct cmsghdr *cmsg; | ||
766 | int size = 0; | 768 | int size = 0; |
769 | int retval; | ||
770 | |||
771 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { | ||
772 | if (!CMSG_OK(msg, cmsg)) | ||
773 | return -EINVAL; | ||
774 | |||
775 | if (cmsg->cmsg_level != SOL_RDS) | ||
776 | continue; | ||
777 | |||
778 | switch (cmsg->cmsg_type) { | ||
779 | case RDS_CMSG_RDMA_ARGS: | ||
780 | retval = rds_rdma_extra_size(CMSG_DATA(cmsg)); | ||
781 | if (retval < 0) | ||
782 | return retval; | ||
783 | size += retval; | ||
784 | break; | ||
785 | |||
786 | case RDS_CMSG_RDMA_DEST: | ||
787 | case RDS_CMSG_RDMA_MAP: | ||
788 | /* these are valid but do no add any size */ | ||
789 | break; | ||
790 | |||
791 | default: | ||
792 | return -EINVAL; | ||
793 | } | ||
794 | |||
795 | } | ||
767 | 796 | ||
768 | size += ceil(data_len, PAGE_SIZE) * sizeof(struct scatterlist); | 797 | size += ceil(data_len, PAGE_SIZE) * sizeof(struct scatterlist); |
769 | 798 | ||
770 | return size; | 799 | return size; |
771 | } | 800 | } |
@@ -896,11 +925,11 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
896 | if (ret) | 925 | if (ret) |
897 | goto out; | 926 | goto out; |
898 | 927 | ||
899 | if ((rm->m_rdma_cookie || rm->rdma.m_rdma_op) && | 928 | if ((rm->m_rdma_cookie || rm->rdma.m_rdma_op.r_active) && |
900 | !conn->c_trans->xmit_rdma) { | 929 | !conn->c_trans->xmit_rdma) { |
901 | if (printk_ratelimit()) | 930 | if (printk_ratelimit()) |
902 | printk(KERN_NOTICE "rdma_op %p conn xmit_rdma %p\n", | 931 | printk(KERN_NOTICE "rdma_op %p conn xmit_rdma %p\n", |
903 | rm->rdma.m_rdma_op, conn->c_trans->xmit_rdma); | 932 | &rm->rdma.m_rdma_op, conn->c_trans->xmit_rdma); |
904 | ret = -EOPNOTSUPP; | 933 | ret = -EOPNOTSUPP; |
905 | goto out; | 934 | goto out; |
906 | } | 935 | } |