Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2008627pxb; Sat, 7 Nov 2020 06:14:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTNy4pov1wLlNncoVj5t4PBlr7422kKyABDTqbAX4oy0G2Gh7R823ZBc0DDAEGPtUq+HRf X-Received: by 2002:a50:a6d0:: with SMTP id f16mr6791022edc.135.1604758457138; Sat, 07 Nov 2020 06:14:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604758457; cv=none; d=google.com; s=arc-20160816; b=recQ/Uynzj83JyEaQZv9dIL4B37Ea3Pa3q2pviJLcHHPAk1od6kzHLz5tcMt7MgUrq bYFmaGFouKtZ4W24t+t1a1vIbqAnj6g77f6pCJeUd1OzKFvZQ8X5sn2VCiunsmOObgey 6vjuqOyWQZOEh6WoIRdGC4RqRKcvfcl/CHpmc7atYz9iVDLwOHCeQf8FqtYOmo+ckS7E Ks0BTqXZcc932sQrfbRfiuKMu+DO1buUUpz2mKy9GEg0nxR9+Jl+nvTyA+aZzbIbfCQl 7Gxjt7qgOQqBR8yBdP68usPIwRnO7OXM0FohChMu4nzMVHLG+LAK/njxggnEkHNTXjZx 8WAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1veQ+PGupoh7aTARctQQ3OK8efxlHeyC0E/+k4Z55fQ=; b=grJa0nc4grpNhvXDak7MPFalI1QNM6Wp2Rh54q1M1aMkLbGBx6zUp/sZeXwJbH3IE4 9RD8LupKnW2j5OWsW3alD0txnwPLnRiJGYWsUof8P44kLkM+6jdctHMx3DevAGLAJ47z vzTccFYpxPlDjCfkZTPszwGJy8zEmKlKzIsPZLtr6UOvlZ5WuyvLX2ycTH861Be3Rq2i 433WYmIkzvmwxOYUmJ62xzX5T4ZEDHTiv3bf5nKtamvSpCZWrrLNpg7k4LH/vhebz0/F 68+5F3y6m5Uc83I7mSVAJYklNYTQJyuhQMJ5D/ASEUlc2FpTYoz5fMeIHNBKIlHuxTE+ S9Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PRUDSfyW; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo6si3255469edb.67.2020.11.07.06.13.42; Sat, 07 Nov 2020 06:14:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PRUDSfyW; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725798AbgKGONh (ORCPT + 99 others); Sat, 7 Nov 2020 09:13:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:58208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbgKGONh (ORCPT ); Sat, 7 Nov 2020 09:13:37 -0500 Received: from localhost.localdomain (c-68-36-133-222.hsd1.mi.comcast.net [68.36.133.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D6BD20719 for ; Sat, 7 Nov 2020 14:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604758416; bh=ScIdmztlvC5lGaF8OhAEJdAQTYeDvTVf/YgYH6yqrBA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PRUDSfyWt1rv+UpRD92PcIq4okUMxx7Gwq+lQs0sxIH4ahkPYUZmBuFVdXY8FpEQn fl/lqk0JfnCycC4M9Oc23YbSIetUU73WgXFCRWt2ppItdteXGi7+oB60d72fGqKwqi iLEoIxn9+tGKEmDH5QAWRT/KROiQrMl59Mogce2M= From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v4 01/21] NFS: Remove unnecessary inode locking in nfs_llseek_dir() Date: Sat, 7 Nov 2020 09:03:05 -0500 Message-Id: <20201107140325.281678-2-trondmy@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201107140325.281678-1-trondmy@kernel.org> References: <20201107140325.281678-1-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Remove the contentious inode lock, and instead provide thread safety using the file->f_lock spinlock. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index cb52db9a0cfb..e56b1bd99537 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -955,7 +955,6 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence) { - struct inode *inode = file_inode(filp); struct nfs_open_dir_context *dir_ctx = filp->private_data; dfprintk(FILE, "NFS: llseek dir(%pD2, %lld, %d)\n", @@ -967,15 +966,15 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence) case SEEK_SET: if (offset < 0) return -EINVAL; - inode_lock(inode); + spin_lock(&filp->f_lock); break; case SEEK_CUR: if (offset == 0) return filp->f_pos; - inode_lock(inode); + spin_lock(&filp->f_lock); offset += filp->f_pos; if (offset < 0) { - inode_unlock(inode); + spin_unlock(&filp->f_lock); return -EINVAL; } } @@ -987,7 +986,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence) dir_ctx->dir_cookie = 0; dir_ctx->duped = 0; } - inode_unlock(inode); + spin_unlock(&filp->f_lock); return offset; } -- 2.28.0