From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQgOV-00031T-4Z for qemu-devel@nongnu.org; Wed, 25 Feb 2015 13:09:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQgOQ-0001ld-4k for qemu-devel@nongnu.org; Wed, 25 Feb 2015 13:09:11 -0500 From: Max Reitz Date: Wed, 25 Feb 2015 13:08:33 -0500 Message-Id: <1424887718-10800-21-git-send-email-mreitz@redhat.com> In-Reply-To: <1424887718-10800-1-git-send-email-mreitz@redhat.com> References: <1424887718-10800-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH 20/25] block/nbd: Comment on discard/flush silently failing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz 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 --- 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; } request.from = sector_num * 512; -- 2.1.0