{
int offset; /* start of block where indexing is */
struct indexblock *new = NULL, *orig_ib, *locked_ib, *nxt;
- struct block *uninc = NULL;
+ struct block *uninc = NULL, **bp;
int rv = 0;
u32 next;
char *buf;
orig_ib = ib;
locked_ib = ib;
recurse:
- if (!list_empty(&ib->children))
- /* If there are children, we cannot treat this block as empty. */
- return;
if (test_bit(B_InoIdx, &ib->b.flags)) {
/* Empty InoIdx blocks are allowed. However depth must
* be 1. This is where we suddenly collapse a now-empty
*/
up_write(&ib->b.inode->i_alloc_sem);
+ /* ib is empty and so we are going to remove it from the parent.
+ * So we need to clear any 'dirty' status and remove from the
+ * uninc list
+ */
+ if (test_bit(B_Uninc, &ib->b.flags))
+ for (bp = &ib->b.parent->uninc ; *bp ; ) {
+ if (*bp == &ib->b) {
+ *bp = ib->b.chain;
+ clear_bit(B_Uninc, &ib->b.flags);
+ putiref(ib, MKREF(uninc));
+ } else
+ bp = &(*bp)->chain;
+ }
+ if (test_and_clear_bit(B_Dirty, &ib->b.flags))
+ lafs_space_return(fs, 1);
+ if (test_and_clear_bit(B_Realloc, &ib->b.flags))
+ lafs_space_return(fs, 1);
+ /* refile should remove from leaf list */
+ lafs_refile(&ib->b, 0);
/* Options for how to handle the fact that ib is now empty.
* If this block is not yet incorporated, it can
* be quietly deleted.