Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zio: rename "ioctl" to "flush"; remove zio_ioctl() #16064

Closed
wants to merge 4 commits into from

Conversation

robn
Copy link
Member

@robn robn commented Apr 5, 2024

Motivation and Context

ZIO_TYPE_IOCTL has always been confusingly-named, as its only used for device flush, and really couldn't be used for anything else anyway. The presence of zio_ioctl and zio_flush compounded this confusion.

I'd had low-key plans to fix it up someday maybe, but then @amotin raised it in #16061, so here we are.

Description

  • Renames ZIO_TYPE_IOCTL and ZIO_PIPELINE_IOCTL to ZIO_TYPE_FLUSH and ZIO_PIPELINE_FLUSH
  • Renames z_ioctl IO queue to z_flush
  • Removes now-unused io_cmd field from struct zio
  • Removes use of DKIOCFLUSHWRITECACHE, since we now know what all these requests are
  • Removes zio_ioctl(), folds its functionality into zio_flush()
  • Various related naming and comment updates

I've tried to maintain the userspace API, not that there's much of it involved.

The use of X as the flag for flush in zio_impl.h and zpool-events.8 is kinda dubious, but I don't have any obviously better choice, and given the number of drive-by fixes I've done to these two docs in the last year or so I doubt many people will notice or care anyway.

How Has This Been Tested?

Compiled on Linux and FreeBSD, basic sanity check run completed.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@robn robn changed the title zio: rename "ioctl" to "flush" and clean up zio: rename "ioctl" to "flush"; remove zio_ioctl() Apr 5, 2024
include/os/linux/zfs/sys/trace_common.h Show resolved Hide resolved
module/zfs/zio.c Outdated Show resolved Hide resolved
@robn robn force-pushed the zio-ioctl-flush-rename branch 2 times, most recently from f5d0ad5 to 064edaf Compare April 6, 2024 01:55
module/zfs/zio.c Outdated Show resolved Hide resolved
include/sys/fs/zfs.h Outdated Show resolved Hide resolved
module/os/freebsd/zfs/vdev_file.c Show resolved Hide resolved
module/os/linux/zfs/vdev_disk.c Outdated Show resolved Hide resolved
module/os/linux/zfs/vdev_disk.c Outdated Show resolved Hide resolved
@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Apr 8, 2024
It only had one user, zio_flush(), and there are no other vdev ioctls
anyway.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
There's no other options, so we can just always assume its a flush.

Includes some light refactoring where a switch statement was doing
control flow that no longer works.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Without DKIOCFLUSHWRITECACHE, we no longer need the compat header. Note
that we're keeping the userspace SPL compat header, which is used by
libefi.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
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 <rob.norris@klarasystems.com>
@@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this PR vdev_op_io_done is now called for ZIO_TYPE_FLUSH, so this comment is wrong. I didn't want to just remove it, because maybe its pointing to a cleanup opportunity if this is no longer necessary. But I also don't know enough right now to just make the change. I'll come back to it soon, but if a FreeBSDer wants to step in and propose a change, that'd be even better!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This context is indeed not sleepable. Primarily it means no waiting memory allocations, etc, which would not be a problem here. But it also means no sleepable locks, and on FreeBSD ZFS' mutex_enter() called, for example, by zfs_refcount_remove_many(), called by abd_return_buf() is mapped into sleepable sx_xlock(). Since vdev_op_io_done() is now called for ZIO_TYPE_FLUSH, I guess it should be easier to remove this special case here and make vdev_geom_io_done() do everything.

@robn
Copy link
Member Author

robn commented Apr 10, 2024

Feedback addressed, rebased to master, and updated following #16061.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Apr 11, 2024
behlendorf pushed a commit that referenced this pull request Apr 12, 2024
There's no other options, so we can just always assume its a flush.

Includes some light refactoring where a switch statement was doing
control flow that no longer works.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16064
behlendorf pushed a commit that referenced this pull request Apr 12, 2024
Without DKIOCFLUSHWRITECACHE, we no longer need the compat header. Note
that we're keeping the userspace SPL compat header, which is used by
libefi.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16064
behlendorf pushed a commit that referenced this pull request Apr 12, 2024
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 <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16064
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 4, 2024
It only had one user, zio_flush(), and there are no other vdev ioctls
anyway.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes openzfs#16064
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 4, 2024
There's no other options, so we can just always assume its a flush.

Includes some light refactoring where a switch statement was doing
control flow that no longer works.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes openzfs#16064
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 4, 2024
Without DKIOCFLUSHWRITECACHE, we no longer need the compat header. Note
that we're keeping the userspace SPL compat header, which is used by
libefi.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes openzfs#16064
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 4, 2024
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 <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes openzfs#16064
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants