HAMMER 61G/Many: Stabilization of new flush_group code
authorMatthew Dillon <dillon@dragonflybsd.org>
Sun, 13 Jul 2008 01:12:41 +0000 (01:12 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Sun, 13 Jul 2008 01:12:41 +0000 (01:12 +0000)
* 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
sys/vfs/hammer/hammer_flusher.c
sys/vfs/hammer/hammer_mirror.c
sys/vfs/hammer/hammer_prune.c
sys/vfs/hammer/hammer_reblock.c

index 6f3fff1..4c8d74a 100644 (file)
@@ -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);
index c265adc..d614c1b 100644 (file)
@@ -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
index 82d9f8f..34c63c3 100644 (file)
@@ -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);
                }
 
                /*
index f506822..29fa2af 100644 (file)
@@ -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);
index aa2b1e2..2b3418f 100644 (file)
@@ -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;