Skip to content

Commit 2883cad

Browse files
ahrensbehlendorf
authored andcommitted
Illumos #3836
3836 zio_free() can be processed immediately in the common case Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Approved by: Dan McDonald <danmcd@nexenta.com> References: https://www.illumos.org/issues/3836 illumos/illumos-gate@9cb154a Ported-by: Richard Yao <ryao@gentoo.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #1775
1 parent 498877b commit 2883cad

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

include/sys/zio_impl.h

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

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

3030
#ifndef _ZIO_IMPL_H
@@ -38,7 +38,7 @@ extern "C" {
3838
#endif
3939

4040
/*
41-
* XXX -- Describe ZFS I/O pipleine here. Fill in as needed.
41+
* XXX -- Describe ZFS I/O pipeline here. Fill in as needed.
4242
*
4343
* The ZFS I/O pipeline is comprised of various stages which are defined
4444
* in the zio_stage enum below. The individual stages are used to construct
@@ -213,7 +213,6 @@ enum zio_stage {
213213
#define ZIO_FREE_PIPELINE \
214214
(ZIO_INTERLOCK_STAGES | \
215215
ZIO_STAGE_FREE_BP_INIT | \
216-
ZIO_STAGE_ISSUE_ASYNC | \
217216
ZIO_STAGE_DVA_FREE)
218217

219218
#define ZIO_DDT_FREE_PIPELINE \

module/zfs/zio.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,14 +783,28 @@ void
783783
zio_free(spa_t *spa, uint64_t txg, const blkptr_t *bp)
784784
{
785785
metaslab_check_free(spa, bp);
786-
bplist_append(&spa->spa_free_bplist[txg & TXG_MASK], bp);
786+
787+
/*
788+
* Frees that are for the currently-syncing txg, are not going to be
789+
* deferred, and which will not need to do a read (i.e. not GANG or
790+
* DEDUP), can be processed immediately. Otherwise, put them on the
791+
* in-memory list for later processing.
792+
*/
793+
if (BP_IS_GANG(bp) || BP_GET_DEDUP(bp) ||
794+
txg != spa->spa_syncing_txg ||
795+
spa_sync_pass(spa) >= zfs_sync_pass_deferred_free) {
796+
bplist_append(&spa->spa_free_bplist[txg & TXG_MASK], bp);
797+
} else {
798+
VERIFY0(zio_wait(zio_free_sync(NULL, spa, txg, bp, 0)));
799+
}
787800
}
788801

789802
zio_t *
790803
zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
791804
enum zio_flag flags)
792805
{
793806
zio_t *zio;
807+
enum zio_stage stage = ZIO_FREE_PIPELINE;
794808

795809
dprintf_bp(bp, "freeing in txg %llu, pass %u",
796810
(longlong_t)txg, spa->spa_sync_pass);
@@ -802,9 +816,18 @@ zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
802816
metaslab_check_free(spa, bp);
803817
arc_freed(spa, bp);
804818

819+
/*
820+
* GANG and DEDUP blocks can induce a read (for the gang block header,
821+
* or the DDT), so issue them asynchronously so that this thread is
822+
* not tied up.
823+
*/
824+
if (BP_IS_GANG(bp) || BP_GET_DEDUP(bp))
825+
stage |= ZIO_STAGE_ISSUE_ASYNC;
826+
805827
zio = zio_create(pio, spa, txg, bp, NULL, BP_GET_PSIZE(bp),
806-
NULL, NULL, ZIO_TYPE_FREE, ZIO_PRIORITY_FREE, flags,
807-
NULL, 0, NULL, ZIO_STAGE_OPEN, ZIO_FREE_PIPELINE);
828+
NULL, NULL, ZIO_TYPE_FREE, ZIO_PRIORITY_NOW, flags,
829+
NULL, 0, NULL, ZIO_STAGE_OPEN, stage);
830+
808831

809832
return (zio);
810833
}

0 commit comments

Comments
 (0)