Skip to content

Commit 6509f50

Browse files
longlimsftSteve French
authored andcommitted
CIFS: SMBD: Support page offset in RDMA recv
RDMA recv function needs to place data to the correct place starting at page offset. Signed-off-by: Long Li <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent b6903bc commit 6509f50

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

fs/cifs/smbdirect.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,27 +2004,30 @@ static int smbd_recv_buf(struct smbd_connection *info, char *buf,
20042004
* return value: actual data read
20052005
*/
20062006
static int smbd_recv_page(struct smbd_connection *info,
2007-
struct page *page, unsigned int to_read)
2007+
struct page *page, unsigned int page_offset,
2008+
unsigned int to_read)
20082009
{
20092010
int ret;
20102011
char *to_address;
2012+
void *page_address;
20112013

20122014
/* make sure we have the page ready for read */
20132015
ret = wait_event_interruptible(
20142016
info->wait_reassembly_queue,
20152017
info->reassembly_data_length >= to_read ||
20162018
info->transport_status != SMBD_CONNECTED);
20172019
if (ret)
2018-
return 0;
2020+
return ret;
20192021

20202022
/* now we can read from reassembly queue and not sleep */
2021-
to_address = kmap_atomic(page);
2023+
page_address = kmap_atomic(page);
2024+
to_address = (char *) page_address + page_offset;
20222025

20232026
log_read(INFO, "reading from page=%p address=%p to_read=%d\n",
20242027
page, to_address, to_read);
20252028

20262029
ret = smbd_recv_buf(info, to_address, to_read);
2027-
kunmap_atomic(to_address);
2030+
kunmap_atomic(page_address);
20282031

20292032
return ret;
20302033
}
@@ -2038,7 +2041,7 @@ int smbd_recv(struct smbd_connection *info, struct msghdr *msg)
20382041
{
20392042
char *buf;
20402043
struct page *page;
2041-
unsigned int to_read;
2044+
unsigned int to_read, page_offset;
20422045
int rc;
20432046

20442047
info->smbd_recv_pending++;
@@ -2052,15 +2055,16 @@ int smbd_recv(struct smbd_connection *info, struct msghdr *msg)
20522055

20532056
case READ | ITER_BVEC:
20542057
page = msg->msg_iter.bvec->bv_page;
2058+
page_offset = msg->msg_iter.bvec->bv_offset;
20552059
to_read = msg->msg_iter.bvec->bv_len;
2056-
rc = smbd_recv_page(info, page, to_read);
2060+
rc = smbd_recv_page(info, page, page_offset, to_read);
20572061
break;
20582062

20592063
default:
20602064
/* It's a bug in upper layer to get there */
20612065
cifs_dbg(VFS, "CIFS: invalid msg type %d\n",
20622066
msg->msg_iter.type);
2063-
rc = -EIO;
2067+
rc = -EINVAL;
20642068
}
20652069

20662070
info->smbd_recv_pending--;

0 commit comments

Comments
 (0)