* Why does 'direct' influence 'fsync'?
@ 2013-01-25 11:42 Stefan Hajnoczi
2013-01-26 16:28 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2013-01-25 11:42 UTC (permalink / raw)
To: fio; +Cc: Asias He
Is there a way to flush the disk write cache when O_DIRECT is in use?
It seems that direct=1 causes the fsync setting to be ignored. Asias
writes:
> The O_DIRECT do affect the flush behaviour. e.g
>
> guest$ fio --fsync=100 --direct=1
> No virtio_blk_handle_flush is observed on host side every 100 IOs
>
> guest$ fio --fsync=100 --direct=0
> virtio_blk_handle_flush is observed on host side every 100 IOs
Am I missing a reason for this behavior? To me it seems weird since you
could already use --fsync=0 --direct=1 if you want to guarantee that
fsync is not called. I don't see a need to override the fsync setting.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Why does 'direct' influence 'fsync'?
2013-01-25 11:42 Why does 'direct' influence 'fsync'? Stefan Hajnoczi
@ 2013-01-26 16:28 ` Jens Axboe
2013-01-26 16:51 ` Stefan Hajnoczi
0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2013-01-26 16:28 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: fio, Asias He
On Fri, Jan 25 2013, Stefan Hajnoczi wrote:
> Is there a way to flush the disk write cache when O_DIRECT is in use?
>
> It seems that direct=1 causes the fsync setting to be ignored. Asias
> writes:
>
> > The O_DIRECT do affect the flush behaviour. e.g
> >
> > guest$ fio --fsync=100 --direct=1
> > No virtio_blk_handle_flush is observed on host side every 100 IOs
> >
> > guest$ fio --fsync=100 --direct=0
> > virtio_blk_handle_flush is observed on host side every 100 IOs
>
> Am I missing a reason for this behavior? To me it seems weird since you
> could already use --fsync=0 --direct=1 if you want to guarantee that
> fsync is not called. I don't see a need to override the fsync setting.
You are right, fio should not be double guessing options like that. If
you ask for fsync, you should get fsync.
Does the below work for you?
diff --git a/fio.h b/fio.h
index 3a26335..9e20299 100644
--- a/fio.h
+++ b/fio.h
@@ -655,8 +655,6 @@ static inline int should_fsync(struct thread_data *td)
{
if (td->last_was_sync)
return 0;
- if (td->o.odirect)
- return 0;
if (td_write(td) || td_rw(td) || td->o.override_sync)
return 1;
--
Jens Axboe
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: Why does 'direct' influence 'fsync'?
2013-01-26 16:28 ` Jens Axboe
@ 2013-01-26 16:51 ` Stefan Hajnoczi
2013-01-27 1:37 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2013-01-26 16:51 UTC (permalink / raw)
To: Jens Axboe; +Cc: fio, Asias He
On Sat, Jan 26, 2013 at 5:28 PM, Jens Axboe <axboe@kernel.dk> wrote:
> On Fri, Jan 25 2013, Stefan Hajnoczi wrote:
>> Is there a way to flush the disk write cache when O_DIRECT is in use?
>>
>> It seems that direct=1 causes the fsync setting to be ignored. Asias
>> writes:
>>
>> > The O_DIRECT do affect the flush behaviour. e.g
>> >
>> > guest$ fio --fsync=100 --direct=1
>> > No virtio_blk_handle_flush is observed on host side every 100 IOs
>> >
>> > guest$ fio --fsync=100 --direct=0
>> > virtio_blk_handle_flush is observed on host side every 100 IOs
>>
>> Am I missing a reason for this behavior? To me it seems weird since you
>> could already use --fsync=0 --direct=1 if you want to guarantee that
>> fsync is not called. I don't see a need to override the fsync setting.
>
> You are right, fio should not be double guessing options like that. If
> you ask for fsync, you should get fsync.
>
> Does the below work for you?
Yes, thanks!
Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Why does 'direct' influence 'fsync'?
2013-01-26 16:51 ` Stefan Hajnoczi
@ 2013-01-27 1:37 ` Jens Axboe
0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2013-01-27 1:37 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: fio, Asias He
On Sat, Jan 26 2013, Stefan Hajnoczi wrote:
> On Sat, Jan 26, 2013 at 5:28 PM, Jens Axboe <axboe@kernel.dk> wrote:
> > On Fri, Jan 25 2013, Stefan Hajnoczi wrote:
> >> Is there a way to flush the disk write cache when O_DIRECT is in use?
> >>
> >> It seems that direct=1 causes the fsync setting to be ignored. Asias
> >> writes:
> >>
> >> > The O_DIRECT do affect the flush behaviour. e.g
> >> >
> >> > guest$ fio --fsync=100 --direct=1
> >> > No virtio_blk_handle_flush is observed on host side every 100 IOs
> >> >
> >> > guest$ fio --fsync=100 --direct=0
> >> > virtio_blk_handle_flush is observed on host side every 100 IOs
> >>
> >> Am I missing a reason for this behavior? To me it seems weird since you
> >> could already use --fsync=0 --direct=1 if you want to guarantee that
> >> fsync is not called. I don't see a need to override the fsync setting.
> >
> > You are right, fio should not be double guessing options like that. If
> > you ask for fsync, you should get fsync.
> >
> > Does the below work for you?
>
> Yes, thanks!
>
> Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
Great, thanks for reporting and testing!
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-27 1:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-25 11:42 Why does 'direct' influence 'fsync'? Stefan Hajnoczi
2013-01-26 16:28 ` Jens Axboe
2013-01-26 16:51 ` Stefan Hajnoczi
2013-01-27 1:37 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox