Some cleanups for fs/cifs
Subsystems (2)
PATCH 1/10 cifs: Simplify some callers of compound_send_recv()
In reply to Volker LendeckeThis is the first thing compound_send_recv() does.
--- fs/cifs/cached_dir.c | 1 - fs/cifs/smb2inode.c | 2 -- fs/cifs/smb2ops.c | 7 ------- 3 files changed, 10 deletions(-)
fs/cifs/cached_dir.c +0 -1
@@ -174,7 +174,6 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, server->ops->new_lease_key (pfid);memset (rqst,0 ,sizeof (rqst)); - resp_buftype[0 ] = resp_buftype[1 ] =CIFS_NO_BUFFER ;memset (rsp_iov,0 ,sizeof (rsp_iov));/* Open */
fs/cifs/smb2inode.c +0 -2
@@ -92,8 +92,6 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,if (smb3_encryption_required (tcon)) flags |=CIFS_TRANSFORM_REQ ; - resp_buftype[0 ] = resp_buftype[1 ] = resp_buftype[2 ] =CIFS_NO_BUFFER ; -/* We already have a handle so we can skip the open */ if (cfile) goto after_open;
fs/cifs/smb2ops.c +0 -7
@@ -1053,7 +1053,6 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,return -ENOMEM ;memset (rqst,0 ,sizeof (rqst)); - resp_buftype[0 ] = resp_buftype[1 ] = resp_buftype[2 ] =CIFS_NO_BUFFER ;memset (rsp_iov,0 ,sizeof (rsp_iov));if (ses->server->ops->query_all_EAs) {
@@ -1428,8 +1427,6 @@ smb2_ioctl_query_info(const unsigned int xid, rqst = &vars->rqst[0 ]; rsp_iov = &vars->rsp_iov[0 ]; - resp_buftype[0 ] = resp_buftype[1 ] = resp_buftype[2 ] =CIFS_NO_BUFFER ; -if (copy_from_user (&qi, arg,sizeof (struct smb_query_info ))) { rc = -EFAULT ; goto free_vars;
@@ -2158,7 +2155,6 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, flags |=CIFS_TRANSFORM_REQ ;memset (rqst,0 ,sizeof (rqst)); - resp_buftype[0 ] = resp_buftype[1 ] =CIFS_NO_BUFFER ;memset (rsp_iov,0 ,sizeof (rsp_iov));/* Open */
@@ -2484,7 +2480,6 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, flags |=CIFS_TRANSFORM_REQ ;memset (rqst,0 ,sizeof (rqst)); - resp_buftype[0 ] = resp_buftype[1 ] = resp_buftype[2 ] =CIFS_NO_BUFFER ;memset (rsp_iov,0 ,sizeof (rsp_iov));/*
@@ -2914,7 +2909,6 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, flags |=CIFS_TRANSFORM_REQ ;memset (rqst,0 ,sizeof (rqst)); - resp_buftype[0 ] = resp_buftype[1 ] = resp_buftype[2 ] =CIFS_NO_BUFFER ;memset (rsp_iov,0 ,sizeof (rsp_iov)); utf16_path =cifs_convert_path_to_utf16 (full_path, cifs_sb);
@@ -3051,7 +3045,6 @@ smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon, flags |=CIFS_TRANSFORM_REQ ;memset (rqst,0 ,sizeof (rqst)); - resp_buftype[0 ] = resp_buftype[1 ] = resp_buftype[2 ] =CIFS_NO_BUFFER ;memset (rsp_iov,0 ,sizeof (rsp_iov)); utf16_path =cifs_convert_path_to_utf16 (full_path, cifs_sb);
Signature · 1 line
2.30.2
PATCH 2/10 cifs: Make "resp_buf_type" initialization consistent
In reply to Volker LendeckeThe majority of cifs_send_recv() do not initialize resp_buf_type, make this consistent in all callers. Probably does not make a difference in performance, but the consistency improves readability.
--- fs/cifs/cifssmb.c | 6 +++--- fs/cifs/smb2pdu.c | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-)
fs/cifs/cifssmb.c +3 -3
@@ -1378,7 +1378,7 @@ CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,READ_RSP *pSMBr =NULL ;char *pReadData =NULL ;int wct; -int resp_buf_type =0 ; +int resp_buf_type;struct kvec iov[1 ];struct kvec rsp_iov;__u32 pid = io_parms->pid;
@@ -1742,7 +1742,7 @@ CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,WRITE_REQ *pSMB =NULL ;int wct;int smb_hdr_len; -int resp_buf_type =0 ; +int resp_buf_type;__u32 pid = io_parms->pid;__u16 netfid = io_parms->netfid;__u64 offset = io_parms->offset;
@@ -1966,7 +1966,7 @@ CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,int rc =0 ;int timeout =0 ;int bytes_returned =0 ; -int resp_buf_type =0 ; +int resp_buf_type;__u16 params, param_offset, offset, byte_count, count;struct kvec iov[1 ];struct kvec rsp_iov;
fs/cifs/smb2pdu.c +7 -7
@@ -2952,7 +2952,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,struct TCP_Server_Info *server =cifs_pick_channel (ses);struct kvec iov[SMB2_CREATE_IOV_SIZE ];struct kvec rsp_iov = {NULL ,0 }; -int resp_buftype =CIFS_NO_BUFFER ; +int resp_buftype;int rc =0 ;int flags =0 ;
@@ -3149,7 +3149,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,struct TCP_Server_Info *server;struct kvec iov[SMB2_IOCTL_IOV_SIZE ];struct kvec rsp_iov = {NULL ,0 }; -int resp_buftype =CIFS_NO_BUFFER ; +int resp_buftype;int rc =0 ;int flags =0 ;
@@ -3330,7 +3330,7 @@ __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,struct TCP_Server_Info *server =cifs_pick_channel (ses);struct kvec iov[1 ];struct kvec rsp_iov; -int resp_buftype =CIFS_NO_BUFFER ; +int resp_buftype;int rc =0 ;int flags =0 ;bool query_attrs = false;
@@ -3514,7 +3514,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,struct kvec iov[1 ];struct kvec rsp_iov;int rc =0 ; -int resp_buftype =CIFS_NO_BUFFER ; +int resp_buftype;struct cifs_ses *ses = tcon->ses;struct TCP_Server_Info *server;int flags =0 ;
@@ -3693,7 +3693,7 @@ SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,struct smb2_change_notify_rsp *smb_rsp;struct kvec iov[1 ];struct kvec rsp_iov = {NULL ,0 }; -int resp_buftype =CIFS_NO_BUFFER ; +int resp_buftype;int flags =0 ;int rc =0 ;
@@ -3983,7 +3983,7 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,struct kvec iov[1 ];struct kvec rsp_iov = {NULL ,0 };struct TCP_Server_Info *server =cifs_pick_channel (ses); -int resp_buftype =CIFS_NO_BUFFER ; +int resp_buftype;int flags =0 ;int rc =0 ;
@@ -5016,7 +5016,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,struct smb_rqst rqst;struct kvec iov[SMB2_QUERY_DIRECTORY_IOV_SIZE ];struct smb2_query_directory_rsp *rsp =NULL ; -int resp_buftype =CIFS_NO_BUFFER ; +int resp_buftype;struct kvec rsp_iov;int rc =0 ;struct cifs_ses *ses = tcon->ses;
Signature · 1 line
2.30.2
cover Some cleanups for fs/cifs
These are some cleanups and simplifications to fs/cifs which helped me understand the code a bit better.
Volker Lendecke (10):
cifs: Simplify some callers of compound_send_recv()
cifs: Make "resp_buf_type" initialization consistent
cifs: Slightly simplify cifs_readdir()
cifs: Slightly simplify cifs_readdir()
cifs: Simplify SMB2_OP_RMDIR with CREATE_DELETE_ON_CLOSE
cifs: Slightly refactor smb2_compound_op()
cifs: Reduce copy&paste in smb2_compound_op()
cifs: Avoid two "else" branches
cifs: Store smb3_create_tag_posix just once
cifs: Use switch/case to dissect negprot reply ctxts
fs/cifs/cached_dir.c | 1 - fs/cifs/cifssmb.c | 6 +- fs/cifs/readdir.c | 6 +- fs/cifs/smb2inode.c | 163 +++++++++++++------------------------------ fs/cifs/smb2ops.c | 7 -- fs/cifs/smb2pdu.c | 92 ++++++++++-------------- 6 files changed, 91 insertions(+), 184 deletions(-)
Signature · 1 line
2.30.2
PATCH 3/10 cifs: Slightly simplify cifs_readdir()
"else" not needed, we do a "goto" in the if-branch. This makes the following condition a bit easier to read for me.
--- fs/cifs/readdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/readdir.c +2 -1
@@ -1165,7 +1165,8 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)if (rc) {cifs_dbg (FYI ,"fce error %d\n" , rc); goto rddir2_exit; - }else if (current_entry !=NULL ) { + } +if (current_entry !=NULL ) {cifs_dbg (FYI ,"entry %lld found\n" , ctx->pos); }else {if (cfid) {
Signature · 1 line
2.30.2
PATCH 5/10 cifs: Simplify SMB2_OP_RMDIR with CREATE_DELETE_ON_CLOSE
In reply to Volker LendeckeMatch SMB2_OP_DELETE, we don't need the intermediate SMB2_set_info(FILE_DISPOSITION_INFORMATION)
--- fs/cifs/smb2inode.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
fs/cifs/smb2inode.c +2 -17
@@ -76,7 +76,6 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,struct smb2_query_info_rsp *qi_rsp =NULL ;struct cifs_open_info_data *idata;int flags =0 ; -__u8 delete_pending[8 ] = {1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 };unsigned int size[2 ];void *data[2 ];int len;
@@ -208,21 +207,6 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,trace_smb3_mkdir_enter (xid, ses->Suid, tcon->tid, full_path);break ;case SMB2_OP_RMDIR : - rqst[num_rqst].rq_iov = &vars->si_iov[0 ]; - rqst[num_rqst].rq_nvec =1 ; - - size[0 ] =1 ;/* sizeof __u8 See MS-FSCC section 2.4.11 */ - data[0 ] = &delete_pending[0 ]; - - rc =SMB2_set_info_init (tcon, server, - &rqst[num_rqst],COMPOUND_FID , -COMPOUND_FID , current->tgid, -FILE_DISPOSITION_INFORMATION , -SMB2_O_INFO_FILE ,0 , data, size); -if (rc) - goto finished; -smb2_set_next_command (tcon, &rqst[num_rqst]); -smb2_set_related (&rqst[num_rqst++]);trace_smb3_rmdir_enter (xid, ses->Suid, tcon->tid, full_path);break ;case SMB2_OP_SET_EOF :
@@ -738,7 +722,8 @@ smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name, {drop_cached_dir_by_name (xid, tcon, name, cifs_sb);return smb2_compound_op (xid, tcon, cifs_sb, name,DELETE ,FILE_OPEN , -CREATE_NOT_FILE ,ACL_NO_MODE , +CREATE_NOT_FILE |CREATE_DELETE_ON_CLOSE , +ACL_NO_MODE ,NULL ,SMB2_OP_RMDIR ,NULL ,NULL ,NULL ,NULL ,NULL ); }
Signature · 1 line
2.30.2
PATCH 4/10 cifs: Slightly simplify cifs_readdir()
In reply to Volker LendeckeUse the fact that we use "goto" in the else-branch, this avoids an indentation level for the success case.
--- fs/cifs/readdir.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/cifs/readdir.c +2 -3
@@ -1166,9 +1166,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)cifs_dbg (FYI ,"fce error %d\n" , rc); goto rddir2_exit; } -if (current_entry !=NULL ) { -cifs_dbg (FYI ,"entry %lld found\n" , ctx->pos); - }else { +if (current_entry ==NULL ) {if (cfid) {mutex_lock (&cfid->dirents.de_mutex);finished_cached_dirents_count (&cfid->dirents, ctx);
@@ -1177,6 +1175,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)cifs_dbg (FYI ,"Could not find entry\n" ); goto rddir2_exit; } +cifs_dbg (FYI ,"entry %lld found\n" , ctx->pos);cifs_dbg (FYI ,"loop through %d times filling dir for net buf %p\n" , num_to_fill, cifsFile->srch_inf.ntwrk_buf_start); max_len = tcon->ses->server->ops->calc_smb_size(
Signature · 1 line
2.30.2
PATCH 6/10 cifs: Slightly refactor smb2_compound_op()
In reply to Volker LendeckeSimplify if-conditions a bit. The reason for this will become obvious in the next patch.
--- fs/cifs/smb2inode.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
fs/cifs/smb2inode.c +20 -20
@@ -150,14 +150,14 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,SMB2_O_INFO_FILE ,0 ,sizeof (struct smb2_file_all_info ) + PATH_MAX * 2, 0, NULL); -if (!rc) { -smb2_set_next_command (tcon, &rqst[num_rqst]); -smb2_set_related (&rqst[num_rqst]); - } }if (rc) goto finished; +if (!cfile) { +smb2_set_next_command (tcon, &rqst[num_rqst]); +smb2_set_related (&rqst[num_rqst]); + } num_rqst++;trace_smb3_query_info_compound_enter (xid, ses->Suid, tcon->tid, full_path);
@@ -185,14 +185,14 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,SMB2_O_INFO_FILE ,0 ,sizeof (struct smb311_posix_qinfo *) + (PATH_MAX *2 ) + (sizeof(struct cifs_sid) * 2), 0, NULL); -if (!rc) { -smb2_set_next_command (tcon, &rqst[num_rqst]); -smb2_set_related (&rqst[num_rqst]); - } }if (rc) goto finished; +if (!cfile) { +smb2_set_next_command (tcon, &rqst[num_rqst]); +smb2_set_related (&rqst[num_rqst]); + } num_rqst++;trace_smb3_posix_query_info_compound_enter (xid, ses->Suid, tcon->tid, full_path);break ;
@@ -234,13 +234,13 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,FILE_END_OF_FILE_INFORMATION ,SMB2_O_INFO_FILE ,0 , data, size); -if (!rc) { -smb2_set_next_command (tcon, &rqst[num_rqst]); -smb2_set_related (&rqst[num_rqst]); - } }if (rc) goto finished; +if (!cfile) { +smb2_set_next_command (tcon, &rqst[num_rqst]); +smb2_set_related (&rqst[num_rqst]); + } num_rqst++;trace_smb3_set_eof_enter (xid, ses->Suid, tcon->tid, full_path);break ;
@@ -266,14 +266,14 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,COMPOUND_FID , current->tgid,FILE_BASIC_INFORMATION , SMB2_O_INFO_FILE, 0, data, size); -if (!rc) { -smb2_set_next_command (tcon, &rqst[num_rqst]); -smb2_set_related (&rqst[num_rqst]); - } }if (rc) goto finished; +if (!cfile) { +smb2_set_next_command (tcon, &rqst[num_rqst]); +smb2_set_related (&rqst[num_rqst]); + } num_rqst++;trace_smb3_set_info_compound_enter (xid, ses->Suid, tcon->tid, full_path);
@@ -307,13 +307,13 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,COMPOUND_FID ,COMPOUND_FID , current->tgid,FILE_RENAME_INFORMATION , SMB2_O_INFO_FILE, 0, data, size); -if (!rc) { -smb2_set_next_command (tcon, &rqst[num_rqst]); -smb2_set_related (&rqst[num_rqst]); - } }if (rc) goto finished; +if (!cfile) { +smb2_set_next_command (tcon, &rqst[num_rqst]); +smb2_set_related (&rqst[num_rqst]); + } num_rqst++;trace_smb3_rename_enter (xid, ses->Suid, tcon->tid, full_path);break ;
Signature · 1 line
2.30.2
PATCH 8/10 cifs: Avoid two "else" branches
In reply to Volker LendeckeWe goto out of the if-branches, this makes the flow easier to read
--- fs/cifs/smb2pdu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/cifs/smb2pdu.c +6 -4
@@ -2997,11 +2997,13 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, tcon->need_reconnect = true; } goto creat_exit; - }else if (rsp ==NULL )/* unlikely to happen, but safer to check */ + } + +if (rsp ==NULL )/* unlikely to happen, but safer to check */ goto creat_exit; -else -trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, ses->Suid, - oparms->create_options, oparms->desired_access); + +trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, ses->Suid, + oparms->create_options, oparms->desired_access);atomic_inc (&tcon->num_remote_opens); oparms->fid->persistent_fid = rsp->PersistentFileId;
Signature · 1 line
2.30.2
PATCH 7/10 cifs: Reduce copy&paste in smb2_compound_op()
In reply to Volker LendeckeDon't duplicate calls to inner _init() calls when only the fid differs.
--- fs/cifs/smb2inode.c | 102 ++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 74 deletions(-)
fs/cifs/smb2inode.c +28 -74
@@ -38,6 +38,8 @@ free_set_inf_compound(struct smb_rqst *rqst)struct cop_vars {struct cifs_open_parms oparms; +__u64 persistent_fid; +__u64 volatile_fid;struct kvec rsp_iov[3 ];struct smb_rqst rqst[3 ];struct kvec open_iov[SMB2_CREATE_IOV_SIZE ];
@@ -92,8 +94,13 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, flags |=CIFS_TRANSFORM_REQ ;/* We already have a handle so we can skip the open */ -if (cfile) +if (cfile) { + vars->persistent_fid = cfile->fid.persistent_fid; + vars->volatile_fid = cfile->fid.volatile_fid; goto after_open; + }else { + vars->persistent_fid = vars->volatile_fid =COMPOUND_FID ; + }/* Open */ utf16_path =cifs_convert_path_to_utf16 (full_path, cifs_sb);
@@ -132,26 +139,14 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, rqst[num_rqst].rq_iov = &vars->qi_iov[0 ]; rqst[num_rqst].rq_nvec =1 ; -if (cfile) - rc =SMB2_query_info_init (tcon, server, - &rqst[num_rqst], - cfile->fid.persistent_fid, - cfile->fid.volatile_fid, -FILE_ALL_INFORMATION , -SMB2_O_INFO_FILE ,0 , -sizeof (struct smb2_file_all_info ) + -PATH_MAX *2 ,0 ,NULL ); -else { - rc =SMB2_query_info_init (tcon, server, + rc =SMB2_query_info_init (tcon, server, &rqst[num_rqst], -COMPOUND_FID , -COMPOUND_FID , + vars->persistent_fid, + vars->volatile_fid,FILE_ALL_INFORMATION ,SMB2_O_INFO_FILE ,0 ,sizeof (struct smb2_file_all_info ) +PATH_MAX *2 ,0 ,NULL ); - } -if (rc) goto finished;if (!cfile) {
@@ -166,27 +161,15 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, rqst[num_rqst].rq_iov = &vars->qi_iov[0 ]; rqst[num_rqst].rq_nvec =1 ; -if (cfile) - rc =SMB2_query_info_init (tcon, server, + rc =SMB2_query_info_init (tcon, server, &rqst[num_rqst], - cfile->fid.persistent_fid, - cfile->fid.volatile_fid, + vars->persistent_fid, + vars->volatile_fid,SMB_FIND_FILE_POSIX_INFO ,SMB2_O_INFO_FILE ,0 ,/* TBD: fix following to allow for longer SIDs */ sizeof (struct smb311_posix_qinfo *) + (PATH_MAX *2 ) + (sizeof (struct cifs_sid ) *2 ),0 ,NULL ); -else { - rc =SMB2_query_info_init (tcon, server, - &rqst[num_rqst], -COMPOUND_FID , -COMPOUND_FID , -SMB_FIND_FILE_POSIX_INFO , -SMB2_O_INFO_FILE ,0 , -sizeof (struct smb311_posix_qinfo *) + (PATH_MAX *2 ) + - (sizeof (struct cifs_sid ) *2 ),0 ,NULL ); - } -if (rc) goto finished;if (!cfile) {
@@ -216,25 +199,14 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, size[0 ] =8 ;/* sizeof __le64 */ data[0 ] = ptr; -if (cfile) { - rc =SMB2_set_info_init (tcon, server, - &rqst[num_rqst], - cfile->fid.persistent_fid, - cfile->fid.volatile_fid, - current->tgid, -FILE_END_OF_FILE_INFORMATION , -SMB2_O_INFO_FILE ,0 , - data, size); - }else { - rc =SMB2_set_info_init (tcon, server, - &rqst[num_rqst], -COMPOUND_FID , -COMPOUND_FID , - current->tgid, -FILE_END_OF_FILE_INFORMATION , -SMB2_O_INFO_FILE ,0 , - data, size); - } + rc =SMB2_set_info_init (tcon, server, + &rqst[num_rqst], + vars->persistent_fid, + vars->volatile_fid, + current->tgid, +FILE_END_OF_FILE_INFORMATION , +SMB2_O_INFO_FILE ,0 , + data, size);if (rc) goto finished;if (!cfile) {
@@ -252,22 +224,12 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, size[0 ] =sizeof (FILE_BASIC_INFO ); data[0 ] = ptr; -if (cfile) - rc =SMB2_set_info_init (tcon, server, - &rqst[num_rqst], - cfile->fid.persistent_fid, - cfile->fid.volatile_fid, current->tgid, -FILE_BASIC_INFORMATION , -SMB2_O_INFO_FILE ,0 , data, size); -else { - rc =SMB2_set_info_init (tcon, server, + rc =SMB2_set_info_init (tcon, server, &rqst[num_rqst], -COMPOUND_FID , -COMPOUND_FID , current->tgid, + vars->persistent_fid, + vars->volatile_fid, current->tgid,FILE_BASIC_INFORMATION ,SMB2_O_INFO_FILE ,0 , data, size); - } -if (rc) goto finished;if (!cfile) {
@@ -294,20 +256,12 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, size[1 ] = len +2 /* null */ ; data[1 ] = (__le16 *)ptr; -if (cfile) - rc =SMB2_set_info_init (tcon, server, - &rqst[num_rqst], - cfile->fid.persistent_fid, - cfile->fid.volatile_fid, - current->tgid,FILE_RENAME_INFORMATION , -SMB2_O_INFO_FILE ,0 , data, size); -else { - rc =SMB2_set_info_init (tcon, server, + rc =SMB2_set_info_init (tcon, server, &rqst[num_rqst], -COMPOUND_FID ,COMPOUND_FID , + vars->persistent_fid, + vars->volatile_fid, current->tgid,FILE_RENAME_INFORMATION ,SMB2_O_INFO_FILE ,0 , data, size); - }if (rc) goto finished;if (!cfile) {
Signature · 1 line
2.30.2
PATCH 9/10 cifs: Store smb3_create_tag_posix just once
In reply to Volker LendeckeSave 32 bytes in .text and a few lines
--- fs/cifs/smb2pdu.c | 49 +++++++++-------------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-)
fs/cifs/smb2pdu.c +9 -40
@@ -482,28 +482,19 @@ build_netname_ctxt(struct smb2_netname_neg_context *pneg_ctxt, char *hostname)return ALIGN (le16_to_cpu (pneg_ctxt->DataLength) +sizeof (struct smb2_neg_context ),8 ); } +static const char smb3_create_tag_posix[] = { +0x93 ,0xAD ,0x25 ,0x50 ,0x9C ,0xB4 ,0x11 ,0xE7 , +0xB4 ,0x23 ,0x83 ,0xDE ,0x96 ,0x8B ,0xCD ,0x7C +}; +static void build_posix_ctxt (struct smb2_posix_neg_context *pneg_ctxt) { pneg_ctxt->ContextType =SMB2_POSIX_EXTENSIONS_AVAILABLE ; pneg_ctxt->DataLength =cpu_to_le16 (POSIX_CTXT_DATA_LEN ); -/* SMB2_CREATE_TAG_POSIX is "0x93AD25509CB411E7B42383DE968BCD7C" */ - pneg_ctxt->Name[0 ] =0x93 ; - pneg_ctxt->Name[1 ] =0xAD ; - pneg_ctxt->Name[2 ] =0x25 ; - pneg_ctxt->Name[3 ] =0x50 ; - pneg_ctxt->Name[4 ] =0x9C ; - pneg_ctxt->Name[5 ] =0xB4 ; - pneg_ctxt->Name[6 ] =0x11 ; - pneg_ctxt->Name[7 ] =0xE7 ; - pneg_ctxt->Name[8 ] =0xB4 ; - pneg_ctxt->Name[9 ] =0x23 ; - pneg_ctxt->Name[10 ] =0x83 ; - pneg_ctxt->Name[11 ] =0xDE ; - pneg_ctxt->Name[12 ] =0x96 ; - pneg_ctxt->Name[13 ] =0x8B ; - pneg_ctxt->Name[14 ] =0xCD ; - pneg_ctxt->Name[15 ] =0x7C ; +memcpy (pneg_ctxt->Name, + smb3_create_tag_posix, +sizeof (pneg_ctxt->Name)); } static void
@@ -771,24 +762,7 @@ create_posix_buf(umode_t mode) buf->ccontext.NameOffset =cpu_to_le16 (offsetof(struct create_posix , Name)); buf->ccontext.NameLength =cpu_to_le16 (16 ); - -/* SMB2_CREATE_TAG_POSIX is "0x93AD25509CB411E7B42383DE968BCD7C" */ - buf->Name[0 ] =0x93 ; - buf->Name[1 ] =0xAD ; - buf->Name[2 ] =0x25 ; - buf->Name[3 ] =0x50 ; - buf->Name[4 ] =0x9C ; - buf->Name[5 ] =0xB4 ; - buf->Name[6 ] =0x11 ; - buf->Name[7 ] =0xE7 ; - buf->Name[8 ] =0xB4 ; - buf->Name[9 ] =0x23 ; - buf->Name[10 ] =0x83 ; - buf->Name[11 ] =0xDE ; - buf->Name[12 ] =0x96 ; - buf->Name[13 ] =0x8B ; - buf->Name[14 ] =0xCD ; - buf->Name[15 ] =0x7C ; +memcpy (buf->Name, smb3_create_tag_posix,sizeof (buf->Name)); buf->Mode =cpu_to_le32 (mode);cifs_dbg (FYI ,"mode on posix create 0%o\n" , mode);return buf;
@@ -2099,11 +2073,6 @@ smb2_parse_contexts(struct TCP_Server_Info *server,unsigned int next;unsigned int remaining;char *name; -static const char smb3_create_tag_posix[] = { -0x93 ,0xAD ,0x25 ,0x50 ,0x9C , -0xB4 ,0x11 ,0xE7 ,0xB4 ,0x23 ,0x83 , -0xDE ,0x96 ,0x8B ,0xCD ,0x7C - }; *oplock =0 ; data_offset = (char *)rsp +le32_to_cpu (rsp->CreateContextsOffset);
Signature · 1 line
2.30.2
PATCH 10/10 cifs: Use switch/case to dissect negprot reply ctxts
In reply to Volker LendeckeEasier to read than nested if/else statements
--- fs/cifs/smb2pdu.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
fs/cifs/smb2pdu.c +13 -6
@@ -718,23 +718,30 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp,if (clen > len_of_ctxts)break ; -if (pctx->ContextType ==SMB2_PREAUTH_INTEGRITY_CAPABILITIES ) +switch (pctx->ContextType) { +case SMB2_PREAUTH_INTEGRITY_CAPABILITIES :decode_preauth_context ( (struct smb2_preauth_neg_context *)pctx); -else if (pctx->ContextType ==SMB2_ENCRYPTION_CAPABILITIES ) +break ; +case SMB2_ENCRYPTION_CAPABILITIES : rc =decode_encrypt_ctx (server, (struct smb2_encryption_neg_context *)pctx); -else if (pctx->ContextType ==SMB2_COMPRESSION_CAPABILITIES ) +break ; +case SMB2_COMPRESSION_CAPABILITIES :decode_compress_ctx (server, (struct smb2_compression_capabilities_context *)pctx); -else if (pctx->ContextType ==SMB2_POSIX_EXTENSIONS_AVAILABLE ) +break ; +case SMB2_POSIX_EXTENSIONS_AVAILABLE : server->posix_ext_supported = true; -else if (pctx->ContextType ==SMB2_SIGNING_CAPABILITIES ) +break ; +case SMB2_SIGNING_CAPABILITIES :decode_signing_ctx (server, (struct smb2_signing_capabilities *)pctx); -else +break ; +default :cifs_server_dbg (VFS ,"unknown negcontext of type %d ignored\n" ,le16_to_cpu (pctx->ContextType)); + }if (rc)break ;
Signature · 1 line
2.30.2
I like all these changes but I think #5 should be split out into a standalone patch. It changes the rmdir wire semantics so it's not just a cleanup.
Quoted 23 lines · Volker Lendecke
These are some cleanups and simplifications to fs/cifs which helped me understand the code a bit better.
Volker Lendecke (10):
cifs: Simplify some callers ofcompound_send_recv()
cifs: Make "resp_buf_type" initialization consistent
cifs: Slightly simplifycifs_readdir()
cifs: Slightly simplifycifs_readdir()
cifs: SimplifySMB2_OP_RMDIRwithCREATE_DELETE_ON_CLOSE
cifs: Slightly refactorsmb2_compound_op()
cifs: Reduce copy&paste insmb2_compound_op()
cifs: Avoid two "else" branches
cifs: Storesmb3_create_tag_posixjust once
cifs: Use switch/case to dissect negprot reply ctxtsfs/cifs/cached_dir.c | 1 - fs/cifs/cifssmb.c | 6 +- fs/cifs/readdir.c | 6 +- fs/cifs/smb2inode.c | 163 +++++++++++++------------------------------ fs/cifs/smb2ops.c | 7 -- fs/cifs/smb2pdu.c | 92 ++++++++++-------------- 6 files changed, 91 insertions(+), 184 deletions(-)
kernel test robot
build botRe: [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent
In reply to Volker LendeckeThank you for the patch! Perhaps something to improve:
Hi Volker,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on cifs/for-next]
[also build test WARNING on linus/master v6.3-rc2 next-20230315] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Volker-Lendecke/cifs-Simplify-some-callers-of-compound_send_recv/20230315-212751 base: git://git.samba.org/sfrench/cifs-2.6.git for-next patch link: https://lore.kernel.org/r/715459412f19853c56156b8c0ce39fe74f148860.1678885349.git.vl%40samba.org patch subject: [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent config: i386-randconfig-a013-20230313 (https://download.01.org/0day-ci/archive/20230316/[email protected]/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/1bf099b09d9dddfff9f129b27e1a6b1df42f9ec2
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Volker-Lendecke/cifs-Simplify-some-callers-of-compound_send_recv/20230315-212751 git checkout 1bf099b09d9dddfff9f129b27e1a6b1df42f9ec2
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash fs/cifs/ fs/xfs/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> fs/cifs/smb2pdu.c:2973:6: warning: variable 'resp_buftype' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (rc)
^~
fs/cifs/smb2pdu.c:3031:15: note: uninitialized use occurs here
free_rsp_buf(resp_buftype, rsp);
^~~~~~~~~~~~
fs/cifs/smb2pdu.c:2973:2: note: remove the 'if' if its condition is always false
if (rc)
^~~~~~~
fs/cifs/smb2pdu.c:2955:18: note: initialize the variable 'resp_buftype' to silence this warning
int resp_buftype;
^
= 0
fs/cifs/smb2pdu.c:3187:6: warning: variable 'resp_buftype' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (rc)
^~
fs/cifs/smb2pdu.c:3258:15: note: uninitialized use occurs here
free_rsp_buf(resp_buftype, rsp);
^~~~~~~~~~~~
fs/cifs/smb2pdu.c:3187:2: note: remove the 'if' if its condition is always false
if (rc)
^~~~~~~
fs/cifs/smb2pdu.c:3152:18: note: initialize the variable 'resp_buftype' to silence this warning
int resp_buftype;
^
= 0
fs/cifs/smb2pdu.c:3359:6: warning: variable 'resp_buftype' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (rc)
^~
fs/cifs/smb2pdu.c:3385:15: note: uninitialized use occurs here
free_rsp_buf(resp_buftype, rsp);
^~~~~~~~~~~~
fs/cifs/smb2pdu.c:3359:2: note: remove the 'if' if its condition is always false
if (rc)
^~~~~~~
fs/cifs/smb2pdu.c:3333:18: note: initialize the variable 'resp_buftype' to silence this warning
int resp_buftype;
^
= 0
fs/cifs/smb2pdu.c:3543:6: warning: variable 'resp_buftype' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (rc)
^~
fs/cifs/smb2pdu.c:3590:15: note: uninitialized use occurs here
free_rsp_buf(resp_buftype, rsp);
^~~~~~~~~~~~
fs/cifs/smb2pdu.c:3543:2: note: remove the 'if' if its condition is always false
if (rc)
^~~~~~~
fs/cifs/smb2pdu.c:3517:18: note: initialize the variable 'resp_buftype' to silence this warning
int resp_buftype;
^
= 0
fs/cifs/smb2pdu.c:3718:6: warning: variable 'resp_buftype' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (rc)
^~
fs/cifs/smb2pdu.c:3756:15: note: uninitialized use occurs here
free_rsp_buf(resp_buftype, rsp_iov.iov_base);
^~~~~~~~~~~~
fs/cifs/smb2pdu.c:3718:2: note: remove the 'if' if its condition is always false
if (rc)
^~~~~~~
fs/cifs/smb2pdu.c:3696:18: note: initialize the variable 'resp_buftype' to silence this warning
int resp_buftype;
^
= 0
fs/cifs/smb2pdu.c:4004:6: warning: variable 'resp_buftype' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (rc)
^~
fs/cifs/smb2pdu.c:4021:15: note: uninitialized use occurs here
free_rsp_buf(resp_buftype, rsp_iov.iov_base);
^~~~~~~~~~~~
fs/cifs/smb2pdu.c:4004:2: note: remove the 'if' if its condition is always false
if (rc)
^~~~~~~
fs/cifs/smb2pdu.c:3986:18: note: initialize the variable 'resp_buftype' to silence this warning
int resp_buftype;
^
= 0
fs/cifs/smb2pdu.c:5041:6: warning: variable 'resp_buftype' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (rc)
^~
fs/cifs/smb2pdu.c:5077:15: note: uninitialized use occurs here
free_rsp_buf(resp_buftype, rsp);
^~~~~~~~~~~~
fs/cifs/smb2pdu.c:5041:2: note: remove the 'if' if its condition is always false
if (rc)
^~~~~~~
fs/cifs/smb2pdu.c:5019:18: note: initialize the variable 'resp_buftype' to silence this warning
int resp_buftype;
^
= 0
7 warnings generated.
--
>> fs/cifs/cifssmb.c:2028:6: warning: variable 'resp_buf_type' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (waitFlag) {
^~~~~~~~
fs/cifs/cifssmb.c:2079:15: note: uninitialized use occurs here
free_rsp_buf(resp_buf_type, rsp_iov.iov_base);
^~~~~~~~~~~~~
fs/cifs/cifssmb.c:2028:2: note: remove the 'if' if its condition is always false
if (waitFlag) {
^~~~~~~~~~~~~~~
fs/cifs/cifssmb.c:1969:19: note: initialize the variable 'resp_buf_type' to silence this warning
int resp_buf_type;
^
= 01 warning generated.
vim +2973 fs/cifs/smb2pdu.c
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2941
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2942 int
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2943 SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2944 __u8 *oplock, struct smb2_file_all_info *buf,
69dda3059e7a4d Aurelien Aptel 2020-03-02 2945 struct create_posix_rsp *posix,
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2946 struct kvec *err_iov, int *buftype)
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2947 {
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2948 struct smb_rqst rqst;
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2949 struct smb2_create_rsp *rsp = NULL;
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2950 struct cifs_tcon *tcon = oparms->tcon;
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2951 struct cifs_ses *ses = tcon->ses;
352d96f3acc6e0 Aurelien Aptel 2020-05-31 2952 struct TCP_Server_Info *server = cifs_pick_channel(ses);
4d8dfafc5cb88f Ronnie Sahlberg 2018-08-21 2953 struct kvec iov[SMB2_CREATE_IOV_SIZE];
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2954 struct kvec rsp_iov = {NULL, 0};
1bf099b09d9ddd Volker Lendecke 2023-03-15 2955 int resp_buftype;
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2956 int rc = 0;
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2957 int flags = 0;
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2958
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2959 cifs_dbg(FYI, "create/open\n");
352d96f3acc6e0 Aurelien Aptel 2020-05-31 2960 if (!ses || !server)
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2961 return -EIO;
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2962
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2963 if (smb3_encryption_required(tcon))
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2964 flags |= CIFS_TRANSFORM_REQ;
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2965
40eff45b5dc7df Ronnie Sahlberg 2018-06-12 2966 memset(&rqst, 0, sizeof(struct smb_rqst));
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2967 memset(&iov, 0, sizeof(iov));
40eff45b5dc7df Ronnie Sahlberg 2018-06-12 2968 rqst.rq_iov = iov;
4d8dfafc5cb88f Ronnie Sahlberg 2018-08-21 2969 rqst.rq_nvec = SMB2_CREATE_IOV_SIZE;
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2970
352d96f3acc6e0 Aurelien Aptel 2020-05-31 2971 rc = SMB2_open_init(tcon, server,
352d96f3acc6e0 Aurelien Aptel 2020-05-31 2972 &rqst, oplock, oparms, path);
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 @2973 if (rc)
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 2974 goto creat_exit;
40eff45b5dc7df Ronnie Sahlberg 2018-06-12 2975
efe2e9f369c72b Steve French 2019-02-26 2976 trace_smb3_open_enter(xid, tcon->tid, tcon->ses->Suid,
efe2e9f369c72b Steve French 2019-02-26 2977 oparms->create_options, oparms->desired_access);
efe2e9f369c72b Steve French 2019-02-26 2978
352d96f3acc6e0 Aurelien Aptel 2020-05-31 2979 rc = cifs_send_recv(xid, ses, server,
352d96f3acc6e0 Aurelien Aptel 2020-05-31 2980 &rqst, &resp_buftype, flags,
4f33bc35875ae6 Ronnie Sahlberg 2017-11-20 2981 &rsp_iov);
da502f7df03d2d Pavel Shilovsky 2016-10-25 2982 rsp = (struct smb2_create_rsp *)rsp_iov.iov_base;
2503a0dba98948 Pavel Shilovsky 2011-12-26 2983
2503a0dba98948 Pavel Shilovsky 2011-12-26 2984 if (rc != 0) {
2503a0dba98948 Pavel Shilovsky 2011-12-26 2985 cifs_stats_fail_inc(tcon, SMB2_CREATE_HE);
91cb74f5142c14 Ronnie Sahlberg 2018-04-13 2986 if (err_iov && rsp) {
91cb74f5142c14 Ronnie Sahlberg 2018-04-13 2987 *err_iov = rsp_iov;
9d874c36552afb Ronnie Sahlberg 2018-06-08 2988 *buftype = resp_buftype;
91cb74f5142c14 Ronnie Sahlberg 2018-04-13 2989 resp_buftype = CIFS_NO_BUFFER;
91cb74f5142c14 Ronnie Sahlberg 2018-04-13 2990 rsp = NULL;
91cb74f5142c14 Ronnie Sahlberg 2018-04-13 2991 }
28d59363ae746d Steve French 2018-05-30 2992 trace_smb3_open_err(xid, tcon->tid, ses->Suid,
28d59363ae746d Steve French 2018-05-30 2993 oparms->create_options, oparms->desired_access, rc);
7dcc82c2dfd5f1 Steve French 2019-09-11 2994 if (rc == -EREMCHG) {
a0a3036b81f1f6 Joe Perches 2020-04-14 2995 pr_warn_once("server share %s deleted\n",
68e14569d7e5a1 Steve French 2022-09-21 2996 tcon->tree_name);
7dcc82c2dfd5f1 Steve French 2019-09-11 2997 tcon->need_reconnect = true;
7dcc82c2dfd5f1 Steve French 2019-09-11 2998 }
2503a0dba98948 Pavel Shilovsky 2011-12-26 2999 goto creat_exit;
6b7895182ce398 Steve French 2021-11-11 3000 } else if (rsp == NULL) /* unlikely to happen, but safer to check */
6b7895182ce398 Steve French 2021-11-11 3001 goto creat_exit;
6b7895182ce398 Steve French 2021-11-11 3002 else
351a59dace0e0e Paulo Alcantara 2022-03-21 3003 trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid, ses->Suid,
351a59dace0e0e Paulo Alcantara 2022-03-21 3004 oparms->create_options, oparms->desired_access);
2503a0dba98948 Pavel Shilovsky 2011-12-26 3005
fae8044c03c3c0 Steve French 2018-10-19 3006 atomic_inc(&tcon->num_remote_opens);
351a59dace0e0e Paulo Alcantara 2022-03-21 3007 oparms->fid->persistent_fid = rsp->PersistentFileId;
351a59dace0e0e Paulo Alcantara 2022-03-21 3008 oparms->fid->volatile_fid = rsp->VolatileFileId;
86f740f2aed5ea Aurelien Aptel 2020-02-21 3009 oparms->fid->access = oparms->desired_access;
dfe33f9abc0899 Steve French 2018-10-30 3010 #ifdef CONFIG_CIFS_DEBUG2
0d35e382e4e96a Ronnie Sahlberg 2021-11-05 3011 oparms->fid->mid = le64_to_cpu(rsp->hdr.MessageId);
dfe33f9abc0899 Steve French 2018-10-30 3012 #endif /* CIFS_DEBUG2 */
f0df737ee820ec Pavel Shilovsky 2012-09-18 3013
f0df737ee820ec Pavel Shilovsky 2012-09-18 3014 if (buf) {
fbcff33d4204cb Kees Cook 2021-06-21 3015 buf->CreationTime = rsp->CreationTime;
fbcff33d4204cb Kees Cook 2021-06-21 3016 buf->LastAccessTime = rsp->LastAccessTime;
fbcff33d4204cb Kees Cook 2021-06-21 3017 buf->LastWriteTime = rsp->LastWriteTime;
fbcff33d4204cb Kees Cook 2021-06-21 3018 buf->ChangeTime = rsp->ChangeTime;
f0df737ee820ec Pavel Shilovsky 2012-09-18 3019 buf->AllocationSize = rsp->AllocationSize;
f0df737ee820ec Pavel Shilovsky 2012-09-18 3020 buf->EndOfFile = rsp->EndofFile;
f0df737ee820ec Pavel Shilovsky 2012-09-18 3021 buf->Attributes = rsp->FileAttributes;
f0df737ee820ec Pavel Shilovsky 2012-09-18 3022 buf->NumberOfLinks = cpu_to_le32(1);
f0df737ee820ec Pavel Shilovsky 2012-09-18 3023 buf->DeletePending = 0;
f0df737ee820ec Pavel Shilovsky 2012-09-18 3024 }
2e44b288788213 Pavel Shilovsky 2012-09-18 3025
89a5bfa350faf8 Steve French 2019-07-18 3026
89a5bfa350faf8 Steve French 2019-07-18 3027 smb2_parse_contexts(server, rsp, &oparms->fid->epoch,
69dda3059e7a4d Aurelien Aptel 2020-03-02 3028 oparms->fid->lease_key, oplock, buf, posix);
2503a0dba98948 Pavel Shilovsky 2011-12-26 3029 creat_exit:
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 3030 SMB2_open_free(&rqst);
2503a0dba98948 Pavel Shilovsky 2011-12-26 3031 free_rsp_buf(resp_buftype, rsp);
2503a0dba98948 Pavel Shilovsky 2011-12-26 3032 return rc;
2503a0dba98948 Pavel Shilovsky 2011-12-26 3033 }
2503a0dba98948 Pavel Shilovsky 2011-12-26 3034 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Re: [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent
In reply to Volker LendeckeHi Volker,
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Volker-Lendecke/cifs-Simplify-some-callers-of-compound_send_recv/20230315-212751 base: git://git.samba.org/sfrench/cifs-2.6.git for-next patch link: https://lore.kernel.org/r/715459412f19853c56156b8c0ce39fe74f148860.1678885349.git.vl%40samba.org patch subject: [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20230316/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Link: https://lore.kernel.org/r/[email protected]/
New smatch warnings:fs/cifs/smb2pdu.c:3031 SMB2_open() error: uninitialized symbol 'resp_buftype'. fs/cifs/smb2pdu.c:3258 SMB2_ioctl() error: uninitialized symbol 'resp_buftype'. fs/cifs/smb2pdu.c:3385 __SMB2_close() error: uninitialized symbol 'resp_buftype'. fs/cifs/smb2pdu.c:3590 query_info() error: uninitialized symbol 'resp_buftype'. fs/cifs/smb2pdu.c:3756 SMB2_change_notify() error: uninitialized symbol 'resp_buftype'. fs/cifs/smb2pdu.c:4021 SMB2_flush() error: uninitialized symbol 'resp_buftype'. fs/cifs/smb2pdu.c:5077 SMB2_query_directory() error: uninitialized symbol 'resp_buftype'. fs/cifs/cifssmb.c:2079 CIFSSMBPosixLock() error: uninitialized symbol 'resp_buf_type'.
Old smatch warnings:fs/cifs/smb2pdu.c:3750 SMB2_change_notify() error: we previously assumed 'plen' could be null (see line 3709) fs/cifs/cifssmb.c:4082 CIFSFindFirst() warn: missing error code? 'rc' fs/cifs/cifssmb.c:4209 CIFSFindNext() warn: missing error code? 'rc'
vim +/resp_buftype +3031 fs/cifs/smb2pdu.c
f0df737ee820ec Pavel Shilovsky 2012-09-18 3013
f0df737ee820ec Pavel Shilovsky 2012-09-18 3014 if (buf) {
fbcff33d4204cb Kees Cook 2021-06-21 3015 buf->CreationTime = rsp->CreationTime;
fbcff33d4204cb Kees Cook 2021-06-21 3016 buf->LastAccessTime = rsp->LastAccessTime;
fbcff33d4204cb Kees Cook 2021-06-21 3017 buf->LastWriteTime = rsp->LastWriteTime;
fbcff33d4204cb Kees Cook 2021-06-21 3018 buf->ChangeTime = rsp->ChangeTime;
f0df737ee820ec Pavel Shilovsky 2012-09-18 3019 buf->AllocationSize = rsp->AllocationSize;
f0df737ee820ec Pavel Shilovsky 2012-09-18 3020 buf->EndOfFile = rsp->EndofFile;
f0df737ee820ec Pavel Shilovsky 2012-09-18 3021 buf->Attributes = rsp->FileAttributes;
f0df737ee820ec Pavel Shilovsky 2012-09-18 3022 buf->NumberOfLinks = cpu_to_le32(1);
f0df737ee820ec Pavel Shilovsky 2012-09-18 3023 buf->DeletePending = 0;
f0df737ee820ec Pavel Shilovsky 2012-09-18 3024 }
2e44b288788213 Pavel Shilovsky 2012-09-18 3025
89a5bfa350faf8 Steve French 2019-07-18 3026
89a5bfa350faf8 Steve French 2019-07-18 3027 smb2_parse_contexts(server, rsp, &oparms->fid->epoch,
69dda3059e7a4d Aurelien Aptel 2020-03-02 3028 oparms->fid->lease_key, oplock, buf, posix);
2503a0dba98948 Pavel Shilovsky 2011-12-26 3029 creat_exit:
1eb9fb52040fc6 Ronnie Sahlberg 2018-08-08 3030 SMB2_open_free(&rqst);2503a0dba98948 Pavel Shilovsky 2011-12-26 @3031 free_rsp_buf(resp_buftype, rsp);
Hard to tell if this is a false positive without more context, but it looks properly sus.
2503a0dba98948 Pavel Shilovsky 2011-12-26 3032 return rc; 2503a0dba98948 Pavel Shilovsky 2011-12-26 3033 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests