diff mbox

[v3,08/10] ceph-rbd: osdc support for osd call and rollback operations

Message ID b3af48c166286125b5b43faeec3c88def78c5a02.1278539315.git.yehuda@hq.newdream.net (mailing list archive)
State New, archived
Headers show

Commit Message

Yehuda Sadeh July 7, 2010, 10:11 p.m. UTC
None
diff mbox

Patch

diff --git a/fs/ceph/decode.h b/fs/ceph/decode.h
index 65b3e02..5f2d803 100644
--- a/fs/ceph/decode.h
+++ b/fs/ceph/decode.h
@@ -189,6 +189,11 @@  static inline void ceph_encode_string(void **p, void *end,
 		ceph_encode_need(p, end, n, bad);		\
 		ceph_encode_copy(p, pv, n);			\
 	} while (0)
+#define ceph_encode_string_safe(p, end, s, n, bad)		\
+	do {							\
+		ceph_encode_need(p, end, n, bad);		\
+		ceph_encode_string(p, end, s, n);		\
+	} while (0)
 
 
 #endif
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c
index 1cb9533..8b718cb 100644
--- a/fs/ceph/osd_client.c
+++ b/fs/ceph/osd_client.c
@@ -136,6 +136,7 @@  static int op_needs_trail(int op)
 	case CEPH_OSD_OP_GETXATTR:
 	case CEPH_OSD_OP_SETXATTR:
 	case CEPH_OSD_OP_CMPXATTR:
+	case CEPH_OSD_OP_CALL:
 		return 1;
 	default:
 		return 0;
@@ -286,6 +287,27 @@  static void osd_req_encode_op(struct ceph_osd_request *req,
 		dst->payload_len = cpu_to_le32(src->xattr.name_len +
 					       src->xattr.value_len);
 		break;
+	case CEPH_OSD_OP_CALL:
+		BUG_ON(!req->r_trail);
+
+		dst->cls.class_len = src->cls.class_len;
+		dst->cls.method_len = src->cls.method_len;
+		dst->cls.indata_len = cpu_to_le32(src->cls.indata_len);
+
+		ceph_pagelist_append(req->r_trail, src->cls.class_name,
+				     src->cls.class_len);
+		ceph_pagelist_append(req->r_trail, src->cls.method_name,
+				     src->cls.method_len);
+		ceph_pagelist_append(req->r_trail, src->cls.indata,
+				     src->cls.indata_len);
+		dst->payload_len = cpu_to_le32(src->cls.class_len + 
+					       src->cls.method_len +
+					       src->cls.indata_len);
+
+		break;
+	case CEPH_OSD_OP_ROLLBACK:
+		dst->snap.snapid = cpu_to_le64(src->snap.snapid);
+		break;
 	}
 	dst->payload_len = cpu_to_le32(src->payload_len);
 }
diff --git a/fs/ceph/osd_client.h b/fs/ceph/osd_client.h
index 38c4615..979efce 100644
--- a/fs/ceph/osd_client.h
+++ b/fs/ceph/osd_client.h
@@ -135,14 +135,20 @@  struct ceph_osd_req_op {
 			__u8 cmp_mode;     /* CEPH_OSD_CMPXATTR_MODE_* */
 		} xattr;
 		struct {
+			const char *class_name;
 			__u8 class_len;
+			const char *method_name;
 			__u8 method_len;
 			__u8 argc;
+			const char *indata;
 			u32 indata_len;
 		} cls;
 		struct {
 			u64 cookie, count;
 		} pgls;
+	        struct {
+		        u64 snapid;
+	        } snap;
 	};
 	u32 payload_len;
 };