From patchwork Fri Feb 15 13:49:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 1042847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=igalia.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="IpBoOmzP"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 441F7P64M6z9s4Z for ; Sat, 16 Feb 2019 00:52:16 +1100 (AEDT) Received: from localhost ([127.0.0.1]:40292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1guduT-0003p9-Bg for incoming@patchwork.ozlabs.org; Fri, 15 Feb 2019 08:52:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gudsn-00037N-8Q for qemu-devel@nongnu.org; Fri, 15 Feb 2019 08:50:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gudse-0006xn-Pt for qemu-devel@nongnu.org; Fri, 15 Feb 2019 08:50:18 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:56992) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gudsa-0006cU-SF; Fri, 15 Feb 2019 08:50:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Message-Id:Date:Subject:Cc:To:From; bh=5LIid8sRQ4Im8nPktaMzsIYMN85iAeS7IEA4r2ttnUE=; b=IpBoOmzPsJVLh0X80PAJotxnRzEKzYS6dY+Iu2vo4tr6GzWVzM9NjoorVjV2xHYvRNAbP/Em/3jDESj9fuczBDBz3zt4Bbc9LVTT1q4LwMZSalIZ6Q7O9LoxpMRBWJN5L8OV2qA5Cp8yZU3syAm5vZcEkSo1wu5/B8iZFlCp199QqAMeT5ZeafkIBqs9JQhjXelDp1INKDCU76sM7x38ex1/MufTpwvFbIKAfztHr9gBC4JUcxozA5hcHrPQD/6YnqTj9a/dWHoqZhFL0tzZB5zRRelkLLPyGW/ArNbwlX4b+10hRvTWtxmaYeSONxNfuqinVxwIoPyUHTKw18DJJA==; Received: from 62-165-147-230.co.dnainternet.fi ([62.165.147.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gudsF-0007C4-CD; Fri, 15 Feb 2019 14:49:51 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1guds1-0003mT-Ez; Fri, 15 Feb 2019 15:49:37 +0200 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Feb 2019 15:49:32 +0200 Message-Id: <20190215134932.14492-1-berto@igalia.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH] commit: Replace commit_top_bs on failure after deleting the block job 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If there's an error in commit_start() then the block job must be deleted before replacing commit_top_bs, otherwise it will fail because of lack of permissions. This happens since the permission system was introduced in 8dfba2797761d8a43744e4e6571c8175e448a478. Fortunately this bug doesn't seem to be possible to reproduce at the moment without changing the code. Signed-off-by: Alberto Garcia --- block/commit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/commit.c b/block/commit.c index 53148e610b..5deb05925b 100644 --- a/block/commit.c +++ b/block/commit.c @@ -374,10 +374,12 @@ fail: if (s->top) { blk_unref(s->top); } + job_early_fail(&s->common.job); + /* commit_top_bs has to be replaced after deleting the block job, + * otherwise this would fail because of lack of permissions. */ if (commit_top_bs) { bdrv_replace_node(commit_top_bs, top, &error_abort); } - job_early_fail(&s->common.job); }