]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include/cephfs/types.h: move JSON methods to json.h
authorMax Kellermann <max.kellermann@ionos.com>
Fri, 25 Oct 2024 16:04:27 +0000 (18:04 +0200)
committerVenky Shankar <vshankar@redhat.com>
Tue, 22 Jul 2025 05:11:00 +0000 (10:41 +0530)
This eliminates the heavy header dependency on ceph_json.h from most
includers.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/include/cephfs/json.h [new file with mode: 0644]
src/include/cephfs/types.h
src/mds/CInode.cc

diff --git a/src/include/cephfs/json.h b/src/include/cephfs/json.h
new file mode 100644 (file)
index 0000000..fde0d00
--- /dev/null
@@ -0,0 +1,79 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2020 Red Hat, Inc.
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ */
+
+#pragma once
+
+#include "types.h"
+
+#include "common/ceph_json.h"
+
+template<template<typename> class Allocator>
+void inode_t<Allocator>::client_ranges_cb(typename inode_t<Allocator>::client_range_map& c, JSONObj *obj){
+
+  int64_t client;
+  JSONDecoder::decode_json("client", client, obj, true);
+  client_writeable_range_t client_range_tmp;
+  JSONDecoder::decode_json("byte range", client_range_tmp.range, obj, true);
+  JSONDecoder::decode_json("follows", client_range_tmp.follows.val, obj, true);
+  c[client] = client_range_tmp;
+}
+
+template<template<typename> class Allocator>
+void inode_t<Allocator>::old_pools_cb(compact_set<int64_t, std::less<int64_t>, Allocator<int64_t> >& c, JSONObj *obj){
+
+  int64_t tmp;
+  decode_json_obj(tmp, obj);
+  c.insert(tmp);
+}
+
+template<template<typename> class Allocator>
+void inode_t<Allocator>::decode_json(JSONObj *obj)
+{
+
+  JSONDecoder::decode_json("ino", ino.val, obj, true);
+  JSONDecoder::decode_json("rdev", rdev, obj, true);
+  //JSONDecoder::decode_json("ctime", ctime, obj, true);
+  //JSONDecoder::decode_json("btime", btime, obj, true);
+  JSONDecoder::decode_json("mode", mode, obj, true);
+  JSONDecoder::decode_json("uid", uid, obj, true);
+  JSONDecoder::decode_json("gid", gid, obj, true);
+  JSONDecoder::decode_json("nlink", nlink, obj, true);
+  JSONDecoder::decode_json("dir_layout", dir_layout, obj, true);
+  JSONDecoder::decode_json("layout", layout, obj, true);
+  JSONDecoder::decode_json("old_pools", old_pools, inode_t<Allocator>::old_pools_cb, obj, true);
+  JSONDecoder::decode_json("size", size, obj, true);
+  JSONDecoder::decode_json("truncate_seq", truncate_seq, obj, true);
+  JSONDecoder::decode_json("truncate_size", truncate_size, obj, true);
+  JSONDecoder::decode_json("truncate_from", truncate_from, obj, true);
+  JSONDecoder::decode_json("truncate_pending", truncate_pending, obj, true);
+  //JSONDecoder::decode_json("mtime", mtime, obj, true);
+  //JSONDecoder::decode_json("atime", atime, obj, true);
+  JSONDecoder::decode_json("time_warp_seq", time_warp_seq, obj, true);
+  JSONDecoder::decode_json("change_attr", change_attr, obj, true);
+  JSONDecoder::decode_json("export_pin", export_pin, obj, true);
+  JSONDecoder::decode_json("client_ranges", client_ranges, inode_t<Allocator>::client_ranges_cb, obj, true);
+  JSONDecoder::decode_json("dirstat", dirstat, obj, true);
+  JSONDecoder::decode_json("rstat", rstat, obj, true);
+  JSONDecoder::decode_json("accounted_rstat", accounted_rstat, obj, true);
+  JSONDecoder::decode_json("version", version, obj, true);
+  JSONDecoder::decode_json("file_data_version", file_data_version, obj, true);
+  JSONDecoder::decode_json("xattr_version", xattr_version, obj, true);
+  JSONDecoder::decode_json("backtrace_version", backtrace_version, obj, true);
+  JSONDecoder::decode_json("stray_prior_path", stray_prior_path, obj, true);
+  JSONDecoder::decode_json("max_size_ever", max_size_ever, obj, true);
+  JSONDecoder::decode_json("quota", quota, obj, true);
+  JSONDecoder::decode_json("last_scrub_stamp", last_scrub_stamp, obj, true);
+  JSONDecoder::decode_json("last_scrub_version", last_scrub_version, obj, true);
+  JSONDecoder::decode_json("remote_ino", remote_ino.val, obj, true);
+  JSONDecoder::decode_json("referent_inodes", referent_inodes, obj, true);
+}
index dd449dd1ea48d9b0450f532982a7a5b5c034859c..94fa5e7d0b11aabec10dfd24bca32e7c4ddf1103 100644 (file)
 
 #include "include/ceph_assert.h"
 #include <boost/serialization/strong_typedef.hpp>
