Skip to content

Commit ec0abdd

Browse files
author
Trond Myklebust
committed
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 <[email protected]>
1 parent 1db3a48 commit ec0abdd

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

fs/nfs/pnfs.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ void
306306
pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
307307
{
308308
struct inode *inode;
309-
unsigned long i_state;
310309

311310
if (!lo)
312311
return;
@@ -317,12 +316,11 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
317316
if (!list_empty(&lo->plh_segs))
318317
WARN_ONCE(1, "NFS: BUG unfreed layout segments.\n");
319318
pnfs_detach_layout_hdr(lo);
320-
i_state = inode->i_state;
319+
/* Notify pnfs_destroy_layout_final() that we're done */
320+
if (inode->i_state & (I_FREEING | I_CLEAR))
321+
wake_up_var_locked(lo, &inode->i_lock);
321322
spin_unlock(&inode->i_lock);
322323
pnfs_free_layout_hdr(lo);
323-
/* Notify pnfs_destroy_layout_final() that we're done */
324-
if (i_state & (I_FREEING | I_CLEAR))
325-
wake_up_var(lo);
326324
}
327325
}
328326

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

812-
static bool pnfs_layout_removed(struct nfs_inode *nfsi,
813-
struct pnfs_layout_hdr *lo)
814-
{
815-
bool ret;
816-
817-
spin_lock(&nfsi->vfs_inode.i_lock);
818-
ret = nfsi->layout != lo;
819-
spin_unlock(&nfsi->vfs_inode.i_lock);
820-
return ret;
821-
}
822-
823810
void pnfs_destroy_layout_final(struct nfs_inode *nfsi)
824811
{
825812
struct pnfs_layout_hdr *lo = __pnfs_destroy_layout(nfsi);
813+
struct inode *inode = &nfsi->vfs_inode;
826814

827-
if (lo)
828-
wait_var_event(lo, pnfs_layout_removed(nfsi, lo));
815+
if (lo) {
816+
spin_lock(&inode->i_lock);
817+
wait_var_event_spinlock(lo, nfsi->layout != lo,
818+
&inode->i_lock);
819+
spin_unlock(&inode->i_lock);
820+
}
829821
}
830822

831823
static bool

0 commit comments

Comments
 (0)