HAMMER 43C/Many: Performance cleanup
authorMatthew Dillon <dillon@dragonflybsd.org>
Tue, 13 May 2008 05:04:39 +0000 (05:04 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Tue, 13 May 2008 05:04:39 +0000 (05:04 +0000)
* Do not put an inode on the sync list when it becomes inactive, unless
  it no longer has filesystem visibility.  This greatly reduces the amount
  of cycling which occurs on the inode B-Tree element, and greatly reduces
  spurious backend flushes.

  This change results in a major performance improvement for both reads
  and writes in a massively parallel I/O test (blogbench).  Write
  performance more then doubles and read performance increases by 20%.

* Lock the freemap free code.

* Remove some of the debug code.

sys/vfs/hammer/hammer_btree.c
sys/vfs/hammer/hammer_freemap.c
sys/vfs/hammer/hammer_inode.c
sys/vfs/hammer/hammer_ondisk.c

index da83573..21ace0b 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_btree.c,v 1.46 2008/05/12 21:17:18 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_btree.c,v 1.47 2008/05/13 05:04:39 dillon Exp $
  */
 
 /*
@@ -1927,7 +1927,8 @@ hammer_btree_correct_lhb(hammer_cursor_t cursor, hammer_tid_t tid)
  * On return the cursor may end up pointing at an internal node, suitable
  * for further iteration but not for an immediate insertion or deletion.
  *
- * cursor->node may be an internal node or a leaf node.
+ * cursor->node may be an internal node or a leaf node.  The cursor must be
+ * locked (node and parent).
  *
  * NOTE: If cursor->node has one element it is the parent trying to delete
  * that element, make sure cursor->index is properly adjusted on success.
@@ -1992,8 +1993,8 @@ btree_remove(hammer_cursor_t cursor)
                error = hammer_cursor_upgrade(cursor);
 
        if (error) {
-               kprintf("BTREE_REMOVE: Cannot lock parent, skipping\n");
-               Debugger("BTREE_REMOVE");
+               kprintf("Warning: BTREE_REMOVE: Defering parent removal "
+                       "@ %016llx, skipping\n", cursor->parent->node_offset);
                hammer_modify_node_done(parent);
                return (0);
        }
index 270a611..3ccc702 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_freemap.c,v 1.10 2008/05/04 09:06:45 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_freemap.c,v 1.11 2008/05/13 05:04:39 dillon Exp $
  */
 
 /*
@@ -158,6 +158,8 @@ hammer_freemap_free(hammer_transaction_t trans, hammer_off_t phys_offset,
        *errorp = 0;
        ondisk = trans->rootvol->ondisk;
 
+       hammer_lock_ex(&trans->hmp->free_lock);
+
        blockmap = &trans->hmp->blockmap[HAMMER_ZONE_FREEMAP_INDEX];
        layer1_offset = blockmap->phys_offset +
                        HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
@@ -182,6 +184,8 @@ hammer_freemap_free(hammer_transaction_t trans, hammer_off_t phys_offset,
        ++ondisk->vol0_stat_freebigblocks;
        hammer_modify_volume_done(trans->rootvol);
 
+       hammer_unlock(&trans->hmp->free_lock);
+
        if (buffer1)
                hammer_rel_buffer(buffer1, 0);
        if (buffer2)
index 7d6e8fa..3fff7b2 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_inode.c,v 1.57 2008/05/13 00:15:28 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_inode.c,v 1.58 2008/05/13 05:04:39 dillon Exp $
  */
 
 #include "hammer.h"
@@ -67,12 +67,18 @@ hammer_vop_inactive(struct vop_inactive_args *ap)
         * If the inode no longer has visibility in the filesystem and is
         * fairly clean, try to recycle it immediately.  This can deadlock
         * in vfsync() if we aren't careful.
+        * 
+        * Do not queue the inode to the flusher if we still have visibility,
+        * otherwise namespace calls such as chmod will unnecessarily generate
+        * multiple inode updates.
         */
        hammer_inode_unloadable_check(ip, 0);
-       if (ip->flags & HAMMER_INODE_MODMASK)
-               hammer_flush_inode(ip, 0);
-       else if (ip->ino_data.nlinks == 0)
-               vrecycle(ap->a_vp);
+       if (ip->ino_data.nlinks == 0) {
+               if (ip->flags & HAMMER_INODE_MODMASK)
+                       hammer_flush_inode(ip, 0);
+               else
+                       vrecycle(ap->a_vp);
+       }
        return(0);
 }
 
index 6b88b54..b79902f 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_ondisk.c,v 1.42 2008/05/12 21:17:18 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_ondisk.c,v 1.43 2008/05/13 05:04:39 dillon Exp $
  */
 /*
  * Manage HAMMER's on-disk structures.  These routines are primarily
@@ -1044,6 +1044,7 @@ hammer_rel_node(hammer_node_t node)
 void
 hammer_delete_node(hammer_transaction_t trans, hammer_node_t node)
 {
+       KKASSERT((node->flags & HAMMER_NODE_DELETED) == 0);
        node->flags |= HAMMER_NODE_DELETED;
        hammer_blockmap_free(trans, node->node_offset, sizeof(*node->ondisk));
 }