diff options
author | Alex Elder <elder@inktank.com> | 2012-11-14 13:25:19 -0500 |
---|---|---|
committer | Alex Elder <elder@inktank.com> | 2013-01-17 17:34:58 -0500 |
commit | 0903e875caa93e1fb231dd66c69b118dbdad25cb (patch) | |
tree | 6af900cda01ebc6acdd5f76672a28973f1b323c7 /drivers/block/rbd.c | |
parent | 47dba7ba2623b088cbbe1ac0aaa1a034f3249b6d (diff) |
rbd: use a common layout for each device
Each osd message includes a layout structure, and for rbd it is
always the same (at least for osd's in a given pool).
Initialize a layout structure when an rbd_dev gets created and just
copy that into osd requests for the rbd image.
Replace an assertion that was done when initializing the layout
structures with code that catches and handles anything that would
trigger the assertion as soon as it is identified. This precludes
that (bad) condition from ever occurring.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r-- | drivers/block/rbd.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 1c0192c3cf47..d2a6e9589fab 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -235,6 +235,8 @@ struct rbd_device { | |||
235 | 235 | ||
236 | char *header_name; | 236 | char *header_name; |
237 | 237 | ||
238 | struct ceph_file_layout layout; | ||
239 | |||
238 | struct ceph_osd_event *watch_event; | 240 | struct ceph_osd_event *watch_event; |
239 | struct ceph_osd_request *watch_request; | 241 | struct ceph_osd_request *watch_request; |
240 | 242 | ||
@@ -1091,16 +1093,6 @@ static void rbd_coll_end_req(struct rbd_request *rbd_req, | |||
1091 | ret, len); | 1093 | ret, len); |
1092 | } | 1094 | } |
1093 | 1095 | ||
1094 | static void rbd_layout_init(struct ceph_file_layout *layout, u64 pool_id) | ||
1095 | { | ||
1096 | memset(layout, 0, sizeof (*layout)); | ||
1097 | layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); | ||
1098 | layout->fl_stripe_count = cpu_to_le32(1); | ||
1099 | layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); | ||
1100 | rbd_assert(pool_id <= (u64) U32_MAX); | ||
1101 | layout->fl_pg_pool = cpu_to_le32((u32) pool_id); | ||
1102 | } | ||
1103 | |||
1104 | /* | 1096 | /* |
1105 | * Send ceph osd request | 1097 | * Send ceph osd request |
1106 | */ | 1098 | */ |
@@ -1165,7 +1157,7 @@ static int rbd_do_request(struct request *rq, | |||
1165 | strncpy(osd_req->r_oid, object_name, sizeof(osd_req->r_oid)); | 1157 | strncpy(osd_req->r_oid, object_name, sizeof(osd_req->r_oid)); |
1166 | osd_req->r_oid_len = strlen(osd_req->r_oid); | 1158 | osd_req->r_oid_len = strlen(osd_req->r_oid); |
1167 | 1159 | ||
1168 | rbd_layout_init(&osd_req->r_file_layout, rbd_dev->spec->pool_id); | 1160 | osd_req->r_file_layout = rbd_dev->layout; /* struct */ |
1169 | 1161 | ||
1170 | if (op->op == CEPH_OSD_OP_READ || op->op == CEPH_OSD_OP_WRITE) { | 1162 | if (op->op == CEPH_OSD_OP_READ || op->op == CEPH_OSD_OP_WRITE) { |
1171 | op->extent.offset = ofs; | 1163 | op->extent.offset = ofs; |
@@ -2297,6 +2289,13 @@ struct rbd_device *rbd_dev_create(struct rbd_client *rbdc, | |||
2297 | rbd_dev->spec = spec; | 2289 | rbd_dev->spec = spec; |
2298 | rbd_dev->rbd_client = rbdc; | 2290 | rbd_dev->rbd_client = rbdc; |
2299 | 2291 | ||
2292 | /* Initialize the layout used for all rbd requests */ | ||
2293 | |||
2294 | rbd_dev->layout.fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); | ||
2295 | rbd_dev->layout.fl_stripe_count = cpu_to_le32(1); | ||
2296 | rbd_dev->layout.fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); | ||
2297 | rbd_dev->layout.fl_pg_pool = cpu_to_le32((u32) spec->pool_id); | ||
2298 | |||
2300 | return rbd_dev; | 2299 | return rbd_dev; |
2301 | } | 2300 | } |
2302 | 2301 | ||
@@ -2551,6 +2550,12 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev) | |||
2551 | if (parent_spec->pool_id == CEPH_NOPOOL) | 2550 | if (parent_spec->pool_id == CEPH_NOPOOL) |
2552 | goto out; /* No parent? No problem. */ | 2551 | goto out; /* No parent? No problem. */ |
2553 | 2552 | ||
2553 | /* The ceph file layout needs to fit pool id in 32 bits */ | ||
2554 | |||
2555 | ret = -EIO; | ||
2556 | if (WARN_ON(parent_spec->pool_id > (u64) U32_MAX)) | ||
2557 | goto out; | ||
2558 | |||
2554 | image_id = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL); | 2559 | image_id = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL); |
2555 | if (IS_ERR(image_id)) { | 2560 | if (IS_ERR(image_id)) { |
2556 | ret = PTR_ERR(image_id); | 2561 | ret = PTR_ERR(image_id); |
@@ -3680,6 +3685,13 @@ static ssize_t rbd_add(struct bus_type *bus, | |||
3680 | goto err_out_client; | 3685 | goto err_out_client; |
3681 | spec->pool_id = (u64) rc; | 3686 | spec->pool_id = (u64) rc; |
3682 | 3687 | ||
3688 | /* The ceph file layout needs to fit pool id in 32 bits */ | ||
3689 | |||
3690 | if (WARN_ON(spec->pool_id > (u64) U32_MAX)) { | ||
3691 | rc = -EIO; | ||
3692 | goto err_out_client; | ||
3693 | } | ||
3694 | |||
3683 | rbd_dev = rbd_dev_create(rbdc, spec); | 3695 | rbd_dev = rbd_dev_create(rbdc, spec); |
3684 | if (!rbd_dev) | 3696 | if (!rbd_dev) |
3685 | goto err_out_client; | 3697 | goto err_out_client; |