linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] NFS: Remove unnecessary inode locking in nfs_llseek_dir()
@ 2020-10-30 21:57 trondmy
  2020-10-30 21:57 ` [PATCH 2/2] NFS: Remove unnecessary inode lock in nfs_fsync_dir() trondmy
  2020-11-03 11:13 ` [PATCH 1/2] NFS: Remove unnecessary inode locking in nfs_llseek_dir() Benjamin Coddington
  0 siblings, 2 replies; 4+ messages in thread
From: trondmy @ 2020-10-30 21:57 UTC (permalink / raw)
  To: linux-nfs

From: Trond Myklebust <trond.myklebust@hammerspace.com>

Remove the contentious inode lock, and instead provide thread safety
using the file->f_lock spinlock.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] NFS: Remove unnecessary inode lock in nfs_fsync_dir()
  2020-10-30 21:57 [PATCH 1/2] NFS: Remove unnecessary inode locking in nfs_llseek_dir() trondmy
@ 2020-10-30 21:57 ` trondmy
  2020-11-03 11:14   ` Benjamin Coddington
  2020-11-03 11:13 ` [PATCH 1/2] NFS: Remove unnecessary inode locking in nfs_llseek_dir() Benjamin Coddington
  1 sibling, 1 reply; 4+ messages in thread
From: trondmy @ 2020-10-30 21:57 UTC (permalink / raw)
  To: linux-nfs

From: Trond Myklebust <trond.myklebust@hammerspace.com>

nfs_inc_stats() is already thread-safe, and there are no other reasons
to hold the inode lock here.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 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;
 }
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] NFS: Remove unnecessary inode locking in nfs_llseek_dir()
  2020-10-30 21:57 [PATCH 1/2] NFS: Remove unnecessary inode locking in nfs_llseek_dir() trondmy
  2020-10-30 21:57 ` [PATCH 2/2] NFS: Remove unnecessary inode lock in nfs_fsync_dir() trondmy
@ 2020-11-03 11:13 ` Benjamin Coddington
  1 sibling, 0 replies; 4+ messages in thread
From: Benjamin Coddington @ 2020-11-03 11:13 UTC (permalink / raw)
  To: trondmy; +Cc: linux-nfs

On 30 Oct 2020, at 17:57, trondmy@kernel.org wrote:

> From: Trond Myklebust <trond.myklebust@hammerspace.com>
>
> Remove the contentious inode lock, and instead provide thread safety
> using the file->f_lock spinlock.
>
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Reviewed-by: Benjamin Coddington <bcodding@redhat.com>

Ben


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] NFS: Remove unnecessary inode lock in nfs_fsync_dir()
  2020-10-30 21:57 ` [PATCH 2/2] NFS: Remove unnecessary inode lock in nfs_fsync_dir() trondmy
@ 2020-11-03 11:14   ` Benjamin Coddington
  0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Coddington @ 2020-11-03 11:14 UTC (permalink / raw)
  To: trondmy; +Cc: linux-nfs

On 30 Oct 2020, at 17:57, trondmy@kernel.org wrote:

> From: Trond Myklebust <trond.myklebust@hammerspace.com>
>
> nfs_inc_stats() is already thread-safe, and there are no other reasons
> to hold the inode lock here.
>
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Reviewed-by: Benjamin Coddington <bcodding@redhat.com>

Ben


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-03 11:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-30 21:57 [PATCH 1/2] NFS: Remove unnecessary inode locking in nfs_llseek_dir() trondmy
2020-10-30 21:57 ` [PATCH 2/2] NFS: Remove unnecessary inode lock in nfs_fsync_dir() trondmy
2020-11-03 11:14   ` Benjamin Coddington
2020-11-03 11:13 ` [PATCH 1/2] NFS: Remove unnecessary inode locking in nfs_llseek_dir() Benjamin Coddington

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).