diff mbox series

[v4,04/12] libceph: add prefix and suffix in ceph_osd_req_op.extent

Message ID 1569402454-4736-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 Sept. 25, 2019, 9:07 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 | 19 +++++++++++++++++++
 net/ceph/osd_client.c           | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 9a4533a..1a3f8e1 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -97,7 +97,15 @@  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;
@@ -442,6 +450,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 336e1c3..296edd7 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -264,6 +264,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)
@@ -379,7 +405,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);
@@ -696,6 +724,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:
@@ -1945,8 +1975,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);
+			/* extent.prefix and 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: