From 770ce5c3bfeca01266c59598cd7f9ea0df263eb7 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 12 Oct 2018 15:14:22 +0000 Subject: [PATCH] Add ZIO_TYPE_FREE support for indirect vdevs. Upstream code expects only ZIO_TYPE_READ and some ZIO_TYPE_WRITE requests to removed (indirect) vdevs, while on FreeBSD there is also ZIO_TYPE_FREE (TRIM). ZIO_TYPE_FREE requests do not have the data buffers, so don't need the pointer adjustment. PR: 228750, 229007 Reviewed by: allanjude, sef Approved by: re (kib) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D17523 --- .../opensolaris/uts/common/fs/zfs/vdev_indirect.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c index 7bca6c629c4..5fb44936b12 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c @@ -1147,6 +1147,9 @@ vdev_indirect_child_io_done(zio_t *zio) pio->io_error = zio_worst_error(pio->io_error, zio->io_error); mutex_exit(&pio->io_lock); +#ifdef __FreeBSD__ + if (zio->io_abd != NULL) +#endif abd_put(zio->io_abd); } @@ -1262,8 +1265,12 @@ vdev_indirect_io_start(zio_t *zio) zio->io_vsd_ops = &vdev_indirect_vsd_ops; ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0); +#ifdef __FreeBSD__ + if (zio->io_type == ZIO_TYPE_WRITE) { +#else if (zio->io_type != ZIO_TYPE_READ) { ASSERT3U(zio->io_type, ==, ZIO_TYPE_WRITE); +#endif /* * Note: this code can handle other kinds of writes, * but we don't expect them. @@ -1295,6 +1302,9 @@ vdev_indirect_io_start(zio_t *zio) ASSERT3P(list_next(&iv->iv_splits, first), ==, NULL); zio_nowait(zio_vdev_child_io(zio, zio->io_bp, first->is_vdev, first->is_target_offset, +#ifdef __FreeBSD__ + zio->io_abd == NULL ? NULL : +#endif abd_get_offset(zio->io_abd, 0), zio->io_size, zio->io_type, zio->io_priority, 0, vdev_indirect_child_io_done, zio)); @@ -1321,6 +1331,9 @@ vdev_indirect_io_start(zio_t *zio) is != NULL; is = list_next(&iv->iv_splits, is)) { zio_nowait(zio_vdev_child_io(zio, NULL, is->is_vdev, is->is_target_offset, +#ifdef __FreeBSD__ + zio->io_abd == NULL ? NULL : +#endif abd_get_offset(zio->io_abd, is->is_split_offset), is->is_size, zio->io_type,