From patchwork Wed Sep 7 08:31:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 9318623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E9A406077F for ; Wed, 7 Sep 2016 08:32:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F391F29156 for ; Wed, 7 Sep 2016 08:32:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E725A2915B; Wed, 7 Sep 2016 08:32:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E092529156 for ; Wed, 7 Sep 2016 08:32:35 +0000 (UTC) Received: from localhost ([::1]:38863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhYHb-0005DM-27 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Sep 2016 04:32:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhYGN-0004iV-Ft for qemu-devel@nongnu.org; Wed, 07 Sep 2016 04:31:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhYGM-0005kC-D2 for qemu-devel@nongnu.org; Wed, 07 Sep 2016 04:31:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhYGG-0005jh-3S; Wed, 07 Sep 2016 04:31:12 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45A09C057FA9; Wed, 7 Sep 2016 08:31:11 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-76.ams2.redhat.com [10.36.116.76]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u878V8Ee017994; Wed, 7 Sep 2016 04:31:08 -0400 Date: Wed, 7 Sep 2016 10:31:07 +0200 From: Kevin Wolf To: Eric Blake Message-ID: <20160907083107.GC5113@noname.redhat.com> References: <1473188690-14225-1-git-send-email-eblake@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1473188690-14225-1-git-send-email-eblake@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 07 Sep 2016 08:31:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH] iscsi: Fix divide-by-zero regression on raw SG devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-block@nongnu.org, Peter Lieven , qemu-devel@nongnu.org, qemu-stable@nongnu.org, holger@fam-schranz.de, Ronnie Sahlberg , Paolo Bonzini , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Am 06.09.2016 um 21:04 hat Eric Blake geschrieben: > When qemu uses iscsi devices in sg mode, iscsilun->block_size > is left at 0. Prior to commits cf081fca and similar, when > block limits were tracked in sectors, this did not matter: > various block limits were just left at 0. But when we started > scaling by block size, this caused SIGFPE. > > One possible solution for SG mode is to just blindly skip ALL > of iscsi_refresh_limits(), since we already short circuit so > many other things in sg mode. But this patch takes a slightly > more conservative approach, and merely guarantees that scaling > will succeed (for SG devices, the scaling is done to the block > layer default of 512 bytes, since we don't know of any iscsi > devices with a smaller block size), while still using multiples > of the original size. Resulting limits may still be zero in SG > mode (that is, we only fix block_size used as a denominator, not > all uses). > > Reported-by: Holger Schranz > Signed-off-by: Eric Blake > CC: qemu-stable@nongnu.org > --- > > I would really appreciate Holger testing this patch. We could > also go with the much shorter patch that just does > if (bs->sg) { return; } > at the top of iscsi_refresh_limits(), but I'm not sure if that > would break anything else in the block layer (we had several, > but not all, limits that were provably left alone at 0 for > sg mode). Hm, originally I thought that we could even just return for bs->sg in bdrv_refresh_limits() like below because for SG devices the limits should never be used, but with scsi-block they might actually be. Paolo, what do you think? Anyway, let's go with the above patch first, it's a conservative one that qemu-stable and possibly downstream can safely backport. If we're going to add anything else, that would be for 2.8 only. Kevin diff --git a/block/io.c b/block/io.c index fdf7080..144ff65 100644 --- a/block/io.c +++ b/block/io.c @@ -84,7 +84,7 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) memset(&bs->bl, 0, sizeof(bs->bl)); - if (!drv) { + if (!drv || bs->sg) { return; }