HAMMER VFS - Add another lwkt_user_yield()
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 24 Aug 2010 23:09:48 +0000 (16:09 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 24 Aug 2010 23:09:48 +0000 (16:09 -0700)
* Add a lwkt_user_yield() call to reverse b-tree iterations, which are
  used by the pruning code.  Forward iterations already call
  lwkt_user_yield().

sys/vfs/hammer/hammer_btree.c

index b1e2a28..44e5382 100644 (file)
@@ -433,6 +433,7 @@ hammer_btree_iterate_reverse(hammer_cursor_t cursor)
 {
        hammer_node_ondisk_t node;
        hammer_btree_elm_t elm;
+       hammer_mount_t hmp;
        int error = 0;
        int r;
        int s;
@@ -456,11 +457,20 @@ hammer_btree_iterate_reverse(hammer_cursor_t cursor)
                --cursor->index;
 
        /*
+        * HAMMER can wind up being cpu-bound.
+        */
+       hmp = cursor->trans->hmp;
+       if (++hmp->check_yield > hammer_yield_check) {
+               hmp->check_yield = 0;
+               lwkt_user_yield();
+       }
+
+       /*
         * Loop until an element is found or we are done.
         */
        for (;;) {
                ++hammer_stats_btree_iterations;
-               hammer_flusher_clean_loose_ios(cursor->trans->hmp);
+               hammer_flusher_clean_loose_ios(hmp);
 
                /*
                 * We iterate up the tree and then index over one element