]> git-server-git.apps.pok.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>
Wed, 29 Mar 2023 06:36:09 +0000 (14:36 +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>
(cherry picked from commit 82d7d2094116b69f861728028de88d5736002126)

src/include/ceph_fs.h
src/include/types.h

index efc8449f6f9da0555f6f5637a61a558540d94b3e..3804568b9bdd4a56bb7f791e9069a5faf3c040f7 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
@@ -636,6 +638,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 6737f3dc91814731ddfff36c6fd62e2f93efc0a1..63eb72a8a03f8f4e3968eb9ed42526b83791d198 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)