From patchwork Mon Jun 24 18:29:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 11013929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8568513AF for ; Mon, 24 Jun 2019 18:29:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71E282807B for ; Mon, 24 Jun 2019 18:29:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6169E28856; Mon, 24 Jun 2019 18:29:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6CA72807B for ; Mon, 24 Jun 2019 18:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728175AbfFXS3d (ORCPT ); Mon, 24 Jun 2019 14:29:33 -0400 Received: from mail-pf1-f173.google.com ([209.85.210.173]:35860 "EHLO mail-pf1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726885AbfFXS3d (ORCPT ); Mon, 24 Jun 2019 14:29:33 -0400 Received: by mail-pf1-f173.google.com with SMTP id r7so8020571pfl.3 for ; Mon, 24 Jun 2019 11:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=yumXNhr1oecb8v5SyoMBA4cZByIKLjbj0HRrSF+i1t8=; b=bLc62iPZSi/jfA83nytmhgI7n1R6wQZpB+S3XZMrQRzg66NJHcDcCQRC09L4eUx/Cr BWYPVG3K/w9zIT6bpD6EnP/hcl/F53ZiTkpetmigt8JpZJjAJjs0w7RPdICT+ipYXC5d lS307r9bBz6UGg3Vm6Z5pVhrcGUOLciU/gUUnfI4u6ncg6sHoHiiZzCts9CbbsiPMRIW HTk+/jJ4fkq0mPOv601jY8yHMYcR6JIY4ihnLDfE2pdeom4skjSzu892XL2wBEfWVV7g r+WzE6Q0y4GgG+b8kqiVEdFVAdod1r6eLK9zUYaZOXG/JVGOA3Foi1JCigt77FH5RlMC g//A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=yumXNhr1oecb8v5SyoMBA4cZByIKLjbj0HRrSF+i1t8=; b=AJQPZsxd3tlN9GF88IAyes/BxEFuqouN5gtBnyNvbo9JiQQNDxPDmqkKgrQfvPpXvQ M0MvL9q8EsZxWsrxrxhbqiKFHYveIRyfbmjbJ+FKzbV/KSrQT8qBPeTME8lhWuxq8bHO QkUsqkD8dyQ4cYjLakkpe288XufUNQrVsGUK1ZU/UYEFm7rFzifrtVyHS3zcq5X4Zy1I rq0J4XtW4UqcRc+grDbwucv/Dhg93rvjzQLX18VPyTbf/NrQ0PaB6UL/8pdOD2F31rE1 A+O6CuBk6CO8h07zy67G5x/8+VkCia/1JM/tu+Qdtg95D/At2K1RMV+hH4296j8LThDR 5/nA== X-Gm-Message-State: APjAAAVi1yGCSn5DI95CJ8JdFAfnfq6NXEUSAlP/ZBgErtLWRCAxUjp1 J4Bec2ubcM/E3Dhgn+zo1ZgmW9fGVmKkEtm2FnjsXA== X-Google-Smtp-Source: APXvYqzijLRuRn5zzI+2WgpBcUz7wcmTqoX9yGDTwQWVIaw3cS+xJYFLqVMv65JkrHMv9lq8BcG91hgiDh9cdSMhoMI= X-Received: by 2002:a17:90a:360c:: with SMTP id s12mr26895272pjb.30.1561400972037; Mon, 24 Jun 2019 11:29:32 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Mon, 24 Jun 2019 13:29:21 -0500 Message-ID: Subject: Minor cleanup of compound_send_recv To: CIFS Cc: =?utf-8?q?Aur=C3=A9lien_Aptel?= Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In Aurelien's earlier patch series I noticed a cleanup (converting ses->server to a local variable server=ses->server) which made code easier to read in this function. This doesn't require compounding but probably helps his Reviewed-by: Ronnie Sahlberg From 1135a5fc08f45f918a68b3a604ae347cd70f3921 Mon Sep 17 00:00:00 2001 From: Aurelien Aptel Date: Mon, 24 Jun 2019 13:00:12 -0500 Subject: [PATCH] smb3: minor cleanup of compound_send_recv Trivial cleanup. Will make future multichannel code smaller as well. Signed-off-by: Aurelien Aptel --- fs/cifs/transport.c | 46 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 60661b3f983a..5d6d44bfe10a 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -979,6 +979,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, }; unsigned int instance; char *buf; + struct TCP_Server_Info *server; optype = flags & CIFS_OP_MASK; @@ -990,7 +991,8 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, return -EIO; } - if (ses->server->tcpStatus == CifsExiting) + server = ses->server; + if (server->tcpStatus == CifsExiting) return -ENOENT; /* @@ -1001,7 +1003,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, * other requests. * This can be handled by the eventual session reconnect. */ - rc = wait_for_compound_request(ses->server, num_rqst, flags, + rc = wait_for_compound_request(server, num_rqst, flags, &instance); if (rc) return rc; @@ -1017,7 +1019,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, * of smb data. */ - mutex_lock(&ses->server->srv_mutex); + mutex_lock(&server->srv_mutex); /* * All the parts of the compound chain belong obtained credits from the @@ -1026,24 +1028,24 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, * we obtained credits and return -EAGAIN in such cases to let callers * handle it. */ - if (instance != ses->server->reconnect_instance) { - mutex_unlock(&ses->server->srv_mutex); + if (instance != server->reconnect_instance) { + mutex_unlock(&server->srv_mutex); for (j = 0; j < num_rqst; j++) - add_credits(ses->server, &credits[j], optype); + add_credits(server, &credits[j], optype); return -EAGAIN; } for (i = 0; i < num_rqst; i++) { - midQ[i] = ses->server->ops->setup_request(ses, &rqst[i]); + midQ[i] = server->ops->setup_request(ses, &rqst[i]); if (IS_ERR(midQ[i])) { - revert_current_mid(ses->server, i); + revert_current_mid(server, i); for (j = 0; j < i; j++) cifs_delete_mid(midQ[j]); - mutex_unlock(&ses->server->srv_mutex); + mutex_unlock(&server->srv_mutex); /* Update # of requests on wire to server */ for (j = 0; j < num_rqst; j++) - add_credits(ses->server, &credits[j], optype); + add_credits(server, &credits[j], optype); return PTR_ERR(midQ[i]); } @@ -1059,19 +1061,19 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, else midQ[i]->callback = cifs_compound_last_callback; } - cifs_in_send_inc(ses->server); - rc = smb_send_rqst(ses->server, num_rqst, rqst, flags); - cifs_in_send_dec(ses->server); + cifs_in_send_inc(server); + rc = smb_send_rqst(server, num_rqst, rqst, flags); + cifs_in_send_dec(server); for (i = 0; i < num_rqst; i++) cifs_save_when_sent(midQ[i]); if (rc < 0) { - revert_current_mid(ses->server, num_rqst); - ses->server->sequence_number -= 2; + revert_current_mid(server, num_rqst); + server->sequence_number -= 2; } - mutex_unlock(&ses->server->srv_mutex); + mutex_unlock(&server->srv_mutex); /* * If sending failed for some reason or it is an oplock break that we @@ -1079,7 +1081,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, */ if (rc < 0 || (flags & CIFS_NO_SRV_RSP)) { for (i = 0; i < num_rqst; i++) - add_credits(ses->server, &credits[i], optype); + add_credits(server, &credits[i], optype); goto out; } @@ -1099,7 +1101,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, rqst[0].rq_nvec); for (i = 0; i < num_rqst; i++) { - rc = wait_for_response(ses->server, midQ[i]); + rc = wait_for_response(server, midQ[i]); if (rc != 0) break; } @@ -1107,7 +1109,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, for (; i < num_rqst; i++) { cifs_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n", midQ[i]->mid, le16_to_cpu(midQ[i]->command)); - send_cancel(ses->server, &rqst[i], midQ[i]); + send_cancel(server, &rqst[i], midQ[i]); spin_lock(&GlobalMid_Lock); if (midQ[i]->mid_state == MID_REQUEST_SUBMITTED) { midQ[i]->mid_flags |= MID_WAIT_CANCELLED; @@ -1123,7 +1125,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, if (rc < 0) goto out; - rc = cifs_sync_mid_result(midQ[i], ses->server); + rc = cifs_sync_mid_result(midQ[i], server); if (rc != 0) { /* mark this mid as cancelled to not free it below */ cancelled_mid[i] = true; @@ -1140,14 +1142,14 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, buf = (char *)midQ[i]->resp_buf; resp_iov[i].iov_base = buf; resp_iov[i].iov_len = midQ[i]->resp_buf_size + - ses->server->vals->header_preamble_size; + server->vals->header_preamble_size; if (midQ[i]->large_buf) resp_buf_type[i] = CIFS_LARGE_BUFFER; else resp_buf_type[i] = CIFS_SMALL_BUFFER; - rc = ses->server->ops->check_receive(midQ[i], ses->server, + rc = server->ops->check_receive(midQ[i], server, flags & CIFS_LOG_ERROR); /* mark it so buf will not be freed by cifs_delete_mid */ -- 2.20.1