From patchwork Fri Feb 1 20:04:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10793681 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 DEBA3186E for ; Fri, 1 Feb 2019 20:04:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0C0432C9E for ; Fri, 1 Feb 2019 20:04:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C558F330BE; Fri, 1 Feb 2019 20:04:49 +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 65E4D32E44 for ; Fri, 1 Feb 2019 20:04:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730805AbfBAUEt (ORCPT ); Fri, 1 Feb 2019 15:04:49 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34484 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730787AbfBAUEs (ORCPT ); Fri, 1 Feb 2019 15:04:48 -0500 Received: by mail-pg1-f194.google.com with SMTP id j10so3437999pga.1 for ; Fri, 01 Feb 2019 12:04:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=S/XOWhkw0eO5pCMeHogTi4vaXlPRpWPK6e3BkJEqpvo=; b=hEpnlQycXO9qrO/7MUmuDCXdLp5DkXBnupdfk8nmUutJMqdR4vZ6xJvduY/JidB3hr /bARpcDJOtOF30kFJKEQx/uaHZzpRNShJTPmEz+HF3Mk2bv+OctpwTG61G98dcBu5bLf /ELlwMvlwaXY83Z7TDDx5FKvgAAmxl0ELMwup4K+//fCifyba1aWaZeXoyADoZ6t+uyE dSi8cpYHIekCQYHxgD0eRYPoYEqNcoeoMXd0OYbU2dKtd4LYXKljmPqEpz2EXC9CmlqG k7DF8prmsYkDsURAFmm0HMx6J/+I/6zn6tycraGTJQxua5KWh0Xrqk+ZSSp/jmbR0/ir plZw== 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:in-reply-to :references; bh=S/XOWhkw0eO5pCMeHogTi4vaXlPRpWPK6e3BkJEqpvo=; b=aqx8W+8x6vlIfCmhfXVAhf6PHNwGibkKpza9XOQvsyqlt0wqEGvkDs/yY+6Y288bya PfousPEaX40gafXwYb4dwjHYYn/ySrWX6njkGduy2PKvqsbVZ+GEDCwgMj1e0r2yWCXa /p2rJMviJInHd3rY4La+OBvbjyoqc4sGHggAA3a/HHLuEzpoz80dW3LVEUPzGu6PoQL0 NYq1prh8Lqn6RIvZOWp4HAkB/qwRo1uY2i2m9//iq7NaG+p2Br9Oneg86warbEjFdHkN puiqMCHAMX1aicdu96AgL3PAPblYEgUQdlu4VlcrNdugoz5cxMAvKRj7Q0gj05VUHo07 SkSA== X-Gm-Message-State: AJcUukf1xmn8MZTnrnL/t6HsDYIuxJv+7vutbwQd9FhhhDSdFUOksGB8 tkky8JuG4soBmSpB/T0wGQR8Cs0= X-Google-Smtp-Source: ALg8bN4IjHJ2qB8E3CatqL0uKaXNlLALOmxSlGS7cDUG1RVlFyqJbriyBsS8o/KA1ApQf6Ntze/u9w== X-Received: by 2002:a62:c302:: with SMTP id v2mr41088896pfg.155.1549051487376; Fri, 01 Feb 2019 12:04:47 -0800 (PST) Received: from ubuntu-vm.corp.microsoft.com ([2001:4898:80e8:0:a18e:4e9f:6b7c:507d]) by smtp.gmail.com with ESMTPSA id x11sm24247451pfe.72.2019.02.01.12.04.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Feb 2019 12:04:46 -0800 (PST) From: Pavel Shilovsky X-Google-Original-From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 18/23] CIFS: Reopen file before get SMB2 MTU credits for async IO Date: Fri, 1 Feb 2019 12:04:07 -0800 Message-Id: <1549051452-5968-20-git-send-email-pshilov@microsoft.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549051452-5968-1-git-send-email-pshilov@microsoft.com> References: <1549051452-5968-1-git-send-email-pshilov@microsoft.com> 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 Currently we get MTU credits before we check an open file if it needs to be reopened. Reopening the file in such conditions leads to a possibility of being stuck waiting indefinitely for credits in the transport layer. Fix this by reopening the file first if needed and then getting MTU credits for async IO. Signed-off-by: Pavel Shilovsky Signed-off-by: Steve French --- fs/cifs/file.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index e793b55..ef85a3c 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2650,6 +2650,14 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, struct cifs_credits credits_on_stack; struct cifs_credits *credits = &credits_on_stack; + if (open_file->invalidHandle) { + rc = cifs_reopen_file(open_file, false); + if (rc == -EAGAIN) + continue; + else if (rc) + break; + } + rc = server->ops->wait_mtu_credits(server, cifs_sb->wsize, &wsize, credits); if (rc) @@ -2751,9 +2759,8 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, if (!rc) { if (wdata->cfile->invalidHandle) - rc = cifs_reopen_file(wdata->cfile, false); - - if (!rc) + rc = -EAGAIN; + else rc = server->ops->async_writev(wdata, cifs_uncached_writedata_release); } @@ -3355,6 +3362,14 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, iov_iter_advance(&direct_iov, offset - ctx->pos); do { + if (open_file->invalidHandle) { + rc = cifs_reopen_file(open_file, true); + if (rc == -EAGAIN) + continue; + else if (rc) + break; + } + rc = server->ops->wait_mtu_credits(server, cifs_sb->rsize, &rsize, credits); if (rc) @@ -3438,9 +3453,8 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, if (!rc) { if (rdata->cfile->invalidHandle) - rc = cifs_reopen_file(rdata->cfile, true); - - if (!rc) + rc = -EAGAIN; + else rc = server->ops->async_readv(rdata); } @@ -4129,6 +4143,14 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, struct cifs_credits credits_on_stack; struct cifs_credits *credits = &credits_on_stack; + if (open_file->invalidHandle) { + rc = cifs_reopen_file(open_file, true); + if (rc == -EAGAIN) + continue; + else if (rc) + break; + } + rc = server->ops->wait_mtu_credits(server, cifs_sb->rsize, &rsize, credits); if (rc) @@ -4187,9 +4209,8 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, if (!rc) { if (rdata->cfile->invalidHandle) - rc = cifs_reopen_file(rdata->cfile, true); - - if (!rc) + rc = -EAGAIN; + else rc = server->ops->async_readv(rdata); }