From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT6CG-0001BC-F7 for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:29:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VT6C7-0006Ts-UB for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:29:44 -0400 Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]:44427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT6C7-0006Tl-O7 for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:29:35 -0400 Received: by mail-wi0-f170.google.com with SMTP id cb5so4940269wib.3 for ; Mon, 07 Oct 2013 01:29:35 -0700 (PDT) Date: Mon, 7 Oct 2013 10:29:32 +0200 From: Stefan Hajnoczi Message-ID: <20131007082932.GC6254@stefanha-thinkpad.redhat.com> References: <1380029714-5239-1-git-send-email-pl@kamp.de> <1380029714-5239-9-git-send-email-pl@kamp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1380029714-5239-9-git-send-email-pl@kamp.de> 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: Peter Lieven Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, anthony@codemonkey.ws, pbonzini@redhat.com, ronniesahlberg@gmail.com 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, > } > > if (bs->drv->bdrv_co_discard) { > - return bs->drv->bdrv_co_discard(bs, sector_num, nb_sectors); > + int max_discard = bs->bl.max_discard ? > + bs->bl.max_discard : MAX_DISCARD_DEFAULT; > + > + while (nb_sectors > 0) { > + int ret; > + int num = nb_sectors; > + > + /* align request */ > + if (bs->bl.discard_alignment && > + num >= bs->bl.discard_alignment && > + sector_num % bs->bl.discard_alignment) { > + if (num > bs->bl.discard_alignment) { > + num = bs->bl.discard_alignment; > + } > + num -= sector_num % bs->bl.discard_alignment; > + } Is it always possible to discard at arbitrary sector offsets?