From patchwork Sat Jan 19 01:50:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10771903 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 471251390 for ; Sat, 19 Jan 2019 01:50:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B0D02FE8F for ; Sat, 19 Jan 2019 01:50:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F0772FEA8; Sat, 19 Jan 2019 01:50:36 +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 B3D5C2FE8F for ; Sat, 19 Jan 2019 01:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727422AbfASBuf (ORCPT ); Fri, 18 Jan 2019 20:50:35 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33975 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727256AbfASBuf (ORCPT ); Fri, 18 Jan 2019 20:50:35 -0500 Received: by mail-pf1-f195.google.com with SMTP id h3so7455633pfg.1 for ; Fri, 18 Jan 2019 17:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=HFXV3iFWqSoM52hiRBot4cYgK3HO5CIhpICYBzC9vHc=; b=lW+R259jTyjqs+p/FBbM3gR8jg+0MlUu7dWzPYjVbF/x9zJNA270yEwrHqfpJokz/e xhaJ3tkFkGmLk0XSZD34u5YXwGFI3pDdtlDlCebXnaWsJ6pR3OqJHxu7uFTfSrAONdoo 7kZdHhe4TNPRZBx9tMQYwwQS4RJZazAForEDzgDw0GrUcOKxrRJVHZBG8nKc8aOGoUsh qH54LiYIgToIsAt7PzpzD6eUuJQdrNp+jAAskmh+lKWaDIEsdDKUEXqYpgZdigEosmta CZKDlNnvHLpA24LQ/3q1VM6SJ72AQfixg2kgYObu3kVXRu68hCpysdC/EBoRnWhorim1 wfVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=HFXV3iFWqSoM52hiRBot4cYgK3HO5CIhpICYBzC9vHc=; b=SO54XDMP0jSm9sHrjeA0VVOn4hX0VAjdv158r9q1ybTtxJ8U2gGhehtscXRsqXwo3a MjO+xzjXZB0tMP4ICBn0Eyjm8aWBurPYZEKN2aYhZVNPbElxOMPIoe78BRmwSbKsTYkq S3bT/ED1w7P+rEMDrpuzgTdA0t30JEIDbHq4pwWRzWQq1rwXPe7Kg6E+IBJBlX728M4o qUTyh0yGJbEqrRmbEk3eUdRfWHELaMNoj+DJ56PqmvkQ2z7Zi5RHnLrzztI3s/rbImwv vAgg393pub7TEj7IStKalk1k/qlffRnrIPSjkBbpQA8xSRCi6MTFrQfCJeuOUkYGEXgl EAhw== X-Gm-Message-State: AJcUukeQXU5Zm/88mjz5bZ9DeJgSAarMKhFarehLusItaLiKTGZAhCSS e4QQoHDpg9JF8n1c7I40ew== X-Google-Smtp-Source: ALg8bN7RJUQEwpQ1WjglBxr4vIcz5gXP4GvWBIAjJAEfWke6+ndWwXCyL6/2v2i5l1AyTEVQdsz0aA== X-Received: by 2002:a62:b15:: with SMTP id t21mr22317756pfi.136.1547862634317; Fri, 18 Jan 2019 17:50:34 -0800 (PST) Received: from ubuntu-vm.corp.microsoft.com ([2001:4898:80e8:8:a186:4e9f:6b7c:507d]) by smtp.gmail.com with ESMTPSA id m65sm16891439pfg.180.2019.01.18.17.50.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Jan 2019 17:50:33 -0800 (PST) From: Pavel Shilovsky X-Google-Original-From: Pavel Shilovsky To: Steve French , linux-cifs@vger.kernel.org Subject: [PATCH] CIFS: Fix possible hang duing async MTU reads and writes Date: Fri, 18 Jan 2019 17:50:26 -0800 Message-Id: <1547862626-18425-1-git-send-email-pshilov@microsoft.com> X-Mailer: git-send-email 2.7.4 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 When doing MTU i/o we need to leave some credits for possible reopen requests and other operations happening in parallel. Currently we leave 1 credit which is not enough even for reopen only: we need at least 2 credits if durable handle reconnect fails. Also there may be other operations at the same time including compounding ones which require 3 credits at a time each. Fix this by leaving 8 credits which is big enough to cover most scenarios. The proper fix would be to reconnect a file handle first and then obtain credits for an MTU request but this leads to bigger code changes and should happen in other patches. Cc: Signed-off-by: Pavel Shilovsky --- fs/cifs/smb2ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 238b16d..82967f6 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -165,14 +165,14 @@ smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size, scredits = server->credits; /* can deadlock with reopen */ - if (scredits == 1) { + if (scredits <= 8) { *num = SMB2_MAX_BUFFER_SIZE; *credits = 0; break; } - /* leave one credit for a possible reopen */ - scredits--; + /* leave some credits for reopen and other ops */ + scredits -= 8; *num = min_t(unsigned int, size, scredits * SMB2_MAX_BUFFER_SIZE);