提交 7e97332e 编写于 作者: I Ilya Dryomov

rbd: support for data-pool feature

Add support for RBD_FEATURE_DATA_POOL feature.  rbd_dev->layout.pool_id
now stores the data pool id.
Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
Reviewed-by: NJason Dillaman <dillaman@redhat.com>
上级 263423f8
...@@ -123,9 +123,11 @@ static int atomic_dec_return_safe(atomic_t *v) ...@@ -123,9 +123,11 @@ static int atomic_dec_return_safe(atomic_t *v)
#define RBD_FEATURE_LAYERING (1<<0) #define RBD_FEATURE_LAYERING (1<<0)
#define RBD_FEATURE_STRIPINGV2 (1<<1) #define RBD_FEATURE_STRIPINGV2 (1<<1)
#define RBD_FEATURE_EXCLUSIVE_LOCK (1<<2) #define RBD_FEATURE_EXCLUSIVE_LOCK (1<<2)
#define RBD_FEATURE_DATA_POOL (1<<7)
#define RBD_FEATURES_ALL (RBD_FEATURE_LAYERING | \ #define RBD_FEATURES_ALL (RBD_FEATURE_LAYERING | \
RBD_FEATURE_STRIPINGV2 | \ RBD_FEATURE_STRIPINGV2 | \
RBD_FEATURE_EXCLUSIVE_LOCK) RBD_FEATURE_EXCLUSIVE_LOCK | \
RBD_FEATURE_DATA_POOL)
/* Features supported by this (client software) implementation. */ /* Features supported by this (client software) implementation. */
...@@ -146,6 +148,7 @@ struct rbd_image_header { ...@@ -146,6 +148,7 @@ struct rbd_image_header {
__u8 obj_order; __u8 obj_order;
u64 stripe_unit; u64 stripe_unit;
u64 stripe_count; u64 stripe_count;
s64 data_pool_id;
u64 features; /* Might be changeable someday? */ u64 features; /* Might be changeable someday? */
/* The remaining fields need to be updated occasionally */ /* The remaining fields need to be updated occasionally */
...@@ -989,7 +992,8 @@ static void rbd_init_layout(struct rbd_device *rbd_dev) ...@@ -989,7 +992,8 @@ static void rbd_init_layout(struct rbd_device *rbd_dev)
rbd_dev->layout.stripe_unit = rbd_dev->header.stripe_unit; rbd_dev->layout.stripe_unit = rbd_dev->header.stripe_unit;
rbd_dev->layout.stripe_count = rbd_dev->header.stripe_count; rbd_dev->layout.stripe_count = rbd_dev->header.stripe_count;
rbd_dev->layout.object_size = rbd_obj_bytes(&rbd_dev->header); rbd_dev->layout.object_size = rbd_obj_bytes(&rbd_dev->header);
rbd_dev->layout.pool_id = rbd_dev->spec->pool_id; rbd_dev->layout.pool_id = rbd_dev->header.data_pool_id == CEPH_NOPOOL ?
rbd_dev->spec->pool_id : rbd_dev->header.data_pool_id;
RCU_INIT_POINTER(rbd_dev->layout.pool_ns, NULL); RCU_INIT_POINTER(rbd_dev->layout.pool_ns, NULL);
} }
...@@ -4797,6 +4801,7 @@ static struct rbd_device *__rbd_dev_create(struct rbd_client *rbdc, ...@@ -4797,6 +4801,7 @@ static struct rbd_device *__rbd_dev_create(struct rbd_client *rbdc,
INIT_LIST_HEAD(&rbd_dev->node); INIT_LIST_HEAD(&rbd_dev->node);
init_rwsem(&rbd_dev->header_rwsem); init_rwsem(&rbd_dev->header_rwsem);
rbd_dev->header.data_pool_id = CEPH_NOPOOL;
ceph_oid_init(&rbd_dev->header_oid); ceph_oid_init(&rbd_dev->header_oid);
rbd_dev->header_oloc.pool = spec->pool_id; rbd_dev->header_oloc.pool = spec->pool_id;
...@@ -5161,6 +5166,24 @@ static int rbd_dev_v2_striping_info(struct rbd_device *rbd_dev) ...@@ -5161,6 +5166,24 @@ static int rbd_dev_v2_striping_info(struct rbd_device *rbd_dev)
return 0; return 0;
} }
static int rbd_dev_v2_data_pool(struct rbd_device *rbd_dev)
{
__le64 data_pool_id;
int ret;
ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid,
&rbd_dev->header_oloc, "get_data_pool",
NULL, 0, &data_pool_id, sizeof(data_pool_id));
if (ret < 0)
return ret;
if (ret < sizeof(data_pool_id))
return -EBADMSG;
rbd_dev->header.data_pool_id = le64_to_cpu(data_pool_id);
WARN_ON(rbd_dev->header.data_pool_id == CEPH_NOPOOL);
return 0;
}
static char *rbd_dev_image_name(struct rbd_device *rbd_dev) static char *rbd_dev_image_name(struct rbd_device *rbd_dev)
{ {
CEPH_DEFINE_OID_ONSTACK(oid); CEPH_DEFINE_OID_ONSTACK(oid);
...@@ -5858,6 +5881,12 @@ static int rbd_dev_v2_header_onetime(struct rbd_device *rbd_dev) ...@@ -5858,6 +5881,12 @@ static int rbd_dev_v2_header_onetime(struct rbd_device *rbd_dev)
goto out_err; goto out_err;
} }
if (rbd_dev->header.features & RBD_FEATURE_DATA_POOL) {
ret = rbd_dev_v2_data_pool(rbd_dev);
if (ret)
goto out_err;
}
rbd_init_layout(rbd_dev); rbd_init_layout(rbd_dev);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册