* If no next, and parent not empty, just delete
* If parent becomes empty, recurse upwards.
*/
+ nxt = NULL;
+ if (ib->b.siblings.next != &ib->b.parent->children)
+ nxt = list_entry(ib->b.siblings.next, struct indexblock, b.siblings);
if (test_and_clear_bit(B_PrimaryRef, &ib->b.flags)) {
- /* This was not incorporated yet */
- int cr = incorp_index(&ib->b);
+ int cr = 0;
+ /* This was not incorporated yet, revert the uninc status */
+ if (nxt && test_bit(B_PrimaryRef, &nxt->b.flags)) {
+ /* I was in a PrimaryRef chain */
+ putiref(ib, MKREF(primary));
+ } else {
+ struct indexblock *prev = list_entry(ib->b.siblings.prev,
+ struct indexblock,
+ b.siblings);
+ putiref(prev, MKREF(primary));
+ }
list_del_init(&ib->b.siblings);
+ clear_bit(B_Uninc, &ib->b.flags);
if (test_and_clear_bit(B_Dirty, &ib->b.flags))
cr++;
+ if (test_and_clear_bit(B_UnincCredit, &ib->b.flags))
+ cr++;
lafs_space_return(fs, cr);
- } else if (ib->b.siblings.next != &ib->b.parent->children &&
- (nxt = list_entry(ib->b.siblings.next, struct indexblock, b.siblings)) &&
- test_bit(B_PrimaryRef, &nxt->b.flags)) {
+ } else if (nxt && test_bit(B_PrimaryRef, &nxt->b.flags)) {
/* Next block is not incorporated yet, so simply re-address
* it to replace this block.
*/