NFSv4: Fixes for nfs4_inode_return_delegation()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Sun, 10 Oct 2021 08:58:12 +0000 (10:58 +0200)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 20 Oct 2021 22:09:53 +0000 (18:09 -0400)
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>
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;
 }