* [PATCH 00/10] Some cleanups for fs/cifs
@ 2023-03-15 13:05 Volker Lendecke
2023-03-15 13:05 ` [PATCH 01/10] cifs: Simplify some callers of compound_send_recv() Volker Lendecke
` (10 more replies)
0 siblings, 11 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: 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 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(-)
--
2.30.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 01/10] cifs: Simplify some callers of compound_send_recv()
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
@ 2023-03-15 13:05 ` Volker Lendecke
2023-03-15 13:05 ` [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent Volker Lendecke
` (9 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: Volker Lendecke
This is the first thing compound_send_recv() does.
Signed-off-by: Volker Lendecke <vl@samba.org>
---
fs/cifs/cached_dir.c | 1 -
fs/cifs/smb2inode.c | 2 --
fs/cifs/smb2ops.c | 7 -------
3 files changed, 10 deletions(-)
diff --git a/fs/cifs/cached_dir.c b/fs/cifs/cached_dir.c
index 75d5e06306ea..81316efad731 100644
--- a/fs/cifs/cached_dir.c
+++ b/fs/cifs/cached_dir.c
@@ -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 */
diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
index 8dd3791b5c53..eb288836b06b 100644
--- a/fs/cifs/smb2inode.c
+++ b/fs/cifs/smb2inode.c
@@ -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;
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 6dfb865ee9d7..c7c35cad1a41 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -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);
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
2023-03-15 13:05 ` [PATCH 01/10] cifs: Simplify some callers of compound_send_recv() Volker Lendecke
@ 2023-03-15 13:05 ` Volker Lendecke
2023-03-15 19:33 ` kernel test robot
2023-03-20 5:57 ` Dan Carpenter
2023-03-15 13:05 ` [PATCH 03/10] cifs: Slightly simplify cifs_readdir() Volker Lendecke
` (8 subsequent siblings)
10 siblings, 2 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: Volker Lendecke
The 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.
Signed-off-by: Volker Lendecke <vl@samba.org>
---
fs/cifs/cifssmb.c | 6 +++---
fs/cifs/smb2pdu.c | 14 +++++++-------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index a43c78396dd8..1f02c66e5716 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -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;
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 0e53265e1462..dede2d422c1f 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -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;
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 03/10] cifs: Slightly simplify cifs_readdir()
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
2023-03-15 13:05 ` [PATCH 01/10] cifs: Simplify some callers of compound_send_recv() Volker Lendecke
2023-03-15 13:05 ` [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent Volker Lendecke
@ 2023-03-15 13:05 ` Volker Lendecke
2023-03-15 13:05 ` [PATCH 04/10] " Volker Lendecke
` (7 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: Volker Lendecke
"else" not needed, we do a "goto" in the if-branch. This makes the
following condition a bit easier to read for me.
Signed-off-by: Volker Lendecke <vl@samba.org>
---
fs/cifs/readdir.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index ef638086d734..7dfa33b6954f 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -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) {
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 04/10] cifs: Slightly simplify cifs_readdir()
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
` (2 preceding siblings ...)
2023-03-15 13:05 ` [PATCH 03/10] cifs: Slightly simplify cifs_readdir() Volker Lendecke
@ 2023-03-15 13:05 ` Volker Lendecke
2023-03-15 13:05 ` [PATCH 05/10] cifs: Simplify SMB2_OP_RMDIR with CREATE_DELETE_ON_CLOSE Volker Lendecke
` (6 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: Volker Lendecke
Use the fact that we use "goto" in the else-branch, this avoids an
indentation level for the success case.
Signed-off-by: Volker Lendecke <vl@samba.org>
---
fs/cifs/readdir.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 7dfa33b6954f..0bca6dc10093 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -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(
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 05/10] cifs: Simplify SMB2_OP_RMDIR with CREATE_DELETE_ON_CLOSE
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
` (3 preceding siblings ...)
2023-03-15 13:05 ` [PATCH 04/10] " Volker Lendecke
@ 2023-03-15 13:05 ` Volker Lendecke
2023-03-15 13:05 ` [PATCH 06/10] cifs: Slightly refactor smb2_compound_op() Volker Lendecke
` (5 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: Volker Lendecke
Match SMB2_OP_DELETE, we don't need the intermediate
SMB2_set_info(FILE_DISPOSITION_INFORMATION)
Signed-off-by: Volker Lendecke <vl@samba.org>
---
fs/cifs/smb2inode.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
index eb288836b06b..aa848779bc22 100644
--- a/fs/cifs/smb2inode.c
+++ b/fs/cifs/smb2inode.c
@@ -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);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 06/10] cifs: Slightly refactor smb2_compound_op()
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
` (4 preceding siblings ...)
2023-03-15 13:05 ` [PATCH 05/10] cifs: Simplify SMB2_OP_RMDIR with CREATE_DELETE_ON_CLOSE Volker Lendecke
@ 2023-03-15 13:05 ` Volker Lendecke
2023-03-15 13:05 ` [PATCH 07/10] cifs: Reduce copy&paste in smb2_compound_op() Volker Lendecke
` (4 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: Volker Lendecke
Simplify if-conditions a bit. The reason for this will become obvious
in the next patch.
Signed-off-by: Volker Lendecke <vl@samba.org>
---
fs/cifs/smb2inode.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
index aa848779bc22..1aafa79503ce 100644
--- a/fs/cifs/smb2inode.c
+++ b/fs/cifs/smb2inode.c
@@ -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;
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 07/10] cifs: Reduce copy&paste in smb2_compound_op()
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
` (5 preceding siblings ...)
2023-03-15 13:05 ` [PATCH 06/10] cifs: Slightly refactor smb2_compound_op() Volker Lendecke
@ 2023-03-15 13:05 ` Volker Lendecke
2023-03-15 13:05 ` [PATCH 08/10] cifs: Avoid two "else" branches Volker Lendecke
` (3 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: Volker Lendecke
Don't duplicate calls to inner _init() calls when only the fid differs.
Signed-off-by: Volker Lendecke <vl@samba.org>
---
fs/cifs/smb2inode.c | 102 ++++++++++++--------------------------------
1 file changed, 28 insertions(+), 74 deletions(-)
diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
index 1aafa79503ce..cc472602daf0 100644
--- a/fs/cifs/smb2inode.c
+++ b/fs/cifs/smb2inode.c
@@ -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) {
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 08/10] cifs: Avoid two "else" branches
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
` (6 preceding siblings ...)
2023-03-15 13:05 ` [PATCH 07/10] cifs: Reduce copy&paste in smb2_compound_op() Volker Lendecke
@ 2023-03-15 13:05 ` Volker Lendecke
2023-03-15 13:05 ` [PATCH 09/10] cifs: Store smb3_create_tag_posix just once Volker Lendecke
` (2 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: Volker Lendecke
We goto out of the if-branches, this makes the flow easier to read
Signed-off-by: Volker Lendecke <vl@samba.org>
---
fs/cifs/smb2pdu.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index dede2d422c1f..14b909b2348b 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -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;
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 09/10] cifs: Store smb3_create_tag_posix just once
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
` (7 preceding siblings ...)
2023-03-15 13:05 ` [PATCH 08/10] cifs: Avoid two "else" branches Volker Lendecke
@ 2023-03-15 13:05 ` Volker Lendecke
2023-03-15 13:05 ` [PATCH 10/10] cifs: Use switch/case to dissect negprot reply ctxts Volker Lendecke
2023-03-15 14:49 ` [PATCH 00/10] Some cleanups for fs/cifs Tom Talpey
10 siblings, 0 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: Volker Lendecke
Save 32 bytes in .text and a few lines
Signed-off-by: Volker Lendecke <vl@samba.org>
---
fs/cifs/smb2pdu.c | 49 +++++++++--------------------------------------
1 file changed, 9 insertions(+), 40 deletions(-)
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 14b909b2348b..0c1dc33aff05 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -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);
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 10/10] cifs: Use switch/case to dissect negprot reply ctxts
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
` (8 preceding siblings ...)
2023-03-15 13:05 ` [PATCH 09/10] cifs: Store smb3_create_tag_posix just once Volker Lendecke
@ 2023-03-15 13:05 ` Volker Lendecke
2023-03-15 14:49 ` [PATCH 00/10] Some cleanups for fs/cifs Tom Talpey
10 siblings, 0 replies; 14+ messages in thread
From: Volker Lendecke @ 2023-03-15 13:05 UTC (permalink / raw)
To: linux-cifs; +Cc: Volker Lendecke
Easier to read than nested if/else statements
Signed-off-by: Volker Lendecke <vl@samba.org>
---
fs/cifs/smb2pdu.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 0c1dc33aff05..567f2017d143 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -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;
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 00/10] Some cleanups for fs/cifs
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
` (9 preceding siblings ...)
2023-03-15 13:05 ` [PATCH 10/10] cifs: Use switch/case to dissect negprot reply ctxts Volker Lendecke
@ 2023-03-15 14:49 ` Tom Talpey
10 siblings, 0 replies; 14+ messages in thread
From: Tom Talpey @ 2023-03-15 14:49 UTC (permalink / raw)
To: Volker Lendecke, linux-cifs
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.
Acked-by: Tom Talpey <tom@talpey.com>
On 3/15/2023 9:05 AM, Volker Lendecke wrote:
> 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(-)
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent
2023-03-15 13:05 ` [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent Volker Lendecke
@ 2023-03-15 19:33 ` kernel test robot
2023-03-20 5:57 ` Dan Carpenter
1 sibling, 0 replies; 14+ messages in thread
From: kernel test robot @ 2023-03-15 19:33 UTC (permalink / raw)
To: Volker Lendecke, linux-cifs; +Cc: llvm, oe-kbuild-all, Volker Lendecke
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/202303160346.ieaQ1aHI-lkp@intel.com/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 <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303160346.ieaQ1aHI-lkp@intel.com/
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;
^
= 0
1 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
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent
2023-03-15 13:05 ` [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent Volker Lendecke
2023-03-15 19:33 ` kernel test robot
@ 2023-03-20 5:57 ` Dan Carpenter
1 sibling, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2023-03-20 5:57 UTC (permalink / raw)
To: oe-kbuild, Volker Lendecke, linux-cifs
Cc: lkp, oe-kbuild-all, Volker Lendecke
Hi 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/202303160920.kX2EmZmU-lkp@intel.com/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 <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202303160920.kX2EmZmU-lkp@intel.com/
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 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2023-03-20 5:57 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
2023-03-15 13:05 ` [PATCH 01/10] cifs: Simplify some callers of compound_send_recv() Volker Lendecke
2023-03-15 13:05 ` [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent Volker Lendecke
2023-03-15 19:33 ` kernel test robot
2023-03-20 5:57 ` Dan Carpenter
2023-03-15 13:05 ` [PATCH 03/10] cifs: Slightly simplify cifs_readdir() Volker Lendecke
2023-03-15 13:05 ` [PATCH 04/10] " Volker Lendecke
2023-03-15 13:05 ` [PATCH 05/10] cifs: Simplify SMB2_OP_RMDIR with CREATE_DELETE_ON_CLOSE Volker Lendecke
2023-03-15 13:05 ` [PATCH 06/10] cifs: Slightly refactor smb2_compound_op() Volker Lendecke
2023-03-15 13:05 ` [PATCH 07/10] cifs: Reduce copy&paste in smb2_compound_op() Volker Lendecke
2023-03-15 13:05 ` [PATCH 08/10] cifs: Avoid two "else" branches Volker Lendecke
2023-03-15 13:05 ` [PATCH 09/10] cifs: Store smb3_create_tag_posix just once Volker Lendecke
2023-03-15 13:05 ` [PATCH 10/10] cifs: Use switch/case to dissect negprot reply ctxts Volker Lendecke
2023-03-15 14:49 ` [PATCH 00/10] Some cleanups for fs/cifs Tom Talpey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).