reexport lock fixes v2
Subsystems (4)
cover reexport lock fixes v2
From: "J. Bruce Fields" <[email protected]>
The following fix up some problems that can cause crashes or silently broken lock guarantees in the reexport case.
Not fixed:
- Attempts to reclaim locks after a reboot of the reexport server will fail. This at least seems like an improvement over the current situation, which is that they'll succeed even in cases where they shouldn't. Complete support for reboot recovery is a bigger job.
- NFSv4.1+ lock nofications don't work. So, clients have to poll as they do with NFSv4.0, which is suboptimal, but correct (and an improvement over the current situation, which is a kernel oops).
So what we have at this point is a suboptimal lock implementation that doesn't support lock recovery.
Another alternative might be to turn off file locking entirely in the re-export case. I'd rather take the incremental improvement and fix the oopses.
Changes since v1:
- Use ENOGRACE instead of returning NFS-specific error from vfs lock method.
- Take write opens for write locks in the NLM case (as we always have in the NFSv4 case).
- Don't block NLM threads waiting for blocking locks.
With those changes I'm passing connecthon tests for NFSv3-4.2 reexports of an NFSv4.0 filesystem.
--b.
J. Bruce Fields (8):
lockd: lockd server-side shouldn't set fl_ops
nlm: minor nlm_lookup_file argument change
nlm: minor refactoring
lockd: update nlm_lookup_file reexport comment Keep read and write fds with each nlm_file
nfs: don't atempt blocking locks on nfs reexports
lockd: don't attempt blocking locks on nfs reexports
nfs: don't allow reexport reclaims
fs/lockd/svc4proc.c | 6 +- fs/lockd/svclock.c | 80 +++++++++++++---------- fs/lockd/svcproc.c | 6 +- fs/lockd/svcsubs.c | 125 +++++++++++++++++++++++++----------- fs/nfs/export.c | 2 +- fs/nfs/file.c | 3 + fs/nfsd/lockd.c | 8 ++- fs/nfsd/nfs4state.c | 11 +++- fs/nfsd/nfsproc.c | 1 + include/linux/errno.h | 1 + include/linux/exportfs.h | 2 + include/linux/fs.h | 1 + include/linux/lockd/bind.h | 3 +- include/linux/lockd/lockd.h | 13 ++-- 14 files changed, 177 insertions(+), 85 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/8 lockd: lockd server-side shouldn't set fl_ops
From: "J. Bruce Fields" <[email protected]>
Locks have two sets of op arrays, fl_lmops for the lock manager (lockd or nfsd), fl_ops for the filesystem. The server-side lockd code has been setting its own fl_ops, which leads to confusion (and crashes) in the reexport case, where the filesystem expects to be the only one setting fl_ops.
And there's no reason for it that I can see-the lm_get/put_owner ops do the same job.
--- fs/lockd/svclock.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)
fs/lockd/svclock.c +12 -18
@@ -395,28 +395,10 @@ nlmsvc_release_lockowner(struct nlm_lock *lock)nlmsvc_put_lockowner (lock->fl.fl_owner); } -static void nlmsvc_locks_copy_lock (struct file_lock *new,struct file_lock *fl) -{ -struct nlm_lockowner *nlm_lo = (struct nlm_lockowner *)fl->fl_owner; - new->fl_owner =nlmsvc_get_lockowner (nlm_lo); -} - -static void nlmsvc_locks_release_private (struct file_lock *fl) -{ -nlmsvc_put_lockowner ((struct nlm_lockowner *)fl->fl_owner); -} - -static const struct file_lock_operations nlmsvc_lock_ops = { - .fl_copy_lock = nlmsvc_locks_copy_lock, - .fl_release_private = nlmsvc_locks_release_private, -}; -void nlmsvc_locks_init_private (struct file_lock *fl,struct nlm_host *host,pid_t pid) { fl->fl_owner =nlmsvc_find_lockowner (host, pid); -if (fl->fl_owner !=NULL ) - fl->fl_ops = &nlmsvc_lock_ops; }/*
@@ -788,9 +770,21 @@ nlmsvc_notify_blocked(struct file_lock *fl)printk (KERN_WARNING "lockd: notification for unknown block!\n" ); } +static fl_owner_t nlmsvc_get_owner (fl_owner_t owner) +{ +return nlmsvc_get_lockowner (owner); +} + +static void nlmsvc_put_owner (fl_owner_t owner) +{ +nlmsvc_put_lockowner (owner); +} +const struct lock_manager_operations nlmsvc_lock_operations = { .lm_notify = nlmsvc_notify_blocked, .lm_grant = nlmsvc_grant_deferred, + .lm_get_owner = nlmsvc_get_owner, + .lm_put_owner = nlmsvc_put_owner, };/*
Signature · 1 line
2.31.1
PATCH 2/8 nlm: minor nlm_lookup_file argument change
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
It'll come in handy to get the whole nlm_lock.
--- fs/lockd/svc4proc.c | 2 +- fs/lockd/svcproc.c | 2 +- fs/lockd/svcsubs.c | 14 +++++++------- include/linux/lockd/lockd.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-)
fs/lockd/svc4proc.c +1 -1
@@ -40,7 +40,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,/* Obtain file pointer. Not used by FREE_ALL call. */ if (filp !=NULL ) { -if ((error =nlm_lookup_file (rqstp, &file, &lock->fh)) !=0 ) +if ((error =nlm_lookup_file (rqstp, &file, lock)) !=0 ) goto no_locks; *filp = file;
fs/lockd/svcproc.c +1 -1
@@ -69,7 +69,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,/* Obtain file pointer. Not used by FREE_ALL call. */ if (filp !=NULL ) { - error =cast_status (nlm_lookup_file (rqstp, &file, &lock->fh)); + error =cast_status (nlm_lookup_file (rqstp, &file, lock));if (error !=0 ) goto no_locks; *filp = file;
fs/lockd/svcsubs.c +7 -7
@@ -82,31 +82,31 @@ static inline unsigned int file_hash(struct nfs_fh *f)*/ __be32 nlm_lookup_file (struct svc_rqst *rqstp,struct nlm_file **result, -struct nfs_fh *f) +struct nlm_lock *lock) {struct nlm_file *file;unsigned int hash;__be32 nfserr; -nlm_debug_print_fh ("nlm_lookup_file" , f); +nlm_debug_print_fh ("nlm_lookup_file" , &lock->fh); - hash =file_hash (f); + hash =file_hash (&lock->fh);/* Lock file table */ mutex_lock (&nlm_file_mutex);hlist_for_each_entry (file, &nlm_files[hash], f_list) -if (!nfs_compare_fh (&file->f_handle, f)) +if (!nfs_compare_fh (&file->f_handle, &lock->fh)) goto found; -nlm_debug_print_fh ("creating file for" , f); +nlm_debug_print_fh ("creating file for" , &lock->fh); nfserr = nlm_lck_denied_nolocks; file =kzalloc (sizeof (*file),GFP_KERNEL );if (!file) goto out_unlock; -memcpy (&file->f_handle, f,sizeof (struct nfs_fh )); +memcpy (&file->f_handle, &lock->fh,sizeof (struct nfs_fh ));mutex_init (&file->f_mutex);INIT_HLIST_NODE (&file->f_list);INIT_LIST_HEAD (&file->f_blocks);
@@ -117,7 +117,7 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,* We have to make sure we have the right credential to open * the file. */ -if ((nfserr = nlmsvc_ops->fopen (rqstp, f, &file->f_file)) !=0 ) { +if ((nfserr = nlmsvc_ops->fopen (rqstp, &lock->fh, &file->f_file)) !=0 ) {dprintk ("lockd: open failed (error %d)\n" , nfserr); goto out_free; }
include/linux/lockd/lockd.h +1 -1
@@ -286,7 +286,7 @@ void nlmsvc_locks_init_private(struct file_lock *, struct nlm_host *, pid_t);* File handling for the server personality */ __be32 nlm_lookup_file (struct svc_rqst *,struct nlm_file **, -struct nfs_fh *); +struct nlm_lock *);void nlm_release_file (struct nlm_file *);void nlmsvc_release_lockowner (struct nlm_lock *);void nlmsvc_mark_resources (struct net *);
Signature · 1 line
2.31.1
PATCH 3/8 nlm: minor refactoring
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
--- fs/lockd/svclock.c | 16 ++++++++-------- fs/lockd/svcsubs.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-)
fs/lockd/svclock.c +8 -8
@@ -474,8 +474,8 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,__be32 ret; dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n", - locks_inode(file->f_file)->i_sb->s_id, - locks_inode(file->f_file)->i_ino, + nlmsvc_file_inode(file)->i_sb->s_id, + nlmsvc_file_inode(file)->i_ino, lock->fl.fl_type, lock->fl.fl_pid, (long long)lock->fl.fl_start, (long long)lock->fl.fl_end,
@@ -581,8 +581,8 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,struct nlm_lockowner *test_owner;dprintk ("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n" , -locks_inode (file->f_file)->i_sb->s_id, -locks_inode (file->f_file)->i_ino, +nlmsvc_file_inode (file)->i_sb->s_id, +nlmsvc_file_inode (file)->i_ino, lock->fl.fl_type, (long long )lock->fl.fl_start, (long long )lock->fl.fl_end);
@@ -644,8 +644,8 @@ nlmsvc_unlock(struct net *net, struct nlm_file *file, struct nlm_lock *lock)int error;dprintk ("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n" , -locks_inode (file->f_file)->i_sb->s_id, -locks_inode (file->f_file)->i_ino, +nlmsvc_file_inode (file)->i_sb->s_id, +nlmsvc_file_inode (file)->i_ino, lock->fl.fl_pid, (long long )lock->fl.fl_start, (long long )lock->fl.fl_end);
@@ -673,8 +673,8 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *lint status =0 ;dprintk ("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n" , -locks_inode (file->f_file)->i_sb->s_id, -locks_inode (file->f_file)->i_ino, +nlmsvc_file_inode (file)->i_sb->s_id, +nlmsvc_file_inode (file)->i_ino, lock->fl.fl_pid, (long long )lock->fl.fl_start, (long long )lock->fl.fl_end);
fs/lockd/svcsubs.c +2 -2
@@ -45,7 +45,7 @@ static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f)static inline void nlm_debug_print_file (char *msg,struct nlm_file *file) { -struct inode *inode =locks_inode (file->f_file); +struct inode *inode =nlmsvc_file_inode (file);dprintk ("lockd: %s %s/%ld\n" , msg, inode->i_sb->s_id, inode->i_ino);
@@ -415,7 +415,7 @@ nlmsvc_match_sb(void *datap, struct nlm_file *file) {struct super_block *sb = datap; -return sb ==locks_inode (file->f_file)->i_sb; +return sb ==nlmsvc_file_inode (file)->i_sb; }/**
Signature · 1 line
2.31.1
PATCH 4/8 lockd: update nlm_lookup_file reexport comment
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
Update comment to reflect that we *do* allow reexport, whether it's a good idea or not....
--- fs/lockd/svcsubs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/lockd/svcsubs.c +3 -2
@@ -111,8 +111,9 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,INIT_HLIST_NODE (&file->f_list);INIT_LIST_HEAD (&file->f_blocks); -/* Open the file. Note that this must not sleep for too long, else -* we would lock up lockd:-) So no NFS re-exports, folks. +/* +* Open the file. Note that if we're reexporting, for example, +* this could block the lockd thread for a while. * * We have to make sure we have the right credential to open * the file.
Signature · 1 line
2.31.1
PATCH 5/8 Keep read and write fds with each nlm_file
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
We shouldn't really be using a read-only file descriptor to take a write lock.
Most filesystems will put up with it. But NFS, for example, won't.
--- fs/lockd/svc4proc.c | 4 +- fs/lockd/svclock.c | 25 ++++++-- fs/lockd/svcproc.c | 4 +- fs/lockd/svcsubs.c | 112 ++++++++++++++++++++++++++---------- fs/nfsd/lockd.c | 8 ++- include/linux/lockd/bind.h | 3 +- include/linux/lockd/lockd.h | 11 ++-- 7 files changed, 121 insertions(+), 46 deletions(-)
fs/lockd/svc4proc.c +3 -1
@@ -40,12 +40,14 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,/* Obtain file pointer. Not used by FREE_ALL call. */ if (filp !=NULL ) { +int mode =lock_to_openmode (&lock->fl); +if ((error =nlm_lookup_file (rqstp, &file, lock)) !=0 ) goto no_locks; *filp = file;/* Set up the missing parts of the file_lock structure */ - lock->fl.fl_file = file->f_file; + lock->fl.fl_file = file->f_file[mode]; lock->fl.fl_pid = current->tgid; lock->fl.fl_lmops = &nlmsvc_lock_operations;nlmsvc_locks_init_private (&lock->fl, host, (pid_t )lock->svid);
fs/lockd/svclock.c +19 -6
@@ -471,6 +471,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, {struct nlm_block *block =NULL ;int error; +int mode;__be32 ret; dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
@@ -524,7 +525,8 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,if (!wait) lock->fl.fl_flags &= ~FL_SLEEP ; - error =vfs_lock_file (file->f_file,F_SETLK , &lock->fl,NULL ); + mode =lock_to_openmode (&lock->fl); + error =vfs_lock_file (file->f_file[mode],F_SETLK , &lock->fl,NULL ); lock->fl.fl_flags &= ~FL_SLEEP ;dprintk ("lockd: vfs_lock_file returned %d\n" , error);
@@ -577,6 +579,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, struct nlm_lock *conflock, struct nlm_cookie *cookie) { int error; +int mode;__be32 ret;struct nlm_lockowner *test_owner;
@@ -595,7 +598,8 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,/* If there's a conflicting lock, remember to clean up the test lock */ test_owner = (struct nlm_lockowner *)lock->fl.fl_owner; - error =vfs_test_lock (file->f_file, &lock->fl); + mode =lock_to_openmode (&lock->fl); + error =vfs_test_lock (file->f_file[mode], &lock->fl);if (error) {/* We can't currently deal with deferred test requests */ if (error ==FILE_LOCK_DEFERRED )
@@ -641,7 +645,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,__be32 nlmsvc_unlock (struct net *net,struct nlm_file *file,struct nlm_lock *lock) { -int error; +int error =0 ; dprintk("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n", nlmsvc_file_inode(file)->i_sb->s_id,
@@ -654,7 +658,12 @@ nlmsvc_unlock(struct net *net, struct nlm_file *file, struct nlm_lock *lock)nlmsvc_cancel_blocked (net, file, lock); lock->fl.fl_type =F_UNLCK ; - error =vfs_lock_file (file->f_file,F_SETLK , &lock->fl,NULL ); +if (file->f_file[0 ]) + error =vfs_lock_file (file->f_file[0 ],F_SETLK , + &lock->fl,NULL ); +if (file->f_file[1 ]) + error =vfs_lock_file (file->f_file[1 ],F_SETLK , + &lock->fl,NULL );return (error <0 )? nlm_lck_denied_nolocks : nlm_granted; }
@@ -671,6 +680,7 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *l {struct nlm_block *block;int status =0 ; +int mode; dprintk("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n", nlmsvc_file_inode(file)->i_sb->s_id,
@@ -686,7 +696,8 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *l block =nlmsvc_lookup_block (file, lock);mutex_unlock (&file->f_mutex);if (block !=NULL ) { -vfs_cancel_lock (block->b_file->f_file, + mode =lock_to_openmode (&lock->fl); +vfs_cancel_lock (block->b_file->f_file[mode], &block->b_call->a_args.lock.fl); status =nlmsvc_unlink_block (block);nlmsvc_release_block (block);
@@ -803,6 +814,7 @@ nlmsvc_grant_blocked(struct nlm_block *block) {struct nlm_file *file = block->b_file;struct nlm_lock *lock = &block->b_call->a_args.lock; +int mode;int error;loff_t fl_start, fl_end;
@@ -828,7 +840,8 @@ nlmsvc_grant_blocked(struct nlm_block *block) lock->fl.fl_flags |=FL_SLEEP ; fl_start = lock->fl.fl_start; fl_end = lock->fl.fl_end; - error =vfs_lock_file (file->f_file,F_SETLK , &lock->fl,NULL ); + mode =lock_to_openmode (&lock->fl); + error =vfs_lock_file (file->f_file[mode],F_SETLK , &lock->fl,NULL ); lock->fl.fl_flags &= ~FL_SLEEP ; lock->fl.fl_start = fl_start; lock->fl.fl_end = fl_end;
fs/lockd/svcproc.c +3 -1
@@ -55,6 +55,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,struct nlm_host *host =NULL ;struct nlm_file *file =NULL ;struct nlm_lock *lock = &argp->lock; +int mode;__be32 error =0 ;/* nfsd callbacks must have been installed for this procedure */
@@ -75,7 +76,8 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, *filp = file;/* Set up the missing parts of the file_lock structure */ - lock->fl.fl_file = file->f_file; + mode =lock_to_openmode (&lock->fl); + lock->fl.fl_file = file->f_file[mode]; lock->fl.fl_pid = current->tgid; lock->fl.fl_lmops = &nlmsvc_lock_operations;nlmsvc_locks_init_private (&lock->fl, host, (pid_t )lock->svid);
fs/lockd/svcsubs.c +82 -30
199 lines not on this page · raw message
fs/nfsd/lockd.c +6 -2
@@ -25,9 +25,11 @@* Note: we hold the dentry use count while the file is open. */ static __be32 -nlm_fopen (struct svc_rqst *rqstp,struct nfs_fh *f,struct file **filp) +nlm_fopen (struct svc_rqst *rqstp,struct nfs_fh *f,struct file **filp, +int mode) {__be32 nfserr; +int access;struct svc_fh fh;/* must initialize before using! but maxsize doesn't matter */
@@ -36,7 +38,9 @@ nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp)memcpy ((char *)&fh.fh_handle.fh_base, f->data, f->size); fh.fh_export =NULL ; - nfserr =nfsd_open (rqstp, &fh,S_IFREG ,NFSD_MAY_LOCK , filp); + access = (mode ==O_WRONLY ) ?NFSD_MAY_WRITE :NFSD_MAY_READ ; + access |=NFSD_MAY_LOCK ; + nfserr =nfsd_open (rqstp, &fh,S_IFREG , access, filp);fh_put (&fh);/* We return nlm error codes as nlm doesn't know * about nfsd, but nfsd does know about nlm..
include/linux/lockd/bind.h +2 -1
@@ -27,7 +27,8 @@ struct rpc_task;struct nlmsvc_binding {__be32 (*fopen)(struct svc_rqst *,struct nfs_fh *, -struct file **); +struct file **, +int mode);void (*fclose)(struct file *); };
include/linux/lockd/lockd.h +6 -5
@@ -10,6 +10,8 @@#ifndef LINUX_LOCKD_LOCKD_H #define LINUX_LOCKD_LOCKD_H +/* XXX: a lot of this should really be under fs/lockd. */ +#include <linux/in.h> #include <linux/in6.h> #include <net/ipv6.h>
@@ -154,7 +156,8 @@ struct nlm_rqst {struct nlm_file {struct hlist_node f_list;/* linked list */ struct nfs_fh f_handle;/* NFS file handle */ -struct file * f_file;/* VFS file pointer */ +struct file * f_file[2 ];/* VFS file pointers, +indexed by O_ flags */ struct nlm_share * f_shares;/* DOS shares */ struct list_head f_blocks;/* blocked locks */ unsigned int f_locks;/* guesstimate # of locks */
@@ -267,6 +270,7 @@ typedef int (*nlm_host_match_fn_t)(void *cur, struct nlm_host *ref);/* * Server-side lock handling */ +int lock_to_openmode (struct file_lock *);__be32 nlmsvc_lock (struct svc_rqst *,struct nlm_file *,struct nlm_host *,struct nlm_lock *,int ,struct nlm_cookie *,int );
@@ -299,10 +303,7 @@ void nlmsvc_invalidate_all(void);int nlmsvc_unlock_all_by_sb (struct super_block *sb);int nlmsvc_unlock_all_by_ip (struct sockaddr *server_addr); -static inline struct inode *nlmsvc_file_inode (struct nlm_file *file) -{ -return locks_inode (file->f_file); -} +struct inode *nlmsvc_file_inode (struct nlm_file *);static inline int __nlm_privileged_request4 (const struct sockaddr *sap) {
Signature · 1 line
2.31.1
kernel test robot
build botRe: [PATCH 5/8] Keep read and write fds with each nlm_file
I love your patch! Yet something to improve:
Hi Bruce,
I love your patch! Yet something to improve:
[auto build test ERROR on nfs/linux-next]
[also build test ERROR on linus/master v5.14-rc6 next-20210816] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/J-Bruce-Fields/reexport-lock-fixes-v2/20210816-222314 base: git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next config: microblaze-defconfig (attached as .config) compiler: microblaze-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/5c0a3bd14dcbd51724884e23da5dcd85a54c6a2a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review J-Bruce-Fields/reexport-lock-fixes-v2/20210816-222314 git checkout 5c0a3bd14dcbd51724884e23da5dcd85a54c6a2a
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=microblaze SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
microblaze-linux-ld: fs/lockd/svcsubs.o: in function `nlmsvc_match_sb':
>> (.text+0x84): undefined reference to `nlmsvc_file_inode'
microblaze-linux-ld: fs/lockd/svcsubs.o: in function `nlm_traverse_files':
(.text+0x298): undefined reference to `nlmsvc_file_inode'
microblaze-linux-ld: fs/lockd/svcsubs.o: in function `nlm_release_file':
(.text+0x7c0): undefined reference to `nlmsvc_file_inode'
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH 5/8] Keep read and write fds with each nlm_file
In reply to J. Bruce FieldsI love your patch! Yet something to improve:
Hi Bruce,
I love your patch! Yet something to improve:
[auto build test ERROR on nfs/linux-next]
[also build test ERROR on linus/master v5.14-rc6 next-20210816] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/J-Bruce-Fields/reexport-lock-fixes-v2/20210816-222314 base: git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next config: parisc-defconfig (attached as .config) compiler: hppa-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/5c0a3bd14dcbd51724884e23da5dcd85a54c6a2a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review J-Bruce-Fields/reexport-lock-fixes-v2/20210816-222314 git checkout 5c0a3bd14dcbd51724884e23da5dcd85a54c6a2a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=parisc
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "nlmsvc_file_inode" [fs/lockd/lockd.ko] undefined!
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 6/8 nfs: don't atempt blocking locks on nfs reexports
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
NFS implements blocking locks by blocking inside its lock method. In the reexport case, this blocks the nfs server thread, which could lead to deadlocks since an nfs server thread might be required to unlock the conflicting lock. It also causes a crash, since the nfs server thread assumes it can free the lock when its lm_notify lock callback is called.
Ideal would be to make the nfs lock method return without blocking in this case, but for now it works just not to attempt blocking locks. The difference is just that the original client will have to poll (as it does in the v4.0 case) instead of getting a callback when the lock's available.
--- fs/nfs/export.c | 2 +- fs/nfsd/nfs4state.c | 8 ++++++-- include/linux/exportfs.h | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-)
fs/nfs/export.c +1 -1
@@ -180,5 +180,5 @@ const struct export_operations nfs_export_ops = { .fetch_iversion = nfs_fetch_iversion, .flags =EXPORT_OP_NOWCC |EXPORT_OP_NOSUBTREECHK |EXPORT_OP_CLOSE_BEFORE_UNLINK |EXPORT_OP_REMOTE_FS | - EXPORT_OP_NOATOMIC_ATTR, + EXPORT_OP_NOATOMIC_ATTR|EXPORT_OP_SYNC_LOCKS, };
fs/nfsd/nfs4state.c +6 -2
@@ -6835,6 +6835,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,struct nfsd4_blocked_lock *nbl =NULL ;struct file_lock *file_lock =NULL ;struct file_lock *conflock =NULL ; +struct super_block *sb;__be32 status =0 ;int lkflg;int err;
@@ -6856,6 +6857,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,dprintk ("NFSD: nfsd4_lock: permission denied!\n" );return status; } + sb = cstate->current_fh.fh_dentry->d_sb;if (lock->lk_is_new) {if (nfsd4_has_session (cstate))
@@ -6904,7 +6906,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, fp = lock_stp->st_stid.sc_file;switch (lock->lk_type) {case NFS4_READW_LT : -if (nfsd4_has_session (cstate)) +if (nfsd4_has_session (cstate) && + !(sb->s_export_op->flags &EXPORT_OP_SYNC_LOCKS )) fl_flags |=FL_SLEEP ; fallthrough;case NFS4_READ_LT :
@@ -6916,7 +6919,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, fl_type =F_RDLCK ;break ;case NFS4_WRITEW_LT : -if (nfsd4_has_session (cstate)) +if (nfsd4_has_session (cstate) && + !(sb->s_export_op->flags &EXPORT_OP_SYNC_LOCKS )) fl_flags |=FL_SLEEP ; fallthrough;case NFS4_WRITE_LT :
include/linux/exportfs.h +2 -0
@@ -221,6 +221,8 @@ struct export_operations {#define EXPORT_OP_NOATOMIC_ATTR (0x10)/* Filesystem cannot supply atomic attribute updates */ +#define EXPORT_OP_SYNC_LOCKS (0x20)/* Filesystem can't do +asychronous blocking locks */ unsigned long flags; };
Signature · 1 line
2.31.1
PATCH 7/8 lockd: don't attempt blocking locks on nfs reexports
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
As in the v4 case, it doesn't work well to block waiting for a lock on an nfs filesystem.
As in the v4 case, that means we're depending on the client to poll. It's probably incorrect to depend on that, but I *think* clients do poll in practice. In any case, it's an improvement over hanging the lockd thread indefinitely as we currently are.
--- fs/lockd/svclock.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
fs/lockd/svclock.c +10 -3
@@ -31,6 +31,7 @@#include <linux/lockd/nlm.h> #include <linux/lockd/lockd.h> #include <linux/kthread.h> +#include <linux/exportfs.h> #define NLMDBG_FACILITY NLMDBG_SVCLOCK
@@ -470,18 +471,24 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, struct nlm_cookie *cookie, int reclaim) {struct nlm_block *block =NULL ; +struct inode *inode =nlmsvc_file_inode (file);int error;int mode; +int async_block =0 ;__be32 ret;dprintk ("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n" , -nlmsvc_file_inode (file)->i_sb->s_id, -nlmsvc_file_inode (file)->i_ino, + inode->i_sb->s_id, inode->i_ino, lock->fl.fl_type, lock->fl.fl_pid, (long long )lock->fl.fl_start, (long long )lock->fl.fl_end, wait); +if (inode->i_sb->s_export_op->flags &EXPORT_OP_SYNC_LOCKS ) { + async_block = wait; + wait =0 ; + } +/* Lock file against concurrent access */ mutex_lock (&file->f_mutex);/* Get existing block (in case client is busy-waiting)
@@ -542,7 +549,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,*/ if (wait)break ; - ret = nlm_lck_denied; + ret = async_block ? nlm_lck_blocked : nlm_lck_denied; goto out;case FILE_LOCK_DEFERRED :if (wait)
Signature · 1 line
2.31.1
kernel test robot
build botRe: [PATCH 7/8] lockd: don't attempt blocking locks on nfs reexports
I love your patch! Yet something to improve:
Hi Bruce,
I love your patch! Yet something to improve:
[auto build test ERROR on nfs/linux-next]
[also build test ERROR on linus/master v5.14-rc6 next-20210816] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/J-Bruce-Fields/reexport-lock-fixes-v2/20210816-222314 base: git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next config: arc-defconfig (attached as .config) compiler: arc-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/a058b36c95ee50bc722c8077747279f6c7277edc
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review J-Bruce-Fields/reexport-lock-fixes-v2/20210816-222314 git checkout a058b36c95ee50bc722c8077747279f6c7277edc
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
arc-elf-ld: fs/lockd/svclock.o: in function `nlmsvc_lock':
svclock.c:(.text+0xb80): undefined reference to `nlmsvc_file_inode'
>> arc-elf-ld: svclock.c:(.text+0xb80): undefined reference to `nlmsvc_file_inode'
arc-elf-ld: fs/lockd/svcsubs.o: in function `nlmsvc_match_sb':
svcsubs.c:(.text+0x5a): undefined reference to `nlmsvc_file_inode'
arc-elf-ld: svcsubs.c:(.text+0x5a): undefined reference to `nlmsvc_file_inode'
arc-elf-ld: fs/lockd/svcsubs.o: in function `nlmsvc_unlock_all_by_sb':
svcsubs.c:(.text+0x16e): undefined reference to `nlmsvc_file_inode'
arc-elf-ld: fs/lockd/svcsubs.o:svcsubs.c:(.text+0x16e): more undefined references to `nlmsvc_file_inode' follow
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 8/8 nfs: don't allow reexport reclaims
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
In the reexport case, nfsd is currently passing along locks with the reclaim bit set. The client sends a new lock request, which is granted if there's currently no conflict--even if it's possible a conflicting lock could have been briefly held in the interim.
We don't currently have any way to safely grant reclaim, so for now let's just deny them all.
I'm doing this by passing the reclaim bit to nfs and letting it fail the call, with the idea that eventually the client might be able to do something more forgiving here.
--- fs/nfs/file.c | 3 +++ fs/nfsd/nfs4state.c | 3 +++ fs/nfsd/nfsproc.c | 1 + include/linux/errno.h | 1 + include/linux/fs.h | 1 + 5 files changed, 9 insertions(+)
fs/nfs/file.c +3 -0
@@ -806,6 +806,9 @@ int nfs_lock(struct file *filp, int cmd, struct file_lock *fl)nfs_inc_stats (inode,NFSIOS_VFSLOCK ); +if (fl->fl_flags &FL_RECLAIM ) +return -ENOGRACE ; +/* No mandatory locks over NFS */ if (__mandatory_lock (inode) && fl->fl_type !=F_UNLCK ) goto out_err;
fs/nfsd/nfs4state.c +3 -0
@@ -6903,6 +6903,9 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,if (!locks_in_grace (net) && lock->lk_reclaim) goto out; +if (lock->lk_reclaim) + fl_flags |=FL_RECLAIM ; + fp = lock_stp->st_stid.sc_file;switch (lock->lk_type) {case NFS4_READW_LT :
fs/nfsd/nfsproc.c +1 -0
@@ -881,6 +881,7 @@ nfserrno (int errno) { nfserr_serverfault, -ENFILE }, { nfserr_io, -EUCLEAN }, { nfserr_perm, -ENOKEY }, + { nfserr_no_grace, -ENOGRACE}, };int i;
include/linux/errno.h +1 -0
@@ -31,5 +31,6 @@#define EJUKEBOX 528/* Request initiated, but will not complete before timeout */ #define EIOCBQUEUED 529/* iocb queued, will get completion event */ #define ERECALLCONFLICT 530/* conflict with recalled state */ +#define ENOGRACE 531/* NFS file lock reclaim refused */ #endif
include/linux/fs.h +1 -0
@@ -997,6 +997,7 @@ static inline struct file *get_file(struct file *f)#define FL_UNLOCK_PENDING 512/* Lease is being broken */ #define FL_OFDLCK 1024/* lock is "owned" by struct file */ #define FL_LAYOUT 2048/* outstanding pNFS layout */ +#define FL_RECLAIM 4096/* reclaiming from a reboot server */ #define FL_CLOSE_POSIX (FL_POSIX | FL_CLOSE)
Signature · 1 line
2.31.1