All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] nfsd: ensure new clients break delegations
@ 2021-04-16 18:00 J. Bruce Fields
  2021-04-16 18:00 ` [PATCH 2/5] nfsd: hash nfs4_files by inode number J. Bruce Fields
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: J. Bruce Fields @ 2021-04-16 18:00 UTC (permalink / raw)
  To: Chuck Lever; +Cc: linux-nfs, J. Bruce Fields

From: "J. Bruce Fields" <bfields@redhat.com>

If nfsd already has an open file that it plans to use for IO from
another, it may not need to do another vfs open, but it still may need
to break any delegations in case the existing opens are for another
client.

Symptoms are that we may incorrectly fail to break a delegation on a
write open from a different client, when the delegation-holding client
already has a write open.

Fixes: 28df3d1539de ("nfsd: clients don't need to break their own delegations")
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/nfsd/nfs4state.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 97447a64bad0..886e50ed07c2 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4869,6 +4869,11 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp,
 	if (nf)
 		nfsd_file_put(nf);
 
+	status = nfserrno(nfsd_open_break_lease(cur_fh->fh_dentry->d_inode,
+								access));
+	if (status)
+		goto out_put_access;
+
 	status = nfsd4_truncate(rqstp, cur_fh, open);
 	if (status)
 		goto out_put_access;
@@ -6849,11 +6854,20 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
 {
 	struct nfsd_file *nf;
-	__be32 err = nfsd_file_acquire(rqstp, fhp, NFSD_MAY_READ, &nf);
-	if (!err) {
-		err = nfserrno(vfs_test_lock(nf->nf_file, lock));
-		nfsd_file_put(nf);
-	}
+	__be32 err;
+
+	err = nfsd_file_acquire(rqstp, fhp, NFSD_MAY_READ, &nf);
+	if (err)
+		return err;
+	fh_lock(fhp); /* to block new leases till after test_lock: */
+	err = nfserrno(nfsd_open_break_lease(fhp->fh_dentry->d_inode,
+							NFSD_MAY_READ));
+	if (err)
+		goto out;
+	err = nfserrno(vfs_test_lock(nf->nf_file, lock));
+out:
+	fh_unlock(fhp);
+	nfsd_file_put(nf);
 	return err;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] nfsd: hash nfs4_files by inode number
@ 2021-04-19  6:05 kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-04-19  6:05 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4121 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <1618596018-9899-2-git-send-email-bfields@redhat.com>
References: <1618596018-9899-2-git-send-email-bfields@redhat.com>
TO: "J. Bruce Fields" <bfields@redhat.com>
TO: Chuck Lever <chuck.lever@oracle.com>
CC: linux-nfs(a)vger.kernel.org
CC: "J. Bruce Fields" <bfields@redhat.com>

Hi Bruce,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on nfsd/nfsd-next v5.12-rc8 next-20210416]
[cannot apply to cel/for-next]
[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/nfsd-ensure-new-clients-break-delegations/20210417-020217
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 151501160401e2dc669ea7dac2c599b53f220c33
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: ia64-randconfig-s031-20210419 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.3-330-g09ec74f6-dirty
        # https://github.com/0day-ci/linux/commit/c988dd4d08fdbff8c957f1cb0dcc44247c618af3
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review J-Bruce-Fields/nfsd-ensure-new-clients-break-delegations/20210417-020217
        git checkout c988dd4d08fdbff8c957f1cb0dcc44247c618af3
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
   fs/nfsd/nfs4state.c: note: in included file (through include/linux/dcache.h, include/linux/fs.h):
   include/linux/rculist.h:515:9: sparse: sparse: context imbalance in 'put_nfs4_file' - unexpected unlock
   fs/nfsd/nfs4state.c: note: in included file (through include/linux/stringhash.h, include/linux/dcache.h, include/linux/fs.h):
>> include/linux/hash.h:81:45: sparse: sparse: shift too big (4294967104) for type unsigned long long
   fs/nfsd/nfs4state.c: note: in included file (through include/linux/wait.h, include/linux/wait_bit.h, include/linux/fs.h):
   include/linux/list.h:135:19: sparse: sparse: context imbalance in 'put_clnt_odstate' - unexpected unlock
   fs/nfsd/nfs4state.c:977:9: sparse: sparse: context imbalance in 'nfs4_put_stid' - unexpected unlock

vim +81 include/linux/hash.h

ef703f49a6c5b90 George Spelvin 2016-05-26  73  
468a9428521e7d0 George Spelvin 2016-05-26  74  #ifndef HAVE_ARCH_HASH_64
468a9428521e7d0 George Spelvin 2016-05-26  75  #define hash_64 hash_64_generic
468a9428521e7d0 George Spelvin 2016-05-26  76  #endif
468a9428521e7d0 George Spelvin 2016-05-26  77  static __always_inline u32 hash_64_generic(u64 val, unsigned int bits)
ef703f49a6c5b90 George Spelvin 2016-05-26  78  {
ef703f49a6c5b90 George Spelvin 2016-05-26  79  #if BITS_PER_LONG == 64
ef703f49a6c5b90 George Spelvin 2016-05-26  80  	/* 64x64-bit multiply is efficient on all 64-bit processors */
ef703f49a6c5b90 George Spelvin 2016-05-26 @81  	return val * GOLDEN_RATIO_64 >> (64 - bits);
ef703f49a6c5b90 George Spelvin 2016-05-26  82  #else
ef703f49a6c5b90 George Spelvin 2016-05-26  83  	/* Hash 64 bits using only 32x32-bit multiply. */
ef703f49a6c5b90 George Spelvin 2016-05-26  84  	return hash_32((u32)val ^ __hash_32(val >> 32), bits);
ef703f49a6c5b90 George Spelvin 2016-05-26  85  #endif
^1da177e4c3f415 Linus Torvalds 2005-04-16  86  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  87  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 28172 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-04-19 20:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16 18:00 [PATCH 1/5] nfsd: ensure new clients break delegations J. Bruce Fields
2021-04-16 18:00 ` [PATCH 2/5] nfsd: hash nfs4_files by inode number J. Bruce Fields
2021-04-16 19:21   ` Chuck Lever III
2021-04-19 19:53     ` J. Bruce Fields
2021-04-19 20:42       ` Chuck Lever III
2021-04-16 18:00 ` [PATCH 3/5] nfsd: track filehandle aliasing in nfs4_files J. Bruce Fields
2021-04-16 18:00 ` [PATCH 4/5] nfsd: reshuffle some code J. Bruce Fields
2021-04-16 18:00 ` [PATCH 5/5] nfsd: grant read delegations to clients holding writes J. Bruce Fields
2021-04-16 19:11 ` [PATCH 1/5] nfsd: ensure new clients break delegations Chuck Lever III
2021-04-19 19:55   ` J. Bruce Fields
2021-04-19  6:05 [PATCH 2/5] nfsd: hash nfs4_files by inode number kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.