xenblk: Add O_DIRECT and O_SYNC support.
Quoted 10 lines
Quoted 8 lines
Do you think when xenblk backend
make_reponse()means the request have commited to disk?
We have did a sample testing and found withoutBI_RW_SYNCflag setted, eitherO_DIRECTorO_SYNCflag, when vm crashed/power outage, lots of data lost, sometimes more than 1M data lost, that means vm under high data lost risk. WithBI_RW_SYNCflag when callsubmit_bio, open file withO_DIRECTorO_SYNCflag, could sync data very well.What's the vbd type in this case: raw partition, lvm, qcow file, ...?
Raw partition, crashed/power outage, lots of data lost :(
Quoted 5 lines
The existing
BLKIF_OP_WRITE_BARRIERandBLKIF_OP_FLUSH_DISKCACHEshould suffice to implementO_SYNCon the blkfront side, I think.O_DIRECTdoesn't mean writes are synchronous to the platters -- just means the buffer cache is bypassed -- which should generally be the case on the blkback side always anyway.
However, frontend driver could not got the write's flag at all. if we could know the request with O_SYNC flag should be easy to handle, need not touch filesystem layer.O_DIRECT is difference not only buffer head, if read/write is direct-io, need to commit request as soon as possible, means unplug request_queue if request with O_DIRECT flag(request should be marked REQ_RW_SYNC flag).
Thanks,
Joe
Quoted 10 lines · Joe Jin
Quoted 1 line
What's the vbd type in this case: raw partition, lvm, qcow file, ...?
Raw partition, crashed/power outage, lots of data lost :(
Quoted 5 lines
The existing
BLKIF_OP_WRITE_BARRIERandBLKIF_OP_FLUSH_DISKCACHEshould suffice to implementO_SYNCon the blkfront side, I think.O_DIRECTdoesn't mean writes are synchronous to the platters -- just means the buffer cache is bypassed -- which should generally be the case on the blkback side always anyway.
Quoted 3 lines
However, frontend driver could not got the write's flag at all. if we could know the request with
O_SYNCflag should be easy to handle, need not touch filesystem layer.
So what does O_SYNC mean to Linux then? If it's not passed down to the blkdev layer then it can only mean that requests must be synchronously committed as far as that layer. I would therefore imagine you could lose as much data natively as you do running on Xen. Where are these megabytes of data sitting when they get lost, and why does it not happen when running natively? If O_SYNC is not waiting for completion responses from the block layer, that's a limitation of Linux's generic block subsystem, isn't it?
-- Keir
Quoted 4 lines
O_DIRECTis difference not only buffer head, if read/write is direct-io, need to commit request as soon as possible, means unplugrequest_queueif request withO_DIRECTflag(request should be marked REQ_RW_SYNC flag).
Quoted 2 lines
So what does
O_SYNCmean to Linux then? If it's not passed down to the blkdev layer then it can only mean that requests must be synchronously
The block device layer speaks ordering barriers not file flags. The O_SYNC flag is passed to the file system the file system is responsible for turning that into some type of ordering, ditto stuff like fdatasync(). The exact behaviour is then configuable by the fs (eg ext3 has journalled and non journalled data modes)
In terms of data integrity if you are relying on the order of physical media writes internally in Xen you already lost as there is nothing in most ATA specs requiring that a sequence of I/O operations occurs in the order they go to the drive. The sematics of cache flushing versus other I/O are defined so you have ordering points you can impose and some control over the time stuff may sit around before hitting disk.
Alan