From patchwork Fri Feb 1 20:04:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10793683 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 863021390 for ; Fri, 1 Feb 2019 20:04:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77EAD32C9E for ; Fri, 1 Feb 2019 20:04:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C9F3330BE; Fri, 1 Feb 2019 20:04:51 +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 10A8A32C9E for ; Fri, 1 Feb 2019 20:04:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730836AbfBAUEu (ORCPT ); Fri, 1 Feb 2019 15:04:50 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:32856 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730787AbfBAUEu (ORCPT ); Fri, 1 Feb 2019 15:04:50 -0500 Received: by mail-pf1-f194.google.com with SMTP id c123so3755729pfb.0 for ; Fri, 01 Feb 2019 12:04:49 -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=k3DR/GJI3ri84dMwIWJ8jof776E4fIH2W50KfxxDMCE=; b=FuRFkWZyR29Adp156Wan0rGaCzXWXr2Tn3yC4vXbhN44/XXbUXJw5i7NSTG7iMDtpA LCoq6IQGkUFJ+ikOC3OJ6Nc4Imw+mCnRq4h4iEFcx/7ApBfv42Yp/n7hCc4CZzvyRzsB 6OirGrA8S1IGC2tgiABQdBgSVZrUaDhASm9mNiHMdu1Ofvssn3YFcy24/TRUjRquNyT0 edAUDgmdJUVnib0K95kD31YkRcvQUxhELIBMntKLDyFsQ04vxWKHYRqUH2+gSTLswQ47 wshtumWpFG1rHrtteiyEDfElaEVhTbq3bw6okvcIDExNdIejqI/RfT2loOJhaOkDumq3 aleQ== 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=k3DR/GJI3ri84dMwIWJ8jof776E4fIH2W50KfxxDMCE=; b=SUGs0lH4kWrYLehdQrVgxGkteoDrKCYUyiGooLuQDEUmqIz/g1pZl3k3EG5k2e/0Rj EKHC7H8o4EWsLPIymfWfJtAcarCOzW/XCn/2YTIQH58M69037aldHXqV7V2jqr8gnZD+ XUQL0/VwDYaEKQPcjdEKlcVzUvDZGRws6urzaqwy02yt4bjLP/Usq0RPMhejBDEtWdBY afoIiq22OPZj9XUjDI909bcBgrjslum00V1vXnPR1IJeV6RvLSminYWG/k4g4vmmxArG tyWydATYGa11NVjomw4Fj8E0xY7XUdmhUVveejn/Lx0EpU3/HGWPP8a0ZxEdiP5BrN23 4oiA== X-Gm-Message-State: AJcUukcELPNJrTNFz3qzU7a4GKoHY1eEzUArwzsP5GZlyKBC7hAfv4P8 QO4DAmFJTsej+BAqjQVA9xEoz3A= X-Google-Smtp-Source: ALg8bN7WS7y6vS8yLczX4gH01Sq9PKJ5f2aQ50VA1UnR1BejOdxWOBUFoq+u9LU18cXor3gPuybeYg== X-Received: by 2002:a62:509b:: with SMTP id g27mr41121602pfj.48.1549051488540; Fri, 01 Feb 2019 12:04:48 -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.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Feb 2019 12:04:47 -0800 (PST) From: Pavel Shilovsky X-Google-Original-From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 19/23] CIFS: Find and reopen a file before get MTU credits in writepages Date: Fri, 1 Feb 2019 12:04:08 -0800 Message-Id: <1549051452-5968-21-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 Reorder finding and reopening a writable handle file and getting MTU credits in writepages because we may be stuck on low credits otherwise. Signed-off-by: Pavel Shilovsky Signed-off-by: Steve French --- fs/cifs/file.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index ef85a3c..dd8bf69 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2096,15 +2096,16 @@ wdata_send_pages(struct TCP_Server_Info *server, struct cifs_writedata *wdata, if (rc) goto send_pages_out; - if (wdata->cfile != NULL) - cifsFileInfo_put(wdata->cfile); - wdata->cfile = find_writable_file(CIFS_I(mapping->host), false); if (!wdata->cfile) { - cifs_dbg(VFS, "No writable handles for inode\n"); + cifs_dbg(VFS, "No writable handle in writepages\n"); rc = -EBADF; } else { wdata->pid = wdata->cfile->pid; - rc = server->ops->async_writev(wdata, cifs_writedata_release); + if (wdata->cfile->invalidHandle) + rc = -EAGAIN; + else + rc = server->ops->async_writev(wdata, + cifs_writedata_release); } send_pages_out: @@ -2117,11 +2118,13 @@ wdata_send_pages(struct TCP_Server_Info *server, struct cifs_writedata *wdata, static int cifs_writepages(struct address_space *mapping, struct writeback_control *wbc) { - struct cifs_sb_info *cifs_sb = CIFS_SB(mapping->host->i_sb); + struct inode *inode = mapping->host; + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); struct TCP_Server_Info *server; bool done = false, scanned = false, range_whole = false; pgoff_t end, index; struct cifs_writedata *wdata; + struct cifsFileInfo *cfile = NULL; int rc = 0; int saved_rc = 0; unsigned int xid; @@ -2152,6 +2155,11 @@ static int cifs_writepages(struct address_space *mapping, struct cifs_credits credits_on_stack; struct cifs_credits *credits = &credits_on_stack; + if (cfile) + cifsFileInfo_put(cfile); + + cfile = find_writable_file(CIFS_I(inode), false); + rc = server->ops->wait_mtu_credits(server, cifs_sb->wsize, &wsize, credits); if (rc != 0) { @@ -2187,6 +2195,8 @@ static int cifs_writepages(struct address_space *mapping, } wdata->credits = credits_on_stack; + wdata->cfile = cfile; + cfile = NULL; rc = wdata_send_pages(server, wdata, nr_pages, mapping, wbc); @@ -2244,6 +2254,8 @@ static int cifs_writepages(struct address_space *mapping, if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) mapping->writeback_index = index; + if (cfile) + cifsFileInfo_put(cfile); free_xid(xid); return rc; }