Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

smb: server: split out smb_direct_send_iter() out of smb_direct_writev()

This will help to move to common code in future.

Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Stefan Metzmacher and committed by
Steve French
08ffdf0c da20536c

+32 -15
+32 -15
fs/smb/server/transport_rdma.c
··· 959 959 return ret; 960 960 } 961 961 962 - static int smb_direct_writev(struct ksmbd_transport *t, 963 - struct kvec *iov, int niovs, int buflen, 964 - bool need_invalidate, unsigned int remote_key) 962 + static int smb_direct_send_iter(struct smbdirect_socket *sc, 963 + struct iov_iter *iter, 964 + bool need_invalidate, 965 + unsigned int remote_key) 965 966 { 966 - struct smb_direct_transport *st = SMBD_TRANS(t); 967 - struct smbdirect_socket *sc = &st->socket; 968 967 struct smbdirect_socket_parameters *sp = &sc->parameters; 969 968 int ret; 970 969 struct smbdirect_send_batch send_ctx; 971 - struct iov_iter iter; 972 970 int error = 0; 971 + __be32 hdr; 973 972 974 973 if (sc->status != SMBDIRECT_SOCKET_CONNECTED) 975 974 return -ENOTCONN; 976 975 977 - //FIXME: skip RFC1002 header.. 978 - if (WARN_ON_ONCE(niovs <= 1 || iov[0].iov_len != 4)) 976 + /* 977 + * For now we expect the iter to have the full 978 + * message, including a 4 byte length header. 979 + */ 980 + if (iov_iter_count(iter) <= 4) 979 981 return -EINVAL; 980 - iov_iter_kvec(&iter, ITER_SOURCE, iov, niovs, buflen); 981 - iov_iter_advance(&iter, 4); 982 + if (!copy_from_iter_full(&hdr, sizeof(hdr), iter)) 983 + return -EFAULT; 984 + if (iov_iter_count(iter) != be32_to_cpu(hdr)) 985 + return -EINVAL; 982 986 983 987 /* 984 988 * The size must fit into the negotiated 985 989 * fragmented send size. 986 990 */ 987 - if (iov_iter_count(&iter) > sp->max_fragmented_send_size) 991 + if (iov_iter_count(iter) > sp->max_fragmented_send_size) 988 992 return -EMSGSIZE; 989 993 990 994 ksmbd_debug(RDMA, "Sending smb (RDMA): smb_len=%zu\n", 991 - iov_iter_count(&iter)); 995 + iov_iter_count(iter)); 992 996 993 997 smb_direct_send_ctx_init(&send_ctx, need_invalidate, remote_key); 994 - while (iov_iter_count(&iter)) { 998 + while (iov_iter_count(iter)) { 995 999 ret = smb_direct_post_send_data(sc, 996 1000 &send_ctx, 997 - &iter, 998 - iov_iter_count(&iter)); 1001 + iter, 1002 + iov_iter_count(iter)); 999 1003 if (unlikely(ret)) { 1000 1004 error = ret; 1001 1005 break; ··· 1024 1020 ret = -ENOTCONN; 1025 1021 1026 1022 return ret; 1023 + } 1024 + 1025 + static int smb_direct_writev(struct ksmbd_transport *t, 1026 + struct kvec *iov, int niovs, int buflen, 1027 + bool need_invalidate, unsigned int remote_key) 1028 + { 1029 + struct smb_direct_transport *st = SMBD_TRANS(t); 1030 + struct smbdirect_socket *sc = &st->socket; 1031 + struct iov_iter iter; 1032 + 1033 + iov_iter_kvec(&iter, ITER_SOURCE, iov, niovs, buflen); 1034 + 1035 + return smb_direct_send_iter(sc, &iter, need_invalidate, remote_key); 1027 1036 } 1028 1037 1029 1038 static int smb_direct_rdma_write(struct ksmbd_transport *t,