From patchwork Wed Mar 15 13:05:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Lendecke X-Patchwork-Id: 13175814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE6D0C7618A for ; Wed, 15 Mar 2023 13:05:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232101AbjCONFv (ORCPT ); Wed, 15 Mar 2023 09:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231234AbjCONFu (ORCPT ); Wed, 15 Mar 2023 09:05:50 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55E2253734 for ; Wed, 15 Mar 2023 06:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=1T5064wioNMrMT6a7WAGlO0/tunVBULwzIMBnfQ8iMY=; b=q1KTaVVz28SlHoCThQxGIUc1Hn luAVhK//ST58mb/EzmuVO0YtDCN0hblifmPaYn5zQZ57aEq93OYrlyMzFQyMHnDFeBLM2Dsorqj0G LwJQMdnN+AaiqJpuTfHt3SFwvjsNYleADN9iXj+tt8+CdYfgk3tD5B7lNX0Xd+H7i99hnu9phvstO y05MMr4004Ud7DTgtmhKcgysVA9tatx7V3iFJVpZ7Mvq0GtSgRSOUG+e6qGvM+fs8k1Ev1NWz+t+u X4Nk0jYZcWbcJcFLs2WyPidLhKz8+lyX25CtyQVHDzisY8vQd7p7p3wSKe3upUOW6GyPQV4PG6OSJ jtt2TkbX9Sxzqmqrv/Mz0k9bWzFZsMY5N02VIIRLRjOGs1qPH+1pzFuBOd4pvmgd+QqsOWAvyJP0i sQt/8FfwgJMqvGotK4VjzWhVR+z3R2JD+a44byk8zQlB5qd5MeI1EGnGbMT65F3z/JRAaqHcTPXh3 L36F2AclP73ua6aKW+dcfiAT; Received: from [2a01:4f8:252:410e::177:224] (port=40716 helo=atb-devel-224..) by hr2.samba.org with esmtp (Exim) id 1pcQp6-003KNd-94; Wed, 15 Mar 2023 13:05:44 +0000 From: Volker Lendecke To: linux-cifs@vger.kernel.org Cc: Volker Lendecke Subject: [PATCH 01/10] cifs: Simplify some callers of compound_send_recv() Date: Wed, 15 Mar 2023 13:05:22 +0000 Message-Id: <68f03f480eea3b7404dc644e3dac154e55b210d1.1678885349.git.vl@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org This is the first thing compound_send_recv() does. Signed-off-by: Volker Lendecke --- 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); From patchwork Wed Mar 15 13:05:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Lendecke X-Patchwork-Id: 13175813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 323B0C61DA4 for ; Wed, 15 Mar 2023 13:05:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231946AbjCONFu (ORCPT ); Wed, 15 Mar 2023 09:05:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231867AbjCONFu (ORCPT ); Wed, 15 Mar 2023 09:05:50 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 561EB57093 for ; Wed, 15 Mar 2023 06:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=Dd+2o/QhkHPQAqLt1EVZgly77SVHKDmhY2Sv6Tn4gGI=; b=o71KNyF6WpckjFOCOWjRWdkaXN 8gdnz115MRTfanXYdOBfw/wFTmL5PCTKOWaWHfH2BBU87BCDQUrRs/JvK3KzAgH1Nereh2PnEOMV7 qKdxeLHW+mX4X54HkGJbmkJ5rOmkeExqRjXgoMF5Nj2KjhAEUgeL4XOjHEhH3HM7X7YtHoqyKejJx W828XFBAXX1kiA1hUYYgerPI9jlgvvUbaVzI5Y/OPs1VqqT66V1oJAL9uKq7FOlgC5W6nVnsGIFVW EIPmQBkr5Y32Ce+ChXnvhwdAHrdNTU85z7FcOpGVAlnF6Lwp1EIrOd+5oHrBGJoQQZsZGItBPCIss Ly1Fd6afCgbePwEcHx66iAinCG47+ZLkA/phhBI4u4joApkNzCHVmVs0N9O91vpyhTL5Js3+KQtw6 rqNMQb1UMPQUK7LG+RMUNQuoLKxO4SQq7idaUgkI3PFIMenZboIFkJxpmCa/1cjN5fxsuLaMVobmK 0xxdWWxdiD++IdTpduTqRELN; Received: from [2a01:4f8:252:410e::177:224] (port=40716 helo=atb-devel-224..) by hr2.samba.org with esmtp (Exim) id 1pcQp6-003KNd-CI; Wed, 15 Mar 2023 13:05:44 +0000 From: Volker Lendecke To: linux-cifs@vger.kernel.org Cc: Volker Lendecke Subject: [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent Date: Wed, 15 Mar 2023 13:05:23 +0000 Message-Id: <715459412f19853c56156b8c0ce39fe74f148860.1678885349.git.vl@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 --- 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; From patchwork Wed Mar 15 13:05:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Lendecke X-Patchwork-Id: 13175816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3120C76195 for ; Wed, 15 Mar 2023 13:05:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231879AbjCONFw (ORCPT ); Wed, 15 Mar 2023 09:05:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjCONFu (ORCPT ); Wed, 15 Mar 2023 09:05:50 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FE42570A9 for ; Wed, 15 Mar 2023 06:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=9x4Bm9H1uhZfjy1inAXt6rhGoE94LlElYSHSInWdjGU=; b=s4ykIrxG67TJEdVsfXuFCwedGd viDlOovbA1rLaL62ggcTBDQc9XcClXs3a77a1qkMJudc5N3Iy+22Cv/CMIkfmU+mmYCro6fOGrfxg dj/bJQsXdmRTQiZpmHhXhbZuzKVYgxreqpfe5/s8EonmRwUrI5nGgvcLUsv/H0osjQEzqy3wE0J9+ 4wGbprPhLDLzwh4c7Zj2PLK70ji61ndAftMDyWuEbXRDz6cqV1MfHmCMQiPyJTnfDdEWETFWNIYMd w2SMQFrXiPff0+omAuOQraWpE44+AHcyWStSL3EyaHmyNLLVGYPNZ5/yBUeKjSGchniYg21Obf0vd RuJh1ZEI7HvwCQWLY8IL58obM3LFJnAkY20OPZlHMFJBpR1xamIvQDrXlR4zUCs7BDL/yPHobxK0N ZuZkUw0Qo0KNtU2WMNHUniA56Aiwe8KrKyxzt7dAgtVcMxzUBG4B1JhlNHxn0YnDlv+w/KjMBjXVW iOHXzZQh8mZGjZ13Cs9Ay+CW; Received: from [2a01:4f8:252:410e::177:224] (port=40716 helo=atb-devel-224..) by hr2.samba.org with esmtp (Exim) id 1pcQp6-003KNd-Gg; Wed, 15 Mar 2023 13:05:44 +0000 From: Volker Lendecke To: linux-cifs@vger.kernel.org Cc: Volker Lendecke Subject: [PATCH 03/10] cifs: Slightly simplify cifs_readdir() Date: Wed, 15 Mar 2023 13:05:24 +0000 Message-Id: <468ae3a579bb44fca13113680fecfd550e36b055.1678885349.git.vl@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org "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 --- 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) { From patchwork Wed Mar 15 13:05:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Lendecke X-Patchwork-Id: 13175818 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C474C61DA4 for ; Wed, 15 Mar 2023 13:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231979AbjCONFy (ORCPT ); Wed, 15 Mar 2023 09:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230421AbjCONFu (ORCPT ); Wed, 15 Mar 2023 09:05:50 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C36F9570B7 for ; Wed, 15 Mar 2023 06:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=HOrFjIBcjzrBvM4R5nK6rRExlyCGPWQmiwJQgpg/Dfk=; b=R+DsTb1Dt98GFQ/9lZ0+i8gzlP B+08g/jqUhkr1Vx82e5xTJlWo81Pu+lpSLD2+jGfv+lSscczu5oVA47eWrORH0XEFpgq44cJUNB1m BfxrpgK5AVGa9ZlXclHancticzE2F1kfGOA6AoB+fln4NXb+rfLj8Ys4GtkZC+4dY9Am5LPG7ZakC SdTSRVicG/nZ/zcObuL66O2vKsy4UTxId7t3G3tYaieBZd5oE2x2iaCW/i06WYJfHwKjGdgP0v8u0 8lxx+gdlETdwVqwvY+pPrHL2+YpSx2MC3Xy+8X97O/keqnDcCBWPEXDjZbj5LtTjRl+WnTFtbRUU8 EO3KyvbH08hc+JZMnfTSgnc3IuLh5nnbOIOLLGXAzrrKEO4NIXBBoblhrsYArHLnH7UhQlQGfs7KT R0CeP5RpyrDOhuVgpjyFtOclJkqRsJl3m9bW6hnObjg/gnkU0FVkSIm9LRdleNM9bP+Qn4a/umt7o hDX+al7nhdYtNfDqak3c1DJx; Received: from [2a01:4f8:252:410e::177:224] (port=40716 helo=atb-devel-224..) by hr2.samba.org with esmtp (Exim) id 1pcQp6-003KNd-Mv; Wed, 15 Mar 2023 13:05:44 +0000 From: Volker Lendecke To: linux-cifs@vger.kernel.org Cc: Volker Lendecke Subject: [PATCH 04/10] cifs: Slightly simplify cifs_readdir() Date: Wed, 15 Mar 2023 13:05:25 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 --- 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( From patchwork Wed Mar 15 13:05:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Lendecke X-Patchwork-Id: 13175817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42944C7618B for ; Wed, 15 Mar 2023 13:05:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231784AbjCONFx (ORCPT ); Wed, 15 Mar 2023 09:05:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231979AbjCONFu (ORCPT ); Wed, 15 Mar 2023 09:05:50 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C37F574C5 for ; Wed, 15 Mar 2023 06:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=SfouBEuyesxYwEZCCVsPRpPThrluuTkgd+OtrqRBYws=; b=ou3KhAR4fX7VqQPW86+VlGiG4m XPop2DiHPyjV9RlpMipjTAzOogAG/GPjKzkHcrh1MjyAYIxw8ptknmAWXEuXiZymOVu3jw1mDs96Y tHb/7jp5cJXeb5gFz0QB8GrzhuJfkMwULFiZ9jdoKA5tpST5TEYlk9PPdLVks+gLV4X36M+7NuHB6 vDnUxlZGgdTcPNgoWqL6Ex04dC97n1SwWspx4Ll04MleKOCLeDcpl8D3It5LC+by81mS02LcEGn7T PKs/uVJCaXGqbL/kEUmKOtmmR+VYkGvL4aeBP7rSKBug0NrBmLY+m2jH4F4lzT51BIwvv2f3UrS1n //av4DMGJMHn6o0kCU/45BRCU7M2CoFsr+jHsUoMGQ5grXW27E3d9kS+JmnRHyOrbD+XwpXTTGNCw FQXsKgEdziPp8DYuz3xttF53HO0hS62rycWaYqO1ubP/qnNBhZSgiNOsgX+t1c85iOiInwioalcY2 Ag3vJdbYyd6mekOwVF8r5tS5; Received: from [2a01:4f8:252:410e::177:224] (port=40716 helo=atb-devel-224..) by hr2.samba.org with esmtp (Exim) id 1pcQp6-003KNd-Sw; Wed, 15 Mar 2023 13:05:44 +0000 From: Volker Lendecke To: linux-cifs@vger.kernel.org Cc: Volker Lendecke Subject: [PATCH 05/10] cifs: Simplify SMB2_OP_RMDIR with CREATE_DELETE_ON_CLOSE Date: Wed, 15 Mar 2023 13:05:26 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Match SMB2_OP_DELETE, we don't need the intermediate SMB2_set_info(FILE_DISPOSITION_INFORMATION) Signed-off-by: Volker Lendecke --- 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); } From patchwork Wed Mar 15 13:05:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Lendecke X-Patchwork-Id: 13175819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F6F8C76196 for ; Wed, 15 Mar 2023 13:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229666AbjCONFy (ORCPT ); Wed, 15 Mar 2023 09:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232048AbjCONFv (ORCPT ); Wed, 15 Mar 2023 09:05:51 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E220574E2 for ; Wed, 15 Mar 2023 06:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=cEfFtEnIZYJNmeBLa8ldPbNYOnS64MqRE09FsR6rbwA=; b=pQXGYHcKrORM9DtDJfGnz08gtV v7kmql46iaUdcz0WAEk5E+YsZFn5Qsrn1b4ywWaicURgo08iYx7rj7C05scclcpOc9obT/zufBalM 7NDDqbtfjffYffHmgLAeKDWV+6tsdRjHDmKVyickfcSGgYYXMX0P7ejNYnKAfnhkn+huVGounJVWv pk71n/d7yY4s+zsizG0f4Mk+Scrt56Or5RQOP3Mps2XbjYeprr0Cox4hTVbu/N7f6OsYYMSpEjfWP 0HMIXpwr7U41jDIYcHc4wbV+dKikOSHaakWG1Ul7MvpgcOy2VJI5snjqYMQZ9/DyFcdEiMDtAoGHI V7i2/5IVN5my5UKAcwTODAfjwC09+52qMnUCF09NoQiDyNV0GqiC5oiIKCRRZVIibrkXzUzEbSJ4C 3NGpyM5uv1ul5Yvcb8lZFCpGHfsEbU9eDozOAdkK1/ymTFLxRDeePMa6j76MufMVMjpbg7tgxMBMh jWv+jh4nXiCpM6JZheh6hhnp; Received: from [2a01:4f8:252:410e::177:224] (port=40716 helo=atb-devel-224..) by hr2.samba.org with esmtp (Exim) id 1pcQp7-003KNd-1c; Wed, 15 Mar 2023 13:05:45 +0000 From: Volker Lendecke To: linux-cifs@vger.kernel.org Cc: Volker Lendecke Subject: [PATCH 06/10] cifs: Slightly refactor smb2_compound_op() Date: Wed, 15 Mar 2023 13:05:27 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Simplify if-conditions a bit. The reason for this will become obvious in the next patch. Signed-off-by: Volker Lendecke --- 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; From patchwork Wed Mar 15 13:05:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Lendecke X-Patchwork-Id: 13175822 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF756C7618A for ; Wed, 15 Mar 2023 13:05:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230421AbjCONF5 (ORCPT ); Wed, 15 Mar 2023 09:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232142AbjCONFv (ORCPT ); Wed, 15 Mar 2023 09:05:51 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51F6757D03 for ; Wed, 15 Mar 2023 06:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=eeAnBm6rZ/lfUfeN7eeTm3Ui1YOIY1DcyIgKdyum0Vk=; b=sr6Xt3M4h94MKxjlLj8/x0A9A6 UxAsvcIXbZVTVgxcdvSVhHAkuUyeqyY/DHkJ+5cBDSeQZFC8QWZkXwWxOn9tyIxdMRo4QlPEWSch2 EBlG/FOyfRYrBLJ2XMjC/ascwypiiuXOVLwTQ8bCO/v00hlWU3raR1c0IszZoQvTiY4Kek0MTbkGv JFIa6EMfDlED1ovH/GKkl9JqlD1xp8uIll67tFfCH0tJdYXtSlchUefMaV0lXKG4pJ8mnUWjnDvAn 13E3xIUnrnWlZJmdnsmEuF7vkSmCqUEMIbLx4gOX5DMOLs4WEPmjTregTa6yYT0wcmtyRR7YOBYiq TWnkn6LYh6Uj9Y3OFcHoeWw6bTQSuoF/y1gDNPPO+kbEJ6VFxkZ47zcUBErWKK9kjD7ZLgdhZiBnc I39dVtiSaCCPxlElPSvltb5ZtIFCwmsdLYvO9j2KA/HUc/1N5C2s9wuVHDtIBZmH61VNmE3VPsJUX NaQKYO9VKrq2QoJWUY2Klyjm; Received: from [2a01:4f8:252:410e::177:224] (port=40716 helo=atb-devel-224..) by hr2.samba.org with esmtp (Exim) id 1pcQp7-003KNd-7e; Wed, 15 Mar 2023 13:05:45 +0000 From: Volker Lendecke To: linux-cifs@vger.kernel.org Cc: Volker Lendecke Subject: [PATCH 07/10] cifs: Reduce copy&paste in smb2_compound_op() Date: Wed, 15 Mar 2023 13:05:28 +0000 Message-Id: <1abb37fcfdd554e51527d4fd3c1103e66ea455a7.1678885349.git.vl@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Don't duplicate calls to inner _init() calls when only the fid differs. Signed-off-by: Volker Lendecke --- 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) { From patchwork Wed Mar 15 13:05:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Lendecke X-Patchwork-Id: 13175820 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD982C6FD1D for ; Wed, 15 Mar 2023 13:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231847AbjCONFz (ORCPT ); Wed, 15 Mar 2023 09:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232056AbjCONFv (ORCPT ); Wed, 15 Mar 2023 09:05:51 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88736515E5 for ; Wed, 15 Mar 2023 06:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=UlnvtVTzFExutVsAMVpB1aL+jRYagjdQDq/OUASBgP0=; b=fFWGdNCPJOc3oobed79IcDo7VA yQXFV8lojdkZ2I9AovKlEmXcNuoKGMF8L6yk0E9DrzBVsHGFlySXt9KCNFqbYhSNMM0dPD7JB7nyF xlkFyWvSKH0S6jo2ASC4LVQusp0pmLAm55WAvatLhkCApXbJO7PCoQPusPKp6xNtFUdcaCJx39ql2 eTmRrNgWrDABJzVmnz1dUEhLeaw+e5RUAfCBjGlSEFukjjHTjfmwsHjvROPautlFFGhr6uadUckHz 8k4TJskPfyWSClTr30BhIvZzTNcvgFcCEz7863JbpAYFAR0rCZCv2PfsgJYXBPTgxGWpFSU5gHSJ1 5EbfwZqbHozMsJ4t2T20Qwqx65nE5PxX9cYxodI8Al+Jefpmetcn2qN8XenaIcB57dbJ63Fc4QnUj Itt7arcDHvl5XulqMFGA5tFTNbC0owf86y3O4HRsplvT34RXFVieNVzToo1hkldQBh8IQzzRUK5Ka y2L9uyobwasg6iHGOn3xIPLI; Received: from [2a01:4f8:252:410e::177:224] (port=40716 helo=atb-devel-224..) by hr2.samba.org with esmtp (Exim) id 1pcQp7-003KNd-EC; Wed, 15 Mar 2023 13:05:45 +0000 From: Volker Lendecke To: linux-cifs@vger.kernel.org Cc: Volker Lendecke Subject: [PATCH 08/10] cifs: Avoid two "else" branches Date: Wed, 15 Mar 2023 13:05:29 +0000 Message-Id: <89a7deedf5ab90f9247f0a3a26ac3ed9efb2c588.1678885349.git.vl@samba.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org We goto out of the if-branches, this makes the flow easier to read Signed-off-by: Volker Lendecke --- 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; From patchwork Wed Mar 15 13:05:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Lendecke X-Patchwork-Id: 13175821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93FBCC61DA4 for ; Wed, 15 Mar 2023 13:05:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232048AbjCONF4 (ORCPT ); Wed, 15 Mar 2023 09:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231234AbjCONFw (ORCPT ); Wed, 15 Mar 2023 09:05:52 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE2A957D07 for ; Wed, 15 Mar 2023 06:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=aM0oakkiFXBAksukeeaWT6kPwK50+QtzTF0tQNARWOs=; b=cuByXm1eSk12ZAAqA1oxVnsRSC ioEjGG4Us50qzPRLrGwGW8fGHfF5aFrgIQtbYBsxMzsk68+5LOsUNjsxKO3KZyURfKXirm1IEDNuW XFUavk3YRK6CamjFIHP65qDnjVjQjqXTX1/xHxZypGASWyL9SNBx9EcCFHpxkq6Of+ZS3IQC8DZSD 6gvZqVTitK69+H3WudXhn+pqKKKm4HYQwR8eYXAOyCMOMC0Mi4mofQeRC33+ZxzjNOaXut6n6xWGa Hd2pNQ3pS7M8vtPyqkyoxgE/5L3YO63L3An/veP56Do95hPGnYKCFEciJrTFEDglcu5NqsF4gQ+KW wTw3Cg4kFGFCbIANIT7vwo+mZdqIZjUOaFkRrDK023a1fplcYPt/D/zNDKHM5jUz9AIhyL9WdAMeq 7b28ctnYvKtpyFYEnGebKAPJL6EEsW/0/WD3U1PTUxx9FFIJJvzzuera4G3x3VJo8eU2pDyi2+4Vl TMePFot+5SndlS3apytn9Pdr; Received: from [2a01:4f8:252:410e::177:224] (port=40716 helo=atb-devel-224..) by hr2.samba.org with esmtp (Exim) id 1pcQp7-003KNd-No; Wed, 15 Mar 2023 13:05:45 +0000 From: Volker Lendecke To: linux-cifs@vger.kernel.org Cc: Volker Lendecke Subject: [PATCH 09/10] cifs: Store smb3_create_tag_posix just once Date: Wed, 15 Mar 2023 13:05:30 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Save 32 bytes in .text and a few lines Signed-off-by: Volker Lendecke --- 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); From patchwork Wed Mar 15 13:05:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Lendecke X-Patchwork-Id: 13175858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7153AC61DA4 for ; Wed, 15 Mar 2023 13:25:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbjCONZb (ORCPT ); Wed, 15 Mar 2023 09:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231800AbjCONZ0 (ORCPT ); Wed, 15 Mar 2023 09:25:26 -0400 Received: from hr2.samba.org (hr2.samba.org [IPv6:2a01:4f8:192:486::2:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EACEA1EFDE for ; Wed, 15 Mar 2023 06:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-Id:Date:Cc:To:From; bh=klM021FBVtacpRPK1rpakjfz9zCAFYsaUnmD8BdJDyY=; b=HBv/5JyfSZD3s5Dxr+Pmhriq32 0ioDkWKEIlC2Jon2Grsv6VVHZHuKXkeHqzLu8Le5ql3+8yJDrlaf+VuzsyDMk7e+4HiYreePAhRYz enOGAaasfga8BJr8KKiozxCZK2XK2EavVI5FmO8mxZGLsIgp93A/0G3IWN5YPisDIjksTV1b68XLw wA4bytab4FgalgR5kfKEFF1EFJs+HoQF2hN4TZS/OKj92+uiGj1WCg0vYRVkcOIKalxKhV1kBzPv7 6yeov+8RXNw8LF6PsrsacJe6rZkR557Cmpjc1vz3AAX7AvBUWBzKe+7A6mkuBreaBuZy3+AhuD+aI Xw9/srJVxZHH8cqGuiDLFKB8bsuiJ9BRjoBLDbQvK86RAmgEODzOH45185/H2+aWV7BNcAzrvjEL/ BonAfUMIJCsp/PayszWcAgBnJDy/lYDgW4piHRchsRX+9d9N8BQlOMvA/knjxnvg0vUpy6gXypkvi sjj41IsJBAiZrfwzsBgnVOD8; Received: from [2a01:4f8:252:410e::177:224] (port=40716 helo=atb-devel-224..) by hr2.samba.org with esmtp (Exim) id 1pcQp7-003KNd-Tm; Wed, 15 Mar 2023 13:05:45 +0000 From: Volker Lendecke To: linux-cifs@vger.kernel.org Cc: Volker Lendecke Subject: [PATCH 10/10] cifs: Use switch/case to dissect negprot reply ctxts Date: Wed, 15 Mar 2023 13:05:31 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Easier to read than nested if/else statements Signed-off-by: Volker Lendecke --- 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;