Skip to content

Commit acbad6f

Browse files
Alex Reecebehlendorf
authored andcommitted
Illumos 4753 - increase number of outstanding async writes when sync task is waiting
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 illumos/illumos-gate@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
1 parent 1f6f97f commit acbad6f

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

include/sys/spa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ extern uint64_t bp_get_dsize(spa_t *spa, const blkptr_t *bp);
822822
extern boolean_t spa_has_slogs(spa_t *spa);
823823
extern boolean_t spa_is_root(spa_t *spa);
824824
extern boolean_t spa_writeable(spa_t *spa);
825+
extern boolean_t spa_has_pending_synctask(spa_t *spa);
825826

826827
extern int spa_mode(spa_t *spa);
827828
extern uint64_t strtonum(const char *str, char **nptr);

include/sys/txg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Use is subject to license terms.
2424
*/
2525
/*
26-
* Copyright (c) 2013 by Delphix. All rights reserved.
26+
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
2727
*/
2828

2929
#ifndef _SYS_TXG_H
@@ -118,6 +118,7 @@ extern void txg_wait_callbacks(struct dsl_pool *dp);
118118
extern void txg_list_create(txg_list_t *tl, size_t offset);
119119
extern void txg_list_destroy(txg_list_t *tl);
120120
extern boolean_t txg_list_empty(txg_list_t *tl, uint64_t txg);
121+
extern boolean_t txg_all_lists_empty(txg_list_t *tl);
121122
extern boolean_t txg_list_add(txg_list_t *tl, void *p, uint64_t txg);
122123
extern boolean_t txg_list_add_tail(txg_list_t *tl, void *p, uint64_t txg);
123124
extern void *txg_list_remove(txg_list_t *tl, uint64_t txg);

module/zfs/spa_misc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,16 @@ spa_writeable(spa_t *spa)
17561756
return (!!(spa->spa_mode & FWRITE));
17571757
}
17581758

1759+
/*
1760+
* Returns true if there is a pending sync task in any of the current
1761+
* syncing txg, the current quiescing txg, or the current open txg.
1762+
*/
1763+
boolean_t
1764+
spa_has_pending_synctask(spa_t *spa)
1765+
{
1766+
return (!txg_all_lists_empty(&spa->spa_dsl_pool->dp_sync_tasks));
1767+
}
1768+
17591769
int
17601770
spa_mode(spa_t *spa)
17611771
{

module/zfs/txg.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/*
2222
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
2323
* Portions Copyright 2011 Martin Matuska
24-
* Copyright (c) 2013 by Delphix. All rights reserved.
24+
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
2525
*/
2626

2727
#include <sys/zfs_context.h>
@@ -786,6 +786,26 @@ txg_list_empty(txg_list_t *tl, uint64_t txg)
786786
return (tl->tl_head[txg & TXG_MASK] == NULL);
787787
}
788788

789+
/*
790+
* Returns true if all txg lists are empty.
791+
*
792+
* Warning: this is inherently racy (an item could be added immediately
793+
* after this function returns). We don't bother with the lock because
794+
* it wouldn't change the semantics.
795+
*/
796+
boolean_t
797+
txg_all_lists_empty(txg_list_t *tl)
798+
{
799+
int i;
800+
801+
for (i = 0; i < TXG_SIZE; i++) {
802+
if (!txg_list_empty(tl, i)) {
803+
return (B_FALSE);
804+
}
805+
}
806+
return (B_TRUE);
807+
}
808+
789809
/*
790810
* Add an entry to the list (unless it's already on the list).
791811
* Returns B_TRUE if it was actually added.

module/zfs/vdev_queue.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626
/*
27-
* Copyright (c) 2013 by Delphix. All rights reserved.
27+
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
2828
*/
2929

3030
#include <sys/zfs_context.h>
@@ -230,14 +230,23 @@ vdev_queue_class_min_active(zio_priority_t p)
230230
}
231231

232232
static int
233-
vdev_queue_max_async_writes(uint64_t dirty)
233+
vdev_queue_max_async_writes(spa_t *spa)
234234
{
235235
int writes;
236+
uint64_t dirty = spa->spa_dsl_pool->dp_dirty_total;
236237
uint64_t min_bytes = zfs_dirty_data_max *
237238
zfs_vdev_async_write_active_min_dirty_percent / 100;
238239
uint64_t max_bytes = zfs_dirty_data_max *
239240
zfs_vdev_async_write_active_max_dirty_percent / 100;
240241

242+
/*
243+
* Sync tasks correspond to interactive user actions. To reduce the
244+
* execution time of those actions we push data out as fast as possible.
245+
*/
246+
if (spa_has_pending_synctask(spa)) {
247+
return (zfs_vdev_async_write_max_active);
248+
}
249+
241250
if (dirty < min_bytes)
242251
return (zfs_vdev_async_write_min_active);
243252
if (dirty > max_bytes)
@@ -270,8 +279,7 @@ vdev_queue_class_max_active(spa_t *spa, zio_priority_t p)
270279
case ZIO_PRIORITY_ASYNC_READ:
271280
return (zfs_vdev_async_read_max_active);
272281
case ZIO_PRIORITY_ASYNC_WRITE:
273-
return (vdev_queue_max_async_writes(
274-
spa->spa_dsl_pool->dp_dirty_total));
282+
return (vdev_queue_max_async_writes(spa));
275283
case ZIO_PRIORITY_SCRUB:
276284
return (zfs_vdev_scrub_max_active);
277285
default:

0 commit comments

Comments
 (0)