diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2017-01-25 12:16:22 -0500 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2017-02-20 06:16:14 -0500 |
commit | 67e2b65274e3c5fc9100544c1f90adcc85dbe597 (patch) | |
tree | 97d2c9c3b9e05f6eef721da9ff8ac43fa719ee62 | |
parent | 7e97332ea9caad3b7c6d86bc3b982e17eda2f736 (diff) |
rbd: set offset and length outside of rbd_obj_request_create()
The allocation doesn't depend on offset and length. Both offset and
length can be changed after obj_request is allocated, too.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Jason Dillaman <dillaman@redhat.com>
-rw-r--r-- | drivers/block/rbd.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index ceac7877b5f4..c975d49e612c 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -1631,7 +1631,9 @@ static void rbd_obj_request_submit(struct rbd_obj_request *obj_request) | |||
1631 | { | 1631 | { |
1632 | struct ceph_osd_request *osd_req = obj_request->osd_req; | 1632 | struct ceph_osd_request *osd_req = obj_request->osd_req; |
1633 | 1633 | ||
1634 | dout("%s %p osd_req %p\n", __func__, obj_request, osd_req); | 1634 | dout("%s %p \"%s\" %llu~%llu osd_req %p\n", __func__, |
1635 | obj_request, obj_request->object_name, obj_request->offset, | ||
1636 | obj_request->length, osd_req); | ||
1635 | if (obj_request_img_data_test(obj_request)) { | 1637 | if (obj_request_img_data_test(obj_request)) { |
1636 | WARN_ON(obj_request->callback != rbd_img_obj_callback); | 1638 | WARN_ON(obj_request->callback != rbd_img_obj_callback); |
1637 | rbd_img_request_get(obj_request->img_request); | 1639 | rbd_img_request_get(obj_request->img_request); |
@@ -2073,7 +2075,6 @@ static void rbd_osd_req_destroy(struct ceph_osd_request *osd_req) | |||
2073 | /* object_name is assumed to be a non-null pointer and NUL-terminated */ | 2075 | /* object_name is assumed to be a non-null pointer and NUL-terminated */ |
2074 | 2076 | ||
2075 | static struct rbd_obj_request *rbd_obj_request_create(const char *object_name, | 2077 | static struct rbd_obj_request *rbd_obj_request_create(const char *object_name, |
2076 | u64 offset, u64 length, | ||
2077 | enum obj_request_type type) | 2078 | enum obj_request_type type) |
2078 | { | 2079 | { |
2079 | struct rbd_obj_request *obj_request; | 2080 | struct rbd_obj_request *obj_request; |
@@ -2094,18 +2095,13 @@ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name, | |||
2094 | } | 2095 | } |
2095 | 2096 | ||
2096 | obj_request->object_name = memcpy(name, object_name, size); | 2097 | obj_request->object_name = memcpy(name, object_name, size); |
2097 | obj_request->offset = offset; | ||
2098 | obj_request->length = length; | ||
2099 | obj_request->flags = 0; | ||
2100 | obj_request->which = BAD_WHICH; | 2098 | obj_request->which = BAD_WHICH; |
2101 | obj_request->type = type; | 2099 | obj_request->type = type; |
2102 | INIT_LIST_HEAD(&obj_request->links); | 2100 | INIT_LIST_HEAD(&obj_request->links); |
2103 | init_completion(&obj_request->completion); | 2101 | init_completion(&obj_request->completion); |
2104 | kref_init(&obj_request->kref); | 2102 | kref_init(&obj_request->kref); |
2105 | 2103 | ||
2106 | dout("%s: \"%s\" %llu/%llu %d -> obj %p\n", __func__, object_name, | 2104 | dout("%s %p\n", __func__, obj_request); |
2107 | offset, length, (int)type, obj_request); | ||
2108 | |||
2109 | return obj_request; | 2105 | return obj_request; |
2110 | } | 2106 | } |
2111 | 2107 | ||
@@ -2517,21 +2513,21 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, | |||
2517 | while (resid) { | 2513 | while (resid) { |
2518 | struct ceph_osd_request *osd_req; | 2514 | struct ceph_osd_request *osd_req; |
2519 | const char *object_name; | 2515 | const char *object_name; |
2520 | u64 offset; | 2516 | u64 offset = rbd_segment_offset(rbd_dev, img_offset); |
2521 | u64 length; | 2517 | u64 length = rbd_segment_length(rbd_dev, img_offset, resid); |
2522 | 2518 | ||
2523 | object_name = rbd_segment_name(rbd_dev, img_offset); | 2519 | object_name = rbd_segment_name(rbd_dev, img_offset); |
2524 | if (!object_name) | 2520 | if (!object_name) |
2525 | goto out_unwind; | 2521 | goto out_unwind; |
2526 | offset = rbd_segment_offset(rbd_dev, img_offset); | 2522 | obj_request = rbd_obj_request_create(object_name, type); |
2527 | length = rbd_segment_length(rbd_dev, img_offset, resid); | ||
2528 | obj_request = rbd_obj_request_create(object_name, | ||
2529 | offset, length, type); | ||
2530 | /* object request has its own copy of the object name */ | 2523 | /* object request has its own copy of the object name */ |
2531 | rbd_segment_name_free(object_name); | 2524 | rbd_segment_name_free(object_name); |
2532 | if (!obj_request) | 2525 | if (!obj_request) |
2533 | goto out_unwind; | 2526 | goto out_unwind; |
2534 | 2527 | ||
2528 | obj_request->offset = offset; | ||
2529 | obj_request->length = length; | ||
2530 | |||
2535 | /* | 2531 | /* |
2536 | * set obj_request->img_request before creating the | 2532 | * set obj_request->img_request before creating the |
2537 | * osd_request so that it gets the right snapc | 2533 | * osd_request so that it gets the right snapc |
@@ -2870,7 +2866,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request) | |||
2870 | size_t size; | 2866 | size_t size; |
2871 | int ret; | 2867 | int ret; |
2872 | 2868 | ||
2873 | stat_request = rbd_obj_request_create(obj_request->object_name, 0, 0, | 2869 | stat_request = rbd_obj_request_create(obj_request->object_name, |
2874 | OBJ_REQUEST_PAGES); | 2870 | OBJ_REQUEST_PAGES); |
2875 | if (!stat_request) | 2871 | if (!stat_request) |
2876 | return -ENOMEM; | 2872 | return -ENOMEM; |