Skip to content

Commit

Permalink
zio: rename ZIO_TYPE_IOCTL to ZIO_TYPE_FLUSH
Browse files Browse the repository at this point in the history
The only possible ioctl is a flush, and any other kind of meta-operation
introduced in the future is likely to have different semantics (much
like trim did). So, lets just call it what it is.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <robn@despairlabs.com>
  • Loading branch information
robn committed Apr 6, 2024
1 parent 5dbdf9a commit f5d0ad5
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 37 deletions.
8 changes: 7 additions & 1 deletion include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1094,11 +1094,17 @@ typedef enum zio_type {
ZIO_TYPE_WRITE,
ZIO_TYPE_FREE,
ZIO_TYPE_CLAIM,
ZIO_TYPE_IOCTL,
ZIO_TYPE_FLUSH,
ZIO_TYPE_TRIM,
ZIO_TYPES
} zio_type_t;

/*
* Compatbility: _IOCTL was renamed to _FLUSH; keep the old name available to
* user programs.
*/
#define ZIO_TYPE_IOCTL ZIO_TYPE_FLUSH

/*
* Pool statistics. Note: all fields should be 64-bit because this
* is passed between kernel and userland as an nvlist uint64 array.
Expand Down
16 changes: 8 additions & 8 deletions include/sys/zio_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ extern "C" {
*
* The ZFS I/O pipeline is comprised of various stages which are defined
* in the zio_stage enum below. The individual stages are used to construct
* these basic I/O operations: Read, Write, Free, Claim, Ioctl and Trim.
* these basic I/O operations: Read, Write, Free, Claim, Flush and Trim.
*
* I/O operations: (XXX - provide detail for each of the operations)
*
* Read:
* Write:
* Free:
* Claim:
* Ioctl:
* Flush:
* Trim:
*
* Although the most common pipeline are used by the basic I/O operations
Expand Down Expand Up @@ -122,7 +122,7 @@ extern "C" {
* zio pipeline stage definitions
*/
enum zio_stage {
ZIO_STAGE_OPEN = 1 << 0, /* RWFCIT */
ZIO_STAGE_OPEN = 1 << 0, /* RWFCXT */

ZIO_STAGE_READ_BP_INIT = 1 << 1, /* R----- */
ZIO_STAGE_WRITE_BP_INIT = 1 << 2, /* -W---- */
Expand Down Expand Up @@ -150,15 +150,15 @@ enum zio_stage {
ZIO_STAGE_DVA_FREE = 1 << 18, /* --F--- */
ZIO_STAGE_DVA_CLAIM = 1 << 19, /* ---C-- */

ZIO_STAGE_READY = 1 << 20, /* RWFCIT */
ZIO_STAGE_READY = 1 << 20, /* RWFCXT */

ZIO_STAGE_VDEV_IO_START = 1 << 21, /* RW--IT */
ZIO_STAGE_VDEV_IO_START = 1 << 21, /* RW--XT */
ZIO_STAGE_VDEV_IO_DONE = 1 << 22, /* RW---T */
ZIO_STAGE_VDEV_IO_ASSESS = 1 << 23, /* RW--IT */
ZIO_STAGE_VDEV_IO_ASSESS = 1 << 23, /* RW--XT */

ZIO_STAGE_CHECKSUM_VERIFY = 1 << 24, /* R----- */

ZIO_STAGE_DONE = 1 << 25 /* RWFCIT */
ZIO_STAGE_DONE = 1 << 25 /* RWFCXT */
};

#define ZIO_ROOT_PIPELINE \
Expand Down Expand Up @@ -259,7 +259,7 @@ enum zio_stage {
(ZIO_INTERLOCK_STAGES | \
ZIO_STAGE_DVA_CLAIM)

#define ZIO_IOCTL_PIPELINE \
#define ZIO_FLUSH_PIPELINE \
(ZIO_INTERLOCK_STAGES | \
ZIO_STAGE_VDEV_IO_START | \
ZIO_STAGE_VDEV_IO_ASSESS)
Expand Down
10 changes: 5 additions & 5 deletions man/man8/zpool-events.8
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ that is, the bits set in the good data which are cleared in the bad data.
.Sh I/O STAGES
The ZFS I/O pipeline is comprised of various stages which are defined below.
The individual stages are used to construct these basic I/O
operations: Read, Write, Free, Claim, Ioctl and Trim.
operations: Read, Write, Free, Claim, Flush and Trim.
These stages may be
set on an event to describe the life cycle of a given I/O request.
.Pp
Expand All @@ -373,7 +373,7 @@ tab(:);
l l l .
Stage:Bit Mask:Operations
_:_:_
ZIO_STAGE_OPEN:0x00000001:RWFCIT
ZIO_STAGE_OPEN:0x00000001:RWFCXT

ZIO_STAGE_READ_BP_INIT:0x00000002:R-----
ZIO_STAGE_WRITE_BP_INIT:0x00000004:-W----
Expand Down Expand Up @@ -403,13 +403,13 @@ ZIO_STAGE_DVA_CLAIM:0x00080000:---C--

ZIO_STAGE_READY:0x00100000:RWFCIT

ZIO_STAGE_VDEV_IO_START:0x00200000:RW--IT
ZIO_STAGE_VDEV_IO_START:0x00200000:RW--XT
ZIO_STAGE_VDEV_IO_DONE:0x00400000:RW---T
ZIO_STAGE_VDEV_IO_ASSESS:0x00800000:RW--IT
ZIO_STAGE_VDEV_IO_ASSESS:0x00800000:RW--XT

ZIO_STAGE_CHECKSUM_VERIFY:0x01000000:R-----

ZIO_STAGE_DONE:0x02000000:RWFCIT
ZIO_STAGE_DONE:0x02000000:RWFCXT
.TE
.
.Sh I/O FLAGS
Expand Down
2 changes: 1 addition & 1 deletion module/os/freebsd/zfs/vdev_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ 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) {
if (zio->io_type == ZIO_TYPE_FLUSH) {
/* XXPOLICY */
if (!vdev_readable(vd)) {
zio->io_error = SET_ERROR(ENXIO);
Expand Down
8 changes: 4 additions & 4 deletions module/os/freebsd/zfs/vdev_geom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ vdev_geom_io_intr(struct bio *bp)
/*
* We have to split bio freeing into two parts, because the ABD code
* cannot be called in this context and vdev_op_io_done is not called
* for ZIO_TYPE_IOCTL zio-s.
* for ZIO_TYPE_FLUSH zio-s.
*/
if (zio->io_type != ZIO_TYPE_READ && zio->io_type != ZIO_TYPE_WRITE) {
g_destroy_bio(bp);
Expand Down Expand Up @@ -1153,7 +1153,7 @@ vdev_geom_io_start(zio_t *zio)

vd = zio->io_vd;

if (zio->io_type == ZIO_TYPE_IOCTL) {
if (zio->io_type == ZIO_TYPE_FLUSH) {
/* XXPOLICY */
if (!vdev_readable(vd)) {
zio->io_error = SET_ERROR(ENXIO);
Expand Down Expand Up @@ -1181,7 +1181,7 @@ vdev_geom_io_start(zio_t *zio)
ASSERT(zio->io_type == ZIO_TYPE_READ ||
zio->io_type == ZIO_TYPE_WRITE ||
zio->io_type == ZIO_TYPE_TRIM ||
zio->io_type == ZIO_TYPE_IOCTL);
zio->io_type == ZIO_TYPE_FLUSH);

cp = vd->vdev_tsd;
if (cp == NULL) {
Expand Down Expand Up @@ -1233,7 +1233,7 @@ vdev_geom_io_start(zio_t *zio)
bp->bio_offset = zio->io_offset;
bp->bio_length = zio->io_size;
break;
case ZIO_TYPE_IOCTL:
case ZIO_TYPE_FLUSH:
bp->bio_cmd = BIO_FLUSH;
bp->bio_data = NULL;
bp->bio_offset = cp->provider->mediasize;
Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/zfs/vdev_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ vdev_disk_io_start(zio_t *zio)
}

switch (zio->io_type) {
case ZIO_TYPE_IOCTL:
case ZIO_TYPE_FLUSH:

if (!vdev_readable(v)) {
rw_exit(&vd->vd_lock);
Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/zfs/vdev_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ 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) {
if (zio->io_type == ZIO_TYPE_FLUSH) {
/* XXPOLICY */
if (!vdev_readable(vd)) {
zio->io_error = SET_ERROR(ENXIO);
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static zio_taskq_info_t zio_taskqs[ZIO_TYPES][ZIO_TASKQ_TYPES] = {
{ ZTI_SYNC, ZTI_N(5), ZTI_SCALE, ZTI_N(5) }, /* WRITE */
{ ZTI_SCALE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* FREE */
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* CLAIM */
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* IOCTL */
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* FLUSH */
{ ZTI_N(4), ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* TRIM */
};

Expand Down
12 changes: 6 additions & 6 deletions module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4924,11 +4924,11 @@ vdev_stat_update(zio_t *zio, uint64_t psize)

/*
* TRIM ops and bytes are reported to user space as
* ZIO_TYPE_IOCTL. This is done to preserve the
* ZIO_TYPE_FLUSH. This is done to preserve the
* vdev_stat_t structure layout for user space.
*/
if (type == ZIO_TYPE_TRIM)
vs_type = ZIO_TYPE_IOCTL;
vs_type = ZIO_TYPE_FLUSH;

/*
* Solely for the purposes of 'zpool iostat -lqrw'
Expand Down Expand Up @@ -6239,12 +6239,12 @@ vdev_prop_get(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl)
case VDEV_PROP_OPS_TRIM:
/*
* TRIM ops and bytes are reported to user
* space as ZIO_TYPE_IOCTL. This is done to
* space as ZIO_TYPE_FLUSH. This is done to
* preserve the vdev_stat_t structure layout
* for user space.
*/
vdev_prop_add_list(outnvl, propname, NULL,
vd->vdev_stat.vs_ops[ZIO_TYPE_IOCTL],
vd->vdev_stat.vs_ops[ZIO_TYPE_FLUSH],
ZPROP_SRC_NONE);
continue;
case VDEV_PROP_BYTES_NULL:
Expand Down Expand Up @@ -6275,12 +6275,12 @@ vdev_prop_get(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl)
case VDEV_PROP_BYTES_TRIM:
/*
* TRIM ops and bytes are reported to user
* space as ZIO_TYPE_IOCTL. This is done to
* space as ZIO_TYPE_FLUSH. This is done to
* preserve the vdev_stat_t structure layout
* for user space.
*/
vdev_prop_add_list(outnvl, propname, NULL,
vd->vdev_stat.vs_bytes[ZIO_TYPE_IOCTL],
vd->vdev_stat.vs_bytes[ZIO_TYPE_FLUSH],
ZPROP_SRC_NONE);
continue;
case VDEV_PROP_REMOVING:
Expand Down
10 changes: 5 additions & 5 deletions module/zfs/vdev_draid.c
Original file line number Diff line number Diff line change
Expand Up @@ -2548,11 +2548,11 @@ vdev_draid_read_config_spare(vdev_t *vd)
}

/*
* Handle any ioctl requested of the distributed spare. Only flushes
* are supported in which case all children must be flushed.
* Handle any flush requested of the distributed spare. All children must be
* flushed.
*/
static int
vdev_draid_spare_ioctl(zio_t *zio)
vdev_draid_spare_flush(zio_t *zio)
{
vdev_t *vd = zio->io_vd;
int error = 0;
Expand Down Expand Up @@ -2592,8 +2592,8 @@ vdev_draid_spare_io_start(zio_t *zio)
}

switch (zio->io_type) {
case ZIO_TYPE_IOCTL:
zio->io_error = vdev_draid_spare_ioctl(zio);
case ZIO_TYPE_FLUSH:
zio->io_error = vdev_draid_spare_flush(zio);
break;

case ZIO_TYPE_WRITE:
Expand Down
8 changes: 4 additions & 4 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const char *const zio_type_name[ZIO_TYPES] = {
* Note: Linux kernel thread name length is limited
* so these names will differ from upstream open zfs.
*/
"z_null", "z_rd", "z_wr", "z_fr", "z_cl", "z_ioctl", "z_trim"
"z_null", "z_rd", "z_wr", "z_fr", "z_cl", "z_flush", "z_trim"
};

int zio_dva_throttle_enabled = B_TRUE;
Expand Down Expand Up @@ -1632,8 +1632,8 @@ zio_flush(zio_t *pio, vdev_t *vd)

if (vd->vdev_children == 0) {
zio_nowait(zio_create(pio, pio->io_spa, 0, NULL, NULL, 0, 0,
NULL, NULL, ZIO_TYPE_IOCTL, ZIO_PRIORITY_NOW, flags, vd, 0,
NULL, ZIO_STAGE_OPEN, ZIO_IOCTL_PIPELINE));
NULL, NULL, ZIO_TYPE_FLUSH, ZIO_PRIORITY_NOW, flags, vd, 0,
NULL, ZIO_STAGE_OPEN, ZIO_FLUSH_PIPELINE));
} else {
for (uint64_t c = 0; c < vd->vdev_children; c++)
zio_flush(pio, vd->vdev_child[c]);
Expand Down Expand Up @@ -4236,7 +4236,7 @@ zio_vdev_io_assess(zio_t *zio)
* boolean flag so that we don't bother with it in the future.
*/
if ((zio->io_error == ENOTSUP || zio->io_error == ENOTTY) &&
zio->io_type == ZIO_TYPE_IOCTL && vd != NULL)
zio->io_type == ZIO_TYPE_FLUSH && vd != NULL)
vd->vdev_nowritecache = B_TRUE;

if (zio->io_error)
Expand Down

0 comments on commit f5d0ad5

Please sign in to comment.