mirror of
https://github.com/torvalds/linux.git
synced 2025-04-12 16:47:42 +00:00
NLM/NFSD: Fix lock notifications for async-capable filesystems
Instead of checking just the exportfs flag, use the new locks_can_async_lock() helper which allows NLM and NFSD to once again support lock notifications for all filesystems which use posix_lock_file(). Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Link: https://lore.kernel.org/r/865c40da44af67939e8eb560d17a26c9c50f23e0.1726083391.git.bcodding@redhat.com Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
2253ab99f2
commit
7e64c5bc49
@ -30,7 +30,6 @@
|
|||||||
#include <linux/sunrpc/svc_xprt.h>
|
#include <linux/sunrpc/svc_xprt.h>
|
||||||
#include <linux/lockd/nlm.h>
|
#include <linux/lockd/nlm.h>
|
||||||
#include <linux/lockd/lockd.h>
|
#include <linux/lockd/lockd.h>
|
||||||
#include <linux/exportfs.h>
|
|
||||||
|
|
||||||
#define NLMDBG_FACILITY NLMDBG_SVCLOCK
|
#define NLMDBG_FACILITY NLMDBG_SVCLOCK
|
||||||
|
|
||||||
@ -481,7 +480,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
|
|||||||
struct nlm_host *host, struct nlm_lock *lock, int wait,
|
struct nlm_host *host, struct nlm_lock *lock, int wait,
|
||||||
struct nlm_cookie *cookie, int reclaim)
|
struct nlm_cookie *cookie, int reclaim)
|
||||||
{
|
{
|
||||||
struct inode *inode = nlmsvc_file_inode(file);
|
struct inode *inode __maybe_unused = nlmsvc_file_inode(file);
|
||||||
struct nlm_block *block = NULL;
|
struct nlm_block *block = NULL;
|
||||||
int error;
|
int error;
|
||||||
int mode;
|
int mode;
|
||||||
@ -496,7 +495,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
|
|||||||
(long long)lock->fl.fl_end,
|
(long long)lock->fl.fl_end,
|
||||||
wait);
|
wait);
|
||||||
|
|
||||||
if (!exportfs_lock_op_is_async(inode->i_sb->s_export_op)) {
|
if (!locks_can_async_lock(nlmsvc_file_file(file)->f_op)) {
|
||||||
async_block = wait;
|
async_block = wait;
|
||||||
wait = 0;
|
wait = 0;
|
||||||
}
|
}
|
||||||
@ -550,7 +549,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
|
|||||||
* requests on the underlaying ->lock() implementation but
|
* requests on the underlaying ->lock() implementation but
|
||||||
* only one nlm_block to being granted by lm_grant().
|
* only one nlm_block to being granted by lm_grant().
|
||||||
*/
|
*/
|
||||||
if (exportfs_lock_op_is_async(inode->i_sb->s_export_op) &&
|
if (locks_can_async_lock(nlmsvc_file_file(file)->f_op) &&
|
||||||
!list_empty(&block->b_list)) {
|
!list_empty(&block->b_list)) {
|
||||||
spin_unlock(&nlm_blocked_lock);
|
spin_unlock(&nlm_blocked_lock);
|
||||||
ret = nlm_lck_blocked;
|
ret = nlm_lck_blocked;
|
||||||
|
@ -7953,9 +7953,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
|||||||
fp = lock_stp->st_stid.sc_file;
|
fp = lock_stp->st_stid.sc_file;
|
||||||
switch (lock->lk_type) {
|
switch (lock->lk_type) {
|
||||||
case NFS4_READW_LT:
|
case NFS4_READW_LT:
|
||||||
if (nfsd4_has_session(cstate) ||
|
|
||||||
exportfs_lock_op_is_async(sb->s_export_op))
|
|
||||||
flags |= FL_SLEEP;
|
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case NFS4_READ_LT:
|
case NFS4_READ_LT:
|
||||||
spin_lock(&fp->fi_lock);
|
spin_lock(&fp->fi_lock);
|
||||||
@ -7966,9 +7963,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
|||||||
type = F_RDLCK;
|
type = F_RDLCK;
|
||||||
break;
|
break;
|
||||||
case NFS4_WRITEW_LT:
|
case NFS4_WRITEW_LT:
|
||||||
if (nfsd4_has_session(cstate) ||
|
|
||||||
exportfs_lock_op_is_async(sb->s_export_op))
|
|
||||||
flags |= FL_SLEEP;
|
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case NFS4_WRITE_LT:
|
case NFS4_WRITE_LT:
|
||||||
spin_lock(&fp->fi_lock);
|
spin_lock(&fp->fi_lock);
|
||||||
@ -7988,15 +7982,10 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (lock->lk_type & (NFS4_READW_LT | NFS4_WRITEW_LT) &&
|
||||||
* Most filesystems with their own ->lock operations will block
|
nfsd4_has_session(cstate) &&
|
||||||
* the nfsd thread waiting to acquire the lock. That leads to
|
locks_can_async_lock(nf->nf_file->f_op))
|
||||||
* deadlocks (we don't want every nfsd thread tied up waiting
|
flags |= FL_SLEEP;
|
||||||
* for file locks), so don't attempt blocking lock notifications
|
|
||||||
* on those filesystems:
|
|
||||||
*/
|
|
||||||
if (!exportfs_lock_op_is_async(sb->s_export_op))
|
|
||||||
flags &= ~FL_SLEEP;
|
|
||||||
|
|
||||||
nbl = find_or_allocate_block(lock_sop, &fp->fi_fhandle, nn);
|
nbl = find_or_allocate_block(lock_sop, &fp->fi_fhandle, nn);
|
||||||
if (!nbl) {
|
if (!nbl) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user