From patchwork Fri Feb 1 20:04:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10793687 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 9F70514E1 for ; Fri, 1 Feb 2019 20:04:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 910A932C9E for ; Fri, 1 Feb 2019 20:04:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 828B8330BE; Fri, 1 Feb 2019 20:04:54 +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 247D832C9E for ; Fri, 1 Feb 2019 20:04:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730896AbfBAUEx (ORCPT ); Fri, 1 Feb 2019 15:04:53 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43210 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730787AbfBAUEx (ORCPT ); Fri, 1 Feb 2019 15:04:53 -0500 Received: by mail-pl1-f196.google.com with SMTP id gn14so3733806plb.10 for ; Fri, 01 Feb 2019 12:04:53 -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=toRxBoqLZ2IHytwWefehAzDcg9toGYJnopSsVEdJtoc=; b=K/0KrO7nqd6IUz3su4qGKaZn5zhAsO/RYcGonXO/kC579HqsML8Qs7x8YmAySjscVq +0POaOd20bno1fyzhaLRdcTDk+fOMvqp9V+BrxvCb3rQhrpSmLVtWtpH37p+7bktKvXq zCiLhlu29esIUa8H4K3o1BMZChxHF0UoUyKYNKgEBNVN2Sl0L+I3WISxahCvP3jjxMh8 2ciKTaXUZMYLppYA4ESC8gjnjcF4SwAtsUZq+zvaBqL7wLiMgnsFlSLbX/HWstx1M41z iilk7nkuKoKGF0lACvtZ+o5UJ/E2PGwlflGAG8AH0QAeBa9OmhfzrEvXzT4Nz/9fxF+i ZqRw== 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=toRxBoqLZ2IHytwWefehAzDcg9toGYJnopSsVEdJtoc=; b=qhiHBEzQA9UJhvysJ4KGRHD3Hhe/UrXWjMNJBDXHE8iGxA9jVuxDSISf4wQ1E4POZj +QvNKSIJhChlC/hLaCGO18+2bUlS4sXsf3wTkHbQs0lmLWDxYfnFN3q4lsfgZrtHU16u Zv3bzyMit8F/MYQ9nDHzAlCMUqCXxFrMlCuZyhRG5fopVWzSg/p2wb1J4d4F89hsQI0x pV2LK7sNsYGrs3dl+jeGoEU9p9f23acCfnn+QJN3NMh/HqqAzU4nb6SovH3D+esu2eUh IQqbqh/CPwqQTx7IImn0xoEHt2mAKfubNdYhQBfZsXKs+KA2TIaRbraB/aZCcqVCKiyg YMTA== X-Gm-Message-State: AJcUukc03Qs/iOCcNZD8dBklbhe/+dgYYDm6OC+LAKAMtUtSCz2C6Gg1 WhYM32UD00C6SsiEoa0QdPEk4vI= X-Google-Smtp-Source: ALg8bN6HI4qalP5UKrZ7HkfXoZG/XuruNqytRipoRa1ZdOHNV2v+Vg+IwXm5ICM69XeZM+3SqFwb9A== X-Received: by 2002:a17:902:7614:: with SMTP id k20mr41543046pll.285.1549051492586; Fri, 01 Feb 2019 12:04:52 -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.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Feb 2019 12:04:51 -0800 (PST) From: Pavel Shilovsky X-Google-Original-From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 21/23] CIFS: Move open file handling to writepages Date: Fri, 1 Feb 2019 12:04:10 -0800 Message-Id: <1549051452-5968-23-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 check for an open file existence in wdata_send_pages() which doesn't provide an easy way to handle error codes that will be returned from find_writable_filehandle() once it is changed. Move the check to writepages. Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index cb37b1f..9de7ad5 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2076,11 +2076,12 @@ wdata_prepare_pages(struct cifs_writedata *wdata, unsigned int found_pages, } static int -wdata_send_pages(struct TCP_Server_Info *server, struct cifs_writedata *wdata, - unsigned int nr_pages, struct address_space *mapping, - struct writeback_control *wbc) +wdata_send_pages(struct cifs_writedata *wdata, unsigned int nr_pages, + struct address_space *mapping, struct writeback_control *wbc) { int rc; + struct TCP_Server_Info *server = + tlink_tcon(wdata->cfile->tlink)->ses->server; wdata->sync_mode = wbc->sync_mode; wdata->nr_pages = nr_pages; @@ -2090,22 +2091,16 @@ wdata_send_pages(struct TCP_Server_Info *server, struct cifs_writedata *wdata, page_offset(wdata->pages[nr_pages - 1]), (loff_t)PAGE_SIZE); wdata->bytes = ((nr_pages - 1) * PAGE_SIZE) + wdata->tailsz; + wdata->pid = wdata->cfile->pid; rc = adjust_credits(server, &wdata->credits, wdata->bytes); if (rc) return rc; - if (!wdata->cfile) { - cifs_dbg(VFS, "No writable handle in writepages\n"); - rc = -EBADF; - } else { - wdata->pid = wdata->cfile->pid; - if (wdata->cfile->invalidHandle) - rc = -EAGAIN; - else - 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); return rc; } @@ -2193,7 +2188,11 @@ static int cifs_writepages(struct address_space *mapping, wdata->cfile = cfile; cfile = NULL; - rc = wdata_send_pages(server, wdata, nr_pages, mapping, wbc); + if (!wdata->cfile) { + cifs_dbg(VFS, "No writable handle in writepages\n"); + rc = -EBADF; + } else + rc = wdata_send_pages(wdata, nr_pages, mapping, wbc); for (i = 0; i < nr_pages; ++i) unlock_page(wdata->pages[i]);