* [PATCH 2/6] Staticize pmemblk ioengine_ops
2017-01-09 14:41 [PATCH 1/6] Bring in additional sg error cases from Linux kernel (and sg3) header kusumi.tomohiro
@ 2017-01-09 14:41 ` kusumi.tomohiro
2017-01-09 14:42 ` [PATCH 3/6] Fix conditional/message for max lba for sg ioengine kusumi.tomohiro
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: kusumi.tomohiro @ 2017-01-09 14:41 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
Inbox engines can have static ops.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
engines/pmemblk.c | 2 +-
engines/skeleton_external.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/engines/pmemblk.c b/engines/pmemblk.c
index ca72697..5439da0 100644
--- a/engines/pmemblk.c
+++ b/engines/pmemblk.c
@@ -482,7 +482,7 @@ static int fio_pmemblk_unlink_file(struct thread_data *td, struct fio_file *f)
return 0;
}
-struct ioengine_ops ioengine = {
+static struct ioengine_ops ioengine = {
.name = "pmemblk",
.version = FIO_IOOPS_VERSION,
.queue = fio_pmemblk_queue,
diff --git a/engines/skeleton_external.c b/engines/skeleton_external.c
index 63a6f8d..5d6a9ed 100644
--- a/engines/skeleton_external.c
+++ b/engines/skeleton_external.c
@@ -126,7 +126,7 @@ static int fio_skeleton_close(struct thread_data *td, struct fio_file *f)
/*
* Note that the structure is exported, so that fio can get it via
- * dlsym(..., "ioengine");
+ * dlsym(..., "ioengine"); for (and only for) external engines.
*/
struct ioengine_ops ioengine = {
.name = "engine_name",
--
2.5.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/6] Fix conditional/message for max lba for sg ioengine
2017-01-09 14:41 [PATCH 1/6] Bring in additional sg error cases from Linux kernel (and sg3) header kusumi.tomohiro
2017-01-09 14:41 ` [PATCH 2/6] Staticize pmemblk ioengine_ops kusumi.tomohiro
@ 2017-01-09 14:42 ` kusumi.tomohiro
2017-01-09 14:42 ` [PATCH 4/6] Non functional fixup for 16 bytes read capacity " kusumi.tomohiro
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: kusumi.tomohiro @ 2017-01-09 14:42 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
Whether sg ioengine uses 10 or 16 bytes read/write command (by 5ad7be56)
is determined by ->prep() depending on lba to read/write vs 0xFFFFFFFFULL,
so let the message show it depends.
Also remove unused sgio_data::max_lba which is essentially the same
(divide by bs minus 1) as fio_file::real_file_size.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
engines/sg.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/engines/sg.c b/engines/sg.c
index c9a1448..00bf303 100644
--- a/engines/sg.c
+++ b/engines/sg.c
@@ -32,7 +32,6 @@ struct sgio_data {
int *fd_flags;
void *sgbuf;
unsigned int bs;
- long long max_lba;
int type_checked;
};
@@ -535,9 +534,10 @@ static int fio_sgio_type_check(struct thread_data *td, struct fio_file *f)
sd->bs = bs;
// Determine size of commands needed based on max_lba
- sd->max_lba = max_lba;
- if (max_lba > MAX_10B_LBA) {
- dprint(FD_IO, "sgio_type_check: using 16 byte operations: max_lba = 0x%016llx\n", max_lba);
+ if (max_lba >= MAX_10B_LBA) {
+ dprint(FD_IO, "sgio_type_check: using 16 byte read/write "
+ "commands for lba above 0x%016llx/0x%016llx\n",
+ MAX_10B_LBA, max_lba);
}
--
2.5.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 4/6] Non functional fixup for 16 bytes read capacity for sg ioengine
2017-01-09 14:41 [PATCH 1/6] Bring in additional sg error cases from Linux kernel (and sg3) header kusumi.tomohiro
2017-01-09 14:41 ` [PATCH 2/6] Staticize pmemblk ioengine_ops kusumi.tomohiro
2017-01-09 14:42 ` [PATCH 3/6] Fix conditional/message for max lba for sg ioengine kusumi.tomohiro
@ 2017-01-09 14:42 ` kusumi.tomohiro
2017-01-09 14:42 ` [PATCH 5/6] Mention sg ioengine requires filename option kusumi.tomohiro
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: kusumi.tomohiro @ 2017-01-09 14:42 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
engines/sg.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/engines/sg.c b/engines/sg.c
index 00bf303..e70803c 100644
--- a/engines/sg.c
+++ b/engines/sg.c
@@ -20,7 +20,7 @@
#define MAX_SB 64 // sense block maximum return size
struct sgio_cmd {
- unsigned char cdb[16]; // increase to support 16 byte commands
+ unsigned char cdb[16]; // enhanced from 10 to support 16 byte commands
unsigned char sb[MAX_SB]; // add sense block to commands
int nr;
};
@@ -308,7 +308,6 @@ static int fio_sgio_prep(struct thread_data *td, struct io_u *io_u)
* blocks on medium.
*/
if (hdr->dxfer_direction != SG_DXFER_NONE) {
-
if (lba < MAX_10B_LBA) {
hdr->cmdp[2] = (unsigned char) ((lba >> 24) & 0xff);
hdr->cmdp[3] = (unsigned char) ((lba >> 16) & 0xff);
@@ -415,12 +414,11 @@ static int fio_sgio_read_capacity(struct thread_data *td, unsigned int *bs,
}
*bs = (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];
- *max_lba = ((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]) & 0x00000000FFFFFFFFULL; // for some reason max_lba is being sign extended even though unsigned.
-
+ *max_lba = ((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]) & MAX_10B_LBA; // for some reason max_lba is being sign extended even though unsigned.
/*
- * If max lba is 0xFFFFFFFF, then need to retry with
- * 16 byteread capacity
+ * If max lba masked by MAX_10B_LBA equals MAX_10B_LBA,
+ * then need to retry with 16 byte Read Capacity command.
*/
if (*max_lba == MAX_10B_LBA) {
hdr.cmd_len = 16;
@@ -506,7 +504,6 @@ static int fio_sgio_type_check(struct thread_data *td, struct fio_file *f)
unsigned int bs = 0;
unsigned long long max_lba = 0;
-
if (f->filetype == FIO_TYPE_BD) {
if (ioctl(f->fd, BLKSSZGET, &bs) < 0) {
td_verror(td, errno, "ioctl");
@@ -540,7 +537,6 @@ static int fio_sgio_type_check(struct thread_data *td, struct fio_file *f)
MAX_10B_LBA, max_lba);
}
-
if (f->filetype == FIO_TYPE_BD) {
td->io_ops->getevents = NULL;
td->io_ops->event = NULL;
@@ -818,7 +814,7 @@ static struct ioengine_ops ioengine = {
.cleanup = fio_sgio_cleanup,
.open_file = fio_sgio_open,
.close_file = generic_close_file,
- .get_file_size = fio_sgio_get_file_size, // generic_get_file_size
+ .get_file_size = fio_sgio_get_file_size,
.flags = FIO_SYNCIO | FIO_RAWIO,
};
--
2.5.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/6] Mention sg ioengine requires filename option
2017-01-09 14:41 [PATCH 1/6] Bring in additional sg error cases from Linux kernel (and sg3) header kusumi.tomohiro
` (2 preceding siblings ...)
2017-01-09 14:42 ` [PATCH 4/6] Non functional fixup for 16 bytes read capacity " kusumi.tomohiro
@ 2017-01-09 14:42 ` kusumi.tomohiro
2017-01-09 14:42 ` [PATCH 6/6] Fix compile time errors for skeleton_external ioengine kusumi.tomohiro
2017-01-09 15:39 ` [PATCH 1/6] Bring in additional sg error cases from Linux kernel (and sg3) header Jens Axboe
5 siblings, 0 replies; 7+ messages in thread
From: kusumi.tomohiro @ 2017-01-09 14:42 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
similar to the way net ioengine documents filename option.
Also bring in a file type check from fio_sgio_type_check()
to avoid pointless read capacity error against regfiles.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
HOWTO | 3 ++-
engines/sg.c | 8 +++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/HOWTO b/HOWTO
index 4cc733f..33f8718 100644
--- a/HOWTO
+++ b/HOWTO
@@ -819,7 +819,8 @@ ioengine=str Defines how the job issues io to the file. The following
synchronous using the SG_IO ioctl, or if
the target is an sg character device
we use read(2) and write(2) for asynchronous
- io.
+ io. Requires filename option to specify either
+ block or character devices.
null Doesn't transfer any data, just pretends
to. This is mainly used to exercise fio
diff --git a/engines/sg.c b/engines/sg.c
index e70803c..3f7d911 100644
--- a/engines/sg.c
+++ b/engines/sg.c
@@ -525,7 +525,7 @@ static int fio_sgio_type_check(struct thread_data *td, struct fio_file *f)
}
} else {
td_verror(td, EINVAL, "wrong file type");
- log_err("ioengine sg only works on block devices\n");
+ log_err("ioengine sg only works on block or character devices\n");
return 1;
}
@@ -789,6 +789,12 @@ static int fio_sgio_get_file_size(struct thread_data *td, struct fio_file *f)
if (fio_file_size_known(f))
return 0;
+ if (f->filetype != FIO_TYPE_BD && f->filetype != FIO_TYPE_CHAR) {
+ td_verror(td, EINVAL, "wrong file type");
+ log_err("ioengine sg only works on block or character devices\n");
+ return 1;
+ }
+
ret = fio_sgio_read_capacity(td, &bs, &max_lba);
if (ret ) {
td_verror(td, td->error, "fio_sgio_read_capacity");
--
2.5.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 6/6] Fix compile time errors for skeleton_external ioengine
2017-01-09 14:41 [PATCH 1/6] Bring in additional sg error cases from Linux kernel (and sg3) header kusumi.tomohiro
` (3 preceding siblings ...)
2017-01-09 14:42 ` [PATCH 5/6] Mention sg ioengine requires filename option kusumi.tomohiro
@ 2017-01-09 14:42 ` kusumi.tomohiro
2017-01-09 15:39 ` [PATCH 1/6] Bring in additional sg error cases from Linux kernel (and sg3) header Jens Axboe
5 siblings, 0 replies; 7+ messages in thread
From: kusumi.tomohiro @ 2017-01-09 14:42 UTC (permalink / raw)
To: axboe, fio; +Cc: Tomohiro Kusumi
From: Tomohiro Kusumi <tkusumi@tuxera.com>
though this file is not compiled by default.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
engines/skeleton_external.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/engines/skeleton_external.c b/engines/skeleton_external.c
index 5d6a9ed..4bebcc4 100644
--- a/engines/skeleton_external.c
+++ b/engines/skeleton_external.c
@@ -109,11 +109,11 @@ static void fio_skeleton_cleanup(struct thread_data *td)
/*
* Hook for opening the given file. Unless the engine has special
- * needs, it usually just provides generic_file_open() as the handler.
+ * needs, it usually just provides generic_open_file() as the handler.
*/
static int fio_skeleton_open(struct thread_data *td, struct fio_file *f)
{
- return generic_file_open(td, f);
+ return generic_open_file(td, f);
}
/*
@@ -121,7 +121,7 @@ static int fio_skeleton_open(struct thread_data *td, struct fio_file *f)
*/
static int fio_skeleton_close(struct thread_data *td, struct fio_file *f)
{
- generic_file_close(td, f);
+ return generic_close_file(td, f);
}
/*
--
2.5.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 1/6] Bring in additional sg error cases from Linux kernel (and sg3) header
2017-01-09 14:41 [PATCH 1/6] Bring in additional sg error cases from Linux kernel (and sg3) header kusumi.tomohiro
` (4 preceding siblings ...)
2017-01-09 14:42 ` [PATCH 6/6] Fix compile time errors for skeleton_external ioengine kusumi.tomohiro
@ 2017-01-09 15:39 ` Jens Axboe
5 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2017-01-09 15:39 UTC (permalink / raw)
To: kusumi.tomohiro; +Cc: fio, Tomohiro Kusumi
Applied 1-6, thanks!
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread