Skip to contentSkip to conversation

engines: Add Network Block Device (NBD) support.

PATCH Superseded Richard W.M. Jones 1 participant 2 messages Apr 25, 2019 Kbuild

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 engines: Add Network Block Device (NBD) support.

v1 was posted here:
https://www.spinics.net/lists/fio/index.html#07806

v2 isn't a particularly large change vs v1, but I have fixed whitespace and other formatting issues. The main thing is that I've fixed the example nbd.fio file so it runs multiple jobs, and tested it a lot more.

Rich.

#1 lore raw

PATCH v2 1/1 engines: Add Network Block Device (NBD) support.

To test nbdkit and the memory (RAM disk) plugin:

  $ rm -f /tmp/socket
  $ nbdkit -U /tmp/socket memory size=1G --run './fio examples/nbd.fio'

To test qemu-nbd with a backing file:

  $ rm -f /tmp/disk.img /tmp/socket
  $ truncate -s 1G /tmp/disk.img
  $ qemu-nbd -t -f raw -k /tmp/socket /tmp/disk.img
  $ ./fio examples/nbd.fio
---
 HOWTO            |   2 +
 Makefile         |   2 +-
 engines/nbd.c    | 563 +++++++++++++++++++++++++++++++++++++++++++++++
 examples/nbd.fio |  26 +++
 fio.1            |   3 +
 optgroup.c       |   4 +
 optgroup.h       |   2 +
 options.c        |   3 +
 8 files changed, 604 insertions(+), 1 deletion(-)
HOWTO +2 -0
index 4fd4da14..8697d182 100644
@@ -1993,6 +1993,8 @@ I/O engine
 			requests for IME. FIO will then decide when to commit these requests.
 		**libiscsi**
 			Read and write iscsi lun with libiscsi.
+		**nbd**
+			Synchronous read and write a Network Block Device (NBD).
 
 I/O engine specific parameters
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Makefile +1 -1
index d7e5fca7..1650a6c9 100644
@@ -45,7 +45,7 @@ SOURCE :=	$(sort $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/crc/*.c)) \
 		pshared.c options.c \
 		smalloc.c filehash.c profile.c debug.c engines/cpu.c \
 		engines/mmap.c engines/sync.c engines/null.c engines/net.c \
-		engines/ftruncate.c engines/filecreate.c \
+		engines/ftruncate.c engines/filecreate.c engines/nbd.c \
 		server.c client.c iolog.c backend.c libfio.c flow.c cconv.c \
 		gettime-thread.c helpers.c json.c idletime.c td_error.c \
 		profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \
engines/nbd.c new file +563 -0

563 lines not on this page · raw message

examples/nbd.fio new file +26 -0
new file mode 100644
index 00000000..7515faab
@@ -0,0 +1,26 @@
+# The NBD engine is synchronous, although could be made to work
+# asynchronously with some effort.  However because of this we
+# need to run multiple jobs in order to test parallelism.
+
+[global]
+ioengine=nbd
+sockname=/tmp/socket
+rw=randrw
+size=64m
+nbdsize=64m
+time_based
+runtime=60
+numjobs=4
+group_reporting
+
+[thread0]
+offset=0
+
+[thread1]
+offset=64m
+
+[thread2]
+offset=128m
+
+[thread3]
+offset=192m
fio.1 +3 -0
index 2708b503..7e075fec 100644
@@ -1754,6 +1754,9 @@ FIO will then decide when to commit these requests.
 .TP
 .B libiscsi
 Read and write iscsi lun with libiscsi.
+.TP
+.B nbd
+Synchronous read and write a Network Block Device (NBD).
 .SS "I/O engine specific parameters"
 In addition, there are some parameters which are only valid when a specific
 \fBioengine\fR is in use. These are used identically to normal parameters,
optgroup.c +4 -0
index 04ceec7e..c228ff29 100644
@@ -169,6 +169,10 @@ static const struct opt_group fio_opt_cat_groups[] = {
 		.name	= "libhdfs I/O engine", /* libhdfs */
 		.mask	= FIO_OPT_G_HDFS,
 	},
+	{
+		.name	= "NBD I/O engine", /* NBD */
+		.mask	= FIO_OPT_G_NBD,
+	},
 	{
 		.name	= NULL,
 	},
optgroup.h +2 -0
index 148c8da1..8009bf25 100644
@@ -63,6 +63,7 @@ enum opt_category_group {
 	__FIO_OPT_G_SG,
 	__FIO_OPT_G_MMAP,
 	__FIO_OPT_G_ISCSI,
+	__FIO_OPT_G_NBD,
 	__FIO_OPT_G_NR,
 
 	FIO_OPT_G_RATE		= (1ULL << __FIO_OPT_G_RATE),
@@ -102,6 +103,7 @@ enum opt_category_group {
 	FIO_OPT_G_MMAP		= (1ULL << __FIO_OPT_G_MMAP),
 	FIO_OPT_G_INVALID	= (1ULL << __FIO_OPT_G_NR),
 	FIO_OPT_G_ISCSI         = (1ULL << __FIO_OPT_G_ISCSI),
+	FIO_OPT_G_NBD		= (1ULL << __FIO_OPT_G_NBD),
 };
 
 extern const struct opt_group *opt_group_from_mask(uint64_t *mask);
options.c +3 -0
index 95086074..f4c9bedf 100644
@@ -1899,6 +1899,9 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
 			    .help = "HTTP (WebDAV/S3) IO engine",
 			  },
 #endif
+			  { .ival = "nbd",
+			    .help = "Network Block Device (NBD) IO engine"
+			  },
 		},
 	},
 	{
Signature · 1 line
2.20.1