From 8127777d876d19030e2fbc7e5db8098e5dc98023 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Tue, 20 Dec 2022 12:39:22 +0800 Subject: [PATCH] mds: add MDSCapAuth support Need to add writeable/readable members and send them back to clients. Fixes: https://tracker.ceph.com/issues/57154 Signed-off-by: Xiubo Li (cherry picked from commit 6e4a6448022051ba9a33f4cb4b0af2298f2622aa) --- src/CMakeLists.txt | 1 + src/crimson/CMakeLists.txt | 1 + src/mds/CMakeLists.txt | 1 - src/mds/MDSAuthCaps.cc | 6 ++++++ src/mds/MDSAuthCaps.h | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index af33d4d6affea..f91dd1abe7fcb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -302,6 +302,7 @@ endif(WITH_BLKIN) set(mds_files) list(APPEND mds_files mds/MDSMap.cc + mds/MDSAuthCaps.cc mds/FSMap.cc mds/FSMapUser.cc mds/inode_backtrace.cc diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index e2b37fac9cbf0..723e6cb55f081 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -110,6 +110,7 @@ add_library(crimson-common STATIC ${PROJECT_SOURCE_DIR}/src/mds/FSMap.cc ${PROJECT_SOURCE_DIR}/src/mds/FSMapUser.cc ${PROJECT_SOURCE_DIR}/src/mds/MDSMap.cc + ${PROJECT_SOURCE_DIR}/src/mds/MDSAuthCaps.cc ${PROJECT_SOURCE_DIR}/src/msg/msg_types.cc ${PROJECT_SOURCE_DIR}/src/msg/Message.cc ${PROJECT_SOURCE_DIR}/src/mon/PGMap.cc diff --git a/src/mds/CMakeLists.txt b/src/mds/CMakeLists.txt index a12898f38c78e..88c8a1db0854a 100644 --- a/src/mds/CMakeLists.txt +++ b/src/mds/CMakeLists.txt @@ -34,7 +34,6 @@ set(mds_srcs snap.cc SessionMap.cc MDSContext.cc - MDSAuthCaps.cc MDLog.cc MDSCacheObject.cc Mantle.cc diff --git a/src/mds/MDSAuthCaps.cc b/src/mds/MDSAuthCaps.cc index e428707247569..03b6413b15b6e 100644 --- a/src/mds/MDSAuthCaps.cc +++ b/src/mds/MDSAuthCaps.cc @@ -456,3 +456,9 @@ ostream &operator<<(ostream &out, const MDSAuthCaps &cap) return out; } +ostream &operator<<(ostream &out, const MDSCapAuth &auth) +{ + out << "MDSCapAuth(" << auth.match << "readable=" + << auth.readable << ", writeable=" << auth.writeable << ")"; + return out; +} diff --git a/src/mds/MDSAuthCaps.h b/src/mds/MDSAuthCaps.h index 266bc27c7e806..16282bca9b820 100644 --- a/src/mds/MDSAuthCaps.h +++ b/src/mds/MDSAuthCaps.h @@ -175,6 +175,40 @@ struct MDSCapMatch { }; WRITE_CLASS_ENCODER(MDSCapMatch) +struct MDSCapAuth { + MDSCapAuth() {} + MDSCapAuth(MDSCapMatch m, bool r, bool w) : + match(m), readable(r), writeable(w) {} + + const MDSCapAuth& operator=(const MDSCapAuth& m) { + match = m.match; + readable = m.readable; + writeable = m.writeable; + return *this; + } + + void encode(ceph::buffer::list& bl) const { + ENCODE_START(1, 1, bl); + encode(match, bl); + encode(readable, bl); + encode(writeable, bl); + ENCODE_FINISH(bl); + } + + void decode(ceph::buffer::list::const_iterator& p) { + DECODE_START(1, p); + decode(match, p); + decode(readable, p); + decode(writeable, p); + DECODE_FINISH(p); + } + + MDSCapMatch match; + bool readable; + bool writeable; +}; +WRITE_CLASS_ENCODER(MDSCapAuth) + struct MDSCapGrant { MDSCapGrant(const MDSCapSpec &spec_, const MDSCapMatch &match_, boost::optional n) @@ -248,6 +282,7 @@ private: }; std::ostream &operator<<(std::ostream &out, const MDSCapMatch &match); +std::ostream &operator<<(std::ostream &out, const MDSCapAuth &auth); std::ostream &operator<<(std::ostream &out, const MDSCapSpec &spec); std::ostream &operator<<(std::ostream &out, const MDSCapGrant &grant); std::ostream &operator<<(std::ostream &out, const MDSAuthCaps &cap); -- 2.39.5