[PATCH] cleanup sg ioctl vs read approach
diff --git a/fio-io.c b/fio-io.c
index 3f55a19..aaf8fe1 100644
--- a/fio-io.c
+++ b/fio-io.c
@@ -544,16 +544,20 @@
 	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 @@
 	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;