]> git.neil.brown.name Git - LaFS.git/commitdiff
Make the first segment 'active'.
authorNeilBrown <neilb@suse.de>
Sat, 3 Jul 2010 00:13:00 +0000 (10:13 +1000)
committerNeilBrown <neilb@suse.de>
Sat, 3 Jul 2010 00:51:27 +0000 (10:51 +1000)
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 <neilb@suse.de>
lafs.h
roll.c
segments.c

diff --git a/lafs.h b/lafs.h
index 7c9928a8d1765ff241a3659ec6cfa6be6b3c9472..606d3b7e08aaf6310abadbf51c0bad7a65649915 100644 (file)
--- 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 ab29e7aea4e491120878c55b1daa387cc6ef6a11..14deaf55ad9b6b145e2c423f4f185b858587e4fb 100644 (file)
--- 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,
index 0a52a47e9c2ec6250246676d11ed4e5d2c9330b7..c970305c7e1496a545ddbfef0bc29ec49a0ba8a5 100644 (file)
@@ -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'