aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/rbd.c9
-rw-r--r--include/linux/ceph/osd_client.h3
-rw-r--r--net/ceph/osd_client.c43
3 files changed, 22 insertions, 33 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index b6872d3cb04c..88de8ccb29bd 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1026,12 +1026,12 @@ out_err:
1026/* 1026/*
1027 * helpers for osd request op vectors. 1027 * helpers for osd request op vectors.
1028 */ 1028 */
1029static struct ceph_osd_req_op *rbd_create_rw_ops(int num_ops, 1029static struct ceph_osd_req_op *rbd_create_rw_ops(int num_op,
1030 int opcode, u32 payload_len) 1030 int opcode, u32 payload_len)
1031{ 1031{
1032 struct ceph_osd_req_op *ops; 1032 struct ceph_osd_req_op *ops;
1033 1033
1034 ops = kzalloc(sizeof (*ops) * (num_ops + 1), GFP_NOIO); 1034 ops = kzalloc(num_op * sizeof (*ops), GFP_NOIO);
1035 if (!ops) 1035 if (!ops)
1036 return NULL; 1036 return NULL;
1037 1037
@@ -1149,7 +1149,7 @@ static int rbd_do_request(struct request *rq,
1149 (unsigned long long) len, coll, coll_index); 1149 (unsigned long long) len, coll, coll_index);
1150 1150
1151 osdc = &rbd_dev->rbd_client->client->osdc; 1151 osdc = &rbd_dev->rbd_client->client->osdc;
1152 osd_req = ceph_osdc_alloc_request(osdc, snapc, ops, false, GFP_NOIO); 1152 osd_req = ceph_osdc_alloc_request(osdc, snapc, num_op, false, GFP_NOIO);
1153 if (!osd_req) { 1153 if (!osd_req) {
1154 ret = -ENOMEM; 1154 ret = -ENOMEM;
1155 goto done_pages; 1155 goto done_pages;
@@ -1178,7 +1178,8 @@ static int rbd_do_request(struct request *rq,
1178 ofs, &len, &bno, osd_req, ops); 1178 ofs, &len, &bno, osd_req, ops);
1179 rbd_assert(ret == 0); 1179 rbd_assert(ret == 0);
1180 1180
1181 ceph_osdc_build_request(osd_req, ofs, len, ops, snapc, snapid, &mtime); 1181 ceph_osdc_build_request(osd_req, ofs, len, num_op, ops,
1182 snapc, snapid, &mtime);
1182 1183
1183 if (linger_req) { 1184 if (linger_req) {
1184 ceph_osdc_set_request_linger(osdc, osd_req); 1185 ceph_osdc_set_request_linger(osdc, osd_req);
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 75f56d372d44..2b04d054e09d 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -214,12 +214,13 @@ extern int ceph_calc_raw_layout(struct ceph_file_layout *layout,
214 214
215extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, 215extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
216 struct ceph_snap_context *snapc, 216 struct ceph_snap_context *snapc,
217 struct ceph_osd_req_op *ops, 217 unsigned int num_op,
218 bool use_mempool, 218 bool use_mempool,
219 gfp_t gfp_flags); 219 gfp_t gfp_flags);
220 220
221extern void ceph_osdc_build_request(struct ceph_osd_request *req, 221extern void ceph_osdc_build_request(struct ceph_osd_request *req,
222 u64 off, u64 len, 222 u64 off, u64 len,
223 unsigned int num_op,
223 struct ceph_osd_req_op *src_ops, 224 struct ceph_osd_req_op *src_ops,
224 struct ceph_snap_context *snapc, 225 struct ceph_snap_context *snapc,
225 u64 snap_id, 226 u64 snap_id,
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index bdc3bb12bfd5..500ae8b49321 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -160,25 +160,14 @@ void ceph_osdc_release_request(struct kref *kref)
160} 160}
161EXPORT_SYMBOL(ceph_osdc_release_request); 161EXPORT_SYMBOL(ceph_osdc_release_request);
162 162
163static int get_num_ops(struct ceph_osd_req_op *ops)
164{
165 int i = 0;
166
167 while (ops[i].op)
168 i++;
169
170 return i;
171}
172
173struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, 163struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
174 struct ceph_snap_context *snapc, 164 struct ceph_snap_context *snapc,
175 struct ceph_osd_req_op *ops, 165 unsigned int num_op,
176 bool use_mempool, 166 bool use_mempool,
177 gfp_t gfp_flags) 167 gfp_t gfp_flags)
178{ 168{
179 struct ceph_osd_request *req; 169 struct ceph_osd_request *req;
180 struct ceph_msg *msg; 170 struct ceph_msg *msg;
181 int num_op = get_num_ops(ops);
182 size_t msg_size = sizeof(struct ceph_osd_request_head); 171 size_t msg_size = sizeof(struct ceph_osd_request_head);
183 172
184 msg_size += num_op*sizeof(struct ceph_osd_op); 173 msg_size += num_op*sizeof(struct ceph_osd_op);
@@ -317,7 +306,7 @@ static void osd_req_encode_op(struct ceph_osd_request *req,
317 * 306 *
318 */ 307 */
319void ceph_osdc_build_request(struct ceph_osd_request *req, 308void ceph_osdc_build_request(struct ceph_osd_request *req,
320 u64 off, u64 len, 309 u64 off, u64 len, unsigned int num_op,
321 struct ceph_osd_req_op *src_ops, 310 struct ceph_osd_req_op *src_ops,
322 struct ceph_snap_context *snapc, u64 snap_id, 311 struct ceph_snap_context *snapc, u64 snap_id,
323 struct timespec *mtime) 312 struct timespec *mtime)
@@ -327,7 +316,6 @@ void ceph_osdc_build_request(struct ceph_osd_request *req,
327 struct ceph_osd_req_op *src_op; 316 struct ceph_osd_req_op *src_op;
328 struct ceph_osd_op *op; 317 struct ceph_osd_op *op;
329 void *p; 318 void *p;
330 int num_op = get_num_ops(src_ops);
331 size_t msg_size = sizeof(*head) + num_op*sizeof(*op); 319 size_t msg_size = sizeof(*head) + num_op*sizeof(*op);
332 int flags = req->r_flags; 320 int flags = req->r_flags;
333 u64 data_len = 0; 321 u64 data_len = 0;
@@ -346,20 +334,17 @@ void ceph_osdc_build_request(struct ceph_osd_request *req,
346 head->flags = cpu_to_le32(flags); 334 head->flags = cpu_to_le32(flags);
347 if (flags & CEPH_OSD_FLAG_WRITE) 335 if (flags & CEPH_OSD_FLAG_WRITE)
348 ceph_encode_timespec(&head->mtime, mtime); 336 ceph_encode_timespec(&head->mtime, mtime);
337 BUG_ON(num_op > (unsigned int) ((u16) -1));
349 head->num_ops = cpu_to_le16(num_op); 338 head->num_ops = cpu_to_le16(num_op);
350 339
351
352 /* fill in oid */ 340 /* fill in oid */
353 head->object_len = cpu_to_le32(req->r_oid_len); 341 head->object_len = cpu_to_le32(req->r_oid_len);
354 memcpy(p, req->r_oid, req->r_oid_len); 342 memcpy(p, req->r_oid, req->r_oid_len);
355 p += req->r_oid_len; 343 p += req->r_oid_len;
356 344
357 src_op = src_ops; 345 src_op = src_ops;
358 while (src_op->op) { 346 while (num_op--)
359 osd_req_encode_op(req, op, src_op); 347 osd_req_encode_op(req, op++, src_op++);
360 src_op++;
361 op++;
362 }
363 348
364 data_len += req->r_trail.length; 349 data_len += req->r_trail.length;
365 350
@@ -414,23 +399,24 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
414 bool use_mempool, int num_reply, 399 bool use_mempool, int num_reply,
415 int page_align) 400 int page_align)
416{ 401{
417 struct ceph_osd_req_op ops[3]; 402 struct ceph_osd_req_op ops[2];
418 struct ceph_osd_request *req; 403 struct ceph_osd_request *req;
404 unsigned int num_op = 1;
419 int r; 405 int r;
420 406
407 memset(&ops, 0, sizeof ops);
408
421 ops[0].op = opcode; 409 ops[0].op = opcode;
422 ops[0].extent.truncate_seq = truncate_seq; 410 ops[0].extent.truncate_seq = truncate_seq;
423 ops[0].extent.truncate_size = truncate_size; 411 ops[0].extent.truncate_size = truncate_size;
424 ops[0].payload_len = 0;
425 412
426 if (do_sync) { 413 if (do_sync) {
427 ops[1].op = CEPH_OSD_OP_STARTSYNC; 414 ops[1].op = CEPH_OSD_OP_STARTSYNC;
428 ops[1].payload_len = 0; 415 num_op++;
429 ops[2].op = 0; 416 }
430 } else
431 ops[1].op = 0;
432 417
433 req = ceph_osdc_alloc_request(osdc, snapc, ops, use_mempool, GFP_NOFS); 418 req = ceph_osdc_alloc_request(osdc, snapc, num_op, use_mempool,
419 GFP_NOFS);
434 if (!req) 420 if (!req)
435 return ERR_PTR(-ENOMEM); 421 return ERR_PTR(-ENOMEM);
436 req->r_flags = flags; 422 req->r_flags = flags;
@@ -446,7 +432,8 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
446 req->r_num_pages = calc_pages_for(page_align, *plen); 432 req->r_num_pages = calc_pages_for(page_align, *plen);
447 req->r_page_alignment = page_align; 433 req->r_page_alignment = page_align;
448 434
449 ceph_osdc_build_request(req, off, *plen, ops, snapc, vino.snap, mtime); 435 ceph_osdc_build_request(req, off, *plen, num_op, ops,
436 snapc, vino.snap, mtime);
450 437
451 return req; 438 return req;
452} 439}