Commit fe5478e0 authored by Ilya Dryomov's avatar Ilya Dryomov

rbd: do away with obj_request in rbd_obj_read_sync()

rbd_obj_request machinery is completely unnecessary here; all that's
being done is fetching a metadata object - no striping, cloning, etc.
More importantly, rbd_osd_req_create() grabs pool id from layout and
that is becoming a data pool id.

Kill offset argument - all metadata objects are small and read in full.
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Reviewed-by: default avatarJason Dillaman <dillaman@redhat.com>
parent 431a02cd
...@@ -4242,63 +4242,46 @@ static void rbd_free_disk(struct rbd_device *rbd_dev) ...@@ -4242,63 +4242,46 @@ static void rbd_free_disk(struct rbd_device *rbd_dev)
} }
static int rbd_obj_read_sync(struct rbd_device *rbd_dev, static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
const char *object_name, struct ceph_object_id *oid,
u64 offset, u64 length, void *buf) struct ceph_object_locator *oloc,
void *buf, int buf_len)
{ {
struct rbd_obj_request *obj_request; struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
struct page **pages = NULL; struct ceph_osd_request *req;
u32 page_count; struct page **pages;
size_t size; int num_pages = calc_pages_for(0, buf_len);
int ret; int ret;
page_count = (u32) calc_pages_for(offset, length); req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_KERNEL);
pages = ceph_alloc_page_vector(page_count, GFP_KERNEL); if (!req)
if (IS_ERR(pages)) return -ENOMEM;
return PTR_ERR(pages);
ret = -ENOMEM;
obj_request = rbd_obj_request_create(object_name, offset, length,
OBJ_REQUEST_PAGES);
if (!obj_request)
goto out;
obj_request->pages = pages;
obj_request->page_count = page_count;
obj_request->osd_req = rbd_osd_req_create(rbd_dev, OBJ_OP_READ, 1,
obj_request);
if (!obj_request->osd_req)
goto out;
osd_req_op_extent_init(obj_request->osd_req, 0, CEPH_OSD_OP_READ, ceph_oid_copy(&req->r_base_oid, oid);
offset, length, 0, 0); ceph_oloc_copy(&req->r_base_oloc, oloc);
osd_req_op_extent_osd_data_pages(obj_request->osd_req, 0, req->r_flags = CEPH_OSD_FLAG_READ;
obj_request->pages,
obj_request->length,
obj_request->offset & ~PAGE_MASK,
false, false);
rbd_obj_request_submit(obj_request); ret = ceph_osdc_alloc_messages(req, GFP_KERNEL);
ret = rbd_obj_request_wait(obj_request);
if (ret) if (ret)
goto out; goto out_req;
ret = obj_request->result; pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL);
if (ret < 0) if (IS_ERR(pages)) {
goto out; ret = PTR_ERR(pages);
goto out_req;
}
rbd_assert(obj_request->xferred <= (u64) SIZE_MAX); osd_req_op_extent_init(req, 0, CEPH_OSD_OP_READ, 0, buf_len, 0, 0);
size = (size_t) obj_request->xferred; osd_req_op_extent_osd_data_pages(req, 0, pages, buf_len, 0, false,
ceph_copy_from_page_vector(pages, buf, 0, size); true);
rbd_assert(size <= (size_t)INT_MAX);
ret = (int)size; ceph_osdc_start_request(osdc, req, false);
out: ret = ceph_osdc_wait_request(osdc, req);
if (obj_request) if (ret >= 0)
rbd_obj_request_put(obj_request); ceph_copy_from_page_vector(pages, buf, 0, ret);
else
ceph_release_page_vector(pages, page_count);
out_req:
ceph_osdc_put_request(req);
return ret; return ret;
} }
...@@ -4334,8 +4317,8 @@ static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev) ...@@ -4334,8 +4317,8 @@ static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev)
if (!ondisk) if (!ondisk)
return -ENOMEM; return -ENOMEM;
ret = rbd_obj_read_sync(rbd_dev, rbd_dev->header_oid.name, ret = rbd_obj_read_sync(rbd_dev, &rbd_dev->header_oid,
0, size, ondisk); &rbd_dev->header_oloc, ondisk, size);
if (ret < 0) if (ret < 0)
goto out; goto out;
if ((size_t)ret < size) { if ((size_t)ret < size) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment