Skip to content

Commit

Permalink
Re-consolidate zio_delay_interrupt
Browse files Browse the repository at this point in the history
With recent SPL changes there is no longer any need for a per
platform version.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9860
  • Loading branch information
mattmacy authored and behlendorf committed Jan 21, 2020
1 parent 09436c5 commit d3c1e45
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 105 deletions.
1 change: 0 additions & 1 deletion lib/libzpool/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ KERNEL_C = \
zfs_rlock.c \
zil.c \
zio.c \
zio_os.c \
zio_checksum.c \
zio_compress.c \
zio_crypt.c \
Expand Down
1 change: 0 additions & 1 deletion module/os/linux/zfs/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ $(MODULE)-objs += ../os/linux/zfs/spa_misc_os.o
$(MODULE)-objs += ../os/linux/zfs/spa_stats.o
$(MODULE)-objs += ../os/linux/zfs/vdev_disk.o
$(MODULE)-objs += ../os/linux/zfs/vdev_file.o
$(MODULE)-objs += ../os/linux/zfs/zio_os.o
$(MODULE)-objs += ../os/linux/zfs/zfs_acl.o
$(MODULE)-objs += ../os/linux/zfs/zfs_ctldir.o
$(MODULE)-objs += ../os/linux/zfs/zfs_debug.o
Expand Down
103 changes: 0 additions & 103 deletions module/os/linux/zfs/zio_os.c

This file was deleted.

71 changes: 71 additions & 0 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,77 @@ zio_interrupt(zio_t *zio)
zio_taskq_dispatch(zio, ZIO_TASKQ_INTERRUPT, B_FALSE);
}

void
zio_delay_interrupt(zio_t *zio)
{
/*
* The timeout_generic() function isn't defined in userspace, so
* rather than trying to implement the function, the zio delay
* functionality has been disabled for userspace builds.
*/

#ifdef _KERNEL
/*
* If io_target_timestamp is zero, then no delay has been registered
* for this IO, thus jump to the end of this function and "skip" the
* delay; issuing it directly to the zio layer.
*/
if (zio->io_target_timestamp != 0) {
hrtime_t now = gethrtime();

if (now >= zio->io_target_timestamp) {
/*
* This IO has already taken longer than the target
* delay to complete, so we don't want to delay it
* any longer; we "miss" the delay and issue it
* directly to the zio layer. This is likely due to
* the target latency being set to a value less than
* the underlying hardware can satisfy (e.g. delay
* set to 1ms, but the disks take 10ms to complete an
* IO request).
*/

DTRACE_PROBE2(zio__delay__miss, zio_t *, zio,
hrtime_t, now);

zio_interrupt(zio);
} else {
taskqid_t tid;
hrtime_t diff = zio->io_target_timestamp - now;
clock_t expire_at_tick = ddi_get_lbolt() +
NSEC_TO_TICK(diff);

DTRACE_PROBE3(zio__delay__hit, zio_t *, zio,
hrtime_t, now, hrtime_t, diff);

if (NSEC_TO_TICK(diff) == 0) {
/* Our delay is less than a jiffy - just spin */
zfs_sleep_until(zio->io_target_timestamp);
zio_interrupt(zio);
} else {
/*
* Use taskq_dispatch_delay() in the place of
* OpenZFS's timeout_generic().
*/
tid = taskq_dispatch_delay(system_taskq,
(task_func_t *)zio_interrupt,
zio, TQ_NOSLEEP, expire_at_tick);
if (tid == TASKQID_INVALID) {
/*
* Couldn't allocate a task. Just
* finish the zio without a delay.
*/
zio_interrupt(zio);
}
}
}
return;
}
#endif
DTRACE_PROBE1(zio__delay__skip, zio_t *, zio);
zio_interrupt(zio);
}

static void
zio_deadman_impl(zio_t *pio, int ziodepth)
{
Expand Down

0 comments on commit d3c1e45

Please sign in to comment.