Re: [Nbd] [PATCH 1/3] nbd: support FLUSH requests
- To: Alex Bligh <alex@...872...>
- Cc: nbd-general@...72..., Andrew Morton <akpm@...133...>, Paul Clements <Paul.Clements@...124...>, linux-kernel@...25...
- Subject: Re: [Nbd] [PATCH 1/3] nbd: support FLUSH requests
- From: Paolo Bonzini <pbonzini@...696...>
- Date: Wed, 13 Feb 2013 17:02:10 +0100
- Message-id: <511BB902.3080302@...696...>
- In-reply-to: <3EDEF735-9A67-439E-BA65-089C6AAFD1BF@...872...>
- References: <1360685171-3792-1-git-send-email-pbonzini@...696...> <1360685171-3792-2-git-send-email-pbonzini@...696...> <115932E2-48BE-406E-9E75-61D12EB5937A@...872...> <511A8491.5030407@...696...> <20130212133207.ef6b24f5.akpm@...133...> <FF1216D8-C4B3-405E-A4F6-82196A796A94@...872...> <511B8E65.5020507@...696...> <3EDEF735-9A67-439E-BA65-089C6AAFD1BF@...872...>
Il 13/02/2013 16:55, Alex Bligh ha scritto:
>> > But as far as I can test with free servers, the FUA bits have no
>> > advantage over flush. Also, I wasn't sure if SEND_FUA without
>> > SEND_FLUSH is valid, and if so how to handle this combination (treat it
>> > as writethrough and add FUA to all requests? warn and do nothing?).
> On the main opensource nbd client, the following applies:
>
> What REQ_FUA does is an fdatasync() after the write. Code extract and
> comments below from Christoph Hellwig.
>
> What REQ_FLUSH does is to do an fsync().
>
> The way I read Christoph's comment, provided the linux block layer always
> issues a REQ_FLUSH before a REQ_FUA, there is not performance problem.
>
> However, a REQ_FUA is going to do a f(data)?sync AFTER the write, whereas
> the preceding REQ_FLUSH is going to an fsync() BEFORE the write. It seems
> to me that either the FUA and FLUSH semantics are therefore different
> (and we need FUA), or that Christoph's comment is wrong and that you
> are guaranteed a REQ_FLUSH *after* the write with REQ_FUA.
REQ_FLUSH is indeed a flush before the write. fdatasync is fine there too.
If you do not have REQ_FUA, as is the case with this patch, the block
layer converts it to a REQ_FLUSH *after* the write.
See block/blk-flush.c:
* REQ_{FLUSH|FUA} requests are decomposed to sequences consisted of three
* optional steps - PREFLUSH, DATA and POSTFLUSH - according to the request
* properties and hardware capability.
*
* If the device doesn't have writeback cache, FLUSH and FUA don't make any
* difference. The requests are either completed immediately if there's no
* data or executed as normal requests otherwise.
*
* If the device has writeback cache and supports FUA, REQ_FLUSH is
* translated to PREFLUSH but REQ_FUA is passed down directly with DATA.
*
* If the device has writeback cache and doesn't support FUA, REQ_FLUSH is
* translated to PREFLUSH and REQ_FUA to POSTFLUSH.
Paolo
Reply to: