From patchwork Fri Oct 30 21:57:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11870905 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D7ED14B2 for ; Fri, 30 Oct 2020 22:07:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F131722227 for ; Fri, 30 Oct 2020 22:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604095663; bh=ScIdmztlvC5lGaF8OhAEJdAQTYeDvTVf/YgYH6yqrBA=; h=From:To:Subject:Date:List-ID:From; b=UxqQIn/n+eFBxuQwNDQUhUWP4U2b06XKKZOld/BuSHF8Ys4UGd6WOi6cDKutNJ+H3 mRS/u7f+tme7Q9BrExo4Bijt6qJgqT2s0N6u/9XUt2jyvjRO7jCyTE3VzWwpcej+Nj kwBrkouSux9ktOEH0MMikdhqf48hxNqrgCwnnG4s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725797AbgJ3WHm (ORCPT ); Fri, 30 Oct 2020 18:07:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:58808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725792AbgJ3WHm (ORCPT ); Fri, 30 Oct 2020 18:07:42 -0400 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 57AEC2087E for ; Fri, 30 Oct 2020 22:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604095661; bh=ScIdmztlvC5lGaF8OhAEJdAQTYeDvTVf/YgYH6yqrBA=; h=From:To:Subject:Date:From; b=qwabaBBd/yaNsyAlGDinsHd8wDxbh4Q/tKgPToVHuOK0kjcOXLZKh680pL9XFeF4G Pmgj87cBm+w4xbczOGSWdbT4kVljbtmbZHzsKDFn5B41fdHRTIjpxWgP+BymUVLqEQ 4D+kIXKuXp6GZCs/ld8yWZuDxaUZ79u1F7/qsKok= From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 1/2] NFS: Remove unnecessary inode locking in nfs_llseek_dir() Date: Fri, 30 Oct 2020 17:57:29 -0400 Message-Id: <20201030215730.85147-1-trondmy@kernel.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 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 Reviewed-by: Benjamin Coddington --- 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; } From patchwork Fri Oct 30 21:57:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11870907 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BE0461C for ; Fri, 30 Oct 2020 22:07:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C37422227 for ; Fri, 30 Oct 2020 22:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604095663; bh=MOBmL2uL4txSencAZUUeyuOlu/ZATH07W1xk5scpDbw=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=ofwrT1FvT/UkVnWupJsOWHb0OJwKMsuxdaZS3e/VuG6jVNiddGD5c3RB5RvmdAepv oWclQneq4vAfALY3sWvfnCDEflYBt3xllgM7HcKzzC7eFWjsLmwoTsrEFGsehhyt1B guh/A6wthhEBSGhxTPhVVatOD/9tKGkovZqTGoH0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725914AbgJ3WHm (ORCPT ); Fri, 30 Oct 2020 18:07:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:58810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725792AbgJ3WHm (ORCPT ); Fri, 30 Oct 2020 18:07:42 -0400 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 D2B8322227 for ; Fri, 30 Oct 2020 22:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604095662; bh=MOBmL2uL4txSencAZUUeyuOlu/ZATH07W1xk5scpDbw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SR1kYCq4JgZuWtsceH5oAI/VbgCf4DMaX1P3n4E08iexNHd1Bwl6DUF5lUrMbc3BS sgKPgNYH4KTtMrbdn3O/99MPWSt8ys0C9O0TS7LU/cosQO2NAGrYd2gsMbN5iCGI5g aIXSyfaoL2C4SIIaArvBJ1pS7kz6ENIbJ/ddAlbE= From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 2/2] NFS: Remove unnecessary inode lock in nfs_fsync_dir() Date: Fri, 30 Oct 2020 17:57:30 -0400 Message-Id: <20201030215730.85147-2-trondmy@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030215730.85147-1-trondmy@kernel.org> References: <20201030215730.85147-1-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust nfs_inc_stats() is already thread-safe, and there are no other reasons to hold the inode lock here. Signed-off-by: Trond Myklebust Reviewed-by: Benjamin Coddington --- fs/nfs/dir.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index e56b1bd99537..4e011adaf967 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -997,13 +997,9 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence) static int nfs_fsync_dir(struct file *filp, loff_t start, loff_t end, int datasync) { - struct inode *inode = file_inode(filp); - dfprintk(FILE, "NFS: fsync dir(%pD2) datasync %d\n", filp, datasync); - inode_lock(inode); - nfs_inc_stats(inode, NFSIOS_VFSFSYNC); - inode_unlock(inode); + nfs_inc_stats(file_inode(filp), NFSIOS_VFSFSYNC); return 0; }