cifs: prepare SMB2_Flush to be usable in compounds
Subsystems (2)
PATCH 1/1 cifs: prepare SMB2_Flush to be usable in compounds
Create smb2_flush_init() and smb2_flush_free() so we can use the flush command in compounds.
--- fs/cifs/smb2pdu.c | 58 ++++++++++++++++++++++++++++++++++++----------------- fs/cifs/smb2proto.h | 4 ++++ 2 files changed, 44 insertions(+), 18 deletions(-)
fs/cifs/smb2pdu.c +40 -18
@@ -3262,44 +3262,64 @@ SMB2_echo(struct TCP_Server_Info *server)return rc; } +void +SMB2_flush_free (struct smb_rqst *rqst) +{ +if (rqst && rqst->rq_iov) +cifs_small_buf_release (rqst->rq_iov[0 ].iov_base);/* request */ +} +int -SMB2_flush (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid, -u64 volatile_fid) +SMB2_flush_init (const unsigned int xid,struct smb_rqst *rqst, +struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid) { -struct smb_rqst rqst;struct smb2_flush_req *req; -struct cifs_ses *ses = tcon->ses; -struct kvec iov[1 ]; -struct kvec rsp_iov; -int resp_buftype; -int rc =0 ; -int flags =0 ; +struct kvec *iov = rqst->rq_iov;unsigned int total_len; - -cifs_dbg (FYI ,"Flush\n" ); - -if (!ses || !(ses->server)) -return -EIO ; +int rc; rc =smb2_plain_req_init (SMB2_FLUSH , tcon, (void **) &req, &total_len);if (rc)return rc; -if (smb3_encryption_required (tcon)) - flags |=CIFS_TRANSFORM_REQ ; - req->PersistentFileId = persistent_fid; req->VolatileFileId = volatile_fid; iov[0 ].iov_base = (char *)req; iov[0 ].iov_len = total_len; +return 0 ; +} + +int +SMB2_flush (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid, +u64 volatile_fid) +{ +struct cifs_ses *ses = tcon->ses; +struct smb_rqst rqst; +struct kvec iov[1 ]; +struct kvec rsp_iov = {NULL ,0 }; +int resp_buftype =CIFS_NO_BUFFER ; +int flags =0 ; +int rc =0 ; + +cifs_dbg (FYI ,"flush\n" ); +if (!ses || !(ses->server)) +return -EIO ; + +if (smb3_encryption_required (tcon)) + flags |=CIFS_TRANSFORM_REQ ; +memset (&rqst,0 ,sizeof (struct smb_rqst )); +memset (&iov,0 ,sizeof (iov)); rqst.rq_iov = iov; rqst.rq_nvec =1 ; + rc =SMB2_flush_init (xid, &rqst, tcon, persistent_fid, volatile_fid); +if (rc) + goto flush_exit; + rc =cifs_send_recv (xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); -cifs_small_buf_release (req);if (rc !=0 ) {cifs_stats_fail_inc (tcon,SMB2_FLUSH_HE );
@@ -3307,6 +3327,8 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, rc); } + flush_exit: +SMB2_flush_free (&rqst);free_rsp_buf (resp_buftype, rsp_iov.iov_base);return rc; }
fs/cifs/smb2proto.h +4 -0
@@ -158,6 +158,10 @@ extern int SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,extern void SMB2_close_free (struct smb_rqst *rqst);extern int SMB2_flush (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_file_id,u64 volatile_file_id); +extern int SMB2_flush_init (const unsigned int xid,struct smb_rqst *rqst, +struct cifs_tcon *tcon, +u64 persistent_file_id,u64 volatile_file_id); +extern void SMB2_flush_free (struct smb_rqst *rqst);extern int SMB2_query_info (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_file_id,u64 volatile_file_id,struct smb2_file_all_info *data);
Signature · 1 line
2.13.6
пн, 15 июл. 2019 г. в 22:07, Ronnie Sahlberg <[email protected]>:
Quoted 98 lines
Create
smb2_flush_init()andsmb2_flush_free()so we can use the flush command in compounds.Signed-off-by Ronnie Sahlberg <[email protected]>--- fs/cifs/smb2pdu.c | 58 ++++++++++++++++++++++++++++++++++++----------------- fs/cifs/smb2proto.h | 4 ++++ 2 files changed, 44 insertions(+), 18 deletions(-)fs/cifs/smb2pdu.c +38
-18@@ -3262,44 +3262,64 @@ SMB2_echo(struct TCP_Server_Info *server)return rc; } +void +SMB2_flush_free (struct smb_rqst *rqst) +{ +if (rqst && rqst->rq_iov) +cifs_small_buf_release (rqst->rq_iov[0 ].iov_base);/* request */ +} +int -SMB2_flush (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid, -u64 volatile_fid) +SMB2_flush_init (const unsigned int xid,struct smb_rqst *rqst, +struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid) { -struct smb_rqst rqst;struct smb2_flush_req *req; -struct cifs_ses *ses = tcon->ses; -struct kvec iov[1 ]; -struct kvec rsp_iov; -int resp_buftype; -int rc =0 ; -int flags =0 ; +struct kvec *iov = rqst->rq_iov;unsigned int total_len; - -cifs_dbg (FYI ,"Flush\n" ); - -if (!ses || !(ses->server)) -return -EIO ; +int rc; rc =smb2_plain_req_init (SMB2_FLUSH , tcon, (void **) &req, &total_len);if (rc)return rc; -if (smb3_encryption_required (tcon)) - flags |=CIFS_TRANSFORM_REQ ; - req->PersistentFileId = persistent_fid; req->VolatileFileId = volatile_fid; iov[0 ].iov_base = (char *)req; iov[0 ].iov_len = total_len; +return 0 ; +} + +int +SMB2_flush (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid, +u64 volatile_fid) +{ +struct cifs_ses *ses = tcon->ses; +struct smb_rqst rqst; +struct kvec iov[1 ]; +struct kvec rsp_iov = {NULL ,0 }; +int resp_buftype =CIFS_NO_BUFFER ; +int flags =0 ; +int rc =0 ; + +cifs_dbg (FYI ,"flush\n" ); +if (!ses || !(ses->server)) +return -EIO ; + +if (smb3_encryption_required (tcon)) + flags |=CIFS_TRANSFORM_REQ ; +memset (&rqst,0 ,sizeof (struct smb_rqst )); +memset (&iov,0 ,sizeof (iov)); rqst.rq_iov = iov; rqst.rq_nvec =1 ; + rc =SMB2_flush_init (xid, &rqst, tcon, persistent_fid, volatile_fid); +if (rc) + goto flush_exit; + rc =cifs_send_recv (xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); -cifs_small_buf_release (req);if (rc !=0 ) {cifs_stats_fail_inc (tcon,SMB2_FLUSH_HE );
fs/cifs/smb2pdu.c SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, · line 3330
Quoted 4 lines
fs/cifs/smb2pdu.c +1
-0@@ -3307,6 +3327,8 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, rc); } + flush_exit:
The extra space before the label is not needed.
Quoted 20 lines
fs/cifs/smb2pdu.c +1
-0+SMB2_flush_free (&rqst);free_rsp_buf (resp_buftype, rsp_iov.iov_base);return rc; }fs/cifs/smb2proto.h +4
-1@@ -158,6 +158,10 @@ extern int SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,extern void SMB2_close_free (struct smb_rqst *rqst);extern int SMB2_flush (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_file_id,u64 volatile_file_id); +extern int SMB2_flush_init (const unsigned int xid,struct smb_rqst *rqst, +struct cifs_tcon *tcon, +u64 persistent_file_id,u64 volatile_file_id); +extern void SMB2_flush_free (struct smb_rqst *rqst);extern int SMB2_query_info (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_file_id,u64 volatile_file_id,struct smb2_file_all_info *data); --
Quoted 2 lines
2.13.6
Just wondering how are you going to use this? Compound flush and setattr to be sent together?
--
Best regards,
Pavel Shilovsky
ronnie sahlberg
reviewerQuoted 124 lines · Pavel Shilovsky
пн, 15 июл. 2019 г. в 22:07, Ronnie Sahlberg <[email protected]>:
Quoted 98 lines
Create
smb2_flush_init()andsmb2_flush_free()so we can use the flush command in compounds.Signed-off-by Ronnie Sahlberg <[email protected]>--- fs/cifs/smb2pdu.c | 58 ++++++++++++++++++++++++++++++++++++----------------- fs/cifs/smb2proto.h | 4 ++++ 2 files changed, 44 insertions(+), 18 deletions(-)fs/cifs/smb2pdu.c +38
-18@@ -3262,44 +3262,64 @@ SMB2_echo(struct TCP_Server_Info *server)return rc; } +void +SMB2_flush_free (struct smb_rqst *rqst) +{ +if (rqst && rqst->rq_iov) +cifs_small_buf_release (rqst->rq_iov[0 ].iov_base);/* request */ +} +int -SMB2_flush (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid, -u64 volatile_fid) +SMB2_flush_init (const unsigned int xid,struct smb_rqst *rqst, +struct cifs_tcon *tcon,u64 persistent_fid,u64 volatile_fid) { -struct smb_rqst rqst;struct smb2_flush_req *req; -struct cifs_ses *ses = tcon->ses; -struct kvec iov[1 ]; -struct kvec rsp_iov; -int resp_buftype; -int rc =0 ; -int flags =0 ; +struct kvec *iov = rqst->rq_iov;unsigned int total_len; - -cifs_dbg (FYI ,"Flush\n" ); - -if (!ses || !(ses->server)) -return -EIO ; +int rc; rc =smb2_plain_req_init (SMB2_FLUSH , tcon, (void **) &req, &total_len);if (rc)return rc; -if (smb3_encryption_required (tcon)) - flags |=CIFS_TRANSFORM_REQ ; - req->PersistentFileId = persistent_fid; req->VolatileFileId = volatile_fid; iov[0 ].iov_base = (char *)req; iov[0 ].iov_len = total_len; +return 0 ; +} + +int +SMB2_flush (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_fid, +u64 volatile_fid) +{ +struct cifs_ses *ses = tcon->ses; +struct smb_rqst rqst; +struct kvec iov[1 ]; +struct kvec rsp_iov = {NULL ,0 }; +int resp_buftype =CIFS_NO_BUFFER ; +int flags =0 ; +int rc =0 ; + +cifs_dbg (FYI ,"flush\n" ); +if (!ses || !(ses->server)) +return -EIO ; + +if (smb3_encryption_required (tcon)) + flags |=CIFS_TRANSFORM_REQ ; +memset (&rqst,0 ,sizeof (struct smb_rqst )); +memset (&iov,0 ,sizeof (iov)); rqst.rq_iov = iov; rqst.rq_nvec =1 ; + rc =SMB2_flush_init (xid, &rqst, tcon, persistent_fid, volatile_fid); +if (rc) + goto flush_exit; + rc =cifs_send_recv (xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); -cifs_small_buf_release (req);if (rc !=0 ) {cifs_stats_fail_inc (tcon,SMB2_FLUSH_HE );fs/cifs/smb2pdu.c SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, · line 3330
Quoted 4 lines
fs/cifs/smb2pdu.c +1
-0@@ -3307,6 +3327,8 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, rc); } + flush_exit:The extra space before the label is not needed.
Quoted 17 lines
fs/cifs/smb2pdu.c +1
-0+SMB2_flush_free (&rqst);free_rsp_buf (resp_buftype, rsp_iov.iov_base);return rc; }fs/cifs/smb2proto.h +4
-0@@ -158,6 +158,10 @@ extern int SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,extern void SMB2_close_free (struct smb_rqst *rqst);extern int SMB2_flush (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_file_id,u64 volatile_file_id); +extern int SMB2_flush_init (const unsigned int xid,struct smb_rqst *rqst, +struct cifs_tcon *tcon, +u64 persistent_file_id,u64 volatile_file_id); +extern void SMB2_flush_free (struct smb_rqst *rqst); extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
Quoted 8 lines
Quoted 5 lines
fs/cifs/smb2proto.h +0
-1u64 persistent_file_id, u64 volatile_file_id, struct smb2_file_all_info *data); --2.13.6
Just wondering how are you going to use this? Compound flush and setattr to be sent together?
Yeah, I was thinking about expeprimenting in that direction.
Quoted 4 lines
--
Best regards,
Pavel Shilovsky