diff options
author | Yan, Zheng <zyan@redhat.com> | 2014-11-12 21:47:25 -0500 |
---|---|---|
committer | Ilya Dryomov <idryomov@redhat.com> | 2014-12-17 12:09:51 -0500 |
commit | 864e9197f10c77053bbaf12932f5b200bb4ed3c5 (patch) | |
tree | e4ee55d86d9359824092a739e2ce748ef7d5f7c4 /net/ceph | |
parent | d74b50bed037794135cb5a4e7418ad71d9848ce1 (diff) |
libceph: add CREATE osd operation support
Add CEPH_OSD_OP_CREATE support. Also change libceph to not treat
CEPH_OSD_OP_DELETE as an extent op and add an assert to that end.
Signed-off-by: Yan, Zheng <zyan@redhat.com>
Reviewed-by: Ilya Dryomov <idryomov@redhat.com>
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/osd_client.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 2b0555b36e4d..af1b3ee195e9 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -480,8 +480,7 @@ void osd_req_op_extent_init(struct ceph_osd_request *osd_req, | |||
480 | size_t payload_len = 0; | 480 | size_t payload_len = 0; |
481 | 481 | ||
482 | BUG_ON(opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE && | 482 | BUG_ON(opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE && |
483 | opcode != CEPH_OSD_OP_DELETE && opcode != CEPH_OSD_OP_ZERO && | 483 | opcode != CEPH_OSD_OP_ZERO && opcode != CEPH_OSD_OP_TRUNCATE); |
484 | opcode != CEPH_OSD_OP_TRUNCATE); | ||
485 | 484 | ||
486 | op->extent.offset = offset; | 485 | op->extent.offset = offset; |
487 | op->extent.length = length; | 486 | op->extent.length = length; |
@@ -663,7 +662,6 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, | |||
663 | case CEPH_OSD_OP_READ: | 662 | case CEPH_OSD_OP_READ: |
664 | case CEPH_OSD_OP_WRITE: | 663 | case CEPH_OSD_OP_WRITE: |
665 | case CEPH_OSD_OP_ZERO: | 664 | case CEPH_OSD_OP_ZERO: |
666 | case CEPH_OSD_OP_DELETE: | ||
667 | case CEPH_OSD_OP_TRUNCATE: | 665 | case CEPH_OSD_OP_TRUNCATE: |
668 | if (src->op == CEPH_OSD_OP_WRITE) | 666 | if (src->op == CEPH_OSD_OP_WRITE) |
669 | request_data_len = src->extent.length; | 667 | request_data_len = src->extent.length; |
@@ -723,6 +721,9 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, | |||
723 | ceph_osdc_msg_data_add(req->r_request, osd_data); | 721 | ceph_osdc_msg_data_add(req->r_request, osd_data); |
724 | request_data_len = osd_data->pagelist->length; | 722 | request_data_len = osd_data->pagelist->length; |
725 | break; | 723 | break; |
724 | case CEPH_OSD_OP_CREATE: | ||
725 | case CEPH_OSD_OP_DELETE: | ||
726 | break; | ||
726 | default: | 727 | default: |
727 | pr_err("unsupported osd opcode %s\n", | 728 | pr_err("unsupported osd opcode %s\n", |
728 | ceph_osd_op_name(src->op)); | 729 | ceph_osd_op_name(src->op)); |
@@ -763,13 +764,11 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
763 | u64 objnum = 0; | 764 | u64 objnum = 0; |
764 | u64 objoff = 0; | 765 | u64 objoff = 0; |
765 | u64 objlen = 0; | 766 | u64 objlen = 0; |
766 | u32 object_size; | ||
767 | u64 object_base; | ||
768 | int r; | 767 | int r; |
769 | 768 | ||
770 | BUG_ON(opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE && | 769 | BUG_ON(opcode != CEPH_OSD_OP_READ && opcode != CEPH_OSD_OP_WRITE && |
771 | opcode != CEPH_OSD_OP_DELETE && opcode != CEPH_OSD_OP_ZERO && | 770 | opcode != CEPH_OSD_OP_ZERO && opcode != CEPH_OSD_OP_TRUNCATE && |
772 | opcode != CEPH_OSD_OP_TRUNCATE); | 771 | opcode != CEPH_OSD_OP_CREATE && opcode != CEPH_OSD_OP_DELETE); |
773 | 772 | ||
774 | req = ceph_osdc_alloc_request(osdc, snapc, num_ops, use_mempool, | 773 | req = ceph_osdc_alloc_request(osdc, snapc, num_ops, use_mempool, |
775 | GFP_NOFS); | 774 | GFP_NOFS); |
@@ -785,21 +784,24 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
785 | return ERR_PTR(r); | 784 | return ERR_PTR(r); |
786 | } | 785 | } |
787 | 786 | ||
788 | object_size = le32_to_cpu(layout->fl_object_size); | 787 | if (opcode == CEPH_OSD_OP_CREATE || opcode == CEPH_OSD_OP_DELETE) { |
789 | object_base = off - objoff; | 788 | osd_req_op_init(req, 0, opcode); |
790 | if (!(truncate_seq == 1 && truncate_size == -1ULL)) { | 789 | } else { |
791 | if (truncate_size <= object_base) { | 790 | u32 object_size = le32_to_cpu(layout->fl_object_size); |
792 | truncate_size = 0; | 791 | u32 object_base = off - objoff; |
793 | } else { | 792 | if (!(truncate_seq == 1 && truncate_size == -1ULL)) { |
794 | truncate_size -= object_base; | 793 | if (truncate_size <= object_base) { |
795 | if (truncate_size > object_size) | 794 | truncate_size = 0; |
796 | truncate_size = object_size; | 795 | } else { |
796 | truncate_size -= object_base; | ||
797 | if (truncate_size > object_size) | ||
798 | truncate_size = object_size; | ||
799 | } | ||
797 | } | 800 | } |
798 | } | ||
799 | |||
800 | osd_req_op_extent_init(req, 0, opcode, objoff, objlen, | ||
801 | truncate_size, truncate_seq); | ||
802 | 801 | ||
802 | osd_req_op_extent_init(req, 0, opcode, objoff, objlen, | ||
803 | truncate_size, truncate_seq); | ||
804 | } | ||
803 | /* | 805 | /* |
804 | * A second op in the ops array means the caller wants to | 806 | * A second op in the ops array means the caller wants to |
805 | * also issue a include a 'startsync' command so that the | 807 | * also issue a include a 'startsync' command so that the |