From: "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.
Signed-off-by: J. Bruce Fields <[email protected]>
---
fs/lockd/svclock.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index d60e6eea2d57..c99acefb9ec9 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -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)
--
2.31.1
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
Reported-by: kernel test robot <[email protected]>
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/[email protected]