From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT6Ij-0004kT-3u for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:36:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VT6IY-0000St-Pc for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:36:25 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:36126 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT6IY-0000Oy-Fa for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:36:14 -0400 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) From: Peter Lieven In-Reply-To: <20131007082932.GC6254@stefanha-thinkpad.redhat.com> Date: Mon, 7 Oct 2013 10:36:14 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1380029714-5239-1-git-send-email-pl@kamp.de> <1380029714-5239-9-git-send-email-pl@kamp.de> <20131007082932.GC6254@stefanha-thinkpad.redhat.com> Subject: Re: [Qemu-devel] [PATCHv3 08/20] block: honour BlockLimits in bdrv_co_discard List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, anthony@codemonkey.ws, pbonzini@redhat.com, ronniesahlberg@gmail.com Am 07.10.2013 um 10:29 schrieb Stefan Hajnoczi : > On Tue, Sep 24, 2013 at 03:35:02PM +0200, Peter Lieven wrote: >> @@ -4245,7 +4250,37 @@ int coroutine_fn = bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, >> } >>=20 >> if (bs->drv->bdrv_co_discard) { >> - return bs->drv->bdrv_co_discard(bs, sector_num, nb_sectors); >> + int max_discard =3D bs->bl.max_discard ? >> + bs->bl.max_discard : MAX_DISCARD_DEFAULT; >> + >> + while (nb_sectors > 0) { >> + int ret; >> + int num =3D nb_sectors; >> + >> + /* align request */ >> + if (bs->bl.discard_alignment && >> + num >=3D bs->bl.discard_alignment && >> + sector_num % bs->bl.discard_alignment) { >> + if (num > bs->bl.discard_alignment) { >> + num =3D bs->bl.discard_alignment; >> + } >> + num -=3D sector_num % bs->bl.discard_alignment; >> + } >=20 > Is it always possible to discard at arbitrary sector offsets? It should be. This just makes sure that the unaligned part of a request = gets executed first (eventually resulting in an -ENOTSUP) and consecutive calls are aligned. For example. The alignment is 1MB (2048 sectors) and max_discard its = 2048 sectors as well.. Lets say you want to discard 4096 sectors = starting at offset 1024. Then there will be 3 calls 1) discard at 1024, len 1024 2) discard at 2048, len 2048 3) discard at 4096, len 1024. Peter=