From: Max Reitz <mreitz@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 20/25] block/nbd: Comment on discard/flush silently failing
Date: Mon, 16 Mar 2015 09:58:11 -0400 [thread overview]
Message-ID: <5506E173.1000808@redhat.com> (raw)
In-Reply-To: <550027AB.4000107@redhat.com>
On 2015-03-11 at 07:31, Paolo Bonzini wrote:
>
> On 25/02/2015 19:08, Max Reitz wrote:
>> If some operation cannot be performed by a block driver, it is normally
>> supposed to return an error. In these cases, however, it is fine to
>> pretend the operations were carried out successfully because if the NBD
>> block driver would not implement discard or flush in the first place,
>> this is exactly what the block layer would do.
>>
>> Because this may not be obvious, add a comment for it.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>> block/nbd-client.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/block/nbd-client.c b/block/nbd-client.c
>> index be6803d..ab13607 100644
>> --- a/block/nbd-client.c
>> +++ b/block/nbd-client.c
>> @@ -315,6 +315,7 @@ int nbd_client_co_flush(BlockDriverState *bs)
>> ssize_t ret;
>>
>> if (!(client->nbdflags & NBD_FLAG_SEND_FLUSH)) {
>> + /* This mirrors the behavior of bdrv_co_flush() in block.c */
>> return 0;
>> }
>>
>> @@ -350,6 +351,7 @@ int nbd_client_co_discard(BlockDriverState *bs, int64_t sector_num,
>> ssize_t ret;
>>
>> if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) {
>> + /* This mirrors the behavior of bdrv_co_discard() in block.c */
>> return 0;
> Should this return -EOPNOTSUPP instead?
That's what this patch is for. I asked myself the same thing, and it
turns out, the functions deliberately return 0 because bdrv_co_flush()
and bdrv_co_discard() do the same if the block driver does not support
these functions at all, so that's why I'm adding these comments.
Max
> Paolo
>
>> }
>> request.from = sector_num * 512;
>>
next prev parent reply other threads:[~2015-03-16 13:58 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-25 18:08 [Qemu-devel] [PATCH 00/25] nbd: Several fixes Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 01/25] util/uri: Add overflow check to rfc3986_parse_port Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 02/25] qemu-nbd: Detect unused partitions by system == 0 Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 03/25] nbd: Fix nbd_establish_connection()'s return value Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 04/25] nbd: Fix response to invalid requests Max Reitz
2015-03-02 16:52 ` Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 05/25] nbd: Avoid generic -EINVAL Max Reitz
2015-03-11 11:22 ` Paolo Bonzini
2015-03-16 13:51 ` Max Reitz
2015-03-16 14:42 ` Paolo Bonzini
2015-03-16 14:48 ` Max Reitz
2015-03-16 14:49 ` Paolo Bonzini
2015-02-25 18:08 ` [Qemu-devel] [PATCH 06/25] nbd: Pass return value from nbd_handle_list() Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 07/25] nbd: Add "failed to open export" error message Max Reitz
2015-03-11 11:24 ` Paolo Bonzini
2015-03-16 13:55 ` Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 08/25] nbd: Handle blk_getlength() failure Max Reitz
2015-03-11 11:26 ` Paolo Bonzini
2015-02-25 18:08 ` [Qemu-devel] [PATCH 09/25] qemu-nbd: fork() can fail Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 10/25] nbd: Fix potential signed overflow issues Max Reitz
2015-03-11 11:28 ` Paolo Bonzini
2015-02-25 18:08 ` [Qemu-devel] [PATCH 11/25] qemu-nbd: Fix and improve input verification Max Reitz
2015-03-11 11:30 ` Paolo Bonzini
2015-03-16 13:56 ` Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 12/25] nbd: Set block size to BDRV_SECTOR_SIZE Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 13/25] nbd: Enforce sector alignment Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 14/25] coroutine: Add co_yield_timeout() Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 15/25] coroutine-io: Return -errno in case of error Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 16/25] coroutine-io: Add I/O functions with timeout Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 17/25] nbd: Employ timeouts Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 18/25] nbd: Fix nbd_receive_options() Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 19/25] nbd: Fix interpretation of the export flags Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 20/25] block/nbd: Comment on discard/flush silently failing Max Reitz
2015-03-11 11:31 ` Paolo Bonzini
2015-03-16 13:58 ` Max Reitz [this message]
2015-03-16 14:44 ` Paolo Bonzini
2015-03-16 14:49 ` Max Reitz
2015-03-16 14:51 ` Paolo Bonzini
2015-03-16 14:52 ` Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 21/25] nbd: Drop unexpected data for NBD_OPT_LIST Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 22/25] iotests: Add _timeout function Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 23/25] iotests: Add test for invalid qemu-nbd parameters Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 24/25] iotests: Add test for issuing discard over NBD Max Reitz
2015-02-25 18:08 ` [Qemu-devel] [PATCH 25/25] iotests: Add test for a non-existing NBD export Max Reitz
2015-02-25 18:11 ` [Qemu-devel] [PATCH 00/25] nbd: Several fixes Max Reitz
2015-03-11 11:36 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5506E173.1000808@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).