2 /* allocate a new segment at assign it to a lafs_cluster
7 static void cluster_reset(struct lafs *fs, struct lafs_cluster *wc)
9 wc->remaining = dev_by_num(fs, wc->seg.dev)->segment_size;
12 wc->chead_size = sizeof(struct cluster_head);
15 void set_youth(struct lafs *fs, int dev, loff_t seg, int youth)
17 struct lafs_device *dv;
22 dv = dev_by_num(fs, dev);
23 addr = seg / (fs->blocksize/2);
25 db = lafs_dblk(dv->segsum, addr);
27 p = (void*)db->b.data;
28 p[seg % (fs->blocksize/2)] = __cpu_to_le16(youth);
29 lafs_sched_blk(&db->b);
32 int lafs_new_segment(struct lafs *fs, int cnum)
36 struct lafs_cluster *wc = &fs->wc[cnum];
38 if (fs->free_head == fs->free_tail) {
41 if (fs->free_head == fs->free_tail)
44 dev = fs->freelist[fs->free_head].dev;
45 seg = fs->freelist[fs->free_head].seg;
48 if (fs->free_head > 128)
55 wc->seg.table = wc->seg.nxt_table = wc->seg.st_table;
56 wc->seg.row = wc->seg.nxt_row = wc->seg.st_row;
59 cluster_reset(fs, wc);
61 /* Need to set the youth for this segment */
62 set_youth(fs, dev, seg, fs->youth_next++);