Skip to content

Commit 8eb4ecf

Browse files
Ronnie SahlbergSteve French
authored andcommitted
cifs: add SMB2_close_init()/SMB2_close_free()
Signed-off-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]> Reviewed-by: Paulo Alcantara <[email protected]>
1 parent 468d677 commit 8eb4ecf

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

fs/cifs/smb2pdu.c

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,44 +2444,63 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
24442444
return rc;
24452445
}
24462446

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+
24472474
int
24482475
SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon,
24492476
u64 persistent_fid, u64 volatile_fid, int flags)
24502477
{
24512478
struct smb_rqst rqst;
2452-
struct smb2_close_req *req;
2453-
struct smb2_close_rsp *rsp;
2479+
struct smb2_close_rsp *rsp = NULL;
24542480
struct cifs_ses *ses = tcon->ses;
24552481
struct kvec iov[1];
24562482
struct kvec rsp_iov;
24572483
int resp_buftype;
24582484
int rc = 0;
2459-
unsigned int total_len;
24602485

24612486
cifs_dbg(FYI, "Close\n");
24622487

24632488
if (!ses || !(ses->server))
24642489
return -EIO;
24652490

2466-
rc = smb2_plain_req_init(SMB2_CLOSE, tcon, (void **) &req, &total_len);
2467-
if (rc)
2468-
return rc;
2469-
24702491
if (smb3_encryption_required(tcon))
24712492
flags |= CIFS_TRANSFORM_REQ;
24722493

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-
24792494
memset(&rqst, 0, sizeof(struct smb_rqst));
2495+
memset(&iov, 0, sizeof(iov));
24802496
rqst.rq_iov = iov;
24812497
rqst.rq_nvec = 1;
24822498

2499+
rc = SMB2_close_init(tcon, &rqst, persistent_fid, volatile_fid);
2500+
if (rc)
2501+
goto close_exit;
2502+
24832503
rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
2484-
cifs_small_buf_release(req);
24852504
rsp = (struct smb2_close_rsp *)rsp_iov.iov_base;
24862505

24872506
if (rc != 0) {
@@ -2494,6 +2513,7 @@ SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon,
24942513
/* BB FIXME - decode close response, update inode for caching */
24952514

24962515
close_exit:
2516+
SMB2_close_free(&rqst);
24972517
free_rsp_buf(resp_buftype, rsp);
24982518
return rc;
24992519
}

fs/cifs/smb2proto.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ extern int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
141141
u64 persistent_file_id, u64 volatile_file_id);
142142
extern int SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon,
143143
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);
144147
extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
145148
u64 persistent_file_id, u64 volatile_file_id);
146149
extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,

0 commit comments

Comments
 (0)