Skip to contentSkip to conversation

xenblk: Add O_DIRECT and O_SYNC support.

PATCH Joe Jin 3 participants 3 messages Nov 5, 2008

lore
Share & tools
lore

Joe Jin

author
#0 lore raw
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 without BI_RW_SYNC flag setted, either O_DIRECT or O_SYNC flag, when vm crashed/power outage, lots of data lost, sometimes more than 1M data lost, that means vm under high data lost risk. With BI_RW_SYNC flag when call submit_bio, open file with O_DIRECT or O_SYNC flag, 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_BARRIER and BLKIF_OP_FLUSH_DISKCACHE should suffice to implement O_SYNC on the blkfront side, I think. O_DIRECT doesn'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

#1 lore raw
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_BARRIER and BLKIF_OP_FLUSH_DISKCACHE should suffice to implement O_SYNC on the blkfront side, I think. O_DIRECT doesn'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_SYNC flag 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_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).

#2 lore raw
Quoted 2 lines

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

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