* The youth value must have been zero, and we set it to the
* current youth number.
*/
- struct datablock *db = NULL;
u16 *youthp;
struct segstat *ss;
- struct segsum *ssum;
+ struct segsum *ssum = NULL;
int ssnum;
BUG_ON(nonlogged); // FIXME should handle this case, not ignore it
* updates to the Youth block.
*/
if (!test_bit(FinalCheckpoint, &fs->fsstate) &&
- !(db &&
- db->b.inode == fs->devs[*dev].segsum &&
- db->b.fileaddr == ((*seg) >> (fs->blocksize_bits
- - 1)))) {
+ !(ssum &&
+ ssum->devnum == ss->dev &&
+ ssum->segnum == ss->segment)) {
spin_unlock(&fs->lock);
- if (db)
- putdref(db, MKREF(youth));
-
- db = lafs_get_block(fs->devs[*dev].segsum,
- (*seg) >> (fs->blocksize_bits
- - 1),
- NULL, GFP_KERNEL,
- MKREF(youth));
+ if (ssum)
+ ss_put(ssum, fs);
+
+ ssum = segsum_find(fs, ss->segment, ss->dev, 0);
/* As we hold a ref on youth block for anything in the
* table, and that block was loaded at the time, it must
* still be valid.
*/
- BUG_ON(!test_bit(B_Valid, &db->b.flags));
+ BUG_ON(!ssum || !ssum->youthblk);
+ BUG_ON(!test_bit(B_Valid, &ssum->youthblk->b.flags));
+ set_bit(B_PinPending, &ssum->youthblk->b.flags);
+ lafs_pin_dblock(ssum->youthblk, AccountSpace);
goto again;
}
/* HACK youth_next should always be at least 0x8000 so that
if (fs->youth_next < 0x8000)
fs->youth_next = 0x8000;
- if (db && test_bit(FinalCheckpoint, &fs->fsstate)) {
- putdref(db, MKREF(youth));
- db = NULL;
+ if (ssum && test_bit(FinalCheckpoint, &fs->fsstate)) {
+ ss_put(ssum, fs);
+ ssum = NULL;
}
- if (db) {
+ if (ssum) {
u16 y = fs->youth_next;
if (fs->scan.do_decay &&
(fs->scan.free_dev < ss->dev
))
/* Haven't decayed this block yet - revert decay */
y = decay_undo(y);
- youthp = map_dblock(db);
+ youthp = map_dblock(ssum->youthblk);
youthp[(*seg) & ((1 << (fs->blocksize_bits
- 1)) - 1)]
= cpu_to_le16(y);
- unmap_dblock(db, youthp);
+ unmap_dblock(ssum->youthblk, youthp);
+ lafs_dirty_dblock(ssum->youthblk);
}
fs->youth_next++;
/* ?? what do I need to release etc */
/* Maybe this cannot fail because we own references
* to the two blocks !! */
- LAFS_BUG(1, db ? &db->b : NULL);
+ LAFS_BUG(1, NULL);
lafs_checkpoint_lock(fs);
set_bit(B_PinPending, &ssum->ssblk->b.flags);
(void)lafs_pin_dblock(ssum->ssblk, AccountSpace);
- if (ssnum == 0) {
- set_bit(B_PinPending, &ssum->youthblk->b.flags);
- (void)lafs_pin_dblock(ssum->youthblk, AccountSpace);
- }
lafs_checkpoint_unlock(fs);
}
- if (db) {
- lafs_dirty_dblock(db);
- putdref(db, MKREF(youth));
- }
+ if (ssum)
+ ss_put(ssum, fs);
+
dprintk("NEXT segment found %d/%d youth %d\n",
*dev, *seg, fs->youth_next - 1);
/* Note that we return an implicit reference to the ssum */