svn commit: r321614 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys
Alexander Motin
mav at FreeBSD.org
Thu Jul 27 10:30:56 UTC 2017
Author: mav
Date: Thu Jul 27 10:30:55 2017
New Revision: 321614
URL: https://svnweb.freebsd.org/changeset/base/321614
Log:
MFC r320352: zfs: port vdev_file part of illumos change 3306
3306 zdb should be able to issue reads in parallel
illumos/illumos-gate/31d7e8fa33fae995f558673adb22641b5aa8b6e1
https://www.illumos.org/issues/3306
The upstream change was made before we started to import upstream commits
individually. It was imported into the illumos vendor area as r242733.
That commit was MFV-ed in r260138, but as the commit message says
vdev_file.c was left intact.
This commit actually implements the parallel I/O for vdev_file using a
taskqueue with multiple thread. This implementation does not depend on
the illumos or FreeBSD bio interface at all, but uses zio_t to pass
around all the relevent data. So, the code looks a bit different from
the upstream.
This commit also incorporates ZoL commit
zfsonlinux/zfs/bc25c9325b0e5ced897b9820dad239539d561ec9 that fixed
https://github.com/zfsonlinux/zfs/issues/2270
We need to use a dedicated taskqueue for exactly the same reason as ZoL
as we do not implement TASKQ_DYNAMIC.
Obtained from: illumos, ZFS on Linux
Modified:
stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_file.h
stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Thu Jul 27 10:29:29 2017 (r321613)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Thu Jul 27 10:30:55 2017 (r321614)
@@ -39,6 +39,7 @@
#include <sys/zap.h>
#include <sys/zil.h>
#include <sys/vdev_impl.h>
+#include <sys/vdev_file.h>
#include <sys/metaslab.h>
#include <sys/uberblock_impl.h>
#include <sys/txg.h>
@@ -2024,6 +2025,7 @@ spa_init(int mode)
dmu_init();
zil_init();
vdev_cache_stat_init();
+ vdev_file_init();
zfs_prop_init();
zpool_prop_init();
zpool_feature_init();
@@ -2043,6 +2045,7 @@ spa_fini(void)
spa_evict_all();
+ vdev_file_fini();
vdev_cache_stat_fini();
zil_fini();
dmu_fini();
Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_file.h
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_file.h Thu Jul 27 10:29:29 2017 (r321613)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_file.h Thu Jul 27 10:30:55 2017 (r321614)
@@ -39,6 +39,9 @@ typedef struct vdev_file {
vnode_t *vf_vnode;
} vdev_file_t;
+extern void vdev_file_init(void);
+extern void vdev_file_fini(void);
+
#ifdef __cplusplus
}
#endif
Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c Thu Jul 27 10:29:29 2017 (r321613)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c Thu Jul 27 10:30:55 2017 (r321614)
@@ -36,6 +36,21 @@
* Virtual device vector for files.
*/
+static taskq_t *vdev_file_taskq;
+
+void
+vdev_file_init(void)
+{
+ vdev_file_taskq = taskq_create("z_vdev_file", MAX(max_ncpus, 16),
+ minclsyspri, max_ncpus, INT_MAX, 0);
+}
+
+void
+vdev_file_fini(void)
+{
+ taskq_destroy(vdev_file_taskq);
+}
+
static void
vdev_file_hold(vdev_t *vd)
{
@@ -157,41 +172,32 @@ vdev_file_close(vdev_t *vd)
vd->vdev_tsd = NULL;
}
+/*
+ * Implements the interrupt side for file vdev types. This routine will be
+ * called when the I/O completes allowing us to transfer the I/O to the
+ * interrupt taskqs. For consistency, the code structure mimics disk vdev
+ * types.
+ */
static void
-vdev_file_io_start(zio_t *zio)
+vdev_file_io_intr(zio_t *zio)
{
+ zio_delay_interrupt(zio);
+}
+
+static void
+vdev_file_io_strategy(void *arg)
+{
+ zio_t *zio = arg;
vdev_t *vd = zio->io_vd;
vdev_file_t *vf;
vnode_t *vp;
void *addr;
ssize_t resid;
- if (!vdev_readable(vd)) {
- zio->io_error = SET_ERROR(ENXIO);
- zio_interrupt(zio);
- return;
- }
-
vf = vd->vdev_tsd;
vp = vf->vf_vnode;
- if (zio->io_type == ZIO_TYPE_IOCTL) {
- switch (zio->io_cmd) {
- case DKIOCFLUSHWRITECACHE:
- zio->io_error = VOP_FSYNC(vp, FSYNC | FDSYNC,
- kcred, NULL);
- break;
- default:
- zio->io_error = SET_ERROR(ENOTSUP);
- }
-
- zio_execute(zio);
- return;
- }
-
ASSERT(zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE);
- zio->io_target_timestamp = zio_handle_io_delay(zio);
-
if (zio->io_type == ZIO_TYPE_READ) {
addr = abd_borrow_buf(zio->io_abd, zio->io_size);
} else {
@@ -211,12 +217,41 @@ vdev_file_io_start(zio_t *zio)
if (resid != 0 && zio->io_error == 0)
zio->io_error = ENOSPC;
- zio_delay_interrupt(zio);
+ vdev_file_io_intr(zio);
+}
-#ifdef illumos
- VERIFY3U(taskq_dispatch(system_taskq, vdev_file_io_strategy, bp,
+static void
+vdev_file_io_start(zio_t *zio)
+{
+ vdev_t *vd = zio->io_vd;
+ vdev_file_t *vf = vd->vdev_tsd;
+
+ if (zio->io_type == ZIO_TYPE_IOCTL) {
+ /* XXPOLICY */
+ if (!vdev_readable(vd)) {
+ zio->io_error = SET_ERROR(ENXIO);
+ zio_interrupt(zio);
+ return;
+ }
+
+ switch (zio->io_cmd) {
+ case DKIOCFLUSHWRITECACHE:
+ zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC,
+ kcred, NULL);
+ break;
+ default:
+ zio->io_error = SET_ERROR(ENOTSUP);
+ }
+
+ zio_execute(zio);
+ return;
+ }
+
+ ASSERT(zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE);
+ zio->io_target_timestamp = zio_handle_io_delay(zio);
+
+ VERIFY3U(taskq_dispatch(vdev_file_taskq, vdev_file_io_strategy, zio,
TQ_SLEEP), !=, 0);
-#endif
}
/* ARGSUSED */
More information about the svn-src-stable-11
mailing list