}
static void orphan_abort(struct fs *fs);
+static void orphan_commit(struct fs *fs, struct datablock *b, struct datablock *ob);
static int orphan_pin(struct fs *fs, struct datablock *b)
{
struct orphan_md *om = &LAFSI(fs->orphans)->md.orphan;
u32 slot;
- struct orphan *or;
- int ent;
int err;
u32 bnum;
struct datablock *ob;
putdref(ob, MKREF(orphan));
return err;
}
+ orphan_commit(fs, b, ob);
+ mutex_unlock(&fs->orphans->i_mutex);
+ return 0;
+}
+
+static void orphan_commit(struct fs *fs, struct datablock *b, struct datablock *ob)
+{
+ struct orphan_md *om = &LAFSI(fs->orphans)->md.orphan;
+ struct orphan *or;
+ int ent;
+
/* Committed to being an orphan now */
- b->orphan_slot = slot;
+ b->orphan_slot = om->nextfree++;
getdref(b, MKREF(orphan_list));
spin_lock(&fs->lock);
set_bit(B_Orphan, &b->b.flags);
LAFSI(b->b.inode)->filesys->i_ino,
b->b.inode->i_ino, b->b.fileaddr, strblk(&b->b));
- om->nextfree++;
om->reserved--;
putdref(ob, MKREF(orphan_reserve));
or = map_dblock(ob);
- ent = slot - (bnum << (fs->prime_sb->s_blocksize_bits-4));
+ ent = b->orphan_slot - (ob->b.fileaddr
+ << (fs->prime_sb->s_blocksize_bits-4));
or[ent].type = cpu_to_le32(1);
or[ent].filesys = cpu_to_le32(LAFSI(b->b.inode)->filesys->i_ino);
or[ent].inum = cpu_to_le32(b->b.inode->i_ino);
unmap_dblock(ob, or);
lafs_dirty_dblock(ob);
clear_bit(B_PinPending, &ob->b.flags);
- mutex_unlock(&fs->orphans->i_mutex);
- return 0;
}
/* We failed to allocate space to write the update to the orphan