diff mbox series

[v2,04/16] libceph: add prefix and suffix in ceph_osd_req_op.extent

Message ID 1552900534-29026-5-git-send-email-dongsheng.yang@easystack.cn (mailing list archive)
State New, archived
Headers show
Series rbd journaling feature | expand

Commit Message

Dongsheng Yang March 18, 2019, 9:15 a.m. UTC
When we are going to support rbd journaling, we need a
prefix and suffix of ceph_osd_req_op.extent for append
op.

Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
---
 include/linux/ceph/osd_client.h | 17 +++++++++++++++++
 net/ceph/osd_client.c           | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index bde296f..db1ec88 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -97,7 +97,13 @@  struct ceph_osd_req_op {
 			u64 offset, length;
 			u64 truncate_size;
 			u32 truncate_seq;
+			// In common case, extent only need
+			// one ceph_osd_data, extent.osd_data.
+			// But in journaling, we need a prefix
+			// and suffix in append op,
+			struct ceph_osd_data prefix;
 			struct ceph_osd_data osd_data;
+			struct ceph_osd_data suffix;
 		} extent;
 		struct {
 			u32 name_len;
@@ -435,6 +441,17 @@  void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req,
 					 unsigned int which,
 					 struct ceph_bvec_iter *bvec_pos);
 
+
+extern void osd_req_op_extent_prefix_pages(struct ceph_osd_request *,
+					unsigned int which,
+					struct page **pages, u64 length,
+					u32 alignment, bool pages_from_pool,
+					bool own_pages);
+extern void osd_req_op_extent_suffix_pages(struct ceph_osd_request *,
+					unsigned int which,
+					struct page **pages, u64 length,
+					u32 alignment, bool pages_from_pool,
+					bool own_pages);
 extern void osd_req_op_cls_request_data_pagelist(struct ceph_osd_request *,
 					unsigned int which,
 					struct ceph_pagelist *pagelist);
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index c5807b3..ba6092b 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -272,6 +272,32 @@  void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req,
 }
 EXPORT_SYMBOL(osd_req_op_extent_osd_data_bvec_pos);
 
+void osd_req_op_extent_prefix_pages(struct ceph_osd_request *osd_req,
+			unsigned int which, struct page **pages,
+			u64 length, u32 alignment,
+			bool pages_from_pool, bool own_pages)
+{
+	struct ceph_osd_data *prefix;
+
+	prefix = osd_req_op_data(osd_req, which, extent, prefix);
+	ceph_osd_data_pages_init(prefix, pages, length, alignment,
+				pages_from_pool, own_pages);
+}
+EXPORT_SYMBOL(osd_req_op_extent_prefix_pages);
+
+void osd_req_op_extent_suffix_pages(struct ceph_osd_request *osd_req,
+			unsigned int which, struct page **pages,
+			u64 length, u32 alignment,
+			bool pages_from_pool, bool own_pages)
+{
+	struct ceph_osd_data *suffix;
+
+	suffix = osd_req_op_data(osd_req, which, extent, suffix);
+	ceph_osd_data_pages_init(suffix, pages, length, alignment,
+				pages_from_pool, own_pages);
+}
+EXPORT_SYMBOL(osd_req_op_extent_suffix_pages);
+
 static void osd_req_op_cls_request_info_pagelist(
 			struct ceph_osd_request *osd_req,
 			unsigned int which, struct ceph_pagelist *pagelist)
@@ -387,7 +413,9 @@  static void osd_req_op_data_release(struct ceph_osd_request *osd_req,
 	case CEPH_OSD_OP_WRITE:
 	case CEPH_OSD_OP_WRITEFULL:
 	case CEPH_OSD_OP_APPEND:
+		ceph_osd_data_release(&op->extent.prefix);
 		ceph_osd_data_release(&op->extent.osd_data);
+		ceph_osd_data_release(&op->extent.suffix);
 		break;
 	case CEPH_OSD_OP_CALL:
 		ceph_osd_data_release(&op->cls.request_info);
@@ -704,6 +732,8 @@  static void get_num_data_items(struct ceph_osd_request *req,
 		case CEPH_OSD_OP_WRITE:
 		case CEPH_OSD_OP_WRITEFULL:
 		case CEPH_OSD_OP_APPEND:
+			*num_request_data_items += 3;
+			break;
 		case CEPH_OSD_OP_SETXATTR:
 		case CEPH_OSD_OP_CMPXATTR:
 		case CEPH_OSD_OP_NOTIFY_ACK:
@@ -1953,8 +1983,13 @@  static void setup_request_data(struct ceph_osd_request *req)
 		case CEPH_OSD_OP_WRITEFULL:
 		case CEPH_OSD_OP_APPEND:
 			WARN_ON(op->indata_len != op->extent.length);
+			// op->extent.prefix and op->extent.suffix can be NONE
+			ceph_osdc_msg_data_add(request_msg,
+					       &op->extent.prefix);
 			ceph_osdc_msg_data_add(request_msg,
 					       &op->extent.osd_data);
+			ceph_osdc_msg_data_add(request_msg,
+					       &op->extent.suffix);
 			break;
 		case CEPH_OSD_OP_SETXATTR:
 		case CEPH_OSD_OP_CMPXATTR: