}
}
+static void flip_phase(struct block *b)
+{
+ struct indexblock *p;
+ int oldphase = !!test_bit(B_Phase1, &b->flags);
+
+ if (oldphase)
+ clear_bit(B_Phase1, &b->flags);
+ else
+ set_bit(B_Phase1, &b->flags);
+
+ p = b->parent;
+
+ if (p) {
+ atomic_inc(&p->pincnt[1-oldphase]);
+ atomic_dec(&p->pincnt[oldphase]);
+ } else
+ LAFS_BUG(!test_bit(B_Root, &b->flags), b);
+
+ /* move 'next' credits to 'here' */
+ if (!test_bit(B_Credit, &b->flags) &&
+ test_and_clear_bit(B_NCredit, &b->flags))
+ set_bit(B_Credit, &b->flags);
+
+ if (!test_bit(B_ICredit, &b->flags) &&
+ test_and_clear_bit(B_NICredit, &b->flags))
+ set_bit(B_ICredit, &b->flags);
+}
+
void lafs_phase_flip(struct fs *fs, struct indexblock *ib)
{
/* We are performing a checkpoint, this block has been written
* For InoIdx, we transfer the pinning and Credits to the
* Data block rather than release them.
*/
- struct indexblock *p = NULL;
int oldphase = !!test_bit(B_Phase1, &ib->b.flags);
struct block *ulist;
return;
}
- if (!test_bit(B_InoIdx, &ib->b.flags)) {
- struct inode *ino = ib->b.inode;
- spin_lock(&ino->i_data.private_lock);
-
- if (oldphase)
- clear_bit(B_Phase1, &ib->b.flags);
- else
- set_bit(B_Phase1, &ib->b.flags);
-
- p = ib->b.parent;
-
- atomic_inc(&p->pincnt[1-oldphase]);
- atomic_dec(&p->pincnt[oldphase]);
-
- /* move 'next' credits to 'here' */
- if (!test_bit(B_Credit, &ib->b.flags) &&
- test_and_clear_bit(B_NCredit, &ib->b.flags))
- set_bit(B_Credit, &ib->b.flags);
-
- if (!test_bit(B_ICredit, &ib->b.flags) &&
- test_and_clear_bit(B_NICredit, &ib->b.flags))
- set_bit(B_ICredit, &ib->b.flags);
-
- spin_unlock(&ino->i_data.private_lock);
+ flip_phase(&ib->b);
- if (lafs_prealloc(&ib->b, ReleaseSpace) < 0) {
- /* Couldn't get all N*Credit, so
- * Pin all children to this phase, so they
- * won't be needed.
- */
- pin_all_children(ib);
- }
-
- } else {
+ if (test_bit(B_InoIdx, &ib->b.flags)) {
struct lafs_inode *lai = LAFSI(ib->b.inode);
struct datablock *db = lai->dblock;
struct inode *ino = db->b.inode;
spin_lock(&ino->i_data.private_lock);
-
lai->cblocks += lai->pblocks;
lai->pblocks = 0;
lai->ciblocks += lai->piblocks;
lai->md.fs.pblocks_used;
lai->md.fs.pblocks_used = 0;
}
-
- if (oldphase)
- clear_bit(B_Phase1, &ib->b.flags);
- else
- set_bit(B_Phase1, &ib->b.flags);
-
- p = ib->b.parent;
- if (p) {
- atomic_inc(&p->pincnt[1-oldphase]);
- atomic_dec(&p->pincnt[oldphase]);
- } else
- LAFS_BUG(!test_bit(B_Root, &ib->b.flags), &ib->b);
-
- /* move 'next' credits to 'here' */
- if (!test_bit(B_Credit, &ib->b.flags) &&
- test_and_clear_bit(B_NCredit, &ib->b.flags))
- set_bit(B_Credit, &ib->b.flags);
-
- if (!test_bit(B_ICredit, &ib->b.flags) &&
- test_and_clear_bit(B_NICredit, &ib->b.flags))
- set_bit(B_ICredit, &ib->b.flags);
-
spin_unlock(&ino->i_data.private_lock);
- if (lafs_prealloc(&ib->b, ReleaseSpace) < 0)
- pin_all_children(ib);
-
/* maybe data block needs to be on leaf list */
- lafs_refile(&LAFSI(ib->b.inode)->dblock->b, 0);
+ lafs_refile(&db->b, 0);
+ }
- // FIXME move Dirty/UnincCredit to data block
+ if (lafs_prealloc(&ib->b, ReleaseSpace) < 0) {
+ /* Couldn't get all N*Credit, so
+ * Pin all children to this phase, so they
+ * won't be needed.
+ */
+ pin_all_children(ib);
}
spin_lock(&ib->b.inode->i_data.private_lock);
LAFS_BUG(ib->uninc_next, &ib->b);
lafs_refile(&ib->b, 0);
- if (p)
+ if (ib->b.parent)
/* Parent may need to be attached to a phase_leafs now */
- lafs_refile(&p->b, 0);
+ lafs_refile(&ib->b.parent->b, 0);
}
/*