From: Jens Axboe Date: Wed, 24 May 2006 23:30:48 +0000 (+0200) Subject: [PATCH] cleanup sg ioctl vs read approach X-Git-Tag: fio-1.4~25 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=f3a4ef5e991972a0e372adba766ec0ef568019ab [PATCH] cleanup sg ioctl vs read approach --- diff --git a/fio-io.c b/fio-io.c index 3f55a19c..aaf8fe19 100644 --- a/fio-io.c +++ b/fio-io.c @@ -544,16 +544,20 @@ static int fio_sgio_getevents(struct thread_data *td, int min, int max, return r; } -static int fio_sgio_doio(struct thread_data *td, struct io_u *io_u, int sync) +static int fio_sgio_ioctl_doio(struct thread_data *td, struct io_u *io_u) { struct sgio_data *sd = td->io_data; struct sg_io_hdr *hdr = &io_u->hdr; - int ret; - if (td->filetype == FIO_TYPE_BD) { - sd->events[0] = io_u; - return ioctl(td->fd, SG_IO, hdr); - } + sd->events[0] = io_u; + + return ioctl(td->fd, SG_IO, hdr); +} + +static int fio_sgio_rw_doio(struct thread_data *td, struct io_u *io_u, int sync) +{ + struct sg_io_hdr *hdr = &io_u->hdr; + int ret; ret = write(td->fd, hdr, sizeof(*hdr)); if (ret < 0) @@ -568,6 +572,14 @@ static int fio_sgio_doio(struct thread_data *td, struct io_u *io_u, int sync) return 0; } +static int fio_sgio_doio(struct thread_data *td, struct io_u *io_u, int sync) +{ + if (td->filetype == FIO_TYPE_BD) + return fio_sgio_ioctl_doio(td, io_u); + + return fio_sgio_rw_doio(td, io_u, sync); +} + static int fio_sgio_sync(struct thread_data *td) { struct sgio_data *sd = td->io_data;