From patchwork Wed Apr 5 18:28:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 747443 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vyvgD1dMbz9s8N for ; Thu, 6 Apr 2017 04:36:08 +1000 (AEST) Received: from localhost ([::1]:41872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvpmn-000369-Iv for incoming@patchwork.ozlabs.org; Wed, 05 Apr 2017 14:36:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvpgr-0007Bs-HT for qemu-devel@nongnu.org; Wed, 05 Apr 2017 14:30:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvpgm-0002KK-8o for qemu-devel@nongnu.org; Wed, 05 Apr 2017 14:29:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32592) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cvpgd-0002H3-LF; Wed, 05 Apr 2017 14:29:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA371C04BD41; Wed, 5 Apr 2017 18:29:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AA371C04BD41 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jcody@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AA371C04BD41 Received: from localhost (ovpn-116-76.phx2.redhat.com [10.3.116.76]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BDEC4171B6; Wed, 5 Apr 2017 18:29:38 +0000 (UTC) From: Jeff Cody To: qemu-devel@nongnu.org Date: Wed, 5 Apr 2017 14:28:50 -0400 Message-Id: <613303fd54633f005eeea485e32f590994eb299f.1491416061.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 05 Apr 2017 18:29:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 8/9] block/rbd: do not blindly set bs->read_only 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: kwolf@redhat.com, jsnow@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We do not want to just blindly set bs->read_only. The only time we need to set it with the current rbd driver, is if we are using an rbd snapshot. In that case, we must set it to read-only. Signed-off-by: Jeff Cody --- block/rbd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index c5e1aeb..35853c9 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -635,6 +635,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, goto failed_shutdown; } + /* rbd_open is always r/w */ r = rbd_open(s->io_ctx, s->image_name, &s->image, s->snap); if (r < 0) { error_setg_errno(errp, -r, "error reading header from %s", @@ -642,10 +643,14 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, goto failed_open; } - r = bdrv_set_read_only(bs, (s->snap != NULL), &local_err); - if (r < 0) { - error_propagate(errp, local_err); - goto failed_open; + /* If we are using an rbd snapshot, we must be r/o, otherwise + * leave as-is */ + if (s->snap != NULL) { + r = bdrv_set_read_only(bs, true, &local_err); + if (r < 0) { + error_propagate(errp, local_err); + goto failed_open; + } } qemu_opts_del(opts);