From patchwork Sat May 30 23:03:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1301296 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Gzcwn9ka; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49ZH6h1g1zz9sSF for ; Sun, 31 May 2020 09:03:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729522AbgE3XDi (ORCPT ); Sat, 30 May 2020 19:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729520AbgE3XDi (ORCPT ); Sat, 30 May 2020 19:03:38 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22290C03E969 for ; Sat, 30 May 2020 16:03:38 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id b62so3146260ybh.8 for ; Sat, 30 May 2020 16:03:38 -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; bh=w50qEa13vUloOZC3BoqoktatJ6h2xmJIyk0twZtAbxs=; b=Gzcwn9kaG+5CI1ixYQ0vDz38fVpWnZhILeINeZn1TJDlzgXCFSr8st5NQJxdSCEvIL VbQ10DUBcSWrlHkbi689NgMdEGmWoYDCtsVGpMmhbuFoteF/8DFAOUCpboYOnit+kjxz CXgs6U7PHVAMo2BPrCjt57lt1Q4aXtlw4XZbMi1va3pwO4eNwJu61f7DwmE5OQtm/59c 0frsikuGwuPHg4IXD+S9uUugGy1R97rGmj0imEk4qZx7KtPC8iuO2Ew4IPQi+M+p+e9c b89pizippDbjo7ol9K7C2JrNjORzzUhVqLkw8MDl+IoimnkUhTrw5KpRAUqSOG1XBxKA YVDA== 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; bh=w50qEa13vUloOZC3BoqoktatJ6h2xmJIyk0twZtAbxs=; b=Z3cVKrRCUncMwq7/TPh9hUOZnauKWe9wM/ZdBFnjFbUnbuO+6jak+PpcT8W9VPDHrR AIC0yvT1ieuIFzdB2bIivpfkt/VsN2JOcMhnVi6AKel+OBby5YuASntVXPcRYazCNE81 lTMT64cSOawv8WFjcTF1aMbRE+2H3sLxa4z5qcqn0ItRNC6eZgNvHYbDIjGeQpa0eJ1B kV1wGt3jJ+A0J1XA5/54RI39iAGcWCSCrXr28yLAGJH3BxUyhqku07P2LKOYzfMRh6yD UmitR/XhU1fUEhnhEFoQ6PgDU+MQb5ieV7c2cJBImluZIoZYACFIhkhTg16tm9Aiz1Kk jIDA== X-Gm-Message-State: AOAM533hIUX5ptlrrsw2BCvW4tras5eNIkYxMVNJAO/eslhveZrF0IAT cpa4YfAkxDb44YyLWuF3PQZ2/iOT+D13GPaNSdpy6hsrhiQ= X-Google-Smtp-Source: ABdhPJwI+A0RUlzBfmkegGN6PxBvYGrcsud8u4sfgI7BV9LBt/WF4psEzK+xxD/0AGy2J2O7iOD+oFzcgoQsE0DFphA= X-Received: by 2002:a25:3bd8:: with SMTP id i207mr3999811yba.167.1590879817014; Sat, 30 May 2020 16:03:37 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Sat, 30 May 2020 18:03:26 -0500 Message-ID: Subject: [PATCH][SMB3] multichannel: move channel selection in function To: CIFS , samba-technical Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Wasn't sure if these had been sent to the list again. This commit moves channel picking code in separate function. Signed-off-by: Aurelien Aptel Signed-off-by: Steve French From a7cdca2dbd2ba72db59ffcb1c39615b802062022 Mon Sep 17 00:00:00 2001 From: Aurelien Aptel Date: Wed, 22 Apr 2020 15:58:57 +0200 Subject: [PATCH 1/4] cifs: multichannel: move channel selection in function This commit moves channel picking code in separate function. Signed-off-by: Aurelien Aptel Signed-off-by: Steve French --- fs/cifs/cifsproto.h | 1 + fs/cifs/transport.c | 38 +++++++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 12a895e02db4..692822d4523a 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -95,6 +95,7 @@ extern int cifs_call_async(struct TCP_Server_Info *server, mid_receive_t *receive, mid_callback_t *callback, mid_handle_t *handle, void *cbdata, const int flags, const struct cifs_credits *exist_credits); +extern struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses); extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, struct smb_rqst *rqst, int *resp_buf_type, const int flags, struct kvec *resp_iov); diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index c97570eb2c18..6be293ddba72 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -993,6 +993,32 @@ cifs_cancelled_callback(struct mid_q_entry *mid) DeleteMidQEntry(mid); } +/* + * Return a channel (master if none) of @ses that can be used to send + * regular requests. + * + * If we are currently binding a new channel (negprot/sess.setup), + * return the new incomplete channel. + */ +struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses) +{ + uint index = 0; + + if (!ses) + return NULL; + + if (!ses->binding) { + /* round robin */ + if (ses->chan_count > 1) { + index = (uint)atomic_inc_return(&ses->chan_seq); + index %= ses->chan_count; + } + return ses->chans[index].server; + } else { + return cifs_ses_server(ses); + } +} + int compound_send_recv(const unsigned int xid, struct cifs_ses *ses, const int flags, const int num_rqst, struct smb_rqst *rqst, @@ -1018,17 +1044,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, return -EIO; } - if (!ses->binding) { - uint index = 0; - - if (ses->chan_count > 1) { - index = (uint)atomic_inc_return(&ses->chan_seq); - index %= ses->chan_count; - } - server = ses->chans[index].server; - } else { - server = cifs_ses_server(ses); - } + server = cifs_pick_channel(ses); if (server->tcpStatus == CifsExiting) return -ENOENT; -- 2.20.1