aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-07-03 17:01:19 -0400
committerAlex Elder <elder@inktank.com>2012-10-01 15:30:53 -0400
commitb1b5402aa9c4a9aeb8431886e41b0a1d127318d1 (patch)
treeb1a64ee08e120c156d563ea4eda617463d980b76 /drivers/block
parent1e1301998ee80d9a8cc09297906293f16f8a6064 (diff)
rbd: get image features for a v2 image
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 potentially in use for this image (or its snapshot), and one representing features that must be supported by the client in order to work with the image. 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 <elder@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 64a4dd5f6f2b..b8b8271bd9e2 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2206,6 +2206,40 @@ out:
2206 return ret; 2206 return ret;
2207} 2207}
2208 2208
2209static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
2210 u64 *snap_features)
2211{
2212 __le64 snapid = cpu_to_le64(snap_id);
2213 struct {
2214 __le64 features;
2215 __le64 incompat;
2216 } features_buf = { 0 };
2217 int ret;
2218
2219 ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name,
2220 "rbd", "get_features",
2221 (char *) &snapid, sizeof (snapid),
2222 (char *) &features_buf, sizeof (features_buf),
2223 CEPH_OSD_FLAG_READ, NULL);
2224 dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret);
2225 if (ret < 0)
2226 return ret;
2227 *snap_features = le64_to_cpu(features_buf.features);
2228
2229 dout(" snap_id 0x%016llx features = 0x%016llx incompat = 0x%016llx\n",
2230 (unsigned long long) snap_id,
2231 (unsigned long long) *snap_features,
2232 (unsigned long long) le64_to_cpu(features_buf.incompat));
2233
2234 return 0;
2235}
2236
2237static int rbd_dev_v2_features(struct rbd_device *rbd_dev)
2238{
2239 return _rbd_dev_v2_snap_features(rbd_dev, CEPH_NOSNAP,
2240 &rbd_dev->header.features);
2241}
2242
2209/* 2243/*
2210 * Scan the rbd device's current snapshot list and compare it to the 2244 * Scan the rbd device's current snapshot list and compare it to the
2211 * newly-received snapshot context. Remove any existing snapshots 2245 * newly-received snapshot context. Remove any existing snapshots
@@ -2739,6 +2773,12 @@ static int rbd_dev_v2_probe(struct rbd_device *rbd_dev)
2739 ret = rbd_dev_v2_object_prefix(rbd_dev); 2773 ret = rbd_dev_v2_object_prefix(rbd_dev);
2740 if (ret < 0) 2774 if (ret < 0)
2741 goto out_err; 2775 goto out_err;
2776
2777 /* Get the features for the image */
2778
2779 ret = rbd_dev_v2_features(rbd_dev);
2780 if (ret < 0)
2781 goto out_err;
2742 rbd_dev->image_format = 2; 2782 rbd_dev->image_format = 2;
2743 2783
2744 dout("discovered version 2 image, header name is %s\n", 2784 dout("discovered version 2 image, header name is %s\n",