]> Pileus Git - ~andy/linux/commitdiff
libceph: hold off building osd request
authorAlex Elder <elder@inktank.com>
Thu, 14 Mar 2013 19:09:06 +0000 (14:09 -0500)
committerSage Weil <sage@inktank.com>
Thu, 2 May 2013 04:18:01 +0000 (21:18 -0700)
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>
fs/ceph/addr.c
fs/ceph/file.c
net/ceph/osd_client.c

index 7b6d9b22e254bef160be8b289953d620526db9fb..0a3d2ce89660e30a31fd5f168ee48260b3920c48 100644 (file)
@@ -319,8 +319,6 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
        if (IS_ERR(req))
                return PTR_ERR(req);
 
-       ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL);
-
        /* build page vector */
        nr_pages = calc_pages_for(0, len);
        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)
        req->r_callback = finish_read;
        req->r_inode = inode;
 
+       ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL);
+
        dout("start_read %p starting %p %lld~%lld\n", inode, req, off, len);
        ret = ceph_osdc_start_request(osdc, req, false);
        if (ret < 0)
index 3d6dcf23b4adbdfac96a8f16599646cfe957384b..47826c2ef5111b990f690f4a0e4de6e29fce7370 100644 (file)
@@ -540,9 +540,6 @@ more:
        if (IS_ERR(req))
                return PTR_ERR(req);
 
-       ceph_osdc_build_request(req, pos, num_ops, ops,
-                               snapc, vino.snap, &mtime);
-
        /* write from beginning of first page, regardless of io alignment */
        page_align = file->f_flags & O_DIRECT ? buf_align : io_align;
        num_pages = calc_pages_for(page_align, len);
@@ -583,6 +580,10 @@ more:
        req->r_data_out.alignment = page_align;
        req->r_inode = inode;
 
+       /* BUG_ON(vino.snap != CEPH_NOSNAP); */
+       ceph_osdc_build_request(req, pos, num_ops, ops,
+                               snapc, vino.snap, &mtime);
+
        ret = ceph_osdc_start_request(&fsc->client->osdc, req, false);
        if (!ret) {
                if (req->r_safe_callback) {
index 115790aac30a3d4a48ddb0dbd8c82ae0e83eabee..9ca693d0df19ed47599830d40ba84c2269c9d3ba 100644 (file)
@@ -2056,8 +2056,6 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
        if (IS_ERR(req))
                return PTR_ERR(req);
 
-       ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL);
-
        /* it may be a short read due to an object boundary */
 
        osd_data = &req->r_data_in;
@@ -2069,6 +2067,8 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
        dout("readpages  final extent is %llu~%llu (%llu bytes align %d)\n",
             off, *plen, osd_data->length, page_align);
 
+       ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL);
+
        rc = ceph_osdc_start_request(osdc, req, false);
        if (!rc)
                rc = ceph_osdc_wait_request(osdc, req);
@@ -2105,8 +2105,6 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
        if (IS_ERR(req))
                return PTR_ERR(req);
 
-       ceph_osdc_build_request(req, off, 1, &op, snapc, CEPH_NOSNAP, mtime);
-
        /* it may be a short write due to an object boundary */
        osd_data = &req->r_data_out;
        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,
        osd_data->alignment = page_align;
        dout("writepages %llu~%llu (%llu bytes)\n", off, len, osd_data->length);
 
+       ceph_osdc_build_request(req, off, 1, &op, snapc, CEPH_NOSNAP, mtime);
+
        rc = ceph_osdc_start_request(osdc, req, true);
        if (!rc)
                rc = ceph_osdc_wait_request(osdc, req);