From patchwork Fri Apr 26 12:06:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2493231 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C40D8DFE86 for ; Fri, 26 Apr 2013 12:06:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753485Ab3DZMGJ (ORCPT ); Fri, 26 Apr 2013 08:06:09 -0400 Received: from mail-ia0-f172.google.com ([209.85.210.172]:62016 "EHLO mail-ia0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751332Ab3DZMGI (ORCPT ); Fri, 26 Apr 2013 08:06:08 -0400 Received: by mail-ia0-f172.google.com with SMTP id i20so3650191ian.3 for ; Fri, 26 Apr 2013 05:06:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=FAMlHBrM7EQ9PeTfUTidKMtqQAAwZ2OfWSfht5gRWS4=; b=gOdmesY58AjPGcVKw1BvckmpQR/IKa+Lxzs0t+4zmv7kjZD6U1aKOIx/VykRzWURW3 bGIv+5DjcSN0sThk7dplFO+mS0gg8Ehofj/O4k940Edy4bIVkSj96p+tI3c4GUhcp7gH fWEH1+vcAz1gV7gkRZVHDUQCJ0pmj3gNYU5ZS9FaKP+uGWGaGMZgXLZbX6jqSeJ9+t7g sA+HEJ3K0nORfJxnYPwWEzZNu/esya8I6WuITiYloEmWPUGJIrPZh9IzA+aUsfxRY+cG nExch/mzKp3Q/2gqQhFhDTQ2k/NoGEOLz0Zw9wOsfFr7Ji2KAoM18TBe1h0BUjVaSgg5 3bEQ== X-Received: by 10.50.108.104 with SMTP id hj8mr1653834igb.62.1366977967702; Fri, 26 Apr 2013 05:06:07 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id hi4sm2818829igc.6.2013.04.26.05.06.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Apr 2013 05:06:06 -0700 (PDT) Message-ID: <517A6DAE.7010604@inktank.com> Date: Fri, 26 Apr 2013 07:06:06 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 3/6] rbd: only update values on snap_info success References: <517A6D39.80000@inktank.com> In-Reply-To: <517A6D39.80000@inktank.com> X-Gm-Message-State: ALoCoQkTRtN3+wtoGHFnbwB5ga4AMi+6IH1ehoEzI8FIWBjmwyVZXGAgHG/BDGTxZoSZwJ0ZiI6b Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Change rbd_dev_v2_snap_info() so it only ever sets values of the size and features parameters if looking up the snapshot name was successful. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) "rbd", "get_snapshot_name", @@ -3940,17 +3941,30 @@ static char *rbd_dev_v2_snap_info(struct rbd_device *rbd_dev, u32 which, u64 *snap_size, u64 *snap_features) { u64 snap_id; + u64 size; + u64 features; + char *snap_name; int ret; + rbd_assert(which < rbd_dev->header.snapc->num_snaps); snap_id = rbd_dev->header.snapc->snaps[which]; - ret = _rbd_dev_v2_snap_size(rbd_dev, snap_id, NULL, snap_size); + ret = _rbd_dev_v2_snap_size(rbd_dev, snap_id, NULL, &size); if (ret) - return ERR_PTR(ret); - ret = _rbd_dev_v2_snap_features(rbd_dev, snap_id, snap_features); + goto out_err; + + ret = _rbd_dev_v2_snap_features(rbd_dev, snap_id, &features); if (ret) - return ERR_PTR(ret); + goto out_err; + + snap_name = rbd_dev_v2_snap_name(rbd_dev, which); + if (!IS_ERR(snap_name)) { + *snap_size = size; + *snap_features = features; + } - return rbd_dev_v2_snap_name(rbd_dev, which); + return snap_name; +out_err: + return ERR_PTR(ret); } static char *rbd_dev_snap_info(struct rbd_device *rbd_dev, u32 which, diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 1e01f0d..e7d10d3 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3908,6 +3908,7 @@ static char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, u32 which) if (!reply_buf) return ERR_PTR(-ENOMEM); + rbd_assert(which < rbd_dev->header.snapc->num_snaps); snap_id = cpu_to_le64(rbd_dev->header.snapc->snaps[which]); ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name,