diff options
author | Alex Elder <elder@inktank.com> | 2013-04-03 02:28:57 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:18:06 -0400 |
commit | 43bfe5de9fa78e07248b70992ce50321efec622c (patch) | |
tree | 8aa7ce9ad14551bdfcb1bf166a90b65a3dab7c02 /net/ceph/osd_client.c | |
parent | 9fc6e0647180f72392f03a29863b6602e22aa024 (diff) |
libceph: define osd data initialization helpers
Define and use functions that encapsulate the initializion of a
ceph_osd_data structure.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph/osd_client.c')
-rw-r--r-- | net/ceph/osd_client.c | 55 |
1 files changed, 39 insertions, 16 deletions
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 | ||
82 | void 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 | } | ||
93 | EXPORT_SYMBOL(ceph_osd_data_pages_init); | ||
94 | |||
95 | void 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 | } | ||
101 | EXPORT_SYMBOL(ceph_osd_data_pagelist_init); | ||
102 | |||
103 | #ifdef CONFIG_BLOCK | ||
104 | void 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 | } | ||
111 | EXPORT_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 | ||