@@ -150,6 +150,8 @@ struct svc_rdma_chunk_ctxt {
150
150
struct svcxprt_rdma * cc_rdma ;
151
151
struct list_head cc_rwctxts ;
152
152
int cc_sqecount ;
153
+ enum ib_wc_status cc_status ;
154
+ struct completion cc_done ;
153
155
};
154
156
155
157
static void svc_rdma_cc_cid_init (struct svcxprt_rdma * rdma ,
@@ -299,29 +301,15 @@ static void svc_rdma_wc_read_done(struct ib_cq *cq, struct ib_wc *wc)
299
301
struct svc_rdma_chunk_ctxt * cc =
300
302
container_of (cqe , struct svc_rdma_chunk_ctxt , cc_cqe );
301
303
struct svcxprt_rdma * rdma = cc -> cc_rdma ;
302
- struct svc_rdma_read_info * info =
303
- container_of (cc , struct svc_rdma_read_info , ri_cc );
304
304
305
305
trace_svcrdma_wc_read (wc , & cc -> cc_cid );
306
306
307
307
atomic_add (cc -> cc_sqecount , & rdma -> sc_sq_avail );
308
308
wake_up (& rdma -> sc_send_wait );
309
309
310
- if (unlikely (wc -> status != IB_WC_SUCCESS )) {
311
- set_bit (XPT_CLOSE , & rdma -> sc_xprt .xpt_flags );
312
- svc_rdma_recv_ctxt_put (rdma , info -> ri_readctxt );
313
- } else {
314
- spin_lock (& rdma -> sc_rq_dto_lock );
315
- list_add_tail (& info -> ri_readctxt -> rc_list ,
316
- & rdma -> sc_read_complete_q );
317
- /* Note the unlock pairs with the smp_rmb in svc_xprt_ready: */
318
- set_bit (XPT_DATA , & rdma -> sc_xprt .xpt_flags );
319
- spin_unlock (& rdma -> sc_rq_dto_lock );
320
-
321
- svc_xprt_enqueue (& rdma -> sc_xprt );
322
- }
323
-
324
- svc_rdma_read_info_free (info );
310
+ cc -> cc_status = wc -> status ;
311
+ complete (& cc -> cc_done );
312
+ return ;
325
313
}
326
314
327
315
/* This function sleeps when the transport's Send Queue is congested.
@@ -676,8 +664,8 @@ static int svc_rdma_build_read_segment(struct svc_rdma_read_info *info,
676
664
struct svc_rdma_recv_ctxt * head = info -> ri_readctxt ;
677
665
struct svc_rdma_chunk_ctxt * cc = & info -> ri_cc ;
678
666
struct svc_rqst * rqstp = info -> ri_rqst ;
679
- struct svc_rdma_rw_ctxt * ctxt ;
680
667
unsigned int sge_no , seg_len , len ;
668
+ struct svc_rdma_rw_ctxt * ctxt ;
681
669
struct scatterlist * sg ;
682
670
int ret ;
683
671
@@ -693,8 +681,6 @@ static int svc_rdma_build_read_segment(struct svc_rdma_read_info *info,
693
681
seg_len = min_t (unsigned int , len ,
694
682
PAGE_SIZE - info -> ri_pageoff );
695
683
696
- head -> rc_arg .pages [info -> ri_pageno ] =
697
- rqstp -> rq_pages [info -> ri_pageno ];
698
684
if (!info -> ri_pageoff )
699
685
head -> rc_page_count ++ ;
700
686
@@ -788,12 +774,10 @@ static int svc_rdma_copy_inline_range(struct svc_rdma_read_info *info,
788
774
page_len = min_t (unsigned int , remaining ,
789
775
PAGE_SIZE - info -> ri_pageoff );
790
776
791
- head -> rc_arg .pages [info -> ri_pageno ] =
792
- rqstp -> rq_pages [info -> ri_pageno ];
793
777
if (!info -> ri_pageoff )
794
778
head -> rc_page_count ++ ;
795
779
796
- dst = page_address (head -> rc_arg . pages [info -> ri_pageno ]);
780
+ dst = page_address (rqstp -> rq_pages [info -> ri_pageno ]);
797
781
memcpy (dst + info -> ri_pageno , src + offset , page_len );
798
782
799
783
info -> ri_totalbytes += page_len ;
@@ -813,7 +797,7 @@ static int svc_rdma_copy_inline_range(struct svc_rdma_read_info *info,
813
797
* svc_rdma_read_multiple_chunks - Construct RDMA Reads to pull data item Read chunks
814
798
* @info: context for RDMA Reads
815
799
*
816
- * The chunk data lands in head->rc_arg as a series of contiguous pages,
800
+ * The chunk data lands in rqstp->rq_arg as a series of contiguous pages,
817
801
* like an incoming TCP call.
818
802
*
819
803
* Return values:
@@ -827,8 +811,8 @@ static noinline int svc_rdma_read_multiple_chunks(struct svc_rdma_read_info *inf
827
811
{
828
812
struct svc_rdma_recv_ctxt * head = info -> ri_readctxt ;
829
813
const struct svc_rdma_pcl * pcl = & head -> rc_read_pcl ;
814
+ struct xdr_buf * buf = & info -> ri_rqst -> rq_arg ;
830
815
struct svc_rdma_chunk * chunk , * next ;
831
- struct xdr_buf * buf = & head -> rc_arg ;
832
816
unsigned int start , length ;
833
817
int ret ;
834
818
@@ -864,9 +848,9 @@ static noinline int svc_rdma_read_multiple_chunks(struct svc_rdma_read_info *inf
864
848
buf -> len += info -> ri_totalbytes ;
865
849
buf -> buflen += info -> ri_totalbytes ;
866
850
867
- head -> rc_hdr_count = 1 ;
868
- buf -> head [0 ].iov_base = page_address (head -> rc_pages [0 ]);
851
+ buf -> head [0 ].iov_base = page_address (info -> ri_rqst -> rq_pages [0 ]);
869
852
buf -> head [0 ].iov_len = min_t (size_t , PAGE_SIZE , info -> ri_totalbytes );
853
+ buf -> pages = & info -> ri_rqst -> rq_pages [1 ];
870
854
buf -> page_len = info -> ri_totalbytes - buf -> head [0 ].iov_len ;
871
855
return 0 ;
872
856
}
@@ -875,9 +859,9 @@ static noinline int svc_rdma_read_multiple_chunks(struct svc_rdma_read_info *inf
875
859
* svc_rdma_read_data_item - Construct RDMA Reads to pull data item Read chunks
876
860
* @info: context for RDMA Reads
877
861
*
878
- * The chunk data lands in the page list of head->rc_arg .pages.
862
+ * The chunk data lands in the page list of rqstp->rq_arg .pages.
879
863
*
880
- * Currently NFSD does not look at the head->rc_arg .tail[0] iovec .
864
+ * Currently NFSD does not look at the rqstp->rq_arg .tail[0] kvec .
881
865
* Therefore, XDR round-up of the Read chunk and trailing
882
866
* inline content must both be added at the end of the pagelist.
883
867
*
@@ -891,7 +875,7 @@ static noinline int svc_rdma_read_multiple_chunks(struct svc_rdma_read_info *inf
891
875
static int svc_rdma_read_data_item (struct svc_rdma_read_info * info )
892
876
{
893
877
struct svc_rdma_recv_ctxt * head = info -> ri_readctxt ;
894
- struct xdr_buf * buf = & head -> rc_arg ;
878
+ struct xdr_buf * buf = & info -> ri_rqst -> rq_arg ;
895
879
struct svc_rdma_chunk * chunk ;
896
880
unsigned int length ;
897
881
int ret ;
@@ -901,8 +885,6 @@ static int svc_rdma_read_data_item(struct svc_rdma_read_info *info)
901
885
if (ret < 0 )
902
886
goto out ;
903
887
904
- head -> rc_hdr_count = 0 ;
905
-
906
888
/* Split the Receive buffer between the head and tail
907
889
* buffers at Read chunk's position. XDR roundup of the
908
890
* chunk is not included in either the pagelist or in
@@ -921,7 +903,8 @@ static int svc_rdma_read_data_item(struct svc_rdma_read_info *info)
921
903
* Currently these chunks always start at page offset 0,
922
904
* thus the rounded-up length never crosses a page boundary.
923
905
*/
924
- length = XDR_QUADLEN (info -> ri_totalbytes ) << 2 ;
906
+ buf -> pages = & info -> ri_rqst -> rq_pages [0 ];
907
+ length = xdr_align_size (chunk -> ch_length );
925
908
buf -> page_len = length ;
926
909
buf -> len += length ;
927
910
buf -> buflen += length ;
@@ -1033,8 +1016,7 @@ static int svc_rdma_read_call_chunk(struct svc_rdma_read_info *info)
1033
1016
* @info: context for RDMA Reads
1034
1017
*
1035
1018
* The start of the data lands in the first page just after the
1036
- * Transport header, and the rest lands in the page list of
1037
- * head->rc_arg.pages.
1019
+ * Transport header, and the rest lands in rqstp->rq_arg.pages.
1038
1020
*
1039
1021
* Assumptions:
1040
1022
* - A PZRC is never sent in an RDMA_MSG message, though it's
@@ -1049,8 +1031,7 @@ static int svc_rdma_read_call_chunk(struct svc_rdma_read_info *info)
1049
1031
*/
1050
1032
static noinline int svc_rdma_read_special (struct svc_rdma_read_info * info )
1051
1033
{
1052
- struct svc_rdma_recv_ctxt * head = info -> ri_readctxt ;
1053
- struct xdr_buf * buf = & head -> rc_arg ;
1034
+ struct xdr_buf * buf = & info -> ri_rqst -> rq_arg ;
1054
1035
int ret ;
1055
1036
1056
1037
ret = svc_rdma_read_call_chunk (info );
@@ -1060,35 +1041,15 @@ static noinline int svc_rdma_read_special(struct svc_rdma_read_info *info)
1060
1041
buf -> len += info -> ri_totalbytes ;
1061
1042
buf -> buflen += info -> ri_totalbytes ;
1062
1043
1063
- head -> rc_hdr_count = 1 ;
1064
- buf -> head [0 ].iov_base = page_address (head -> rc_pages [0 ]);
1044
+ buf -> head [0 ].iov_base = page_address (info -> ri_rqst -> rq_pages [0 ]);
1065
1045
buf -> head [0 ].iov_len = min_t (size_t , PAGE_SIZE , info -> ri_totalbytes );
1046
+ buf -> pages = & info -> ri_rqst -> rq_pages [1 ];
1066
1047
buf -> page_len = info -> ri_totalbytes - buf -> head [0 ].iov_len ;
1067
1048
1068
1049
out :
1069
1050
return ret ;
1070
1051
}
1071
1052
1072
- /* Pages under I/O have been copied to head->rc_pages. Ensure they
1073
- * are not released by svc_xprt_release() until the I/O is complete.
1074
- *
1075
- * This has to be done after all Read WRs are constructed to properly
1076
- * handle a page that is part of I/O on behalf of two different RDMA
1077
- * segments.
1078
- *
1079
- * Do this only if I/O has been posted. Otherwise, we do indeed want
1080
- * svc_xprt_release() to clean things up properly.
1081
- */
1082
- static void svc_rdma_save_io_pages (struct svc_rqst * rqstp ,
1083
- const unsigned int start ,
1084
- const unsigned int num_pages )
1085
- {
1086
- unsigned int i ;
1087
-
1088
- for (i = start ; i < num_pages + start ; i ++ )
1089
- rqstp -> rq_pages [i ] = NULL ;
1090
- }
1091
-
1092
1053
/**
1093
1054
* svc_rdma_process_read_list - Pull list of Read chunks from the client
1094
1055
* @rdma: controlling RDMA transport
@@ -1153,11 +1114,22 @@ int svc_rdma_process_read_list(struct svcxprt_rdma *rdma,
1153
1114
goto out_err ;
1154
1115
1155
1116
trace_svcrdma_post_read_chunk (& cc -> cc_cid , cc -> cc_sqecount );
1117
+ init_completion (& cc -> cc_done );
1156
1118
ret = svc_rdma_post_chunk_ctxt (cc );
1157
1119
if (ret < 0 )
1158
1120
goto out_err ;
1159
- svc_rdma_save_io_pages (rqstp , 0 , head -> rc_page_count );
1160
- return 1 ;
1121
+
1122
+ ret = 1 ;
1123
+ wait_for_completion (& cc -> cc_done );
1124
+ if (cc -> cc_status != IB_WC_SUCCESS )
1125
+ ret = - EIO ;
1126
+
1127
+ /* rq_respages starts after the last arg page */
1128
+ rqstp -> rq_respages = & rqstp -> rq_pages [head -> rc_page_count ];
1129
+ rqstp -> rq_next_page = rqstp -> rq_respages + 1 ;
1130
+
1131
+ /* Ensure svc_rdma_recv_ctxt_put() does not try to release pages */
1132
+ head -> rc_page_count = 0 ;
1161
1133
1162
1134
out_err :
1163
1135
svc_rdma_read_info_free (info );
0 commit comments