Skip to content

Commit

Permalink
remove zia
Browse files Browse the repository at this point in the history
  • Loading branch information
calccrypto committed Jun 11, 2024
1 parent 44a5aa0 commit 665454b
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 717 deletions.
9 changes: 6 additions & 3 deletions include/sys/zia.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ int zia_onload(void **handle, void *buf, size_t size);

/* calls abd_iterate_func on the abd to copy abd data back and forth */
int zia_offload_abd(void *provider, abd_t *abd,
size_t size, size_t min_offload_size, boolean_t *local_offload);
int zia_onload_abd(abd_t *abd, size_t size, boolean_t keep_handle);
size_t size, size_t min_offload_size,
boolean_t *local_offload, boolean_t lock);
int zia_onload_abd(abd_t *abd, size_t size,
boolean_t keep_handle, boolean_t lock);
/* move a handle into an abd */
void zia_move_into_abd(abd_t *dst, void **src);
int zia_free_abd(abd_t *abd, boolean_t lock);
Expand All @@ -162,7 +164,8 @@ int zia_free_abd(abd_t *abd, boolean_t lock);
* if offloaded locally, just free the handle
* if not, onload the data and free the handle
*/
int zia_cleanup_abd(abd_t *abd, size_t size, boolean_t local_offload);
int zia_cleanup_abd(abd_t *abd, size_t size,
boolean_t local_offload, boolean_t lock);

/* if the accelerator failed, restart the zio */
void zia_restart_before_vdev(zio_t *zio);
Expand Down
55 changes: 0 additions & 55 deletions module/os/linux/zfs/vdev_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <sys/vdev_trim.h>
#include <sys/abd.h>
#include <sys/fs/zfs.h>
#include <sys/zia.h>
#include <sys/zio.h>
#include <linux/blkpg.h>
#include <linux/msdos_fs.h>
Expand Down Expand Up @@ -302,7 +301,6 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize,
reread_part = B_TRUE;
}

zia_disk_close(v);
vdev_blkdev_put(bdev, mode, zfs_vdev_holder);
}

Expand Down Expand Up @@ -421,11 +419,6 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize,
*logical_ashift = highbit64(MAX(logical_block_size,
SPA_MINBLOCKSIZE)) - 1;

zia_get_props(v->vdev_spa)->min_offload_size = 2 << *physical_ashift;

/* open disk; ignore errors - will fall back to ZFS */
zia_disk_open(v, v->vdev_path, vd->vd_bdev);

return (0);
}

Expand All @@ -438,7 +431,6 @@ vdev_disk_close(vdev_t *v)
return;

if (vd->vd_bdev != NULL) {
zia_disk_close(v);
vdev_blkdev_put(vd->vd_bdev, spa_mode(v->vdev_spa),
zfs_vdev_holder);
}
Expand Down Expand Up @@ -801,8 +793,6 @@ __vdev_disk_physio(struct block_device *bdev, zio_t *zio,
return (error);
}

EXPORT_SYMBOL(__vdev_disk_physio);

BIO_END_IO_PROTO(vdev_disk_io_flush_completion, bio, error)
{
zio_t *zio = bio->bi_private;
Expand Down Expand Up @@ -845,8 +835,6 @@ vdev_disk_io_flush(struct block_device *bdev, zio_t *zio)
return (0);
}

EXPORT_SYMBOL(vdev_disk_io_flush);

static int
vdev_disk_io_trim(zio_t *zio)
{
Expand Down Expand Up @@ -925,17 +913,6 @@ vdev_disk_io_start(zio_t *zio)
break;
}

error = zia_disk_flush(v, zio);

/*
* have to return here in order to not dispatch
* this zio to multiple task queues
*/
if (error == 0) {
rw_exit(&vd->vd_lock);
return;
}

error = vdev_disk_io_flush(vd->vd_bdev, zio);
if (error == 0) {
rw_exit(&vd->vd_lock);
Expand Down Expand Up @@ -975,37 +952,6 @@ vdev_disk_io_start(zio_t *zio)
}

zio->io_target_timestamp = zio_handle_io_delay(zio);

error = EIO;

if (rw == WRITE) {
boolean_t local_offload = B_FALSE;
zia_props_t *zia_props = zia_get_props(zio->io_spa);
if ((zia_props->disk_write == 1) &&
(zio->io_can_offload == B_TRUE)) {
if (zia_offload_abd(zia_props->provider, zio->io_abd,
zio->io_size, zia_props->min_offload_size,
&local_offload) == ZIA_OK) {
error = zia_disk_write(v, zio, zio->io_size,
zio->io_offset, 0);
}
}

if (error == 0) {
rw_exit(&vd->vd_lock);
return;
}

error = zia_cleanup_abd(zio->io_abd, zio->io_size,
local_offload);

if (error == ZIA_ACCELERATOR_DOWN) {
zia_disable_offloading(zio, B_TRUE);
rw_exit(&vd->vd_lock);
zio_interrupt(zio);
return;
}
}
error = __vdev_disk_physio(vd->vd_bdev, zio,
zio->io_size, zio->io_offset, rw, 0);
rw_exit(&vd->vd_lock);
Expand All @@ -1030,7 +976,6 @@ vdev_disk_io_done(zio_t *zio)
vdev_disk_t *vd = v->vdev_tsd;

