spin_unlock(&fs->lock);
new->depth = ib->depth;
- list_add(&new->b.siblings, &ib->b.siblings);
- getiref(ib, MKREF(primary));
+ if (ib->b.siblings.next != &ib->b.parent->children &&
+ test_bit(B_PrimaryRef, &list_entry(ib->b.siblings.next,
+ struct block, siblings)->flags))
+ /* Inserting into a PrimaryRef chain */
+ getiref(new, MKREF(primary));
+ else
+ getiref(ib, MKREF(primary));
set_bit(B_PrimaryRef, &new->b.flags);
+ list_add(&new->b.siblings, &ib->b.siblings);
new->b.parent = ib->b.parent;
(void)getiref(new->b.parent, MKREF(child));
new->b.inode = ib->b.inode;
spin_unlock(&fs->lock);
new->depth = ib->depth;
- list_add(&new->b.siblings, &ib->b.siblings);
- getiref(ib, MKREF(primary));
+ if (ib->b.siblings.next != &ib->b.parent->children &&
+ test_bit(B_PrimaryRef, &list_entry(ib->b.siblings.next,
+ struct block, siblings)->flags))
+ /* Inserting into a PrimaryRef chain */
+ getiref(new, MKREF(primary));
+ else
+ getiref(ib, MKREF(primary));
set_bit(B_PrimaryRef, &new->b.flags);
+ list_add(&new->b.siblings, &ib->b.siblings);
new->b.parent = ib->b.parent;
(void)getiref(new->b.parent, MKREF(child));
new->b.inode = ib->b.inode;