diff options
author | Alex Elder <elder@inktank.com> | 2013-03-14 15:09:05 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:17:58 -0400 |
commit | acead002b200569273bed331c93c4a91d25e10b8 (patch) | |
tree | 779bf689da149acf73bd75f51641f3700469f6b7 /net/ceph | |
parent | a19308048182d5f9e16b03b1d1c038d9346c7589 (diff) |
libceph: don't build request in ceph_osdc_new_request()
This patch moves the call to ceph_osdc_build_request() out of
ceph_osdc_new_request() and into its caller.
This is in order to defer formatting osd operation information into
the request message until just before request is started.
The only unusual (ab)user of ceph_osdc_build_request() is
ceph_writepages_start(), where the final length of write request may
change (downward) based on the current inode size or the oldest
snapshot context with dirty data for the inode.
The remaining callers don't change anything in the request after has
been built.
This means the ops array is now supplied by the caller. It also
means there is no need to pass the mtime to ceph_osdc_new_request()
(it gets provided to ceph_osdc_build_request()). And rather than
passing a do_sync flag, have the number of ops in the ops array
supplied imply adding a second STARTSYNC operation after the READ or
WRITE requested.
This and some of the patches that follow are related to having the
messenger (only) be responsible for filling the content of the
message header, as described here:
http://tracker.ceph.com/issues/4589
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/osd_client.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 0b4951e27532..115790aac30a 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -512,9 +512,7 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, | |||
512 | msg->front.iov_len = msg_size; | 512 | msg->front.iov_len = msg_size; |
513 | msg->hdr.front_len = cpu_to_le32(msg_size); | 513 | msg->hdr.front_len = cpu_to_le32(msg_size); |
514 | 514 | ||
515 | dout("build_request msg_size was %d num_ops %d\n", (int)msg_size, | 515 | dout("build_request msg_size was %d\n", (int)msg_size); |
516 | num_ops); | ||
517 | return; | ||
518 | } | 516 | } |
519 | EXPORT_SYMBOL(ceph_osdc_build_request); | 517 | EXPORT_SYMBOL(ceph_osdc_build_request); |
520 | 518 | ||
@@ -532,18 +530,15 @@ EXPORT_SYMBOL(ceph_osdc_build_request); | |||
532 | struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | 530 | struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, |
533 | struct ceph_file_layout *layout, | 531 | struct ceph_file_layout *layout, |
534 | struct ceph_vino vino, | 532 | struct ceph_vino vino, |
535 | u64 off, u64 *plen, | 533 | u64 off, u64 *plen, int num_ops, |
534 | struct ceph_osd_req_op *ops, | ||
536 | int opcode, int flags, | 535 | int opcode, int flags, |
537 | struct ceph_snap_context *snapc, | 536 | struct ceph_snap_context *snapc, |
538 | int do_sync, | ||
539 | u32 truncate_seq, | 537 | u32 truncate_seq, |
540 | u64 truncate_size, | 538 | u64 truncate_size, |
541 | struct timespec *mtime, | ||
542 | bool use_mempool) | 539 | bool use_mempool) |
543 | { | 540 | { |
544 | struct ceph_osd_req_op ops[2]; | ||
545 | struct ceph_osd_request *req; | 541 | struct ceph_osd_request *req; |
546 | unsigned int num_op = do_sync ? 2 : 1; | ||
547 | u64 objnum = 0; | 542 | u64 objnum = 0; |
548 | u64 objoff = 0; | 543 | u64 objoff = 0; |
549 | u64 objlen = 0; | 544 | u64 objlen = 0; |
@@ -553,7 +548,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
553 | 548 | ||
554 | BUG_ON(opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE); | 549 | BUG_ON(opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE); |
555 | 550 | ||
556 | req = ceph_osdc_alloc_request(osdc, snapc, num_op, use_mempool, | 551 | req = ceph_osdc_alloc_request(osdc, snapc, num_ops, use_mempool, |
557 | GFP_NOFS); | 552 | GFP_NOFS); |
558 | if (!req) | 553 | if (!req) |
559 | return ERR_PTR(-ENOMEM); | 554 | return ERR_PTR(-ENOMEM); |
@@ -578,7 +573,12 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
578 | 573 | ||
579 | osd_req_op_extent_init(&ops[0], opcode, objoff, objlen, | 574 | osd_req_op_extent_init(&ops[0], opcode, objoff, objlen, |
580 | truncate_size, truncate_seq); | 575 | truncate_size, truncate_seq); |
581 | if (do_sync) | 576 | /* |
577 | * A second op in the ops array means the caller wants to | ||
578 | * also issue a include a 'startsync' command so that the | ||
579 | * osd will flush data quickly. | ||
580 | */ | ||
581 | if (num_ops > 1) | ||
582 | osd_req_op_init(&ops[1], CEPH_OSD_OP_STARTSYNC); | 582 | osd_req_op_init(&ops[1], CEPH_OSD_OP_STARTSYNC); |
583 | 583 | ||
584 | req->r_file_layout = *layout; /* keep a copy */ | 584 | req->r_file_layout = *layout; /* keep a copy */ |
@@ -587,9 +587,6 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
587 | vino.ino, objnum); | 587 | vino.ino, objnum); |
588 | req->r_oid_len = strlen(req->r_oid); | 588 | req->r_oid_len = strlen(req->r_oid); |
589 | 589 | ||
590 | ceph_osdc_build_request(req, off, num_op, ops, | ||
591 | snapc, vino.snap, mtime); | ||
592 | |||
593 | return req; | 590 | return req; |
594 | } | 591 | } |
595 | EXPORT_SYMBOL(ceph_osdc_new_request); | 592 | EXPORT_SYMBOL(ceph_osdc_new_request); |
@@ -2047,17 +2044,20 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, | |||
2047 | { | 2044 | { |
2048 | struct ceph_osd_request *req; | 2045 | struct ceph_osd_request *req; |
2049 | struct ceph_osd_data *osd_data; | 2046 | struct ceph_osd_data *osd_data; |
2047 | struct ceph_osd_req_op op; | ||
2050 | int rc = 0; | 2048 | int rc = 0; |
2051 | 2049 | ||
2052 | dout("readpages on ino %llx.%llx on %llu~%llu\n", vino.ino, | 2050 | dout("readpages on ino %llx.%llx on %llu~%llu\n", vino.ino, |
2053 | vino.snap, off, *plen); | 2051 | vino.snap, off, *plen); |
2054 | req = ceph_osdc_new_request(osdc, layout, vino, off, plen, | 2052 | req = ceph_osdc_new_request(osdc, layout, vino, off, plen, 1, &op, |
2055 | CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, | 2053 | CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, |
2056 | NULL, 0, truncate_seq, truncate_size, NULL, | 2054 | NULL, truncate_seq, truncate_size, |
2057 | false); | 2055 | false); |
2058 | if (IS_ERR(req)) | 2056 | if (IS_ERR(req)) |
2059 | return PTR_ERR(req); | 2057 | return PTR_ERR(req); |
2060 | 2058 | ||
2059 | ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL); | ||
2060 | |||
2061 | /* it may be a short read due to an object boundary */ | 2061 | /* it may be a short read due to an object boundary */ |
2062 | 2062 | ||
2063 | osd_data = &req->r_data_in; | 2063 | osd_data = &req->r_data_in; |
@@ -2092,19 +2092,21 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino, | |||
2092 | { | 2092 | { |
2093 | struct ceph_osd_request *req; | 2093 | struct ceph_osd_request *req; |
2094 | struct ceph_osd_data *osd_data; | 2094 | struct ceph_osd_data *osd_data; |
2095 | struct ceph_osd_req_op op; | ||
2095 | int rc = 0; | 2096 | int rc = 0; |
2096 | int page_align = off & ~PAGE_MASK; | 2097 | int page_align = off & ~PAGE_MASK; |
2097 | 2098 | ||
2098 | BUG_ON(vino.snap != CEPH_NOSNAP); | 2099 | BUG_ON(vino.snap != CEPH_NOSNAP); /* snapshots aren't writeable */ |
2099 | req = ceph_osdc_new_request(osdc, layout, vino, off, &len, | 2100 | req = ceph_osdc_new_request(osdc, layout, vino, off, &len, 1, &op, |
2100 | CEPH_OSD_OP_WRITE, | 2101 | CEPH_OSD_OP_WRITE, |
2101 | CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE, | 2102 | CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE, |
2102 | snapc, 0, | 2103 | snapc, truncate_seq, truncate_size, |
2103 | truncate_seq, truncate_size, mtime, | ||
2104 | true); | 2104 | true); |
2105 | if (IS_ERR(req)) | 2105 | if (IS_ERR(req)) |
2106 | return PTR_ERR(req); | 2106 | return PTR_ERR(req); |
2107 | 2107 | ||
2108 | ceph_osdc_build_request(req, off, 1, &op, snapc, CEPH_NOSNAP, mtime); | ||
2109 | |||
2108 | /* it may be a short write due to an object boundary */ | 2110 | /* it may be a short write due to an object boundary */ |
2109 | osd_data = &req->r_data_out; | 2111 | osd_data = &req->r_data_out; |
2110 | osd_data->type = CEPH_OSD_DATA_TYPE_PAGES; | 2112 | osd_data->type = CEPH_OSD_DATA_TYPE_PAGES; |