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: Trond Myklebust <trond.myklebust@hammerspace.com>
pull/1340/head
Trond Myklebust 2025-07-18 16:44:03 -07:00
parent 1db3a48e83
commit ec0abdda89
1 changed files with 10 additions and 18 deletions

View File

@ -306,7 +306,6 @@ void
pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo) pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
{ {
struct inode *inode; struct inode *inode;
unsigned long i_state;
if (!lo) if (!lo)
return; return;
@ -317,12 +316,11 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
if (!list_empty(&lo->plh_segs)) if (!list_empty(&lo->plh_segs))
WARN_ONCE(1, "NFS: BUG unfreed layout segments.\n"); WARN_ONCE(1, "NFS: BUG unfreed layout segments.\n");
pnfs_detach_layout_hdr(lo); 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); spin_unlock(&inode->i_lock);
pnfs_free_layout_hdr(lo); 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); 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) void pnfs_destroy_layout_final(struct nfs_inode *nfsi)
{ {
struct pnfs_layout_hdr *lo = __pnfs_destroy_layout(nfsi); struct pnfs_layout_hdr *lo = __pnfs_destroy_layout(nfsi);
struct inode *inode = &nfsi->vfs_inode;
if (lo) if (lo) {
wait_var_event(lo, pnfs_layout_removed(nfsi, lo)); spin_lock(&inode->i_lock);
wait_var_event_spinlock(lo, nfsi->layout != lo,
&inode->i_lock);
spin_unlock(&inode->i_lock);
}
} }
static bool static bool