Skip to content

Commit

Permalink
engines/io_uring: remove dead code related to trim
Browse files Browse the repository at this point in the history
Now that we are no longer using an NVMe IOCTL to send io_uring_cmd trim
commands we can just use the existing pathway to carry out synchronous
trim commands for zoned devices. So we no longer need this code.

Signed-off-by: Vincent Fu <[email protected]>
  • Loading branch information
vincentkfu committed Jul 5, 2023
1 parent 4885a6e commit 7f57e30
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 67 deletions.
26 changes: 1 addition & 25 deletions engines/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,27 +564,6 @@ static inline void fio_ioring_cmdprio_prep(struct thread_data *td,
ld->sqes[io_u->index].ioprio = io_u->ioprio;
}

static int fio_ioring_cmd_io_u_trim(struct thread_data *td,
struct io_u *io_u)
{
struct fio_file *f = io_u->file;
int ret;

if (td->o.zone_mode == ZONE_MODE_ZBD) {
ret = zbd_do_io_u_trim(td, io_u);
if (ret == io_u_completed)
return io_u->xfer_buflen;
if (ret)
goto err;
}

return fio_nvme_trim(td, f, io_u->offset, io_u->xfer_buflen);

err:
io_u->error = ret;
return 0;
}

static enum fio_q_status fio_ioring_queue(struct thread_data *td,
struct io_u *io_u)
{
Expand All @@ -601,10 +580,7 @@ static enum fio_q_status fio_ioring_queue(struct thread_data *td,
if (ld->queued)
return FIO_Q_BUSY;

if (!strcmp(td->io_ops->name, "io_uring_cmd"))
fio_ioring_cmd_io_u_trim(td, io_u);
else
do_io_u_trim(td, io_u);
do_io_u_trim(td, io_u);

io_u_mark_submit(td, 1);
io_u_mark_complete(td, 1);
Expand Down
39 changes: 0 additions & 39 deletions engines/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,45 +83,6 @@ int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
return 0;
}

static int nvme_trim(int fd, __u32 nsid, __u32 nr_range, __u32 data_len,
void *data)
{
struct nvme_passthru_cmd cmd = {
.opcode = nvme_cmd_dsm,
.nsid = nsid,
.addr = (__u64)(uintptr_t)data,
.data_len = data_len,
.cdw10 = nr_range - 1,
.cdw11 = NVME_ATTRIBUTE_DEALLOCATE,
};

return ioctl(fd, NVME_IOCTL_IO_CMD, &cmd);
}

int fio_nvme_trim(const struct thread_data *td, struct fio_file *f,
unsigned long long offset, unsigned long long len)
{
struct nvme_data *data = FILE_ENG_DATA(f);
struct nvme_dsm_range dsm;
int ret;

if (data->lba_ext) {
dsm.nlb = len / data->lba_ext;
dsm.slba = offset / data->lba_ext;
} else {
dsm.nlb = len >> data->lba_shift;
dsm.slba = offset >> data->lba_shift;
}

ret = nvme_trim(f->fd, data->nsid, 1, sizeof(struct nvme_dsm_range),
&dsm);
if (ret)
log_err("%s: nvme_trim failed for offset %llu and len %llu, err=%d\n",
f->file_name, offset, len, ret);

return ret;
}

static int nvme_identify(int fd, __u32 nsid, enum nvme_identify_cns cns,
enum nvme_csi csi, void *data)
{
Expand Down
3 changes: 0 additions & 3 deletions engines/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ struct nvme_dsm_range {
__le64 slba;
};

int fio_nvme_trim(const struct thread_data *td, struct fio_file *f,
unsigned long long offset, unsigned long long len);

int fio_nvme_iomgmt_ruhs(struct thread_data *td, struct fio_file *f,
struct nvme_fdp_ruh_status *ruhs, __u32 bytes);

Expand Down

0 comments on commit 7f57e30

Please sign in to comment.