From 15e75dab0356ebcefc0d64b7602eddebd559e126 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 13 Jul 2008 01:12:41 +0000 Subject: [PATCH] HAMMER 61G/Many: Stabilization of new flush_group code * The mirroring, reblocking, and pruning code are now more robust in checking that too many meta-data buffers have not built up. * Fix a bug in the flusher (today's flusher work) where pure meta-data changes to the media were not being flushed unless there was also a modified inode or two to flush. --- sys/vfs/hammer/hammer.h | 3 ++- sys/vfs/hammer/hammer_flusher.c | 30 +++++++++++++++++++++++++++++- sys/vfs/hammer/hammer_mirror.c | 8 ++++---- sys/vfs/hammer/hammer_prune.c | 8 ++++---- sys/vfs/hammer/hammer_reblock.c | 8 ++++---- 5 files changed, 43 insertions(+), 14 deletions(-) diff --git a/sys/vfs/hammer/hammer.h b/sys/vfs/hammer/hammer.h index 6f3fff18cc..4c8d74a53e 100644 --- a/sys/vfs/hammer/hammer.h +++ b/sys/vfs/hammer/hammer.h @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.114 2008/07/12 23:04:50 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.115 2008/07/13 01:12:41 dillon Exp $ */ /* * This header file contains structures used internally by the HAMMERFS @@ -1116,6 +1116,7 @@ void hammer_flusher_create(hammer_mount_t hmp); void hammer_flusher_destroy(hammer_mount_t hmp); void hammer_flusher_sync(hammer_mount_t hmp); int hammer_flusher_async(hammer_mount_t hmp, hammer_flush_group_t flg); +int hammer_flusher_async_one(hammer_mount_t hmp); void hammer_flusher_wait(hammer_mount_t hmp, int seq); int hammer_flusher_meta_limit(hammer_mount_t hmp); int hammer_flusher_meta_halflimit(hammer_mount_t hmp); diff --git a/sys/vfs/hammer/hammer_flusher.c b/sys/vfs/hammer/hammer_flusher.c index c265adc768..d614c1baa4 100644 --- a/sys/vfs/hammer/hammer_flusher.c +++ b/sys/vfs/hammer/hammer_flusher.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_flusher.c,v 1.37 2008/07/12 23:04:50 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_flusher.c,v 1.38 2008/07/13 01:12:41 dillon Exp $ */ /* * HAMMER dependancy flusher thread @@ -106,6 +106,21 @@ hammer_flusher_async(hammer_mount_t hmp, hammer_flush_group_t close_flg) return(seq); } +int +hammer_flusher_async_one(hammer_mount_t hmp) +{ + int seq; + + if (hmp->flusher.td) { + seq = hmp->flusher.next; + if (hmp->flusher.signal++ == 0) + wakeup(&hmp->flusher.signal); + } else { + seq = hmp->flusher.done; + } + return(seq); +} + void hammer_flusher_wait(hammer_mount_t hmp, int seq) { @@ -229,6 +244,7 @@ hammer_flusher_flush(hammer_mount_t hmp) hammer_inode_t ip; hammer_inode_t next_ip; int slave_index; + int count; /* * Just in-case there's a flush race on mount @@ -239,7 +255,9 @@ hammer_flusher_flush(hammer_mount_t hmp) /* * We only do one flg but we may have to loop/retry. */ + count = 0; while ((flg = TAILQ_FIRST(&hmp->flush_group_list)) != NULL) { + ++count; if (hammer_debug_general & 0x0001) { kprintf("hammer_flush %d ttl=%d recs=%d\n", hmp->flusher.act, @@ -332,6 +350,16 @@ hammer_flusher_flush(hammer_mount_t hmp) } } + /* + * We may have pure meta-data to flush, even if there were no + * flush groups. + */ + if (count == 0 && hmp->locked_dirty_space) { + hammer_start_transaction_fls(&hmp->flusher.trans, hmp); + hammer_flusher_finalize(&hmp->flusher.trans, 1); + hammer_done_transaction(&hmp->flusher.trans); + } + /* * Clean up any freed big-blocks (typically zone-2). * resv->flush_group is typically set several flush groups ahead diff --git a/sys/vfs/hammer/hammer_mirror.c b/sys/vfs/hammer/hammer_mirror.c index 82d9f8f846..34c63c317e 100644 --- a/sys/vfs/hammer/hammer_mirror.c +++ b/sys/vfs/hammer/hammer_mirror.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_mirror.c,v 1.14 2008/07/12 23:04:50 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_mirror.c,v 1.15 2008/07/13 01:12:41 dillon Exp $ */ /* * HAMMER mirroring ioctls - serialize and deserialize modifications made @@ -354,12 +354,12 @@ hammer_ioc_mirror_write(hammer_transaction_t trans, hammer_inode_t ip, * Don't blow out the buffer cache. Leave room for frontend * cache as well. */ - if (hammer_flusher_meta_halflimit(trans->hmp) || - hammer_flusher_undo_exhausted(trans, 2)) { + while (hammer_flusher_meta_halflimit(trans->hmp) || + hammer_flusher_undo_exhausted(trans, 2)) { hammer_unlock_cursor(&cursor, 0); hammer_flusher_wait(trans->hmp, seq); hammer_lock_cursor(&cursor, 0); - seq = hammer_flusher_async(trans->hmp, NULL); + seq = hammer_flusher_async_one(trans->hmp); } /* diff --git a/sys/vfs/hammer/hammer_prune.c b/sys/vfs/hammer/hammer_prune.c index f506822a5d..29fa2afdf1 100644 --- a/sys/vfs/hammer/hammer_prune.c +++ b/sys/vfs/hammer/hammer_prune.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_prune.c,v 1.16 2008/07/12 23:04:50 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_prune.c,v 1.17 2008/07/13 01:12:41 dillon Exp $ */ #include "hammer.h" @@ -214,12 +214,12 @@ retry: } ++prune->stat_scanrecords; - if (hammer_flusher_meta_halflimit(trans->hmp) || - hammer_flusher_undo_exhausted(trans, 2)) { + while (hammer_flusher_meta_halflimit(trans->hmp) || + hammer_flusher_undo_exhausted(trans, 2)) { hammer_unlock_cursor(&cursor, 0); hammer_flusher_wait(trans->hmp, seq); hammer_lock_cursor(&cursor, 0); - seq = hammer_flusher_async(trans->hmp, NULL); + seq = hammer_flusher_async_one(trans->hmp); } hammer_sync_lock_sh(trans); error = hammer_btree_iterate_reverse(&cursor); diff --git a/sys/vfs/hammer/hammer_reblock.c b/sys/vfs/hammer/hammer_reblock.c index aa2b1e2de2..2b3418f512 100644 --- a/sys/vfs/hammer/hammer_reblock.c +++ b/sys/vfs/hammer/hammer_reblock.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_reblock.c,v 1.29 2008/07/12 23:04:50 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_reblock.c,v 1.30 2008/07/13 01:12:41 dillon Exp $ */ /* * HAMMER reblocker - This code frees up fragmented physical space @@ -155,12 +155,12 @@ retry: error = hammer_reblock_helper(reblock, &cursor, elm); hammer_sync_unlock(trans); - if (hammer_flusher_meta_halflimit(trans->hmp) || - hammer_flusher_undo_exhausted(trans, 2)) { + while (hammer_flusher_meta_halflimit(trans->hmp) || + hammer_flusher_undo_exhausted(trans, 2)) { hammer_unlock_cursor(&cursor, 0); hammer_flusher_wait(trans->hmp, seq); hammer_lock_cursor(&cursor, 0); - seq = hammer_flusher_async(trans->hmp, NULL); + seq = hammer_flusher_async_one(trans->hmp); } if (error == 0) { cursor.flags |= HAMMER_CURSOR_ATEDISK; -- 2.41.0