Why does 'direct' influence 'fsync'?
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
Quoted 7 lines · writes:
The
O_DIRECTdo affect the flush behaviour. e.gguest$ fio --fsync=100 --direct=1
Novirtio_blk_handle_flushis observed on host side every 100 IOsguest$ fio --fsync=100 --direct=0
virtio_blk_handle_flushis 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
Quoted 10 lines · Stefan Hajnoczi
Is there a way to flush the disk write cache when
O_DIRECTis in use?It seems that direct=1 causes the fsync setting to be ignored. Asias
Quoted 5 lines · writes:
The
O_DIRECTdo affect the flush behaviour. e.gguest$ fio --fsync=100 --direct=1
Novirtio_blk_handle_flushis observed on host side every 100 IOs
Quoted 6 lines
Quoted 2 lines
guest$ fio --fsync=100 --direct=0
virtio_blk_handle_flushis observed on host side every 100 IOsAm 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?
fio.h +0 -2
@@ -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 ;
Signature · 1 line
Jens Axboe
Stefan Hajnoczi
Tested-byQuoted 14 lines · Jens Axboe
Quoted 13 lines · Stefan Hajnoczi
Is there a way to flush the disk write cache when
O_DIRECTis in use?It seems that direct=1 causes the fsync setting to be ignored. Asias
Quoted 7 lines · writes:
The
O_DIRECTdo affect the flush behaviour. e.gguest$ fio --fsync=100 --direct=1
Novirtio_blk_handle_flushis observed on host side every 100 IOsguest$ fio --fsync=100 --direct=0
virtio_blk_handle_flushis observed on host side every 100 IOs
Quoted 8 lines
Quoted 3 lines
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!
Quoted 19 lines · Stefan Hajnoczi
Quoted 18 lines · Jens Axboe
Quoted 16 lines · Stefan Hajnoczi
Is there a way to flush the disk write cache when
O_DIRECTis in use?It seems that direct=1 causes the fsync setting to be ignored. Asias
Quoted 7 lines · writes:
The
O_DIRECTdo affect the flush behaviour. e.gguest$ fio --fsync=100 --direct=1
Novirtio_blk_handle_flushis observed on host side every 100 IOsguest$ fio --fsync=100 --direct=0
virtio_blk_handle_flushis observed on host side every 100 IOsAm 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.
Quoted 8 lines
Quoted 4 lines
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 <[email protected]>
Great, thanks for reporting and testing!
Signature · 1 line
Jens Axboe