/* Having reserved the block, we need to get a segref,
* which will involve reserving those blocks too.
+ * However we never get a segref for Root.
*/
- while (err == 0 && !test_bit(B_SegRef, &b->flags))
+ while (err == 0
+ && !test_bit(B_Root, &b->flags)
+ && !test_bit(B_SegRef, &b->flags))
err = lafs_seg_ref_block(b, 0);
return err;
LAFS_BUG(i == fs->maxsnapshot, blk);
blk->physaddr = phys; /* superblock doesn't get
counted in summaries */
+ LAFS_BUG(test_bit(B_SegRef, &blk->flags), blk);
set_bit(B_PhysValid, &blk->flags);
fs->ss[i].root_addr = phys;
lai = LAFSI(blk->inode);
* dirty after the checkpoint.
* So just return
*/
+ if (test_and_clear_bit(B_SegRef, &blk->flags))
+ lafs_seg_deref(fs, blk->physaddr, 0);
blk->physaddr = phys;
set_bit(B_PhysValid, &blk->flags);
return 0;
* find the matching segsum block. If it already
* has SegRef, we add the reference and retry from the start.
* If it doesn't have SegRef, we prealloc and then tail recurse.
+ * Note: we never set SegRef on B_Root blocks as their usage
+ * isn't recorded.
*/
int lafs_seg_ref_block(struct block *b, int ssnum)
{
getref(b, MKREF(segref));
while (!test_bit(B_SegRef, &b->flags)) {
+
+ BUG_ON(test_bit(B_Root, &b->flags));
+
if (b->physaddr == 0) {
set_bit(B_SegRef, &b->flags);
break;