summaryrefslogtreecommitdiffstats
path: root/include/linux/ceph
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2018-01-20 04:30:11 -0500
committerIlya Dryomov <idryomov@gmail.com>2018-04-02 04:12:39 -0400
commitb9e281c2b38804984d619e1d9efc4b9020bcb291 (patch)
treef60492d187e96375c3212679d4ca4a9ad3bcf146 /include/linux/ceph
parentf9dcbc44cd317ee3c5e443db7f9a62f52689f08e (diff)
libceph: introduce BVECS data type
In preparation for rbd "fancy" striping, introduce ceph_bvec_iter for working with bio_vec array data buffers. The wrappers are trivial, but make it look similar to ceph_bio_iter. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'include/linux/ceph')
-rw-r--r--include/linux/ceph/messenger.h42
-rw-r--r--include/linux/ceph/osd_client.h8
2 files changed, 50 insertions, 0 deletions
diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
index d7b9605fd51d..c7dfcb8a1fb2 100644
--- a/include/linux/ceph/messenger.h
+++ b/include/linux/ceph/messenger.h
@@ -76,6 +76,7 @@ enum ceph_msg_data_type {
76#ifdef CONFIG_BLOCK 76#ifdef CONFIG_BLOCK
77 CEPH_MSG_DATA_BIO, /* data source/destination is a bio list */ 77 CEPH_MSG_DATA_BIO, /* data source/destination is a bio list */
78#endif /* CONFIG_BLOCK */ 78#endif /* CONFIG_BLOCK */
79 CEPH_MSG_DATA_BVECS, /* data source/destination is a bio_vec array */
79}; 80};
80 81
81static __inline__ bool ceph_msg_data_type_valid(enum ceph_msg_data_type type) 82static __inline__ bool ceph_msg_data_type_valid(enum ceph_msg_data_type type)
@@ -87,6 +88,7 @@ static __inline__ bool ceph_msg_data_type_valid(enum ceph_msg_data_type type)
87#ifdef CONFIG_BLOCK 88#ifdef CONFIG_BLOCK
88 case CEPH_MSG_DATA_BIO: 89 case CEPH_MSG_DATA_BIO:
89#endif /* CONFIG_BLOCK */ 90#endif /* CONFIG_BLOCK */
91 case CEPH_MSG_DATA_BVECS:
90 return true; 92 return true;
91 default: 93 default:
92 return false; 94 return false;
@@ -139,6 +141,42 @@ struct ceph_bio_iter {
139 141
140#endif /* CONFIG_BLOCK */ 142#endif /* CONFIG_BLOCK */
141 143
144struct ceph_bvec_iter {
145 struct bio_vec *bvecs;
146 struct bvec_iter iter;
147};
148
149#define __ceph_bvec_iter_advance_step(it, n, STEP) do { \
150 BUG_ON((n) > (it)->iter.bi_size); \
151 (void)(STEP); \
152 bvec_iter_advance((it)->bvecs, &(it)->iter, (n)); \
153} while (0)
154
155/*
156 * Advance @it by @n bytes.
157 */
158#define ceph_bvec_iter_advance(it, n) \
159 __ceph_bvec_iter_advance_step(it, n, 0)
160
161/*
162 * Advance @it by @n bytes, executing BVEC_STEP for each bio_vec.
163 */
164#define ceph_bvec_iter_advance_step(it, n, BVEC_STEP) \
165 __ceph_bvec_iter_advance_step(it, n, ({ \
166 struct bio_vec bv; \
167 struct bvec_iter __cur_iter; \
168 \
169 __cur_iter = (it)->iter; \
170 __cur_iter.bi_size = (n); \
171 for_each_bvec(bv, (it)->bvecs, __cur_iter, __cur_iter) \
172 (void)(BVEC_STEP); \
173 }))
174
175#define ceph_bvec_iter_shorten(it, n) do { \
176 BUG_ON((n) > (it)->iter.bi_size); \
177 (it)->iter.bi_size = (n); \
178} while (0)
179
142struct ceph_msg_data { 180struct ceph_msg_data {
143 struct list_head links; /* ceph_msg->data */ 181 struct list_head links; /* ceph_msg->data */
144 enum ceph_msg_data_type type; 182 enum ceph_msg_data_type type;
@@ -149,6 +187,7 @@ struct ceph_msg_data {
149 u32 bio_length; 187 u32 bio_length;
150 }; 188 };
151#endif /* CONFIG_BLOCK */ 189#endif /* CONFIG_BLOCK */
190 struct ceph_bvec_iter bvec_pos;
152 struct { 191 struct {
153 struct page **pages; /* NOT OWNER. */ 192 struct page **pages; /* NOT OWNER. */
154 size_t length; /* total # bytes */ 193 size_t length; /* total # bytes */
@@ -170,6 +209,7 @@ struct ceph_msg_data_cursor {
170#ifdef CONFIG_BLOCK 209#ifdef CONFIG_BLOCK
171 struct ceph_bio_iter bio_iter; 210 struct ceph_bio_iter bio_iter;
172#endif /* CONFIG_BLOCK */ 211#endif /* CONFIG_BLOCK */
212 struct bvec_iter bvec_iter;
173 struct { /* pages */ 213 struct { /* pages */
174 unsigned int page_offset; /* offset in page */ 214 unsigned int page_offset; /* offset in page */
175 unsigned short page_index; /* index in array */ 215 unsigned short page_index; /* index in array */
@@ -336,6 +376,8 @@ extern void ceph_msg_data_add_pagelist(struct ceph_msg *msg,
336void ceph_msg_data_add_bio(struct ceph_msg *msg, struct ceph_bio_iter *bio_pos, 376void ceph_msg_data_add_bio(struct ceph_msg *msg, struct ceph_bio_iter *bio_pos,
337 u32 length); 377 u32 length);
338#endif /* CONFIG_BLOCK */ 378#endif /* CONFIG_BLOCK */
379void ceph_msg_data_add_bvecs(struct ceph_msg *msg,
380 struct ceph_bvec_iter *bvec_pos);
339 381
340extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags, 382extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
341 bool can_fail); 383 bool can_fail);
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 315691490cb0..528ccc943cee 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -57,6 +57,7 @@ enum ceph_osd_data_type {
57#ifdef CONFIG_BLOCK 57#ifdef CONFIG_BLOCK
58 CEPH_OSD_DATA_TYPE_BIO, 58 CEPH_OSD_DATA_TYPE_BIO,
59#endif /* CONFIG_BLOCK */ 59#endif /* CONFIG_BLOCK */
60 CEPH_OSD_DATA_TYPE_BVECS,
60}; 61};
61 62
62struct ceph_osd_data { 63struct ceph_osd_data {
@@ -76,6 +77,7 @@ struct ceph_osd_data {
76 u32 bio_length; 77 u32 bio_length;
77 }; 78 };
78#endif /* CONFIG_BLOCK */ 79#endif /* CONFIG_BLOCK */
80 struct ceph_bvec_iter bvec_pos;
79 }; 81 };
80}; 82};
81 83
@@ -410,6 +412,9 @@ void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *osd_req,
410 struct ceph_bio_iter *bio_pos, 412 struct ceph_bio_iter *bio_pos,
411 u32 bio_length); 413 u32 bio_length);
412#endif /* CONFIG_BLOCK */ 414#endif /* CONFIG_BLOCK */
415void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req,
416 unsigned int which,
417 struct ceph_bvec_iter *bvec_pos);
413 418
414extern void osd_req_op_cls_request_data_pagelist(struct ceph_osd_request *, 419extern void osd_req_op_cls_request_data_pagelist(struct ceph_osd_request *,
415 unsigned int which, 420 unsigned int which,
@@ -419,6 +424,9 @@ extern void osd_req_op_cls_request_data_pages(struct ceph_osd_request *,
419 struct page **pages, u64 length, 424 struct page **pages, u64 length,
420 u32 alignment, bool pages_from_pool, 425 u32 alignment, bool pages_from_pool,
421 bool own_pages); 426 bool own_pages);
427void osd_req_op_cls_request_data_bvecs(struct ceph_osd_request *osd_req,
428 unsigned int which,
429 struct bio_vec *bvecs, u32 bytes);
422extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *, 430extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,
423 unsigned int which, 431 unsigned int which,
424 struct page **pages, u64 length, 432 struct page **pages, u64 length,