spin_lock(&fs->lock);
if (test_bit(B_Pinned, &b->b.flags)) {
- /* Erasing a Pinned datablock should only happen when it is
- * on a 'leaf' list. If it is not, because there are children
- * (i.e. an InoIdx block) still pinned, then it should be erased
- * first.
+ /* When erasing a pinned dblock it will usually be on a
+ * leaf list, so we must remove it.
+ * However it is IOLocked so it might not be on the leaf list.
*/
- LAFS_BUG(list_empty(&b->b.lru), &b->b);
- list_del_init(&b->b.lru);
+ int onlru = 0;
+ LAFS_BUG(test_bit(B_Writeback, &b->b.flags), &b->b);
+ if (!list_empty(&b->b.lru)) {
+ onlru = 1;
+ list_del_init(&b->b.lru);
+ }
if (!test_bit(B_Root, &b->b.flags))
atomic_dec(&b->b.parent->pincnt
[!!test_bit(B_Phase1, &b->b.flags)]);
spin_unlock(&fs->lock);
if (!test_bit(B_Root, &b->b.flags))
lafs_refile(&b->b.parent->b, 0);
- putiref(b, MKREF(leaf));
+ if (onlru)
+ putiref(b, MKREF(leaf));
} else
spin_unlock(&fs->lock);