]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_fs.h: switch to use its own encode/decode helpers
authorXiubo Li <xiubli@redhat.com>
Tue, 5 Jul 2022 03:47:16 +0000 (11:47 +0800)
committerXiubo Li <xiubli@redhat.com>
Thu, 16 Feb 2023 00:44:24 +0000 (08:44 +0800)
Prepare switching num_retry and num_fwd to __le32.

Fixes: https://tracker.ceph.com/issues/57854
Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/include/ceph_fs.h
src/include/types.h

index c83ffa4eec63eb71201e8e33df693cfcf5d76d14..f2d8a2d242e832b848c319ee8dded8692078a1c8 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "msgr.h"
 #include "rados.h"
+#include "include/encoding.h"
+#include "include/denc.h"
 
 /*
  * The data structures defined here are shared between Linux kernel and
@@ -639,6 +641,38 @@ struct ceph_mds_request_head {
        union ceph_mds_request_args args;
 } __attribute__ ((packed));
 
+void inline encode(const struct ceph_mds_request_head& h, ceph::buffer::list& bl) {
+  using ceph::encode;
+  encode(h.version, bl);
+  encode(h.oldest_client_tid, bl);
+  encode(h.mdsmap_epoch, bl);
+  encode(h.flags, bl);
+  encode(h.num_retry, bl);
+  encode(h.num_fwd, bl);
+  encode(h.num_releases, bl);
+  encode(h.op, bl);
+  encode(h.caller_uid, bl);
+  encode(h.caller_gid, bl);
+  encode(h.ino, bl);
+  bl.append((char*)&h.args, sizeof(h.args));
+}
+
+void inline decode(struct ceph_mds_request_head& h, ceph::buffer::list::const_iterator& bl) {
+  using ceph::decode;
+  decode(h.version, bl);
+  decode(h.oldest_client_tid, bl);
+  decode(h.mdsmap_epoch, bl);
+  decode(h.flags, bl);
+  decode(h.num_retry, bl);
+  decode(h.num_fwd, bl);
+  decode(h.num_releases, bl);
+  decode(h.op, bl);
+  decode(h.caller_uid, bl);
+  decode(h.caller_gid, bl);
+  decode(h.ino, bl);
+  bl.copy(sizeof(h.args), (char*)&(h.args));
+}
+
 /* cap/lease release record */
 struct ceph_mds_request_release {
        __le64 ino, cap_id;            /* ino and unique cap id */
index 12a0b2a6dbff85815aeafd6fd753a3bdc811a9a4..a76360db4035a171b929514d007cf98bb7bfff26 100644 (file)
@@ -320,7 +320,6 @@ WRITE_RAW_ENCODER(ceph_file_layout)
 WRITE_RAW_ENCODER(ceph_dir_layout)
 WRITE_RAW_ENCODER(ceph_mds_session_head)
 WRITE_RAW_ENCODER(ceph_mds_request_head_legacy)
-WRITE_RAW_ENCODER(ceph_mds_request_head)
 WRITE_RAW_ENCODER(ceph_mds_request_release)
 WRITE_RAW_ENCODER(ceph_filelock)
 WRITE_RAW_ENCODER(ceph_mds_caps_head)