-#include "common/ceph_json.h"
 
 #define CEPH_FS_ONDISK_MAGIC "ceph fs volume v011"
 #define MAX_MDS                   0x100
 
+class JSONObj;
+
 BOOST_STRONG_TYPEDEF(uint64_t, mds_gid_t)
 extern const mds_gid_t MDS_GID_NONE;
 
@@ -1233,67 +1234,6 @@ void inode_t<Allocator>::dump(ceph::Formatter *f) const
   f->close_section();
 }
 
-template<template<typename> class Allocator>
-void inode_t<Allocator>::client_ranges_cb(typename inode_t<Allocator>::client_range_map& c, JSONObj *obj){
-
-  int64_t client;
-  JSONDecoder::decode_json("client", client, obj, true);
-  client_writeable_range_t client_range_tmp;
-  JSONDecoder::decode_json("byte range", client_range_tmp.range, obj, true);
-  JSONDecoder::decode_json("follows", client_range_tmp.follows.val, obj, true);
-  c[client] = client_range_tmp;
-}
-
-template<template<typename> class Allocator>
-void inode_t<Allocator>::old_pools_cb(compact_set<int64_t, std::less<int64_t>, Allocator<int64_t> >& c, JSONObj *obj){
-
-  int64_t tmp;
-  decode_json_obj(tmp, obj);
-  c.insert(tmp);
-}
-
-template<template<typename> class Allocator>
-void inode_t<Allocator>::decode_json(JSONObj *obj)
-{
-
-  JSONDecoder::decode_json("ino", ino.val, obj, true);
-  JSONDecoder::decode_json("rdev", rdev, obj, true);
-  //JSONDecoder::decode_json("ctime", ctime, obj, true);
-  //JSONDecoder::decode_json("btime", btime, obj, true);
-  JSONDecoder::decode_json("mode", mode, obj, true);
-  JSONDecoder::decode_json("uid", uid, obj, true);
-  JSONDecoder::decode_json("gid", gid, obj, true);
-  JSONDecoder::decode_json("nlink", nlink, obj, true);
-  JSONDecoder::decode_json("dir_layout", dir_layout, obj, true);
-  JSONDecoder::decode_json("layout", layout, obj, true);
-  JSONDecoder::decode_json("old_pools", old_pools, inode_t<Allocator>::old_pools_cb, obj, true);
-  JSONDecoder::decode_json("size", size, obj, true);
-  JSONDecoder::decode_json("truncate_seq", truncate_seq, obj, true);
-  JSONDecoder::decode_json("truncate_size", truncate_size, obj, true);
-  JSONDecoder::decode_json("truncate_from", truncate_from, obj, true);
-  JSONDecoder::decode_json("truncate_pending", truncate_pending, obj, true);
-  //JSONDecoder::decode_json("mtime", mtime, obj, true);
-  //JSONDecoder::decode_json("atime", atime, obj, true);
-  JSONDecoder::decode_json("time_warp_seq", time_warp_seq, obj, true);
-  JSONDecoder::decode_json("change_attr", change_attr, obj, true);
-  JSONDecoder::decode_json("export_pin", export_pin, obj, true);
-  JSONDecoder::decode_json("client_ranges", client_ranges, inode_t<Allocator>::client_ranges_cb, obj, true);
-  JSONDecoder::decode_json("dirstat", dirstat, obj, true);
-  JSONDecoder::decode_json("rstat", rstat, obj, true);
-  JSONDecoder::decode_json("accounted_rstat", accounted_rstat, obj, true);
-  JSONDecoder::decode_json("version", version, obj, true);
-  JSONDecoder::decode_json("file_data_version", file_data_version, obj, true);
-  JSONDecoder::decode_json("xattr_version", xattr_version, obj, true);
-  JSONDecoder::decode_json("backtrace_version", backtrace_version, obj, true);
-  JSONDecoder::decode_json("stray_prior_path", stray_prior_path, obj, true);
-  JSONDecoder::decode_json("max_size_ever", max_size_ever, obj, true);
-  JSONDecoder::decode_json("quota", quota, obj, true);
-  JSONDecoder::decode_json("last_scrub_stamp", last_scrub_stamp, obj, true);
-  JSONDecoder::decode_json("last_scrub_version", last_scrub_version, obj, true);
-  JSONDecoder::decode_json("remote_ino", remote_ino.val, obj, true);
-  JSONDecoder::decode_json("referent_inodes", referent_inodes, obj, true);
-}
-
 template<template<typename> class Allocator>
 void inode_t<Allocator>::generate_test_instances(std::list<inode_t*>& ls)
 {
index c0209e9cab8a302330456c541c78f1abcb26e189..8f5f42b5adf75e67697e2c34a81328b5adb618a0 100644 (file)
@@ -44,6 +44,7 @@
 #include "global/global_context.h"
 #include "include/denc.h"
 #include "include/ceph_assert.h"
+#include "include/cephfs/json.h"
 #include "include/int_types.h"
 #include "include/random.h" // for ceph::util::generate_random_number()