NFS/pnfs: Ensure that _pnfs_return_layout() waits for layoutreturn completion
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Sun, 19 Apr 2020 18:38:00 +0000 (14:38 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sun, 19 Apr 2020 23:27:26 +0000 (19:27 -0400)
We require that any outstanding layout return completes before we can
free up the inode so that the layout itself can be freed.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/pnfs.c

index b8d78f3933651a2c042bf92ff3bebed471d6c69e..3bf6899cba95bb0bcb8f50eb620ff84e8363117e 100644 (file)
@@ -1332,13 +1332,15 @@ _pnfs_return_layout(struct inode *ino)
                        !valid_layout) {
                spin_unlock(&ino->i_lock);
                dprintk("NFS: %s no layout segments to return\n", __func__);
-               goto out_put_layout_hdr;
+               goto out_wait_layoutreturn;
        }
 
        send = pnfs_prepare_layoutreturn(lo, &stateid, &cred, NULL);
        spin_unlock(&ino->i_lock);
        if (send)
                status = pnfs_send_layoutreturn(lo, &stateid, &cred, IOMODE_ANY, true);
+out_wait_layoutreturn:
+       wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN, TASK_UNINTERRUPTIBLE);
 out_put_layout_hdr:
        pnfs_free_lseg_list(&tmp_list);
        pnfs_put_layout_hdr(lo);