From: NeilBrown Date: Wed, 23 Jun 2010 02:14:34 +0000 (+1000) Subject: lafs_refile: fix nextparent handing. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=468d091113b8810e5d338d26bfc6550c641bcab6;p=LaFS.git lafs_refile: fix nextparent handing. It is now possible that 'nextparent' is already a sibling of the current block (inoidx vs ino data). So handle that, and generally clean up the code. Signed-off-by: NeilBrown --- diff --git a/index.c b/index.c index 13e5bc9..73936f8 100644 --- a/index.c +++ b/index.c @@ -906,15 +906,16 @@ void lafs_refile(struct block *b, int dec) int credits; fs = fs_from_inode(b->inode); /* Don't need ->parent any more */ - if (next_parent == &b->parent->b) { - if (atomic_dec_and_test(&next_parent - ->refcnt)) - LAFS_BUG(1, b); - } else { - LAFS_BUG(next_parent, b); + if (next_parent == NULL) next_parent = &b->parent->b; - } - del_ref(next_parent, MKREF(child), + else if (next_parent == &b->parent->b || + next_parent->parent == b->parent) { + if (atomic_dec_and_test(&b->parent->b.refcnt)) + LAFS_BUG(1, b); + } else + LAFS_BUG(1, b); + + del_ref(&b->parent->b, MKREF(child), __FILE__, __LINE__); b->parent = NULL; if (test_and_clear_bit(B_SegRef, &b->flags))