3 * allocate a dirty block to a cluster so we can easily write it
7 * For now, don't sort the blocks and assume that the cluster head
8 * and segment will have adequate room for all blocks.
9 * That is sufficient for mkfs
11 #include <lafs/lafs.h>
15 void lafs_cluster_allocate(struct lafs_blk *b, int cnum)
17 struct lafs *fs = b->ino->fs;
18 struct lafs_cluster *wc;
19 if (!(b->flags & B_Dirty))
21 if (!(b->flags & B_Sched))
24 if (!(b->flags & B_Index) &&
25 b->ino->type == TypeInodeFile &&
27 (dblk(b)->my_inode->iflags & I_Dirty))
28 lafs_inode_fillblock(dblk(b)->my_inode, b->data);
30 if ((b->flags & B_Index) &&
31 b->ino->iblock == iblk(b)) {
32 /* InoIdx block - cannot write that, must write the
33 * data block instead */
34 lafs_dirty_blk(&b->ino->dblock->b);
42 if (wc->remaining == 0) {
43 /* FIXME lafs_cluster_flush(fs, cnum) ?? */
44 lafs_new_segment(fs, cnum);
49 list_add_tail(&b->leafs, &wc->blocks);