From: Jeff Layton <jlayton@kernel.org>
To: chuck.lever@oracle.com, linux-fsdevel@vger.kernel.org
Cc: trond.myklebust@hammerspace.com, linux-nfs@vger.kernel.org
Subject: [PATCH 2/3] filelock: remove redundant filp argument from vfs_test_lock
Date: Mon, 14 Nov 2022 10:02:39 -0500 [thread overview]
Message-ID: <20221114150240.198648-3-jlayton@kernel.org> (raw)
In-Reply-To: <20221114150240.198648-1-jlayton@kernel.org>
struct file_lock already has a fl_file field that must be populated, so
the @filp argument to this function is redundant. Remove it and use
fl_file instead.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/lockd/svclock.c | 4 +---
fs/locks.c | 10 +++++-----
fs/nfsd/nfs4state.c | 2 +-
include/linux/fs.h | 4 ++--
4 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index c965783b71a6..21ee6b1c4d9e 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -586,7 +586,6 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
struct nlm_lock *conflock, struct nlm_cookie *cookie)
{
int error;
- int mode;
__be32 ret;
dprintk("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n",
@@ -601,8 +600,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
goto out;
}
- mode = lock_to_openmode(&lock->fl);
- error = vfs_test_lock(file->f_file[mode], &lock->fl);
+ error = vfs_test_lock(&lock->fl);
if (error) {
/* We can't currently deal with deferred test requests */
if (error == FILE_LOCK_DEFERRED)
diff --git a/fs/locks.c b/fs/locks.c
index a38845633f73..0bc1808f7d98 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -2138,15 +2138,15 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
/**
* vfs_test_lock - test file byte range lock
- * @filp: The file to test lock for
* @fl: The lock to test; also used to hold result
*
* Returns -ERRNO on failure. Indicates presence of conflicting lock by
* setting conf->fl_type to something other than F_UNLCK.
*/
-int vfs_test_lock(struct file *filp, struct file_lock *fl)
+int vfs_test_lock(struct file_lock *fl)
{
- WARN_ON_ONCE(filp != fl->fl_file);
+ struct file *filp = fl->fl_file;
+
if (filp->f_op->lock)
return filp->f_op->lock(filp, F_GETLK, fl);
posix_test_lock(filp, fl);
@@ -2246,7 +2246,7 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock *flock)
fl->fl_owner = filp;
}
- error = vfs_test_lock(filp, fl);
+ error = vfs_test_lock(fl);
if (error)
goto out;
@@ -2453,7 +2453,7 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 *flock)
fl->fl_owner = filp;
}
- error = vfs_test_lock(filp, fl);
+ error = vfs_test_lock(fl);
if (error)
goto out;
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index eab75ba9f44d..beec9da50016 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -7537,7 +7537,7 @@ static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct
if (err)
goto out;
lock->fl_file = nf->nf_file;
- err = nfserrno(vfs_test_lock(nf->nf_file, lock));
+ err = nfserrno(vfs_test_lock(lock));
lock->fl_file = NULL;
out:
inode_unlock(inode);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 57b6eed9a44d..507fa1a61bb5 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1167,7 +1167,7 @@ extern void locks_release_private(struct file_lock *);
extern void posix_test_lock(struct file *, struct file_lock *);
extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
extern int locks_delete_block(struct file_lock *);
-extern int vfs_test_lock(struct file *, struct file_lock *);
+extern int vfs_test_lock(struct file_lock *);
extern int vfs_lock_file(unsigned int, struct file_lock *, struct file_lock *);
extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
bool vfs_file_has_locks(struct file *file);
@@ -1269,7 +1269,7 @@ static inline int locks_delete_block(struct file_lock *waiter)
return -ENOENT;
}
-static inline int vfs_test_lock(struct file *filp, struct file_lock *fl)
+static inline int vfs_test_lock(struct file_lock *fl)
{
return 0;
}
--
2.38.1
next prev parent reply other threads:[~2022-11-14 15:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 15:02 [PATCH 0/3] filelock: remove redundant filp arguments from API Jeff Layton
2022-11-14 15:02 ` [PATCH 1/3] filelock: remove redundant filp argument from vfs_lock_file Jeff Layton
2022-11-15 8:59 ` Christoph Hellwig
2022-11-14 15:02 ` Jeff Layton [this message]
2022-11-15 8:59 ` [PATCH 2/3] filelock: remove redundant filp argument from vfs_test_lock Christoph Hellwig
2022-11-14 15:02 ` [PATCH 3/3] filelock: remove redundant filp arg from vfs_cancel_lock Jeff Layton
2022-11-15 9:00 ` Christoph Hellwig
2022-11-14 15:08 ` [PATCH 0/3] filelock: remove redundant filp arguments from API Chuck Lever III
2022-11-14 15:31 ` Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221114150240.198648-3-jlayton@kernel.org \
--to=jlayton@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox