From: NeilBrown Date: Sat, 26 Jun 2010 03:22:17 +0000 (+1000) Subject: Drop ssnum arg from lafs_free_get X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=22327915c1feb3279649b44bb4cde1a0db3b4fda;p=LaFS.git Drop ssnum arg from lafs_free_get It doesn't really make sense - we get a free segment for anything from any snapshot that needs to be written. Note that this makes more obvious the fact that snapshots are not at all well supported yet. Worry about that later. Signed-off-by: NeilBrown --- diff --git a/cluster.c b/cluster.c index 7128745..4be7e47 100644 --- a/cluster.c +++ b/cluster.c @@ -387,7 +387,7 @@ static void new_segment(struct fs *fs, int cnum) /* FIXME */ /* This gets a reference on the 'segsum' */ - lafs_free_get(fs, &dev, &seg, 0, 0); + lafs_free_get(fs, &dev, &seg, 0); wc->seg.dev = dev; wc->seg.num = seg; seg_setpos(fs, &wc->seg, (p = segtovirt(fs, dev, seg))); diff --git a/lafs.h b/lafs.h index bd937a3..5060639 100644 --- a/lafs.h +++ b/lafs.h @@ -625,7 +625,7 @@ void lafs_segtrack_free(struct segtracker *st); extern int temp_credits;/* debugging */ void lafs_space_use(struct fs *fs, int); void lafs_free_get(struct fs *fs, unsigned int *dev, u32 *seg, - int nonlogged, int ssnum); + int nonlogged); int lafs_get_cleanable(struct fs *fs, u16 *dev, u32 *seg); void lafs_space_return(struct fs *fs, int credits); diff --git a/segments.c b/segments.c index ada9ea6..66d9faa 100644 --- a/segments.c +++ b/segments.c @@ -1027,7 +1027,7 @@ static void segdelete_all(struct segtracker *st, struct fs *fs) } void lafs_free_get(struct fs *fs, unsigned int *dev, u32 *seg, - int nonlogged, int ssnum) + int nonlogged) { /* Select and return a free segment. * The youth value must have been zero, and we set it to the @@ -1075,6 +1075,7 @@ again: * over-ride that */ struct segsum *ssum; + int ssnum; if (fs->youth_next < 0x8000) fs->youth_next = 0x8000; @@ -1095,24 +1096,29 @@ again: spin_unlock(&fs->lock); /* now need to reserve/dirty/reference the youth and - * segsum block + * segsum block for each snapshot that could possibly + * get written here. + * NOTE: this needs fixing to support snapshots. Later. */ - ssum = segsum_find(fs, ss->segment, ss->dev, ssnum); - if (IS_ERR(ss)) - /* ?? what do I need to release etc */ - /* Maybe this cannot fail because we own references - * to the two blocks !! */ - LAFS_BUG(1, &db->b); - lafs_checkpoint_lock(fs); - (void)lafs_reserve_block(&ssum->ssblk->b, AccountSpace); - if (ssnum == 0) - (void)lafs_reserve_block(&ssum->youthblk->b, AccountSpace); + for (ssnum = 0; ssnum < 1 ; ssnum++) { + ssum = segsum_find(fs, ss->segment, ss->dev, ssnum); + if (IS_ERR(ss)) + /* ?? what do I need to release etc */ + /* Maybe this cannot fail because we own references + * to the two blocks !! */ + LAFS_BUG(1, &db->b); + lafs_checkpoint_lock(fs); + (void)lafs_reserve_block(&ssum->ssblk->b, AccountSpace); + if (ssnum == 0) + (void)lafs_reserve_block(&ssum->youthblk->b, AccountSpace); + lafs_checkpoint_unlock(fs); + /* These aren't in the table any more - the segsum holds + * the necessary reference */ + putdref(ssum->ssblk, MKREF(intable)); + putdref(ssum->youthblk, MKREF(intable)); + } lafs_dirty_dblock(db); - lafs_checkpoint_unlock(fs); putdref(db, MKREF(youth)); - /* These aren't in the table any more */ - putdref(ssum->ssblk, MKREF(intable)); - putdref(ssum->youthblk, MKREF(intable)); 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 */