diff options
Diffstat (limited to 'net/ceph/osd_client.c')
-rw-r--r-- | net/ceph/osd_client.c | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 23491e92b229..ad24f210bf0c 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -329,25 +329,32 @@ static bool osd_req_opcode_valid(u16 opcode) | |||
329 | * other information associated with them. It also serves as a | 329 | * other information associated with them. It also serves as a |
330 | * common init routine for all the other init functions, below. | 330 | * common init routine for all the other init functions, below. |
331 | */ | 331 | */ |
332 | void osd_req_op_init(struct ceph_osd_req_op *op, u16 opcode) | 332 | static struct ceph_osd_req_op * |
333 | osd_req_op_init(struct ceph_osd_request *osd_req, unsigned int which, | ||
334 | u16 opcode) | ||
333 | { | 335 | { |
336 | struct ceph_osd_req_op *op; | ||
337 | |||
338 | BUG_ON(which >= osd_req->r_num_ops); | ||
334 | BUG_ON(!osd_req_opcode_valid(opcode)); | 339 | BUG_ON(!osd_req_opcode_valid(opcode)); |
335 | 340 | ||
341 | op = &osd_req->r_ops[which]; | ||
336 | memset(op, 0, sizeof (*op)); | 342 | memset(op, 0, sizeof (*op)); |
337 | |||
338 | op->op = opcode; | 343 | op->op = opcode; |
344 | |||
345 | return op; | ||
339 | } | 346 | } |
340 | 347 | ||
341 | void osd_req_op_extent_init(struct ceph_osd_req_op *op, u16 opcode, | 348 | void osd_req_op_extent_init(struct ceph_osd_request *osd_req, |
349 | unsigned int which, u16 opcode, | ||
342 | u64 offset, u64 length, | 350 | u64 offset, u64 length, |
343 | u64 truncate_size, u32 truncate_seq) | 351 | u64 truncate_size, u32 truncate_seq) |
344 | { | 352 | { |
353 | struct ceph_osd_req_op *op = osd_req_op_init(osd_req, which, opcode); | ||
345 | size_t payload_len = 0; | 354 | size_t payload_len = 0; |
346 | 355 | ||
347 | BUG_ON(opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE); | 356 | BUG_ON(opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE); |
348 | 357 | ||
349 | osd_req_op_init(op, opcode); | ||
350 | |||
351 | op->extent.offset = offset; | 358 | op->extent.offset = offset; |
352 | op->extent.length = length; | 359 | op->extent.length = length; |
353 | op->extent.truncate_size = truncate_size; | 360 | op->extent.truncate_size = truncate_size; |
@@ -359,9 +366,15 @@ void osd_req_op_extent_init(struct ceph_osd_req_op *op, u16 opcode, | |||
359 | } | 366 | } |
360 | EXPORT_SYMBOL(osd_req_op_extent_init); | 367 | EXPORT_SYMBOL(osd_req_op_extent_init); |
361 | 368 | ||
362 | void osd_req_op_extent_update(struct ceph_osd_req_op *op, u64 length) | 369 | void osd_req_op_extent_update(struct ceph_osd_request *osd_req, |
370 | unsigned int which, u64 length) | ||
363 | { | 371 | { |
364 | u64 previous = op->extent.length; | 372 | struct ceph_osd_req_op *op; |
373 | u64 previous; | ||
374 | |||
375 | BUG_ON(which >= osd_req->r_num_ops); | ||
376 | op = &osd_req->r_ops[which]; | ||
377 | previous = op->extent.length; | ||
365 | 378 | ||
366 | if (length == previous) | 379 | if (length == previous) |
367 | return; /* Nothing to do */ | 380 | return; /* Nothing to do */ |
@@ -372,24 +385,25 @@ void osd_req_op_extent_update(struct ceph_osd_req_op *op, u64 length) | |||
372 | } | 385 | } |
373 | EXPORT_SYMBOL(osd_req_op_extent_update); | 386 | EXPORT_SYMBOL(osd_req_op_extent_update); |
374 | 387 | ||
375 | void osd_req_op_extent_osd_data(struct ceph_osd_req_op *op, | 388 | void osd_req_op_extent_osd_data(struct ceph_osd_request *osd_req, |
389 | unsigned int which, | ||
376 | struct ceph_osd_data *osd_data) | 390 | struct ceph_osd_data *osd_data) |
377 | { | 391 | { |
378 | op->extent.osd_data = osd_data; | 392 | BUG_ON(which >= osd_req->r_num_ops); |
393 | osd_req->r_ops[which].extent.osd_data = osd_data; | ||
379 | } | 394 | } |
380 | EXPORT_SYMBOL(osd_req_op_extent_osd_data); | 395 | EXPORT_SYMBOL(osd_req_op_extent_osd_data); |
381 | 396 | ||
382 | void osd_req_op_cls_init(struct ceph_osd_req_op *op, u16 opcode, | 397 | void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which, |
383 | const char *class, const char *method, | 398 | u16 opcode, const char *class, const char *method, |
384 | const void *request_data, size_t request_data_size) | 399 | const void *request_data, size_t request_data_size) |
385 | { | 400 | { |
401 | struct ceph_osd_req_op *op = osd_req_op_init(osd_req, which, opcode); | ||
386 | size_t payload_len = 0; | 402 | size_t payload_len = 0; |
387 | size_t size; | 403 | size_t size; |
388 | 404 | ||
389 | BUG_ON(opcode != CEPH_OSD_OP_CALL); | 405 | BUG_ON(opcode != CEPH_OSD_OP_CALL); |
390 | 406 | ||
391 | osd_req_op_init(op, opcode); | ||
392 | |||
393 | op->cls.class_name = class; | 407 | op->cls.class_name = class; |
394 | size = strlen(class); | 408 | size = strlen(class); |
395 | BUG_ON(size > (size_t) U8_MAX); | 409 | BUG_ON(size > (size_t) U8_MAX); |
@@ -412,26 +426,28 @@ void osd_req_op_cls_init(struct ceph_osd_req_op *op, u16 opcode, | |||
412 | op->payload_len = payload_len; | 426 | op->payload_len = payload_len; |
413 | } | 427 | } |
414 | EXPORT_SYMBOL(osd_req_op_cls_init); | 428 | EXPORT_SYMBOL(osd_req_op_cls_init); |
415 | 429 | void osd_req_op_cls_response_data(struct ceph_osd_request *osd_req, | |
416 | void osd_req_op_cls_response_data(struct ceph_osd_req_op *op, | 430 | unsigned int which, |
417 | struct ceph_osd_data *response_data) | 431 | struct ceph_osd_data *response_data) |
418 | { | 432 | { |
419 | op->cls.response_data = response_data; | 433 | BUG_ON(which >= osd_req->r_num_ops); |
434 | osd_req->r_ops[which].cls.response_data = response_data; | ||
420 | } | 435 | } |
421 | EXPORT_SYMBOL(osd_req_op_cls_response_data); | 436 | EXPORT_SYMBOL(osd_req_op_cls_response_data); |
422 | 437 | ||
423 | void osd_req_op_watch_init(struct ceph_osd_req_op *op, u16 opcode, | 438 | void osd_req_op_watch_init(struct ceph_osd_request *osd_req, |
439 | unsigned int which, u16 opcode, | ||
424 | u64 cookie, u64 version, int flag) | 440 | u64 cookie, u64 version, int flag) |
425 | { | 441 | { |
426 | BUG_ON(opcode != CEPH_OSD_OP_NOTIFY_ACK && opcode != CEPH_OSD_OP_WATCH); | 442 | struct ceph_osd_req_op *op = osd_req_op_init(osd_req, which, opcode); |
427 | 443 | ||
428 | osd_req_op_init(op, opcode); | 444 | BUG_ON(opcode != CEPH_OSD_OP_NOTIFY_ACK && opcode != CEPH_OSD_OP_WATCH); |
429 | 445 | ||
430 | op->watch.cookie = cookie; | 446 | op->watch.cookie = cookie; |
431 | /* op->watch.ver = version; */ /* XXX 3847 */ | 447 | /* op->watch.ver = version; */ /* XXX 3847 */ |
432 | op->watch.ver = cpu_to_le64(version); | 448 | op->watch.ver = cpu_to_le64(version); |
433 | if (opcode == CEPH_OSD_OP_WATCH && flag) | 449 | if (opcode == CEPH_OSD_OP_WATCH && flag) |
434 | op->watch.flag = (u8) 1; | 450 | op->watch.flag = (u8)1; |
435 | } | 451 | } |
436 | EXPORT_SYMBOL(osd_req_op_watch_init); | 452 | EXPORT_SYMBOL(osd_req_op_watch_init); |
437 | 453 | ||
@@ -629,7 +645,6 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
629 | { | 645 | { |
630 | struct ceph_osd_request *req; | 646 | struct ceph_osd_request *req; |
631 | struct ceph_osd_data *osd_data; | 647 | struct ceph_osd_data *osd_data; |
632 | struct ceph_osd_req_op *op; | ||
633 | u64 objnum = 0; | 648 | u64 objnum = 0; |
634 | u64 objoff = 0; | 649 | u64 objoff = 0; |
635 | u64 objlen = 0; | 650 | u64 objlen = 0; |
@@ -665,10 +680,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
665 | truncate_size = object_size; | 680 | truncate_size = object_size; |
666 | } | 681 | } |
667 | 682 | ||
668 | op = &req->r_ops[0]; | 683 | osd_req_op_extent_init(req, 0, opcode, objoff, objlen, |
669 | osd_req_op_extent_init(op, opcode, objoff, objlen, | ||
670 | truncate_size, truncate_seq); | 684 | truncate_size, truncate_seq); |
671 | osd_req_op_extent_osd_data(op, osd_data); | 685 | osd_req_op_extent_osd_data(req, 0, osd_data); |
672 | 686 | ||
673 | /* | 687 | /* |
674 | * A second op in the ops array means the caller wants to | 688 | * A second op in the ops array means the caller wants to |
@@ -676,7 +690,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
676 | * osd will flush data quickly. | 690 | * osd will flush data quickly. |
677 | */ | 691 | */ |
678 | if (num_ops > 1) | 692 | if (num_ops > 1) |
679 | osd_req_op_init(++op, CEPH_OSD_OP_STARTSYNC); | 693 | osd_req_op_init(req, 1, CEPH_OSD_OP_STARTSYNC); |
680 | 694 | ||
681 | req->r_file_layout = *layout; /* keep a copy */ | 695 | req->r_file_layout = *layout; /* keep a copy */ |
682 | 696 | ||