All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] don't change direct I/O xfer size during initial layout setup
@ 2017-09-04 15:23 kusumi.tomohiro
  2017-09-04 19:36 ` Sitsofe Wheeler
  0 siblings, 1 reply; 11+ messages in thread
From: kusumi.tomohiro @ 2017-09-04 15:23 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

8c43ba62('filesetup: align layout buffer') and
6e344dc3('filesetup: keep OS_O_DIRECT flag when pre-allocating file')
need to keep the valid transfer size throughout the entire writes.

The write(2) size may be truncated on the last write and break the
dio requirement. This results in td_verror() in the output.

--
 # mount | grep " on / "
 /dev/mapper/fedora-root on / type xfs (rw,relatime,attr2,inode64,noquota)
 # ./fio --name=xxx --kb_base=1000 --ioengine=sync --rw=read --bs=4KiB --size=10MiB --unlink=1 --direct=1 | grep "err="
 xxx: (groupid=0, jobs=1): err= 0: pid=3526: Mon Sep  4 18:03:57 2017
 # ./fio --name=xxx --kb_base=1000 --ioengine=sync --rw=read --bs=4KiB --size=10MB --unlink=1 --direct=1 | grep "err="
 fio: pid=3538, err=22/file:filesetup.c:238, func=write, error=Invalid argument
 xxx: (groupid=0, jobs=1): err=22 (file:filesetup.c:238, func=write, error=Invalid argument): pid=3538: Mon Sep  4 18:04:04 2017

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 filesetup.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/filesetup.c b/filesetup.c
index 5e8ea35..42d95db 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -112,6 +112,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
 	unsigned long long left;
 	unsigned int bs, alloc_size = 0;
 	char *b = NULL;
+	bool done = false;
 
 	if (read_only) {
 		log_err("fio: refusing extend of file due to read-only\n");
@@ -211,11 +212,15 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
 		goto err;
 	}
 
-	while (left && !td->terminate) {
+	while (!done && !td->terminate) {
 		ssize_t r;
 
-		if (bs > left)
-			bs = left;
+		/* If bs >= left this is the last write */
+		if (bs > left) {
+			done = true;
+			if (!td->o.odirect)
+				bs = left;
+		}
 
 		fill_io_buffer(td, b, bs, bs);
 
@@ -223,6 +228,8 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
 
 		if (r > 0) {
 			left -= r;
+			if (!left)
+				done = true;
 			continue;
 		} else {
 			if (r < 0) {
-- 
2.9.5



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-09-06 10:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-04 15:23 [PATCH] don't change direct I/O xfer size during initial layout setup kusumi.tomohiro
2017-09-04 19:36 ` Sitsofe Wheeler
2017-09-04 19:48   ` Tomohiro Kusumi
2017-09-05  5:59     ` Sitsofe Wheeler
2017-09-05  6:14       ` Tomohiro Kusumi
2017-09-05 14:39         ` Jens Axboe
2017-09-05 14:54           ` Tomohiro Kusumi
2017-09-05 14:58             ` Jens Axboe
2017-09-05 19:00               ` Sitsofe Wheeler
2017-09-05 19:45                 ` Jens Axboe
2017-09-06 10:13                   ` weiping zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.