static void set_youth(struct fs *fs, struct segsum *ss)
{
u16 y;
- u16 *youthp;
+ u16 *ybuf, *youthp;
+ int dirty = 0;
/* HACK youth_next should always be at least 0x8000 so that
* cleanable score differentiates well for new segments.
))
/* Haven't decayed this block yet - revert decay */
y = decay_undo(y);
- youthp = map_dblock(ss->youthblk);
- youthp[ss->segnum & ((1 << (fs->blocksize_bits
- - 1)) - 1)]
- = cpu_to_le16(y);
- fs->youth_next++;
+ ybuf = map_dblock(ss->youthblk);
+ youthp = ybuf + (ss->segnum & ((1 << (fs->blocksize_bits
+ - 1)) - 1));
+ if (le16_to_cpu(*youthp) < 8) {
+ *youthp = cpu_to_le16(y);
+ fs->youth_next++;
+ dirty = 1;
+ }
unmap_dblock(ss->youthblk, youthp);
- lafs_dirty_dblock(ss->youthblk);
+ if (dirty)
+ lafs_dirty_dblock(ss->youthblk);
}
static void seg_apply(struct fs *fs, struct segsum *ss)
err = lafs_read_block(ss->ssblk);
BUG_ON(err); // FIXME do something useful here
seg_inc(fs, ss, diff, 1);
+
+ if (diff > 0 && ss->youthblk)
+ set_youth(fs, ss);
}
/* lafs_seg_apply_all