]> git.itanic.dy.fi Git - linux-stable/commitdiff
NFSv4: Fixes for nfs4_inode_return_delegation()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Sun, 10 Oct 2021 08:58:12 +0000 (10:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:11:57 +0000 (11:11 +0200)
commit 6e176d47160cec8bcaa28d9aa06926d72d54237c upstream.

We mustn't call nfs_wb_all() on anything other than a regular file.
Furthermore, we can exit early when we don't hold a delegation.

Reported-by: David Wysochanski <dwysocha@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Thorsten Leemhuis <regressions@leemhuis.info>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfs/delegation.c

index 11118398f495c1ae180db8a9dcce5e8acee4a73e..7c9eb679dbdbf8a3eb39d3b18b129364ae9e8211 100644 (file)
@@ -755,11 +755,13 @@ int nfs4_inode_return_delegation(struct inode *inode)
        struct nfs_delegation *delegation;
 
        delegation = nfs_start_delegation_return(nfsi);
-       /* Synchronous recall of any application leases */
-       break_lease(inode, O_WRONLY | O_RDWR);
-       nfs_wb_all(inode);
-       if (delegation != NULL)
+       if (delegation != NULL) {
+               /* Synchronous recall of any application leases */
+               break_lease(inode, O_WRONLY | O_RDWR);
+               if (S_ISREG(inode->i_mode))
+                       nfs_wb_all(inode);
                return nfs_end_delegation_return(inode, delegation, 1);
+       }
        return 0;
 }