]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Illumos 4753 - increase number of outstanding async writes when sync task is waiting
authorAlex Reece <alex@delphix.com>
Fri, 18 Jul 2014 15:08:31 +0000 (07:08 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 23 Sep 2014 20:50:55 +0000 (13:50 -0700)
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Garrett D'Amore <garrett@damore.org>

References:
    https://www.illumos.org/issues/4753
    https://github.com/illumos/illumos-gate/commit/73527f4

Comments by Matt Ahrens from the issue tracker:
    When a sync task is waiting for a txg to complete, we should hurry
    it along by increasing the number of outstanding async writes
    (i.e. make vdev_queue_max_async_writes() return a larger number).
    Initially we might just have a tunable for "minimum async writes
    while a synctask is waiting" and set it to 3.

Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2716

include/sys/spa.h
include/sys/txg.h
module/zfs/spa_misc.c
module/zfs/txg.c
module/zfs/vdev_queue.c

index cc9569255f48e6581c77f6968e924da01069cf9b..1faf0420f21a2f3d6a5f96f8449e14dcfa1416e7 100644 (file)
@@ -822,6 +822,7 @@ extern uint64_t bp_get_dsize(spa_t *spa, const blkptr_t *bp);
 extern boolean_t spa_has_slogs(spa_t *spa);
 extern boolean_t spa_is_root(spa_t *spa);
 extern boolean_t spa_writeable(spa_t *spa);
+extern boolean_t spa_has_pending_synctask(spa_t *spa);
 
 extern int spa_mode(spa_t *spa);
 extern uint64_t strtonum(const char *str, char **nptr);
index 1bb6bac917e43e34fcaf0b8160b0b1b04aa29047..44f81beca420bbc7f66cfbb136787d3246440ed0 100644 (file)
@@ -23,7 +23,7 @@
  * Use is subject to license terms.
  */
 /*
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  */
 
 #ifndef _SYS_TXG_H
@@ -118,6 +118,7 @@ extern void txg_wait_callbacks(struct dsl_pool *dp);
 extern void txg_list_create(txg_list_t *tl, size_t offset);
 extern void txg_list_destroy(txg_list_t *tl);
 extern boolean_t txg_list_empty(txg_list_t *tl, uint64_t txg);
+extern boolean_t txg_all_lists_empty(txg_list_t *tl);
 extern boolean_t txg_list_add(txg_list_t *tl, void *p, uint64_t txg);
 extern boolean_t txg_list_add_tail(txg_list_t *tl, void *p, uint64_t txg);
 extern void *txg_list_remove(txg_list_t *tl, uint64_t txg);
index 1bed90027ecdaf86abf2623380bc4f104b854cd3..abe313de474d1664a9c5275d2dfa486acdf678fc 100644 (file)
@@ -1756,6 +1756,16 @@ spa_writeable(spa_t *spa)
        return (!!(spa->spa_mode & FWRITE));
 }
 
+/*
+ * Returns true if there is a pending sync task in any of the current
+ * syncing txg, the current quiescing txg, or the current open txg.
+ */
+boolean_t
+spa_has_pending_synctask(spa_t *spa)
+{
+       return (!txg_all_lists_empty(&spa->spa_dsl_pool->dp_sync_tasks));
+}
+
 int
 spa_mode(spa_t *spa)
 {
index a39732bb918111d691253ad39bc696fe5138abe3..a102618465d5c06d1690e8bf23d7d73332d43dad 100644 (file)
@@ -21,7 +21,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Portions Copyright 2011 Martin Matuska
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  */
 
 #include <sys/zfs_context.h>
@@ -786,6 +786,26 @@ txg_list_empty(txg_list_t *tl, uint64_t txg)
        return (tl->tl_head[txg & TXG_MASK] == NULL);
 }
 
+/*
+ * Returns true if all txg lists are empty.
+ *
+ * Warning: this is inherently racy (an item could be added immediately
+ * after this function returns). We don't bother with the lock because
+ * it wouldn't change the semantics.
+ */
+boolean_t
+txg_all_lists_empty(txg_list_t *tl)
+{
+       int i;
+
+       for (i = 0; i < TXG_SIZE; i++) {
+               if (!txg_list_empty(tl, i)) {
+                       return (B_FALSE);
+               }
+       }
+       return (B_TRUE);
+}
+
 /*
  * Add an entry to the list (unless it's already on the list).
  * Returns B_TRUE if it was actually added.
index e2758d1c41f5c63ba3ab39f4a7cf611690f6c51b..34e4420da7336f8b2a794976ee6a5490302bb663 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 /*
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  */
 
 #include <sys/zfs_context.h>
@@ -230,14 +230,23 @@ vdev_queue_class_min_active(zio_priority_t p)
 }
 
 static int
-vdev_queue_max_async_writes(uint64_t dirty)
+vdev_queue_max_async_writes(spa_t *spa)
 {
        int writes;
+       uint64_t dirty = spa->spa_dsl_pool->dp_dirty_total;
        uint64_t min_bytes = zfs_dirty_data_max *
            zfs_vdev_async_write_active_min_dirty_percent / 100;
        uint64_t max_bytes = zfs_dirty_data_max *
            zfs_vdev_async_write_active_max_dirty_percent / 100;
 
+       /*
+        * Sync tasks correspond to interactive user actions. To reduce the
+        * execution time of those actions we push data out as fast as possible.
+        */
+       if (spa_has_pending_synctask(spa)) {
+               return (zfs_vdev_async_write_max_active);
+       }
+
        if (dirty < min_bytes)
                return (zfs_vdev_async_write_min_active);
        if (dirty > max_bytes)
@@ -270,8 +279,7 @@ vdev_queue_class_max_active(spa_t *spa, zio_priority_t p)
        case ZIO_PRIORITY_ASYNC_READ:
                return (zfs_vdev_async_read_max_active);
        case ZIO_PRIORITY_ASYNC_WRITE:
-               return (vdev_queue_max_async_writes(
-                   spa->spa_dsl_pool->dp_dirty_total));
+               return (vdev_queue_max_async_writes(spa));
        case ZIO_PRIORITY_SCRUB:
                return (zfs_vdev_scrub_max_active);
        default: