Re: Why does 'direct' influence 'fsync'?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux