From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vkt3y-0002hy-Sy for qemu-devel@nongnu.org; Mon, 25 Nov 2013 05:06:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vkt3t-0002FJ-AM for qemu-devel@nongnu.org; Mon, 25 Nov 2013 05:06:42 -0500 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:54100 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vkt3s-0002Ew-VI for qemu-devel@nongnu.org; Mon, 25 Nov 2013 05:06:37 -0500 Message-ID: <5293213F.30502@kamp.de> Date: Mon, 25 Nov 2013 11:06:55 +0100 From: Peter Lieven MIME-Version: 1.0 References: <1385124001-3576-1-git-send-email-pbonzini@redhat.com> <1385124001-3576-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1385124001-3576-6-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 05/19] block: handle ENOTSUP from discard in generic code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: kwolf@redhat.com, ronniesahlberg@gmail.com, stefanha@redhat.com On 22.11.2013 13:39, Paolo Bonzini wrote: > Similar to write_zeroes, let the generic code receive a ENOTSUP for > discard operations. Since bdrv_discard has advisory semantics, > we can just swallow the error. > > Signed-off-by: Paolo Bonzini > --- > block.c | 2 +- > block/raw-posix.c | 12 ++++++------ > 2 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/block.c b/block.c > index f9674d9..b18ee6b 100644 > --- a/block.c > +++ b/block.c > @@ -4364,7 +4364,7 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, > ret = co.ret; > } > } > - if (ret) { > + if (ret && ret != -ENOTSUP) { > return ret; > } > > diff --git a/block/raw-posix.c b/block/raw-posix.c > index f836c8e..cfa3162 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -323,10 +323,10 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, > } > #endif > > - s->has_discard = 1; > + s->has_discard = true; > #ifdef CONFIG_XFS > if (platform_test_xfs_fd(s->fd)) { > - s->is_xfs = 1; > + s->is_xfs = true; > } > #endif > > @@ -698,8 +698,8 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb) > int ret = -EOPNOTSUPP; > BDRVRawState *s = aiocb->bs->opaque; > > - if (s->has_discard == 0) { > - return 0; > + if (!s->has_discard) { > + return -ENOTSUP; > } > > if (aiocb->aio_type & QEMU_AIO_BLKDEV) { > @@ -734,8 +734,8 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb) > > if (ret == -ENODEV || ret == -ENOSYS || ret == -EOPNOTSUPP || > ret == -ENOTTY) { > - s->has_discard = 0; > - ret = 0; > + s->has_discard = false; > + ret = -ENOTSUP; > } > return ret; > } wouldn't it make sense to return -ENOTSUP in other drivers a well if the operation is not supported and not return 0? Otherwise: Reviewed-by: Peter Lieven