aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/rbd.c14
-rw-r--r--fs/ceph/addr.c13
-rw-r--r--fs/ceph/file.c10
-rw-r--r--include/linux/ceph/osd_client.h11
-rw-r--r--net/ceph/osd_client.c55
5 files changed, 63 insertions, 40 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index afbc9f6f8ff1..ab21b5218ae3 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1350,17 +1350,13 @@ static struct ceph_osd_request *rbd_osd_req_create(
1350 break; /* Nothing to do */ 1350 break; /* Nothing to do */
1351 case OBJ_REQUEST_BIO: 1351 case OBJ_REQUEST_BIO:
1352 rbd_assert(obj_request->bio_list != NULL); 1352 rbd_assert(obj_request->bio_list != NULL);
1353 osd_data->type = CEPH_OSD_DATA_TYPE_BIO; 1353 ceph_osd_data_bio_init(osd_data, obj_request->bio_list,
1354 osd_data->bio = obj_request->bio_list; 1354 obj_request->length);
1355 osd_data->bio_length = obj_request->length;
1356 break; 1355 break;
1357 case OBJ_REQUEST_PAGES: 1356 case OBJ_REQUEST_PAGES:
1358 osd_data->type = CEPH_OSD_DATA_TYPE_PAGES; 1357 ceph_osd_data_pages_init(osd_data, obj_request->pages,
1359 osd_data->pages = obj_request->pages; 1358 obj_request->length, offset & ~PAGE_MASK,
1360 osd_data->length = obj_request->length; 1359 false, false);
1361 osd_data->alignment = offset & ~PAGE_MASK;
1362 osd_data->pages_from_pool = false;
1363 osd_data->own_pages = false;
1364 break; 1360 break;
1365 } 1361 }
1366 1362
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 5d8ce79385ed..cf9032abc8f5 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -342,10 +342,8 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
342 } 342 }
343 pages[i] = page; 343 pages[i] = page;
344 } 344 }
345 req->r_data_in.type = CEPH_OSD_DATA_TYPE_PAGES; 345 ceph_osd_data_pages_init(&req->r_data_in, pages, len, 0,
346 req->r_data_in.pages = pages; 346 false, false);
347 req->r_data_in.length = len;
348 req->r_data_in.alignment = 0;
349 req->r_callback = finish_read; 347 req->r_callback = finish_read;
350 req->r_inode = inode; 348 req->r_inode = inode;
351 349
@@ -917,11 +915,8 @@ get_more_pages:
917 dout("writepages got %d pages at %llu~%llu\n", 915 dout("writepages got %d pages at %llu~%llu\n",
918 locked_pages, offset, len); 916 locked_pages, offset, len);
919 917
920 req->r_data_out.type = CEPH_OSD_DATA_TYPE_PAGES; 918 ceph_osd_data_pages_init(&req->r_data_out, pages, len, 0,
921 req->r_data_out.pages = pages; 919 !!pool, false);
922 req->r_data_out.length = len;
923 req->r_data_out.alignment = 0;
924 req->r_data_out.pages_from_pool = !!pool;
925 920
926 pages = NULL; /* request message now owns the pages array */ 921 pages = NULL; /* request message now owns the pages array */
927 pool = NULL; 922 pool = NULL;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 47826c2ef511..da642af14a28 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -491,6 +491,7 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
491 unsigned long buf_align; 491 unsigned long buf_align;
492 int ret; 492 int ret;
493 struct timespec mtime = CURRENT_TIME; 493 struct timespec mtime = CURRENT_TIME;
494 bool own_pages = false;
494 495
495 if (ceph_snap(file_inode(file)) != CEPH_NOSNAP) 496 if (ceph_snap(file_inode(file)) != CEPH_NOSNAP)
496 return -EROFS; 497 return -EROFS;
@@ -571,14 +572,11 @@ more:
571 if ((file->f_flags & O_SYNC) == 0) { 572 if ((file->f_flags & O_SYNC) == 0) {
572 /* get a second commit callback */ 573 /* get a second commit callback */
573 req->r_safe_callback = sync_write_commit; 574 req->r_safe_callback = sync_write_commit;
574 req->r_data_out.own_pages = 1; 575 own_pages = true;
575 } 576 }
576 } 577 }
577 req->r_data_out.type = CEPH_OSD_DATA_TYPE_PAGES; 578 ceph_osd_data_pages_init(&req->r_data_out, pages, len, page_align,
578 req->r_data_out.pages = pages; 579 false, own_pages);
579 req->r_data_out.length = len;
580 req->r_data_out.alignment = page_align;
581 req->r_inode = inode;
582 580
583 /* BUG_ON(vino.snap != CEPH_NOSNAP); */ 581 /* BUG_ON(vino.snap != CEPH_NOSNAP); */
584 ceph_osdc_build_request(req, pos, num_ops, ops, 582 ceph_osdc_build_request(req, pos, num_ops, ops,
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 5ee1a3776b4b..af60dac1f9c0 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -280,6 +280,17 @@ static inline void ceph_osdc_put_request(struct ceph_osd_request *req)
280 kref_put(&req->r_kref, ceph_osdc_release_request); 280 kref_put(&req->r_kref, ceph_osdc_release_request);
281} 281}
282 282
283extern void ceph_osd_data_pages_init(struct ceph_osd_data *osd_data,
284 struct page **pages, u64 length,
285 u32 alignment, bool pages_from_pool,
286 bool own_pages);
287extern void ceph_osd_data_pagelist_init(struct ceph_osd_data *osd_data,
288 struct ceph_pagelist *pagelist);
289#ifdef CONFIG_BLOCK
290extern void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data,
291 struct bio *bio, size_t bio_length);
292#endif /* CONFIG_BLOCK */
293
283extern int ceph_osdc_start_request(struct ceph_osd_client *osdc, 294extern int ceph_osdc_start_request(struct ceph_osd_client *osdc,
284 struct ceph_osd_request *req, 295 struct ceph_osd_request *req,
285 bool nofail); 296 bool nofail);
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 1379b3313348..f8f8561b602e 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -79,6 +79,38 @@ static int calc_layout(struct ceph_file_layout *layout, u64 off, u64 *plen,
79 return 0; 79 return 0;
80} 80}
81 81
82void ceph_osd_data_pages_init(struct ceph_osd_data *osd_data,
83 struct page **pages, u64 length, u32 alignment,
84 bool pages_from_pool, bool own_pages)
85{
86 osd_data->type = CEPH_OSD_DATA_TYPE_PAGES;
87 osd_data->pages = pages;
88 osd_data->length = length;
89 osd_data->alignment = alignment;
90 osd_data->pages_from_pool = pages_from_pool;
91 osd_data->own_pages = own_pages;
92}
93EXPORT_SYMBOL(ceph_osd_data_pages_init);
94
95void ceph_osd_data_pagelist_init(struct ceph_osd_data *osd_data,
96 struct ceph_pagelist *pagelist)
97{
98 osd_data->type = CEPH_OSD_DATA_TYPE_PAGELIST;
99 osd_data->pagelist = pagelist;
100}
101EXPORT_SYMBOL(ceph_osd_data_pagelist_init);
102
103#ifdef CONFIG_BLOCK
104void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data,
105 struct bio *bio, size_t bio_length)
106{
107 osd_data->type = CEPH_OSD_DATA_TYPE_BIO;
108 osd_data->bio = bio;
109 osd_data->bio_length = bio_length;
110}
111EXPORT_SYMBOL(ceph_osd_data_bio_init);
112#endif /* CONFIG_BLOCK */
113
82/* 114/*
83 * requests 115 * requests
84 */ 116 */
@@ -400,8 +432,7 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req,
400 ceph_pagelist_append(pagelist, src->cls.indata, 432 ceph_pagelist_append(pagelist, src->cls.indata,
401 src->cls.indata_len); 433 src->cls.indata_len);
402 434
403 req->r_data_out.type = CEPH_OSD_DATA_TYPE_PAGELIST; 435 ceph_osd_data_pagelist_init(&req->r_data_out, pagelist);
404 req->r_data_out.pagelist = pagelist;
405 out_data_len = pagelist->length; 436 out_data_len = pagelist->length;
406 break; 437 break;
407 case CEPH_OSD_OP_STARTSYNC: 438 case CEPH_OSD_OP_STARTSYNC:
@@ -2056,7 +2087,6 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
2056 struct page **pages, int num_pages, int page_align) 2087 struct page **pages, int num_pages, int page_align)
2057{ 2088{
2058 struct ceph_osd_request *req; 2089 struct ceph_osd_request *req;
2059 struct ceph_osd_data *osd_data;
2060 struct ceph_osd_req_op op; 2090 struct ceph_osd_req_op op;
2061 int rc = 0; 2091 int rc = 0;
2062 2092
@@ -2071,14 +2101,11 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
2071 2101
2072 /* it may be a short read due to an object boundary */ 2102 /* it may be a short read due to an object boundary */
2073 2103
2074 osd_data = &req->r_data_in; 2104 ceph_osd_data_pages_init(&req->r_data_in, pages, *plen, page_align,
2075 osd_data->type = CEPH_OSD_DATA_TYPE_PAGES; 2105 false, false);
2076 osd_data->pages = pages;
2077 osd_data->length = *plen;
2078 osd_data->alignment = page_align;
2079 2106
2080 dout("readpages final extent is %llu~%llu (%llu bytes align %d)\n", 2107 dout("readpages final extent is %llu~%llu (%llu bytes align %d)\n",
2081 off, *plen, osd_data->length, page_align); 2108 off, *plen, *plen, page_align);
2082 2109
2083 ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL); 2110 ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL);
2084 2111
@@ -2104,7 +2131,6 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
2104 struct page **pages, int num_pages) 2131 struct page **pages, int num_pages)
2105{ 2132{
2106 struct ceph_osd_request *req; 2133 struct ceph_osd_request *req;
2107 struct ceph_osd_data *osd_data;
2108 struct ceph_osd_req_op op; 2134 struct ceph_osd_req_op op;
2109 int rc = 0; 2135 int rc = 0;
2110 int page_align = off & ~PAGE_MASK; 2136 int page_align = off & ~PAGE_MASK;
@@ -2119,12 +2145,9 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
2119 return PTR_ERR(req); 2145 return PTR_ERR(req);
2120 2146
2121 /* it may be a short write due to an object boundary */ 2147 /* it may be a short write due to an object boundary */
2122 osd_data = &req->r_data_out; 2148 ceph_osd_data_pages_init(&req->r_data_out, pages, len, page_align,
2123 osd_data->type = CEPH_OSD_DATA_TYPE_PAGES; 2149 false, false);
2124 osd_data->pages = pages; 2150 dout("writepages %llu~%llu (%llu bytes)\n", off, len, len);
2125 osd_data->length = len;
2126 osd_data->alignment = page_align;
2127 dout("writepages %llu~%llu (%llu bytes)\n", off, len, osd_data->length);
2128 2151
2129 ceph_osdc_build_request(req, off, 1, &op, snapc, CEPH_NOSNAP, mtime); 2152 ceph_osdc_build_request(req, off, 1, &op, snapc, CEPH_NOSNAP, mtime);
2130 2153