diff options
author | Ronnie Sahlberg <lsahlber@redhat.com> | 2018-07-31 19:26:16 -0400 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2018-08-08 17:49:08 -0400 |
commit | 8eb4ecfab03d21146e144b0693ce96839d58202d (patch) | |
tree | 100c17b32f6b4ec75f8527e0dde9d627ae992cfe | |
parent | 468d677954c0d94fec59275d91222257fe8b4416 (diff) |
cifs: add SMB2_close_init()/SMB2_close_free()
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Reviewed-by: Paulo Alcantara <palcantara@suse.com>
-rw-r--r-- | fs/cifs/smb2pdu.c | 48 | ||||
-rw-r--r-- | fs/cifs/smb2proto.h | 3 |
2 files changed, 37 insertions, 14 deletions
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 7c0b30321d9a..78c7190f2295 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
@@ -2445,43 +2445,62 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon, | |||
2445 | } | 2445 | } |
2446 | 2446 | ||
2447 | int | 2447 | int |
2448 | SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, | ||
2449 | u64 persistent_fid, u64 volatile_fid) | ||
2450 | { | ||
2451 | struct smb2_close_req *req; | ||
2452 | struct kvec *iov = rqst->rq_iov; | ||
2453 | unsigned int total_len; | ||
2454 | int rc; | ||
2455 | |||
2456 | rc = smb2_plain_req_init(SMB2_CLOSE, tcon, (void **) &req, &total_len); | ||
2457 | if (rc) | ||
2458 | return rc; | ||
2459 | |||
2460 | req->PersistentFileId = persistent_fid; | ||
2461 | req->VolatileFileId = volatile_fid; | ||
2462 | iov[0].iov_base = (char *)req; | ||
2463 | iov[0].iov_len = total_len; | ||
2464 | |||
2465 | return 0; | ||
2466 | } | ||
2467 | |||
2468 | void | ||
2469 | SMB2_close_free(struct smb_rqst *rqst) | ||
2470 | { | ||
2471 | cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */ | ||
2472 | } | ||
2473 | |||
2474 | int | ||
2448 | SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, | 2475 | SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, |
2449 | u64 persistent_fid, u64 volatile_fid, int flags) | 2476 | u64 persistent_fid, u64 volatile_fid, int flags) |
2450 | { | 2477 | { |
2451 | struct smb_rqst rqst; | 2478 | struct smb_rqst rqst; |
2452 | struct smb2_close_req *req; | 2479 | struct smb2_close_rsp *rsp = NULL; |
2453 | struct smb2_close_rsp *rsp; | ||
2454 | struct cifs_ses *ses = tcon->ses; | 2480 | struct cifs_ses *ses = tcon->ses; |
2455 | struct kvec iov[1]; | 2481 | struct kvec iov[1]; |
2456 | struct kvec rsp_iov; | 2482 | struct kvec rsp_iov; |
2457 | int resp_buftype; | 2483 | int resp_buftype; |
2458 | int rc = 0; | 2484 | int rc = 0; |
2459 | unsigned int total_len; | ||
2460 | 2485 | ||
2461 | cifs_dbg(FYI, "Close\n"); | 2486 | cifs_dbg(FYI, "Close\n"); |
2462 | 2487 | ||
2463 | if (!ses || !(ses->server)) | 2488 | if (!ses || !(ses->server)) |
2464 | return -EIO; | 2489 | return -EIO; |
2465 | 2490 | ||
2466 | rc = smb2_plain_req_init(SMB2_CLOSE, tcon, (void **) &req, &total_len); | ||
2467 | if (rc) | ||
2468 | return rc; | ||
2469 | |||
2470 | if (smb3_encryption_required(tcon)) | 2491 | if (smb3_encryption_required(tcon)) |
2471 | flags |= CIFS_TRANSFORM_REQ; | 2492 | flags |= CIFS_TRANSFORM_REQ; |
2472 | 2493 | ||
2473 | req->PersistentFileId = persistent_fid; | ||
2474 | req->VolatileFileId = volatile_fid; | ||
2475 | |||
2476 | iov[0].iov_base = (char *)req; | ||
2477 | iov[0].iov_len = total_len; | ||
2478 | |||
2479 | memset(&rqst, 0, sizeof(struct smb_rqst)); | 2494 | memset(&rqst, 0, sizeof(struct smb_rqst)); |
2495 | memset(&iov, 0, sizeof(iov)); | ||
2480 | rqst.rq_iov = iov; | 2496 | rqst.rq_iov = iov; |
2481 | rqst.rq_nvec = 1; | 2497 | rqst.rq_nvec = 1; |
2482 | 2498 | ||
2499 | rc = SMB2_close_init(tcon, &rqst, persistent_fid, volatile_fid); | ||
2500 | if (rc) | ||
2501 | goto close_exit; | ||
2502 | |||
2483 | rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); | 2503 | rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); |
2484 | cifs_small_buf_release(req); | ||
2485 | rsp = (struct smb2_close_rsp *)rsp_iov.iov_base; | 2504 | rsp = (struct smb2_close_rsp *)rsp_iov.iov_base; |
2486 | 2505 | ||
2487 | if (rc != 0) { | 2506 | if (rc != 0) { |
@@ -2494,6 +2513,7 @@ SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, | |||
2494 | /* BB FIXME - decode close response, update inode for caching */ | 2513 | /* BB FIXME - decode close response, update inode for caching */ |
2495 | 2514 | ||
2496 | close_exit: | 2515 | close_exit: |
2516 | SMB2_close_free(&rqst); | ||
2497 | free_rsp_buf(resp_buftype, rsp); | 2517 | free_rsp_buf(resp_buftype, rsp); |
2498 | return rc; | 2518 | return rc; |
2499 | } | 2519 | } |
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index 19aa483395c7..fdd8c78648c6 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h | |||
@@ -141,6 +141,9 @@ extern int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, | |||
141 | u64 persistent_file_id, u64 volatile_file_id); | 141 | u64 persistent_file_id, u64 volatile_file_id); |
142 | extern int SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, | 142 | extern int SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, |
143 | u64 persistent_fid, u64 volatile_fid, int flags); | 143 | u64 persistent_fid, u64 volatile_fid, int flags); |
144 | extern int SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, | ||
145 | u64 persistent_file_id, u64 volatile_file_id); | ||
146 | extern void SMB2_close_free(struct smb_rqst *rqst); | ||
144 | extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, | 147 | extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, |
145 | u64 persistent_file_id, u64 volatile_file_id); | 148 | u64 persistent_file_id, u64 volatile_file_id); |
146 | extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon, | 149 | extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon, |