Skip to content

Commit a4ce40a

Browse files
Alex ElderSage Weil
authored andcommitted
libceph: combine initializing and setting osd data
This ends up being a rather large patch but what it's doing is somewhat straightforward. Basically, this is replacing two calls with one. The first of the two calls is initializing a struct ceph_osd_data with data (either a page array, a page list, or a bio list); the second is setting an osd request op so it associates that data with one of the op's parameters. In place of those two will be a single function that initializes the op directly. That means we sort of fan out a set of the needed functions: - extent ops with pages data - extent ops with pagelist data - extent ops with bio list data and - class ops with page data for receiving a response We also have define another one, but it's only used internally: - class ops with pagelist data for request parameters Note that we *still* haven't gotten rid of the osd request's r_data_in and r_data_out fields. All the osd ops refer to them for their data. For now, these data fields are pointers assigned to the appropriate r_data_* field when these new functions are called. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
1 parent 39b44cb commit a4ce40a

5 files changed

Lines changed: 161 additions & 72 deletions

File tree

‎drivers/block/rbd.c‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,6 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request,
15921592
rbd_assert(resid > 0);
15931593
while (resid) {
15941594
struct ceph_osd_request *osd_req;
1595-
struct ceph_osd_data *osd_data;
15961595
const char *object_name;
15971596
unsigned int clone_size;
15981597
u64 offset;
@@ -1625,13 +1624,10 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request,
16251624
obj_request->osd_req = osd_req;
16261625
obj_request->callback = rbd_img_obj_callback;
16271626

1628-
osd_data = write_request ? &osd_req->r_data_out
1629-
: &osd_req->r_data_in;
16301627
osd_req_op_extent_init(osd_req, 0, opcode, offset, length,
16311628
0, 0);
1632-
ceph_osd_data_bio_init(osd_data, obj_request->bio_list,
1633-
obj_request->length);
1634-
osd_req_op_extent_osd_data(osd_req, 0, osd_data);
1629+
osd_req_op_extent_osd_data_bio(osd_req, 0, write_request,
1630+
obj_request->bio_list, obj_request->length);
16351631
rbd_osd_req_format(obj_request, write_request);
16361632

16371633
rbd_img_obj_request_add(img_request, obj_request);
@@ -1821,7 +1817,6 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev,
18211817
{
18221818
struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
18231819
struct rbd_obj_request *obj_request;
1824-
struct ceph_osd_data *osd_data;
18251820
struct page **pages;
18261821
u32 page_count;
18271822
int ret;
@@ -1851,13 +1846,12 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev,
18511846
if (!obj_request->osd_req)
18521847
goto out;
18531848

1854-
osd_data = &obj_request->osd_req->r_data_in;
18551849
osd_req_op_cls_init(obj_request->osd_req, 0, CEPH_OSD_OP_CALL,
18561850
class_name, method_name,
18571851
outbound, outbound_size);
1858-
ceph_osd_data_pages_init(osd_data, obj_request->pages, inbound_size,
1852+
osd_req_op_cls_response_data_pages(obj_request->osd_req, 0,
1853+
obj_request->pages, inbound_size,
18591854
0, false, false);
1860-
osd_req_op_cls_response_data(obj_request->osd_req, 0, osd_data);
18611855
rbd_osd_req_format(obj_request, false);
18621856

18631857
ret = rbd_obj_request_submit(osdc, obj_request);
@@ -2037,7 +2031,6 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
20372031
{
20382032
struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
20392033
struct rbd_obj_request *obj_request;
2040-
struct ceph_osd_data *osd_data;
20412034
struct page **pages = NULL;
20422035
u32 page_count;
20432036
size_t size;
@@ -2061,14 +2054,13 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
20612054
if (!obj_request->osd_req)
20622055
goto out;
20632056

2064-
osd_data = &obj_request->osd_req->r_data_in;
20652057
osd_req_op_extent_init(obj_request->osd_req, 0, CEPH_OSD_OP_READ,
20662058
offset, length, 0, 0);
2067-
ceph_osd_data_pages_init(osd_data, obj_request->pages,
2059+
osd_req_op_extent_osd_data_pages(obj_request->osd_req, 0, false,
2060+
obj_request->pages,
20682061
obj_request->length,
20692062
obj_request->offset & ~PAGE_MASK,
20702063
false, false);
2071-
osd_req_op_extent_osd_data(obj_request->osd_req, 0, osd_data);
20722064
rbd_osd_req_format(obj_request, false);
20732065

20742066
ret = rbd_obj_request_submit(osdc, obj_request);

‎fs/ceph/addr.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
245245
dout("finish_read %p req %p rc %d bytes %d\n", inode, req, rc, bytes);
246246

247247
/* unlock all pages, zeroing any data we didn't read */
248-
osd_data = &req->r_data_in;
248+
osd_data = osd_req_op_extent_osd_data(req, 0, false);
249249
BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_PAGES);
250250
num_pages = calc_pages_for((u64)osd_data->alignment,
251251
(u64)osd_data->length);
@@ -343,8 +343,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
343343
}
344344
pages[i] = page;
345345
}
346-
BUG_ON(req->r_ops[0].extent.osd_data != &req->r_data_in);
347-
ceph_osd_data_pages_init(req->r_ops[0].extent.osd_data, pages, len, 0,
346+
osd_req_op_extent_osd_data_pages(req, 0, false, pages, len, 0,
348347
false, false);
349348
req->r_callback = finish_read;
350349
req->r_inode = inode;
@@ -572,7 +571,7 @@ static void writepages_finish(struct ceph_osd_request *req,
572571
long writeback_stat;
573572
unsigned issued = ceph_caps_issued(ci);
574573

575-
osd_data = &req->r_data_out;
574+
osd_data = osd_req_op_extent_osd_data(req, 0, true);
576575
BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_PAGES);
577576
num_pages = calc_pages_for((u64)osd_data->alignment,
578577
(u64)osd_data->length);
@@ -917,9 +916,8 @@ static int ceph_writepages_start(struct address_space *mapping,
917916
dout("writepages got %d pages at %llu~%llu\n",
918917
locked_pages, offset, len);
919918

920-
BUG_ON(req->r_ops[0].extent.osd_data != &req->r_data_out);
921-
ceph_osd_data_pages_init(req->r_ops[0].extent.osd_data, pages,
922-
len, 0, !!pool, false);
919+
osd_req_op_extent_osd_data_pages(req, 0, true, pages, len, 0,
920+
!!pool, false);
923921

924922
pages = NULL; /* request message now owns the pages array */
925923
pool = NULL;

‎fs/ceph/file.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,7 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
574574
own_pages = true;
575575
}
576576
}
577-
BUG_ON(req->r_ops[0].extent.osd_data != &req->r_data_out);
578-
ceph_osd_data_pages_init(req->r_ops[0].extent.osd_data, pages, len,
577+
osd_req_op_extent_osd_data_pages(req, 0, true, pages, len,
579578
page_align, false, own_pages);
580579

581580
/* BUG_ON(vino.snap != CEPH_NOSNAP); */

‎include/linux/ceph/osd_client.h‎

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,39 @@ extern void osd_req_op_extent_init(struct ceph_osd_request *osd_req,
240240
u64 truncate_size, u32 truncate_seq);
241241
extern void osd_req_op_extent_update(struct ceph_osd_request *osd_req,
242242
unsigned int which, u64 length);
243-
extern void osd_req_op_extent_osd_data(struct ceph_osd_request *osd_req,
243+
244+
extern struct ceph_osd_data *osd_req_op_extent_osd_data(
245+
struct ceph_osd_request *osd_req,
246+
unsigned int which, bool write_request);
247+
extern struct ceph_osd_data *osd_req_op_cls_response_data(
248+
struct ceph_osd_request *osd_req,
249+
unsigned int which);
250+
251+
extern void osd_req_op_extent_osd_data_pages(struct ceph_osd_request *,
252+
unsigned int which, bool write_request,
253+
struct page **pages, u64 length,
254+
u32 alignment, bool pages_from_pool,
255+
bool own_pages);
256+
extern void osd_req_op_extent_osd_data_pagelist(struct ceph_osd_request *,
257+
unsigned int which, bool write_request,
258+
struct ceph_pagelist *pagelist);
259+
#ifdef CONFIG_BLOCK
260+
extern void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *,
261+
unsigned int which, bool write_request,
262+
struct bio *bio, size_t bio_length);
263+
#endif /* CONFIG_BLOCK */
264+
265+
extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,
244266
unsigned int which,
245-
struct ceph_osd_data *osd_data);
267+
struct page **pages, u64 length,
268+
u32 alignment, bool pages_from_pool,
269+
bool own_pages);
270+
246271
extern void osd_req_op_cls_init(struct ceph_osd_request *osd_req,
247272
unsigned int which, u16 opcode,
248273
const char *class, const char *method,
249274
const void *request_data,
250275
size_t request_data_size);
251-
extern void osd_req_op_cls_response_data(struct ceph_osd_request *osd_req,
252-
unsigned int which,
253-
struct ceph_osd_data *response_data);
254276
extern void osd_req_op_watch_init(struct ceph_osd_request *osd_req,
255277
unsigned int which, u16 opcode,
256278
u64 cookie, u64 version, int flag);
@@ -290,17 +312,6 @@ static inline void ceph_osdc_put_request(struct ceph_osd_request *req)
290312
kref_put(&req->r_kref, ceph_osdc_release_request);
291313
}
292314

293-
extern void ceph_osd_data_pages_init(struct ceph_osd_data *osd_data,
294-
struct page **pages, u64 length,
295-
u32 alignment, bool pages_from_pool,
296-
bool own_pages);
297-
extern void ceph_osd_data_pagelist_init(struct ceph_osd_data *osd_data,
298-
struct ceph_pagelist *pagelist);
299-
#ifdef CONFIG_BLOCK
300-
extern void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data,
301-
struct bio *bio, size_t bio_length);
302-
#endif /* CONFIG_BLOCK */
303-
304315
extern int ceph_osdc_start_request(struct ceph_osd_client *osdc,
305316
struct ceph_osd_request *req,
306317
bool nofail);

0 commit comments

Comments
 (0)