Skip to content

Commit 83f2c45

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
NFS: Remove unnecessary inode locking in nfs_llseek_dir()
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> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 6c2190b commit 83f2c45

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

fs/nfs/dir.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,6 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx)
955955

956956
static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence)
957957
{
958-
struct inode *inode = file_inode(filp);
959958
struct nfs_open_dir_context *dir_ctx = filp->private_data;
960959

961960
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)
967966
case SEEK_SET:
968967
if (offset < 0)
969968
return -EINVAL;
970-
inode_lock(inode);
969+
spin_lock(&filp->f_lock);
971970
break;
972971
case SEEK_CUR:
973972
if (offset == 0)
974973
return filp->f_pos;
975-
inode_lock(inode);
974+
spin_lock(&filp->f_lock);
976975
offset += filp->f_pos;
977976
if (offset < 0) {
978-
inode_unlock(inode);
977+
spin_unlock(&filp->f_lock);
979978
return -EINVAL;
980979
}
981980
}
@@ -987,7 +986,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence)
987986
dir_ctx->dir_cookie = 0;
988987
dir_ctx->duped = 0;
989988
}
990-
inode_unlock(inode);
989+
spin_unlock(&filp->f_lock);
991990
return offset;
992991
}
993992

0 commit comments

Comments
 (0)