})
#define PROTO_VERSION_SIZE_EXPAND(_data, _ver) \
- (offset_of(__typeof__(_data), v##_ver) + \
- field_size(__typeof__(_data), v##_ver))
+ field_size(__typeof__(_data), v##_ver)
#define PROTO_VERSION_SIZE(_data, _ver) PROTO_VERSION_SIZE_EXPAND(_data, _ver)
#define PROTO_ANS(_fields...) _fields
#define PROTO_CBK(_fields...) _fields
-#define PROTO_VER(_name, _fields...) struct { _fields } _name
-
-#define PROTO_TYPE(_name, _fields...) typedef struct { _fields } _name
+#define PROTO_VER(_name, _fields) _fields, _name
+
+#define PROTO_STRUCT(_name, _fields) \
+ struct { \
+ _fields \
+ } _name;
+
+#define PROTO_VOID(_a...)
+
+#define PROTO_STRUCT_COND_SELECT(_a, _b, _c, _d...) _c
+
+/* This macro outputs a version structure only if the "name" is present.
+ * Otherwise it returns empty.
+ *
+ * Following this macro call, it's expected to find the normal arguments for
+ * a PROTO_STRUCT() macro.
+ *
+ * Example: PROTO_STRUCT_COND(name)(name, fields) */
+#define PROTO_STRUCT_COND(_name...) \
+ PROTO_STRUCT_COND_SELECT(, ## _name, PROTO_STRUCT, PROTO_VOID)
+
+/* These macros are prepared to create up to 4 version structures. If more are
+ * needed, just create a PROTO_BUILD_5 similar to PROTO_BUILD_4 and call it
+ * from PROTO_TYPE.
+ *
+ * The last version of the structure is also declared as an anonymous
+ * substructure to make access to the fields safer and cleaner.
+ *
+ * This approach is needed to be able to define full structures for each
+ * protocol version (i.e. v1 structure also contains all fields from v0), but
+ * without having to explicitly write them in the protocol definitions. This
+ * prevents a lot of copy&paste, it's less error prone, and makes the protocol
+ * extensions cleaner. */
+#define PROTO_BUILD_1(_fields, _name) \
+ PROTO_STRUCT_COND(_name)(_name, _fields) \
+ PROTO_STRUCT(,_fields)
+
+#define PROTO_BUILD_2(_fields, _name, _more...) \
+ PROTO_STRUCT_COND(_name)(_name, _fields) \
+ PROTO_BUILD_1(_fields _more,)
+
+#define PROTO_BUILD_3(_fields, _name, _more...) \
+ PROTO_STRUCT_COND(_name)(_name, _fields) \
+ PROTO_BUILD_2(_fields _more,)
+
+#define PROTO_BUILD_4(_fields, _name, _more...) \
+ PROTO_STRUCT_COND(_name)(_name, _fields) \
+ PROTO_BUILD_3(_fields _more,)
+
+#define PROTO_TYPE(_name, _fields...) \
+ typedef union { PROTO_BUILD_4(_fields) } _name
#define PROTO_CALL(_name, _req, _ans) \
PROTO_TYPE(proxy_##_name##_req_t, proxy_link_req_t header; _req); \
PROTO_CALL(ceph_version,
PROTO_REQ(
PROTO_VER(v0,
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
int32_t minor;
int32_t patch;
int16_t text;
- );
+ )
)
);
uint32_t uid;
uint32_t gid;
uint32_t groups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t userperm;
- );
+ )
)
);
PROTO_REQ(
PROTO_VER(v0,
uint64_t userperm;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
PROTO_REQ(
PROTO_VER(v0,
int16_t id;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t cmount;
- );
+ )
)
);
PROTO_REQ(
PROTO_VER(v0,
uint64_t cmount;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
uint16_t path;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
uint64_t cmount;
uint32_t size;
uint16_t option;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint16_t value;
- );
+ )
)
);
uint64_t cmount;
uint16_t option;
uint16_t value;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
PROTO_REQ(
PROTO_VER(v0,
uint64_t cmount;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
uint16_t fs;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
uint16_t root;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
PROTO_REQ(
PROTO_VER(v0,
uint64_t cmount;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
uint64_t inode;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
uint32_t want;
uint32_t flags;
uint16_t name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t inode;
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
struct inodeno_t ino;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t inode;
- );
+ )
)
);
PROTO_REQ(
PROTO_VER(v0,
uint64_t cmount;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t inode;
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
uint64_t inode;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
uint32_t want;
uint32_t flags;
uint16_t path;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t inode;
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
uint16_t path;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
PROTO_REQ(
PROTO_VER(v0,
uint64_t cmount;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint16_t path;
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
uint64_t dir;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
bool eod;
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
uint64_t dir;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
embedded_perms_t userperm;
uint64_t inode;
int32_t flags;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t fh;
- );
+ )
)
);
uint32_t want;
uint32_t flags;
uint16_t name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t inode;
uint64_t fh;
- );
+ )
)
);
uint32_t want;
uint32_t flags;
uint16_t name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t inode;
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
uint64_t fh;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
uint64_t new_parent;
uint16_t old_name;
uint16_t new_name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
uint64_t fh;
off_t offset;
int32_t whence;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
off_t offset;
- );
+ )
)
);
uint64_t fh;
int64_t offset;
uint64_t len;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
uint64_t fh;
int64_t offset;
uint64_t len;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
uint64_t inode;
uint64_t parent;
uint16_t name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
embedded_perms_t userperm;
uint64_t parent;
uint16_t name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
uint64_t inode;
uint32_t want;
uint32_t flags;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
embedded_perms_t userperm;
uint64_t inode;
int32_t mask;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
int64_t offset;
int64_t length;
int32_t mode;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
uint64_t cmount;
uint64_t fh;
int32_t dataonly;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
embedded_perms_t userperm;
uint64_t inode;
size_t size;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
size_t size;
- );
+ )
)
);
uint64_t inode;
size_t size;
uint16_t name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
size_t size;
int32_t flags;
uint16_t name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
embedded_perms_t userperm;
uint64_t inode;
uint16_t name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
embedded_perms_t userperm;
uint64_t inode;
size_t size;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
uint32_t flags;
uint16_t name;
uint16_t target;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t inode;
- );
+ )
)
);
uint64_t cmount;
embedded_perms_t userperm;
uint64_t inode;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t dir;
- );
+ )
)
);
uint32_t want;
uint32_t flags;
uint16_t name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t inode;
- );
+ )
)
);
embedded_perms_t userperm;
uint64_t parent;
uint16_t name;
- );
+ ),
PROTO_VER(v1,
uint32_t ngroups;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
PROTO_VER(v0,
uint64_t cmount;
uint64_t dir;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
- );
+ )
)
);
PROTO_REQ(
PROTO_VER(v0,
uint64_t cmount;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
uint64_t userperm;
- );
+ )
)
);
bool write;
bool fsync;
bool syncdataonly;
- );
+ )
),
PROTO_ANS(
PROTO_VER(v0,
int64_t res;
- );
+ )
)
);
PROTO_VER(v0,
uint64_t info;
int64_t res;
- );
+ )
)
);