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: 1027862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; 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.b="lW+R259j"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43hLP82p5Cz9sDB for ; Sat, 19 Jan 2019 12:50:36 +1100 (AEDT) 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 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);