Commit ec0abdda authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFS: Clean up pnfs_put_layout_hdr()/pnfs_destroy_layout_final()



Use the wake_up_var_locked() and wait_var_event_spinlock() helpers.

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 1db3a48e
Loading
Loading
Loading
Loading
+10 −18
Original line number Diff line number Diff line
@@ -306,7 +306,6 @@ void
pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
{
	struct inode *inode;
	unsigned long i_state;

	if (!lo)
		return;
@@ -317,12 +316,11 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
		if (!list_empty(&lo->plh_segs))
			WARN_ONCE(1, "NFS: BUG unfreed layout segments.\n");
		pnfs_detach_layout_hdr(lo);
		i_state = inode->i_state;
		/* Notify pnfs_destroy_layout_final() that we're done */
		if (inode->i_state & (I_FREEING | I_CLEAR))
			wake_up_var_locked(lo, &inode->i_lock);
		spin_unlock(&inode->i_lock);
		pnfs_free_layout_hdr(lo);
		/* Notify pnfs_destroy_layout_final() that we're done */
		if (i_state & (I_FREEING | I_CLEAR))
			wake_up_var(lo);
	}
}

@@ -809,23 +807,17 @@ void pnfs_destroy_layout(struct nfs_inode *nfsi)
}
EXPORT_SYMBOL_GPL(pnfs_destroy_layout);

static bool pnfs_layout_removed(struct nfs_inode *nfsi,
				struct pnfs_layout_hdr *lo)
{
	bool ret;

	spin_lock(&nfsi->vfs_inode.i_lock);
	ret = nfsi->layout != lo;
	spin_unlock(&nfsi->vfs_inode.i_lock);
	return ret;
}

void pnfs_destroy_layout_final(struct nfs_inode *nfsi)
{
	struct pnfs_layout_hdr *lo = __pnfs_destroy_layout(nfsi);
	struct inode *inode = &nfsi->vfs_inode;

	if (lo)
		wait_var_event(lo, pnfs_layout_removed(nfsi, lo));
	if (lo) {
		spin_lock(&inode->i_lock);
		wait_var_event_spinlock(lo, nfsi->layout != lo,
					&inode->i_lock);
		spin_unlock(&inode->i_lock);
	}
}

static bool