diff mbox

NFSv4: Fix sillyrename to return the delegation when appropriate

Message ID 20180529154814.12843-1-trond.myklebust@hammerspace.com (mailing list archive)
State New, archived
Headers show

Commit Message

Trond Myklebust May 29, 2018, 3:48 p.m. UTC
If the file being sillyrenamed is being completely deleted, or
we are using NFSv4.0, then we need to return the delegation before
sending off the sillydelete.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/dir.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

Comments

Anna Schumaker May 29, 2018, 6:33 p.m. UTC | #1
Hi Trond,

On 05/29/2018 11:48 AM, Trond Myklebust wrote:
> If the file being sillyrenamed is being completely deleted, or
> we are using NFSv4.0, then we need to return the delegation before
> sending off the sillydelete.
> 
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
>  fs/nfs/dir.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index b315f53b3aec..ed20ff51f865 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -1399,11 +1399,32 @@ EXPORT_SYMBOL_GPL(nfs_lookup);
>  #if IS_ENABLED(CONFIG_NFS_V4)
>  static int nfs4_lookup_revalidate(struct dentry *, unsigned int);
>  
> +/*
> + * Called when the dentry loses inode.
> + * We use it to clean up silly-renamed files.
> + */
> +static void nfs4_dentry_iput(struct dentry *dentry, struct inode *inode)
> +{
> +	if (S_ISDIR(inode->i_mode))
> +		/* drop any readdir cache as it could easily be old */
> +		NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;
> +
> +	if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
> +		if (inode->i_nlink == 1)
> +			nfs4_inode_return_delegation(inode);
> +		else
> +			nfs4_inode_make_writeable(inode);

I think these functions need to be exported in delegation.c to avoid undefined symbol warnings from the compiler.

Thanks,
Anna

> +		nfs_complete_unlink(dentry, inode);
> +		nfs_drop_nlink(inode);
> +	}
> +	iput(inode);
> +}
> +
>  const struct dentry_operations nfs4_dentry_operations = {
>  	.d_revalidate	= nfs4_lookup_revalidate,
>  	.d_weak_revalidate	= nfs_weak_revalidate,
>  	.d_delete	= nfs_dentry_delete,
> -	.d_iput		= nfs_dentry_iput,
> +	.d_iput		= nfs4_dentry_iput,
>  	.d_automount	= nfs_d_automount,
>  	.d_release	= nfs_d_release,
>  };
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Trond Myklebust May 29, 2018, 7:23 p.m. UTC | #2
On Tue, 2018-05-29 at 14:33 -0400, Anna Schumaker wrote:
> Hi Trond,

> 

> On 05/29/2018 11:48 AM, Trond Myklebust wrote:

> > If the file being sillyrenamed is being completely deleted, or

> > we are using NFSv4.0, then we need to return the delegation before

> > sending off the sillydelete.

> > 

> > Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

> > ---

> >  fs/nfs/dir.c | 23 ++++++++++++++++++++++-

> >  1 file changed, 22 insertions(+), 1 deletion(-)

> > 

> > diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c

> > index b315f53b3aec..ed20ff51f865 100644

> > --- a/fs/nfs/dir.c

> > +++ b/fs/nfs/dir.c

> > @@ -1399,11 +1399,32 @@ EXPORT_SYMBOL_GPL(nfs_lookup);

> >  #if IS_ENABLED(CONFIG_NFS_V4)

> >  static int nfs4_lookup_revalidate(struct dentry *, unsigned int);

> >  

> > +/*

> > + * Called when the dentry loses inode.

> > + * We use it to clean up silly-renamed files.

> > + */

> > +static void nfs4_dentry_iput(struct dentry *dentry, struct inode

> > *inode)

> > +{

> > +	if (S_ISDIR(inode->i_mode))

> > +		/* drop any readdir cache as it could easily be

> > old */

> > +		NFS_I(inode)->cache_validity |=

> > NFS_INO_INVALID_DATA;

> > +

> > +	if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {

> > +		if (inode->i_nlink == 1)

> > +			nfs4_inode_return_delegation(inode);

> > +		else

> > +			nfs4_inode_make_writeable(inode);

> 

> I think these functions need to be exported in delegation.c to avoid

> undefined symbol warnings from the compiler.

> 


Whoops. Yes, thanks for noticing!

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com
kernel test robot June 1, 2018, 8:47 a.m. UTC | #3
Hi Trond,

I love your patch! Yet something to improve:

[auto build test ERROR on nfs/linux-next]
[also build test ERROR on v4.17-rc7 next-20180531]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Trond-Myklebust/NFSv4-Fix-sillyrename-to-return-the-delegation-when-appropriate/20180531-232019
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
config: arm-arm5 (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   fs/nfs/dir.o: In function `nfs4_dentry_iput':
>> dir.c:(.text+0xe04): undefined reference to `nfs4_inode_make_writeable'
>> dir.c:(.text+0xe28): undefined reference to `nfs4_inode_return_delegation'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot June 1, 2018, 1 p.m. UTC | #4
Hi Trond,

I love your patch! Yet something to improve:

[auto build test ERROR on nfs/linux-next]
[also build test ERROR on v4.17-rc7 next-20180531]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Trond-Myklebust/NFSv4-Fix-sillyrename-to-return-the-delegation-when-appropriate/20180531-232019
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
config: mips-fuloong2e_defconfig (attached as .config)
compiler: mips64el-linux-gnuabi64-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> ERROR: "nfs4_inode_make_writeable" [fs/nfs/nfs.ko] undefined!
>> ERROR: "nfs4_inode_return_delegation" [fs/nfs/nfs.ko] undefined!

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index b315f53b3aec..ed20ff51f865 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1399,11 +1399,32 @@  EXPORT_SYMBOL_GPL(nfs_lookup);
 #if IS_ENABLED(CONFIG_NFS_V4)
 static int nfs4_lookup_revalidate(struct dentry *, unsigned int);
 
+/*
+ * Called when the dentry loses inode.
+ * We use it to clean up silly-renamed files.
+ */
+static void nfs4_dentry_iput(struct dentry *dentry, struct inode *inode)
+{
+	if (S_ISDIR(inode->i_mode))
+		/* drop any readdir cache as it could easily be old */
+		NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;
+
+	if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
+		if (inode->i_nlink == 1)
+			nfs4_inode_return_delegation(inode);
+		else
+			nfs4_inode_make_writeable(inode);
+		nfs_complete_unlink(dentry, inode);
+		nfs_drop_nlink(inode);
+	}
+	iput(inode);
+}
+
 const struct dentry_operations nfs4_dentry_operations = {
 	.d_revalidate	= nfs4_lookup_revalidate,
 	.d_weak_revalidate	= nfs_weak_revalidate,
 	.d_delete	= nfs_dentry_delete,
-	.d_iput		= nfs_dentry_iput,
+	.d_iput		= nfs4_dentry_iput,
 	.d_automount	= nfs_d_automount,
 	.d_release	= nfs_d_release,
 };