if (!zfs_check_disk_status(vd->vd_bdev)) {
zia_disk_invalidate(v);
invalidate_bdev(vd->vd_bdev);
v->vdev_remove_wanted = B_TRUE;
spa_async_request(zio->io_spa, SPA_ASYNC_REMOVE);
Expand Down
44 changes: 3 additions & 41 deletions module/os/linux/zfs/vdev_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <sys/fcntl.h>
#include <sys/vnode.h>
#include <sys/zfs_file.h>
#include <sys/zia.h>
#ifdef _KERNEL
#include <linux/falloc.h>
#endif
Expand Down Expand Up @@ -162,12 +161,6 @@ vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
}
#endif

zia_get_props(vd->vdev_spa)->min_offload_size = 2 << *physical_ashift;

/* try to open the file; ignore errors - will fall back to ZFS */
zia_file_open(vd, vd->vdev_path,
vdev_file_open_mode(spa_mode(vd->vdev_spa)), 0);

skip_open:

error = zfs_file_getattr(vf->vf_file, &zfa);
Expand All @@ -191,8 +184,6 @@ vdev_file_close(vdev_t *vd)
if (vd->vdev_reopening || vf == NULL)
return;

zia_file_close(vd);

if (vf->vf_file != NULL) {
(void) zfs_file_close(vf->vf_file);
}
Expand All @@ -212,47 +203,18 @@ vdev_file_io_strategy(void *arg)
void *buf;
loff_t off;
ssize_t size;
int err = 0;
int err;

off = zio->io_offset;
size = zio->io_size;
resid = 0;

if (zio->io_type == ZIO_TYPE_READ) {
buf = abd_borrow_buf(zio->io_abd, size);
buf = abd_borrow_buf(zio->io_abd, zio->io_size);
err = zfs_file_pread(vf->vf_file, buf, size, off, &resid);
abd_return_buf_copy(zio->io_abd, buf, size);
} else {
err = EIO;

boolean_t local_offload = B_FALSE;
zia_props_t *zia_props = zia_get_props(zio->io_spa);
if ((zia_props->file_write == 1) &&
(zio->io_can_offload == B_TRUE)) {
if (zia_offload_abd(zia_props->provider,
zio->io_abd, size, zia_props->min_offload_size,
&local_offload) == ZIA_OK) {
err = zia_file_write(vd, zio->io_abd,
size, off, &resid, &err);
}
}

if (err == 0) {
zio->io_error = err;
if (resid != 0 && zio->io_error == 0)
zio->io_error = SET_ERROR(ENOSPC);

zio_delay_interrupt(zio);
return;
}

err = zia_cleanup_abd(zio->io_abd, size, local_offload);
if (err == ZIA_ACCELERATOR_DOWN) {
zia_disable_offloading(zio, B_TRUE);
zio_delay_interrupt(zio);
return;
}
buf = abd_borrow_buf_copy(zio->io_abd, size);
buf = abd_borrow_buf_copy(zio->io_abd, zio->io_size);
err = zfs_file_pwrite(vf->vf_file, buf, size, off, &resid);
abd_return_buf(zio->io_abd, buf, size);
}
Expand Down
17 changes: 16 additions & 1 deletion module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -9075,7 +9075,8 @@ spa_sync_props(void *arg, dmu_tx_t *tx)
* copied from zfs_ioc_pool_reopen
*/
spa_vdev_state_enter(spa, SCL_NONE);
vdev_reopen(spa->spa_root_vdev);
vdev_close(spa->spa_root_vdev);
(void) vdev_open(spa->spa_root_vdev);
(void) spa_vdev_state_exit(spa, NULL, 0);

spa_history_log_internal(spa, "set", tx,
Expand Down Expand Up @@ -9165,12 +9166,26 @@ spa_sync_props(void *arg, dmu_tx_t *tx)
case ZPOOL_PROP_ZIA_FILE_WRITE:
zia_props->file_write =
fnvpair_value_uint64(elem);

/* reopen devices so that provider is used */
spa_vdev_state_enter(spa, SCL_NONE);
vdev_close(spa->spa_root_vdev);
(void) vdev_open(spa->spa_root_vdev);
(void) spa_vdev_state_exit(spa, NULL, 0);

zia_prop_warn(zia_props->file_write,
"File Write");
break;
case ZPOOL_PROP_ZIA_DISK_WRITE:
zia_props->disk_write =
fnvpair_value_uint64(elem);

/* reopen devices so that provider is used */
spa_vdev_state_enter(spa, SCL_NONE);
vdev_close(spa->spa_root_vdev);
(void) vdev_open(spa->spa_root_vdev);
(void) spa_vdev_state_exit(spa, NULL, 0);

zia_prop_warn(zia_props->disk_write,
"Disk Write");
break;
Expand Down
Loading

0 comments on commit 665454b

Please sign in to comment.