From 4b2140cdf55487edaab898ef177bfc1a5c66fd89 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 3 Jul 2010 10:13:00 +1000 Subject: [PATCH] Make the first segment 'active'. A segment needs to be marked 'active' while we are writing to it. Newly allocated segments get that already, but the segment we start on didn't. Signed-off-by: NeilBrown --- lafs.h | 1 + roll.c | 2 ++ segments.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/lafs.h b/lafs.h index 7c9928a..606d3b7 100644 --- a/lafs.h +++ b/lafs.h @@ -612,6 +612,7 @@ struct datablock *lafs_find_orphan(struct inode *ino); int lafs_prealloc(struct block *b, int type); int lafs_seg_ref_block(struct block *b, int ssnum); void lafs_seg_deref(struct fs *fs, u64 addr, int ssnum); +void lafs_add_active(struct fs *fs, u64 addr); void lafs_seg_forget(struct fs *fs, int dev, u32 seg); void lafs_seg_flush_all(struct fs *fs); void lafs_seg_apply_all(struct fs *fs); diff --git a/roll.c b/roll.c index ab29e7a..14deaf5 100644 --- a/roll.c +++ b/roll.c @@ -526,6 +526,8 @@ static int roll_forward(struct fs *fs) put_page(pg); kfree(buf); + lafs_add_active(fs, next); + /* Now we release all the nlink==0 inode that we found */ while (!list_empty(&fs->pending_orphans)) { struct datablock *db = list_entry(fs->pending_orphans.next, diff --git a/segments.c b/segments.c index 0a52a47..c970305 100644 --- a/segments.c +++ b/segments.c @@ -1322,6 +1322,36 @@ static int add_clean(struct fs *fs, unsigned int dev, u32 seg) return 0; } +void lafs_add_active(struct fs *fs, u64 addr) +{ + /* add this segment to the table as 'active'. + * This is only called once at mount time for the + * active segments. Other segments become active + * via free_get + */ + struct segstat *ss; + int ssn; + u16 *where[SEG_NUM_HEIGHTS]; + struct segsum *ssum = segsum_byaddr(fs, addr, 0); + (void)getdref(ssum->ssblk, MKREF(intable)); + (void)getdref(ssum->youthblk, MKREF(intable)); + spin_lock(&fs->lock); + ss = segfind(fs->segtrack, ssum->devnum, ssum->segnum, where); + BUG_ON(ss); + ssn = segunused(fs->segtrack); + ss = segfollow(fs->segtrack, ssn); + BUG_ON(!ss); + + ss->dev = ssum->devnum; + ss->segment = ssum->segnum; + ss->score = SCORE_ACTIVE; + ss->usage = 0; + seginsert(fs->segtrack, ssn, where); + lafs_check_seg_cnt(fs->segtrack); + + spin_unlock(&fs->lock); +} + static void clean_free(struct fs *fs) { /* We are finishing off a checkpoint. Move all from 'clean' -- 2.39.5