From patchwork Wed Jul 19 22:09:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9853259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E36B860393 for ; Wed, 19 Jul 2017 22:10:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D544328700 for ; Wed, 19 Jul 2017 22:10:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA22728717; Wed, 19 Jul 2017 22:10:06 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 6BA0028700 for ; Wed, 19 Jul 2017 22:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754199AbdGSWKF (ORCPT ); Wed, 19 Jul 2017 18:10:05 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:34778 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753354AbdGSWKE (ORCPT ); Wed, 19 Jul 2017 18:10:04 -0400 Received: by mail-io0-f194.google.com with SMTP id f66so821522iof.1 for ; Wed, 19 Jul 2017 15:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=0tPBtL9keUvNLTs1GZkxbj0io/qBexCcVC2yNO1P568=; b=ZBRbJYMU+xW/KQsqg6fZNHdkMomcWV2Ky+CiM2Gdp9zvLsE7ykyvMdH4XBUdHEjg6u rkf9fs9o9Ga3Lm9nXoeRENpH1Ps+lz9Dx2Xr+r7DHI9XZAqCSeaCSNsUi4QEpGe1AQKE apQ724hSkZQnf7GFtOEoiJGMmtBKtKzy2IUaN8UwmnYwXOD+nFTY9K645ZSJRfsW9gHV gw67UhreEetxya8wuyJBw7nJnPDJV/zfqMxGomuwwTr0FOtfYwV9EFws7svlL+P6ZMxz N3zSZoGN4LkwTIYQpQp6EkIgDJFLL3hUFiDflIjNSAT+6oP3sNMCYY7Q1Lyy/hiYsgJ+ 9AZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=0tPBtL9keUvNLTs1GZkxbj0io/qBexCcVC2yNO1P568=; b=equ77/9DH0I3kzU3dcjMjDxM19XHOOwurC6+bNUB7nc/FbO532eP9XzoXBirY+XbZj L4rJ9brj380f6fImusvtJnm05UZHzqrvoataWUpECZIgFzZOdHQYukkPBFzCkDVJWBCJ JEOjFdlNgAU5XnPR1/pzE7AAq75f/2eIvLAUG6S5UXArkxQs6G0E/BerLj4UxV6ExaSf Bd9J8cOgg09cB3Ph8XfrhaSc8Q6WZP8qGWxowIQnXSs4cDL5JFwabSmrlOkMEG/hIMmb cMwpIL8GQc9CHeDFCZtvIe38OUr6Or+2v5qB1jXj2qeBObG414U28ANRCMQtm6cETVIu op7w== X-Gm-Message-State: AIVw111p9Mk6SmoaXOKFuhWBWPnknDuJ5bq1CO7mARRagB69E+v3Z2/V 2SvaiDbism7+jw== X-Received: by 10.107.141.136 with SMTP id p130mr1564897iod.111.1500502203274; Wed, 19 Jul 2017 15:10:03 -0700 (PDT) Received: from leira.trondhjem.org (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id 9sm518333iop.9.2017.07.19.15.10.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Jul 2017 15:10:02 -0700 (PDT) From: Trond Myklebust To: Chuck Lever , linux-nfs@vger.kernel.org Subject: [PATCH 02/20] NFS: Reduce lock contention in nfs_page_find_head_request() Date: Wed, 19 Jul 2017 18:09:37 -0400 Message-Id: <20170719220955.58210-3-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170719220955.58210-2-trond.myklebust@primarydata.com> References: <20170719220955.58210-1-trond.myklebust@primarydata.com> <20170719220955.58210-2-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a lockless check for whether or not the page might be carrying an existing writeback before we grab the inode->i_lock. Reported-by: Chuck Lever Signed-off-by: Trond Myklebust --- fs/nfs/write.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 1d447e37f472..06e150c4e315 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -190,9 +190,11 @@ static struct nfs_page *nfs_page_find_head_request(struct page *page) struct inode *inode = page_file_mapping(page)->host; struct nfs_page *req = NULL; - spin_lock(&inode->i_lock); - req = nfs_page_find_head_request_locked(NFS_I(inode), page); - spin_unlock(&inode->i_lock); + if (PagePrivate(page) || PageSwapCache(page)) { + spin_lock(&inode->i_lock); + req = nfs_page_find_head_request_locked(NFS_I(inode), page); + spin_unlock(&inode->i_lock); + } return req; }