From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60C66C43381 for ; Wed, 6 Mar 2019 04:15:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 30EB120675 for ; Wed, 6 Mar 2019 04:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728108AbfCFEPy (ORCPT ); Tue, 5 Mar 2019 23:15:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60056 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726432AbfCFEPy (ORCPT ); Tue, 5 Mar 2019 23:15:54 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30E8681127; Wed, 6 Mar 2019 04:15:54 +0000 (UTC) Received: from test1135.test.redhat.com (vpn2-54-133.bne.redhat.com [10.64.54.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87D5819C71; Wed, 6 Mar 2019 04:15:53 +0000 (UTC) From: Ronnie Sahlberg To: linux-cifs Cc: Steve French , Pavel Shilovsky , Ronnie Sahlberg Subject: [PATCH 2/6] cifs: pass flags down into wait_for_free_credits() Date: Wed, 6 Mar 2019 14:15:42 +1000 Message-Id: <20190306041546.10419-3-lsahlber@redhat.com> In-Reply-To: <20190306041546.10419-1-lsahlber@redhat.com> References: <20190306041546.10419-1-lsahlber@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 06 Mar 2019 04:15:54 +0000 (UTC) Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Signed-off-by: Ronnie Sahlberg --- fs/cifs/transport.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 5c4becefde4b..8887db2cd582 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -477,15 +477,24 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer, } static int -wait_for_free_credits(struct TCP_Server_Info *server, const int timeout, - int *credits, unsigned int *instance) +wait_for_free_credits(struct TCP_Server_Info *server, const int flags, + unsigned int *instance) { int rc; + int *credits; + int optype; + + optype = flags & CIFS_OP_MASK; *instance = 0; + credits = server->ops->get_credits_field(server, optype); + /* Since an echo is already inflight, no need to wait to send another */ + if (*credits <= 0 && optype == CIFS_ECHO_OP) + return -EAGAIN; + spin_lock(&server->req_lock); - if (timeout == CIFS_ASYNC_OP) { + if ((flags & CIFS_TIMEOUT_MASK) == CIFS_ASYNC_OP) { /* oplock breaks must not be held up */ server->in_flight++; *credits -= 1; @@ -516,7 +525,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int timeout, */ /* update # of requests on the wire to server */ - if (timeout != CIFS_BLOCKING_OP) { + if ((flags & CIFS_TIMEOUT_MASK) != CIFS_BLOCKING_OP) { *credits -= 1; server->in_flight++; *instance = server->reconnect_instance; @@ -532,18 +541,7 @@ static int wait_for_free_request(struct TCP_Server_Info *server, const int flags, unsigned int *instance) { - int *val; - int timeout, optype; - - timeout = flags & CIFS_TIMEOUT_MASK; - optype = flags & CIFS_OP_MASK; - - val = server->ops->get_credits_field(server, optype); - /* Since an echo is already inflight, no need to wait to send another */ - if (*val <= 0 && optype == CIFS_ECHO_OP) - return -EAGAIN; - - return wait_for_free_credits(server, timeout, val, instance); + return wait_for_free_credits(server, flags, instance); } int -- 2.13.6