From patchwork Fri Sep 7 21:13:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1425151 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 532F33FC71 for ; Fri, 7 Sep 2012 21:13:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757375Ab2IGVNu (ORCPT ); Fri, 7 Sep 2012 17:13:50 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:38161 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757201Ab2IGVNt (ORCPT ); Fri, 7 Sep 2012 17:13:49 -0400 Received: by mail-ie0-f174.google.com with SMTP id e11so40763iej.19 for ; Fri, 07 Sep 2012 14:13:49 -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=3kT7WsseJ2p9DRaxrFonVE/o+c83SqwXG3OoqLt6uMM=; b=R2aEyU6GRXgUxTvSyfLy4dvgjm0mkHi3B2Me1KEjJJUHi1SegOCa+YcXA5rU+S4yOQ En6j23jE3CE5ICAduY37k7naT/7wIyo/t1Yp2cB+gCuF3zzcAxOHos3gsdyBf5X7xV5X xbpcIDTzwQ4n+vXhRKYu/n6ZB+7LARPD9nJtYx3KpFIzfaVSKxyu02zfTpi8VAPb0fUu CAnuPdZ1bBWQPqUQ+xqnrK80DPzLP9AHTJBcTo/wL+Tx4dILyxxr106q+fM4EsGv0Qdc iMB8FdDDwIr0UI51u/QHadpG1Z0DPS1z6mh8Ht0GDXmhbWQ5Y1EDjro/jEVXH+RMSTej i8MQ== Received: by 10.50.160.233 with SMTP id xn9mr582071igb.37.1347052429118; Fri, 07 Sep 2012 14:13:49 -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 ESMTPS id q1sm831672igj.15.2012.09.07.14.13.46 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 14:13:47 -0700 (PDT) Message-ID: <504A638A.8030007@inktank.com> Date: Fri, 07 Sep 2012 16:13:46 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 4/9] rbd: get image features for a v2 image References: <504A6273.7030807@inktank.com> In-Reply-To: <504A6273.7030807@inktank.com> X-Gm-Message-State: ALoCoQnZIYL9s6jm2lK0+0AdYFBWN56ff/YrG2TiOtlniFJ1jeDHqOROVUJOP0CWSROEvp7PzDEy Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org The features values for an rbd format 2 image are fetched from the server using a "get_features" method. The same method is used for getting the features for a snapshot, so structure this addition with a generic helper routine that can get this information for either. The server will provide two 64-bit feature masks, one representing the features used for this image (or snapshot) and one representing features which cannot be used by the client when working with the image (or snapshot). For the time being, neither of these is really used so we keep things simple and just record the first feature vector. Once we start using these feature masks, what we record and what we expose to the user will most likely change. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) * newly-received snapshot context. Remove any existing snapshots @@ -2733,6 +2767,12 @@ static int rbd_dev_v2_probe(struct rbd_device *rbd_dev) ret = rbd_dev_v2_object_prefix(rbd_dev); if (ret < 0) goto out_err; + + /* Get the features for the image */ + + ret = rbd_dev_v2_features(rbd_dev); + if (ret < 0) + goto out_err; rbd_dev->image_format = 2; dout("discovered version 2 image, header name is %s\n", diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 36e848a..d48f025 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2200,6 +2200,40 @@ out: return ret; } +static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id, + u64 *snap_features) +{ + __le64 snapid = cpu_to_le64(snap_id); + struct { + __le64 features; + __le64 incompat; + } features_buf = { 0 }; + int ret; + + ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name, + "rbd", "get_features", + (char *) &snapid, sizeof (snapid), + (char *) &features_buf, sizeof (features_buf), + CEPH_OSD_FLAG_READ, NULL); + dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret); + if (ret < 0) + return ret; + *snap_features = le64_to_cpu(features_buf.features); + + dout(" snap_id 0x%016llx features = 0x%016llx incompat = 0x%016llx\n", + (unsigned long long) snap_id, + (unsigned long long) *snap_features, + (unsigned long long) le64_to_cpu(features_buf.incompat)); + + return 0; +} + +static int rbd_dev_v2_features(struct rbd_device *rbd_dev) +{ + return _rbd_dev_v2_snap_features(rbd_dev, CEPH_NOSNAP, + &rbd_dev->header.features); +} + /* * Scan the rbd device's current snapshot list and compare it to the