@@ -112,6 +112,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)unsignedlonglongleft;unsignedintbs,alloc_size=0;char*b=NULL;+booldone=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)gotoerr;}-while(left&&!td->terminate){+while(!done&&!td->terminate){ssize_tr;-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);
@@ -112,6 +112,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)unsignedlonglongleft;unsignedintbs,alloc_size=0;char*b=NULL;+booldone=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)gotoerr;}-while(left&&!td->terminate){+while(!done&&!td->terminate){ssize_tr;-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);
Hmm. Won't this result in a file that is bigger than requested when
direct=1 and the maximum bs isn't an exact multiple of the extended
filesize? Should it start trying the minimum block size at this stage
with direct=1? If that goes on to not fit wouldn't it be better to do
less given that the main fio job won't be able to fill the gap either?
--
Sitsofe | http://sucs.org/~sits/
@@ -112,6 +112,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)unsignedlonglongleft;unsignedintbs,alloc_size=0;char*b=NULL;+booldone=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)gotoerr;}-while(left&&!td->terminate){+while(!done&&!td->terminate){ssize_tr;-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);
Hmm. Won't this result in a file that is bigger than requested when
direct=1 and the maximum bs isn't an exact multiple of the extended
filesize? Should it start trying the minimum block size at this stage
with direct=1? If that goes on to not fit wouldn't it be better to do
less given that the main fio job won't be able to fill the gap either?
--
Sitsofe | http://sucs.org/~sits/
The td's are also under the dio requirements.
If you really want the exact size, you can truncate(2) it.
Hi,
On 4 September 2017 at 16:23, [off-list ref] wrote:
quoted
From: Tomohiro Kusumi <redacted>
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.
@@ -112,6 +112,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)unsignedlonglongleft;unsignedintbs,alloc_size=0;char*b=NULL;+booldone=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)gotoerr;}-while(left&&!td->terminate){+while(!done&&!td->terminate){ssize_tr;-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);
Hmm. Won't this result in a file that is bigger than requested when
direct=1 and the maximum bs isn't an exact multiple of the extended
filesize? Should it start trying the minimum block size at this stage
with direct=1? If that goes on to not fit wouldn't it be better to do
less given that the main fio job won't be able to fill the gap either?
The td's are also under the dio requirements.
If you really want the exact size, you can truncate(2) it.
Hi,
On 4 September 2017 at 16:23, [off-list ref] wrote:
quoted
From: Tomohiro Kusumi <redacted>
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.
@@ -112,6 +112,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)unsignedlonglongleft;unsignedintbs,alloc_size=0;char*b=NULL;+booldone=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)gotoerr;}-while(left&&!td->terminate){+while(!done&&!td->terminate){ssize_tr;-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);
Hmm. Won't this result in a file that is bigger than requested when
direct=1 and the maximum bs isn't an exact multiple of the extended
filesize? Should it start trying the minimum block size at this stage
with direct=1? If that goes on to not fit wouldn't it be better to do
less given that the main fio job won't be able to fill the gap either?
The td's are also under the dio requirements.
If you really want the exact size, you can truncate(2) it.
Hi,
On 4 September 2017 at 16:23, [off-list ref] wrote:
quoted
From: Tomohiro Kusumi <redacted>
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.
@@ -112,6 +112,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)unsignedlonglongleft;unsignedintbs,alloc_size=0;char*b=NULL;+booldone=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)gotoerr;}-while(left&&!td->terminate){+while(!done&&!td->terminate){ssize_tr;-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);
Hmm. Won't this result in a file that is bigger than requested when
direct=1 and the maximum bs isn't an exact multiple of the extended
filesize? Should it start trying the minimum block size at this stage
with direct=1? If that goes on to not fit wouldn't it be better to do
less given that the main fio job won't be able to fill the gap either?
The td's are also under the dio requirements.
If you really want the exact size, you can truncate(2) it.
You were talking about the size *after* the write....
How many fixups for a simple "use O_DIRECT for layout if the job file
has direct=1 set" have we done now? I'm going to revert the whole thing,
and if someone can convince me that a simple clean patch that gets all
of it right exists, then please do send it. But until that happens,
we're going back to the old behavior of just using buffered IO to lay it
out.
--
Jens Axboe
I think I've made three fixes over the original two commits.
1. non O_DIRECT dio support -> committed -> now reverted
2. segfault on fio_memfree() -> committed -> now reverted
3. this one
As far as I've seen this is it.
(I think pre read can do the same as this function, to avoid
irrelevant errors, though pre read on dio is contradictory)
2017-09-05 17:39 GMT+03:00 Jens Axboe [off-list ref]:
Hi,
On 4 September 2017 at 16:23, [off-list ref] wrote:
quoted
From: Tomohiro Kusumi <redacted>
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.
@@ -112,6 +112,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)unsignedlonglongleft;unsignedintbs,alloc_size=0;char*b=NULL;+booldone=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)gotoerr;}-while(left&&!td->terminate){+while(!done&&!td->terminate){ssize_tr;-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);
Hmm. Won't this result in a file that is bigger than requested when
direct=1 and the maximum bs isn't an exact multiple of the extended
filesize? Should it start trying the minimum block size at this stage
with direct=1? If that goes on to not fit wouldn't it be better to do
less given that the main fio job won't be able to fill the gap either?
The td's are also under the dio requirements.
If you really want the exact size, you can truncate(2) it.
You were talking about the size *after* the write....
How many fixups for a simple "use O_DIRECT for layout if the job file
has direct=1 set" have we done now? I'm going to revert the whole thing,
and if someone can convince me that a simple clean patch that gets all
of it right exists, then please do send it. But until that happens,
we're going back to the old behavior of just using buffered IO to lay it
out.
--
Jens Axboe
I think I've made three fixes over the original two commits.
1. non O_DIRECT dio support -> committed -> now reverted
2. segfault on fio_memfree() -> committed -> now reverted
3. this one
As far as I've seen this is it.
Right, just checked (and reverted) and it's 5 changes all in
all for the change, not including the parent to this email,
which would have made it 6 in all. The original change from Weiping
clearly wasn't well tested or thought through, so it's better
to just kill it all and do it cleanly from scratch instead.
That said, I'm not even convinced we need this change. Logically
it makes sense, but there's really nothing wrong with doing
a buffered layout + cache kill as we have been doing since
the dawn of time in fio.
(I think pre read can do the same as this function, to avoid
irrelevant errors, though pre read on dio is contradictory)
Yeah, pre-read with O_DIRECT would be a waste of time.
--
Jens Axboe
On 5 September 2017 at 15:58, Jens Axboe [off-list ref] wrote:
On 09/05/2017 08:54 AM, Tomohiro Kusumi wrote:
quoted
I think I've made three fixes over the original two commits.
1. non O_DIRECT dio support -> committed -> now reverted
2. segfault on fio_memfree() -> committed -> now reverted
3. this one
As far as I've seen this is it.
Right, just checked (and reverted) and it's 5 changes all in
all for the change, not including the parent to this email,
which would have made it 6 in all. The original change from Weiping
clearly wasn't well tested or thought through, so it's better
to just kill it all and do it cleanly from scratch instead.
That said, I'm not even convinced we need this change. Logically
it makes sense, but there's really nothing wrong with doing
a buffered layout + cache kill as we have been doing since
the dawn of time in fio.
One of the benefits was that it stopped
rm -f /tmp/fiofile; ./fio --loops=10 --filename /tmp/fiofile --bs=4k \
--size=1M --direct=1 --name=go
reporting cached speeds on macOS (a platform where invalidation
doesn't work). The sad thing is that the change wound up slowing
layout right down because the I/O is potentially done in such small
sizes. With the problems it attracted it need a re-think if it's to
avoid attracting a never ending stream of workarounds.
quoted
(I think pre read can do the same as this function, to avoid
irrelevant errors, though pre read on dio is contradictory)
Yeah, pre-read with O_DIRECT would be a waste of time.
On 5 September 2017 at 15:58, Jens Axboe [off-list ref] wrote:
quoted
On 09/05/2017 08:54 AM, Tomohiro Kusumi wrote:
quoted
I think I've made three fixes over the original two commits.
1. non O_DIRECT dio support -> committed -> now reverted
2. segfault on fio_memfree() -> committed -> now reverted
3. this one
As far as I've seen this is it.
Right, just checked (and reverted) and it's 5 changes all in
all for the change, not including the parent to this email,
which would have made it 6 in all. The original change from Weiping
clearly wasn't well tested or thought through, so it's better
to just kill it all and do it cleanly from scratch instead.
That said, I'm not even convinced we need this change. Logically
it makes sense, but there's really nothing wrong with doing
a buffered layout + cache kill as we have been doing since
the dawn of time in fio.
One of the benefits was that it stopped
rm -f /tmp/fiofile; ./fio --loops=10 --filename /tmp/fiofile --bs=4k \
--size=1M --direct=1 --name=go
reporting cached speeds on macOS (a platform where invalidation
doesn't work). The sad thing is that the change wound up slowing
layout right down because the I/O is potentially done in such small
sizes. With the problems it attracted it need a re-think if it's to
avoid attracting a never ending stream of workarounds.
Slowing down layout for everyone is a much larger issue (and a
regression), whereas the lack of cache invalidation on a 2nd tier
platform is much less interesting. Of the two, I know what I'd pick.
It'd be nice if we can get everything working nicely. Honestly, it's not
rocket science (at all) to use O_DIRECT for layouts. The performance
issue is the biggest hurdle, the only thing we can do there is use a
larger block size and hope it closes enough of the gap.
--
Jens Axboe
On Tue, Sep 05, 2017 at 01:45:59PM -0600, Jens Axboe wrote:
On 09/05/2017 01:00 PM, Sitsofe Wheeler wrote:
quoted
On 5 September 2017 at 15:58, Jens Axboe [off-list ref] wrote:
quoted
On 09/05/2017 08:54 AM, Tomohiro Kusumi wrote:
quoted
I think I've made three fixes over the original two commits.
1. non O_DIRECT dio support -> committed -> now reverted
2. segfault on fio_memfree() -> committed -> now reverted
3. this one
As far as I've seen this is it.
Right, just checked (and reverted) and it's 5 changes all in
all for the change, not including the parent to this email,
which would have made it 6 in all. The original change from Weiping
clearly wasn't well tested or thought through, so it's better
to just kill it all and do it cleanly from scratch instead.
That said, I'm not even convinced we need this change. Logically
it makes sense, but there's really nothing wrong with doing
a buffered layout + cache kill as we have been doing since
the dawn of time in fio.
One of the benefits was that it stopped
rm -f /tmp/fiofile; ./fio --loops=10 --filename /tmp/fiofile --bs=4k \
--size=1M --direct=1 --name=go
reporting cached speeds on macOS (a platform where invalidation
doesn't work). The sad thing is that the change wound up slowing
layout right down because the I/O is potentially done in such small
sizes. With the problems it attracted it need a re-think if it's to
avoid attracting a never ending stream of workarounds.
Slowing down layout for everyone is a much larger issue (and a
regression), whereas the lack of cache invalidation on a 2nd tier
platform is much less interesting. Of the two, I know what I'd pick.
It'd be nice if we can get everything working nicely. Honestly, it's not
rocket science (at all) to use O_DIRECT for layouts. The performance
issue is the biggest hurdle, the only thing we can do there is use a
larger block size and hope it closes enough of the gap.
Hi Jens,
How about add a slight check, open a temp file with O_DIRECT but
pre-allocate using buffer io, like following:
@@ -152,6 +152,16 @@ static int extend_file(struct thread_data *td, struct fio_file *f)#endifdprint(FD_FILE,"open file %s, flags %x\n",f->file_name,flags);++if(td->o.odirect){+tmp_fd=open(f->file_name,flags|OS_O_DIRECT,0644);+if(tmp_fd<0&&errno==EINVAL)+log_err("fio: seems like filesystem does not support "\+"direct=1/buffered=0\n");+if(tmp_fd<0)+return1;+close(tmp_fd);+}+f->fd=open(f->file_name,flags,0644);if(f->fd<0){interr=errno;