dprintk("os=%d sh=%d ent=%d nf=%d\n", b->orphan_slot, shift,
ent, om->nextfree);
-
+again:
if (b->orphan_slot != om->nextfree-1) {
/* need to swap in the last entry */
struct inode *bino;
lastor[lastent].type = 0;
unmap_dblock_2(ob2, lastor);
+ if (last.type == 0) {
+ /* this entry was invalidated during read-in.
+ * lets just forget it
+ */
+ om->nextfree--;
+ om->reserved++;
+ orphan_abort(fs);
+ putdref(ob2, MKREF(orphan_move));
+ goto again;
+ }
+
/* The block, being an orphan, must exist */
bino = lafs_iget_fs(fs,
le32_to_cpu(last.filesys),
/* Count how many active orphan slots there are
* in this file (which is the orphan file).
* We simply iterate all the slots until we
- * find an empty one
+ * find an empty one.
+ * We keep references to the blocks so lafs_add_orphans
+ * is certain to find them.
*/
int bnum = -1;
int slots = 1 << (ino->i_blkbits - 4);
break;
unmap_dblock(db, or);
- putdref(db, MKREF(count_orphans));
+ if (slot == 0)
+ putdref(db, MKREF(count_orphans));
} while (slot == slots);
return bnum * slots + slot;
struct orphan *or;
int slot;
- if (!db)
- continue;
-
- if (lafs_read_block(db) < 0) {
- putdref(db, MKREF(add_orphans));
- continue;
- }
+ /* We already own a count_orphans ref on this block */
+ BUG_ON(!db);
+ LAFS_BUG(!test_bit(B_Valid, &db->b.flags), &db->b);
+ putdref(db, MKREF(count_orphans));
or = map_dblock(db);
for (slot = 0; slot < slots && bslot + slot < count; slot++) {
struct inode *oino;
struct datablock *ob;
- if (or[slot].type == 0)
- continue;
+ LAFS_BUG(or[slot].type == 0, &db->b);
oino = lafs_iget_fs(fs,
le32_to_cpu(or[slot].filesys),
le32_to_cpu(or[slot].inum),
SYNC);
- if (IS_ERR(oino))
+ if (IS_ERR(oino)) {
+ or[slot].type = 0;
continue;
+ }
ob = lafs_get_block(oino, le32_to_cpu(or[slot].addr), NULL,
GFP_KERNEL, MKREF(add_orphan));
getdref(db, MKREF(orphan));
ob->orphan_slot = bslot + slot;
lafs_add_orphan(fs, ob);
- }
+ } else
+ or[slot].type = 0;
putdref(ob, MKREF(add_orphan));
}
iput(oino);