aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-14 15:09:06 -0400
committerSage Weil <sage@inktank.com>2013-05-02 00:18:01 -0400
commit02ee07d3002e6c0b0c4ea1982cd7e6aeca203ed6 (patch)
tree1e06ce866c06a3fd03d4b6d9547c5bd376c8758f
parent88486957f9fbf52ff4313ff52d583110a6503c28 (diff)
libceph: hold off building osd request
Defer building the osd request until just before submitting it in all callers except ceph_writepages_start(). (That caller will be handed in the next patch.) Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r--fs/ceph/addr.c4
-rw-r--r--fs/ceph/file.c7
-rw-r--r--net/ceph/osd_client.c8
3 files changed, 10 insertions, 9 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 7b6d9b22e254..0a3d2ce89660 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -319,8 +319,6 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
319 if (IS_ERR(req)) 319 if (IS_ERR(req))
320 return PTR_ERR(req); 320 return PTR_ERR(req);
321 321
322 ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL);
323
324 /* build page vector */ 322 /* build page vector */
325 nr_pages = calc_pages_for(0, len); 323 nr_pages = calc_pages_for(0, len);
326 pages = kmalloc(sizeof(*pages) * nr_pages, GFP_NOFS); 324 pages = kmalloc(sizeof(*pages) * nr_pages, GFP_NOFS);
@@ -351,6 +349,8 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
351 req->r_callback = finish_read; 349 req->r_callback = finish_read;
352 req->r_inode = inode; 350 req->r_inode = inode;
353 351
352 ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL);
353
354 dout("start_read %p starting %p %lld~%lld\n", inode, req, off, len); 354 dout("start_read %p starting %p %lld~%lld\n", inode, req, off, len);
355 ret = ceph_osdc_start_request(osdc, req, false); 355 ret = ceph_osdc_start_request(osdc, req, false);
356 if (ret < 0) 356 if (ret < 0)
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 3d6dcf23b4ad..47826c2ef511 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -540,9 +540,6 @@ more:
540 if (IS_ERR(req)) 540 if (IS_ERR(req))
541 return PTR_ERR(req); 541 return PTR_ERR(req);
542 542
543 ceph_osdc_build_request(req, pos, num_ops, ops,
544 snapc, vino.snap, &mtime);
545
546 /* write from beginning of first page, regardless of io alignment */ 543 /* write from beginning of first page, regardless of io alignment */
547 page_align = file->f_flags & O_DIRECT ? buf_align : io_align; 544 page_align = file->f_flags & O_DIRECT ? buf_align : io_align;
548 num_pages = calc_pages_for(page_align, len); 545 num_pages = calc_pages_for(page_align, len);
@@ -583,6 +580,10 @@ more:
583 req->r_data_out.alignment = page_align; 580 req->r_data_out.alignment = page_align;
584 req->r_inode = inode; 581 req->r_inode = inode;
585 582
583 /* BUG_ON(vino.snap != CEPH_NOSNAP); */
584 ceph_osdc_build_request(req, pos, num_ops, ops,
585 snapc, vino.snap, &mtime);
586
586 ret = ceph_osdc_start_request(&fsc->client->osdc, req, false); 587 ret = ceph_osdc_start_request(&fsc->client->osdc, req, false);
587 if (!ret) { 588 if (!ret) {
588 if (req->r_safe_callback) { 589 if (req->r_safe_callback) {
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 115790aac30a..9ca693d0df19 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -2056,8 +2056,6 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
2056 if (IS_ERR(req)) 2056 if (IS_ERR(req))
2057 return PTR_ERR(req); 2057 return PTR_ERR(req);
2058 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 */ 2059 /* it may be a short read due to an object boundary */
2062 2060
2063 osd_data = &req->r_data_in; 2061 osd_data = &req->r_data_in;
@@ -2069,6 +2067,8 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
2069 dout("readpages final extent is %llu~%llu (%llu bytes align %d)\n", 2067 dout("readpages final extent is %llu~%llu (%llu bytes align %d)\n",
2070 off, *plen, osd_data->length, page_align); 2068 off, *plen, osd_data->length, page_align);
2071 2069
2070 ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL);
2071
2072 rc = ceph_osdc_start_request(osdc, req, false); 2072 rc = ceph_osdc_start_request(osdc, req, false);
2073 if (!rc) 2073 if (!rc)
2074 rc = ceph_osdc_wait_request(osdc, req); 2074 rc = ceph_osdc_wait_request(osdc, req);
@@ -2105,8 +2105,6 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
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
2110 /* it may be a short write due to an object boundary */ 2108 /* it may be a short write due to an object boundary */
2111 osd_data = &req->r_data_out; 2109 osd_data = &req->r_data_out;
2112 osd_data->type = CEPH_OSD_DATA_TYPE_PAGES; 2110 osd_data->type = CEPH_OSD_DATA_TYPE_PAGES;
@@ -2115,6 +2113,8 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
2115 osd_data->alignment = page_align; 2113 osd_data->alignment = page_align;
2116 dout("writepages %llu~%llu (%llu bytes)\n", off, len, osd_data->length); 2114 dout("writepages %llu~%llu (%llu bytes)\n", off, len, osd_data->length);
2117 2115
2116 ceph_osdc_build_request(req, off, 1, &op, snapc, CEPH_NOSNAP, mtime);
2117
2118 rc = ceph_osdc_start_request(osdc, req, true); 2118 rc = ceph_osdc_start_request(osdc, req, true);
2119 if (!rc) 2119 if (!rc)
2120 rc = ceph_osdc_wait_request(osdc, req); 2120 rc = ceph_osdc_wait_request(osdc, req);