From patchwork Tue Oct 9 21:01:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1571601 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 DFA37DFFAD for ; Tue, 9 Oct 2012 21:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756611Ab2JIVBI (ORCPT ); Tue, 9 Oct 2012 17:01:08 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:34485 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756508Ab2JIVBH (ORCPT ); Tue, 9 Oct 2012 17:01:07 -0400 Received: by mail-pa0-f46.google.com with SMTP id hz1so5612010pad.19 for ; Tue, 09 Oct 2012 14:01:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=theQV/XcArIccErgCszAlFlWMKmTQcho9VXGvMRAMdc=; b=J79JqIU7vCaBR22ZY6BWk7ibOU0vBx+96vuo0Oj+xtqyyTxlXNc0Js9ryJwOKm6qnH u8Ly74l1LcLgcY2aY9+btKeRW4k4JtnekAzJqb4cEBUO7pTXYzI2/fNnrcbDcA3Z/hIX F4V+/uZjQhF0mI7TqjGDam+bUU6ryD+X6qeNLlxBrXPR8jEJUopXGF3IPy6TRjnk3faJ dTfoiwR8nY7zQi4ebswNnTUamqnh7RrektQ3SCnbdjOatXTtBytBguvmJNWVjYrSHzPf bYe+lTFBYAAXy6qH0+mAKD/Tw18eSfL5u2RJoBZJrLQEfFSYbVS7VraXNs6i7Ezs3kgU Tqpg== Received: by 10.68.130.201 with SMTP id og9mr66863581pbb.12.1349816467196; Tue, 09 Oct 2012 14:01:07 -0700 (PDT) Received: from ?IPv6:2607:f298:a:607:4823:f93f:93c7:61da? ([2607:f298:a:607:4823:f93f:93c7:61da]) by mx.google.com with ESMTPS id n7sm10133998pav.26.2012.10.09.14.01.01 (version=SSLv3 cipher=OTHER); Tue, 09 Oct 2012 14:01:02 -0700 (PDT) Message-ID: <5074908C.3010808@inktank.com> Date: Tue, 09 Oct 2012 14:01:00 -0700 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 3/4] rbd: implement feature checks References: <50748FA5.4030508@inktank.com> In-Reply-To: <50748FA5.4030508@inktank.com> X-Gm-Message-State: ALoCoQmuaKcT9C33PXeGlKnXXwOaqCtgLCZU+9WsnKNYMtpyttWb4h+Zoc7UDaYVCVwT9/TAv3pL Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Version 2 images have two sets of feature bit fields. The first indicates features possibly used by the image. The second indicates features that the client *must* support in order to use the image. When an image (or snapshot) is first examined, we need to make sure that the local implementation supports the image's required features. If not, fail the probe for the image. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name, @@ -2235,6 +2244,11 @@ static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id, dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret); if (ret < 0) return ret; + + incompat = le64_to_cpu(features_buf.incompat); + if (incompat & ~RBD_FEATURES_ALL) + return -ENOTSUPP; + *snap_features = le64_to_cpu(features_buf.features); dout(" snap_id 0x%016llx features = 0x%016llx incompat = 0x%016llx\n", @@ -2976,7 +2990,7 @@ static int rbd_dev_v2_probe(struct rbd_device *rbd_dev) if (ret < 0) goto out_err; - /* Get the features for the image */ + /* Get the and check features for the image */ ret = rbd_dev_v2_features(rbd_dev); if (ret < 0) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 23f3beb..86ab032 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -70,6 +70,14 @@ #define RBD_IMAGE_ID_LEN_MAX 64 #define RBD_OBJ_PREFIX_LEN_MAX 64 +/* Feature bits */ + +#define RBD_FEATURE_LAYERING 1 + +/* Features supported by this (client software) implementation. */ + +#define RBD_FEATURES_ALL (0) + /* * An RBD device name will be "rbd#", where the "rbd" comes from * RBD_DRV_NAME above, and # is a unique integer identifier. @@ -2225,6 +2233,7 @@ static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id, __le64 features; __le64 incompat; } features_buf = { 0 }; + u64 incompat; int ret;