}
}
+static void set_youth(struct fs *fs, struct segsum *ss)
+{
+ u16 y;
+ u16 *youthp;
+
+ /* HACK youth_next should always be at least 0x8000 so that
+ * cleanable score differentiates well for new segments.
+ * old code would sometimes set youth_next very low, so
+ * over-ride that
+ */
+ if (fs->youth_next < 0x8000)
+ fs->youth_next = 0x8000;
+ y = fs->youth_next;
+ if (fs->scan.do_decay &&
+ (fs->scan.free_dev < ss->devnum
+ || (fs->scan.free_dev == ss->devnum
+ && fs->scan.free_block < (ss->segnum
+ / (fs->blocksize / 2)))
+ ))
+ /* 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++;
+ unmap_dblock(ss->youthblk, youthp);
+ lafs_dirty_dblock(ss->youthblk);
+}
+
static void seg_apply(struct fs *fs, struct segsum *ss)
{
int err;
* The youth value must have been zero, and we set it to the
* current youth number.
*/
- u16 *youthp;
struct segstat *ss;
struct segsum *ssum = NULL;
int ssnum;
ssum = NULL;
}
- if (ssum) {
- u16 y;
- /* HACK youth_next should always be at least 0x8000 so that
- * cleanable score differentiates well for new segments.
- * old code would sometimes set youth_next very low, so
- * over-ride that
- */
-
- if (fs->youth_next < 0x8000)
- fs->youth_next = 0x8000;
- y = fs->youth_next;
- if (fs->scan.do_decay &&
- (fs->scan.free_dev < ss->dev
- || (fs->scan.free_dev == ss->dev
- && fs->scan.free_block < (ss->segment
- / (fs->blocksize / 2)))
- ))
- /* Haven't decayed this block yet - revert decay */
- y = decay_undo(y);
- youthp = map_dblock(ssum->youthblk);
- youthp[(*seg) & ((1 << (fs->blocksize_bits
- - 1)) - 1)]
- = cpu_to_le16(y);
- fs->youth_next++;
- unmap_dblock(ssum->youthblk, youthp);
- lafs_dirty_dblock(ssum->youthblk);
- }
+ if (ssum)
+ set_youth(fs, ssum);
spin_unlock(&fs->lock);