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.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Rob Norris <[email protected]>
Closes openzfs#16064
  • Loading branch information
robn authored and behlendorf committed Apr 12, 2024
1 parent b613709 commit d7605ae
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 47 deletions.
10 changes: 5 additions & 5 deletions cmd/zinject/zinject.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ usage(void)
"\t\tspa_vdev_exit() will trigger a panic.\n"
"\n"
"\tzinject -d device [-e errno] [-L <nvlist|uber|pad1|pad2>] [-F]\n"
"\t\t[-T <read|write|free|claim|ioctl|all>] [-f frequency] pool\n\n"
"\t\t[-T <read|write|free|claim|flush|all>] [-f frequency] pool\n\n"
"\t\tInject a fault into a particular device or the device's\n"
"\t\tlabel. Label injection can either be 'nvlist', 'uber',\n "
"\t\t'pad1', or 'pad2'.\n"
Expand Down Expand Up @@ -425,7 +425,7 @@ print_device_handler(int id, const char *pool, zinject_record_t *record,
void *data)
{
static const char *iotypestr[] = {
"null", "read", "write", "free", "claim", "ioctl", "trim", "all",
"null", "read", "write", "free", "claim", "flush", "trim", "all",
};

int *count = data;
Expand Down Expand Up @@ -978,14 +978,14 @@ main(int argc, char **argv)
io_type = ZIO_TYPE_FREE;
} else if (strcasecmp(optarg, "claim") == 0) {
io_type = ZIO_TYPE_CLAIM;
} else if (strcasecmp(optarg, "ioctl") == 0) {
io_type = ZIO_TYPE_IOCTL;
} else if (strcasecmp(optarg, "flush") == 0) {
io_type = ZIO_TYPE_FLUSH;
} else if (strcasecmp(optarg, "all") == 0) {
io_type = ZIO_TYPES;
} else {
(void) fprintf(stderr, "invalid I/O type "
"'%s': must be 'read', 'write', 'free', "
"'claim', 'ioctl' or 'all'\n", optarg);
"'claim', 'flush' or 'all'\n", optarg);
usage();
libzfs_fini(g_zfs);
return (1);
Expand Down
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;

/*
* Compatibility: _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
18 changes: 9 additions & 9 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_DONE = 1 << 22, /* RW--IT */
ZIO_STAGE_VDEV_IO_ASSESS = 1 << 23, /* RW--IT */
ZIO_STAGE_VDEV_IO_START = 1 << 21, /* RW--XT */
ZIO_STAGE_VDEV_IO_DONE = 1 << 22, /* RW--XT */
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_VDEV_IO_STAGES)

Expand Down
12 changes: 6 additions & 6 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_DONE:0x00400000:RW--IT
ZIO_STAGE_VDEV_IO_ASSESS:0x00800000:RW--IT
ZIO_STAGE_VDEV_IO_START:0x00200000:RW--XT
ZIO_STAGE_VDEV_IO_DONE:0x00400000:RW--XT
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 @@ -1400,7 +1400,7 @@ vdev_disk_io_start(zio_t *zio)
}

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

if (!vdev_readable(v)) {
/* Drive not there, can't flush */
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
12 changes: 6 additions & 6 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, vd->vdev_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 @@ -4086,15 +4086,15 @@ zio_vdev_io_done(zio_t *zio)

ASSERT(zio->io_type == ZIO_TYPE_READ ||
zio->io_type == ZIO_TYPE_WRITE ||
zio->io_type == ZIO_TYPE_IOCTL ||
zio->io_type == ZIO_TYPE_FLUSH ||
zio->io_type == ZIO_TYPE_TRIM);

if (zio->io_delay)
zio->io_delay = gethrtime() - zio->io_delay;

if (vd != NULL && vd->vdev_ops->vdev_op_leaf &&
vd->vdev_ops != &vdev_draid_spare_ops) {
if (zio->io_type != ZIO_TYPE_IOCTL)
if (zio->io_type != ZIO_TYPE_FLUSH)
vdev_queue_io_done(zio);

if (zio_injection_enabled && zio->io_error == 0)
Expand Down Expand Up @@ -4239,7 +4239,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
2 changes: 1 addition & 1 deletion module/zfs/zio_inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ zio_handle_device_injection_impl(vdev_t *vd, zio_t *zio, int err1, int err2)
* We skip over faults in the labels unless it's during device open
* (i.e. zio == NULL) or a device flush (offset is meaningless)
*/
if (zio != NULL && zio->io_type != ZIO_TYPE_IOCTL) {
if (zio != NULL && zio->io_type != ZIO_TYPE_FLUSH) {
uint64_t offset = zio->io_offset;

if (offset < VDEV_LABEL_START_SIZE ||
Expand Down

0 comments on commit d7605ae

Please sign in to comment.