2 /* Force out a checkpoint
3 * All scheduled blocks get incorporated and/or written
4 * then we write out the new state blocks
12 int lafs_checkpoint(struct lafs *fs)
16 fs->checkpointing = CHECKPOINTING | CHECKPOINT_START;
18 while (!list_empty(&fs->leafs)) {
19 while (!list_empty(&fs->leafs)) {
20 b = list_first_entry(&fs->leafs,
23 printf("checkpoint %p %d/%ld %s %p\n", b, b->ino->inum, b->fileaddr,
24 (b->flags & B_Index) ? "index":"data", b->parent);
25 list_del_init(&b->leafs);
26 if (!(b->flags & B_Index)) {
27 struct lafs_dblk *db = dblk(b);
28 if (b->ino->type == TypeSegmentMap) {
29 /* Allow parents to be processed, but freeze this */
30 de_sched(b); b->flags |= B_Sched;
31 list_add(&b->leafs, &fs->account_leafs);
34 if (b->ino->type == TypeInodeFile &&
36 db->my_inode->iblock &&
37 db->my_inode->iblock->sched_cnt) {
43 if (b->flags & B_Index) {
44 struct lafs_iblk *ib = iblk(b);
52 if (!(ib->b.flags & B_Sched))
54 /* We'll pick it up next time 'round */
58 if (b->flags & B_Dirty) {
60 lafs_cluster_allocate(b, 0);
64 lafs_cluster_flush(fs, 0);
66 fs->flags |= LAFS_DELAY_UPDATES;
67 while (!list_empty(&fs->account_leafs)) {
68 b = list_first_entry(&fs->account_leafs,
69 struct lafs_blk, leafs);
71 printf("Account %d/%ld\n", b->ino->inum, b->fileaddr);
72 list_del_init(&b->leafs);
75 list_del_init(&b->leafs);
77 lafs_cluster_allocate(b, 0);
79 fs->checkpointing |= CHECKPOINT_END;
80 lafs_cluster_flush(fs, 0);
81 fs->flags &= ~LAFS_DELAY_UPDATES;