summaryrefslogtreecommitdiffstats
path: root/src/mds/Server.h
diff options
context:
space:
mode:
authorVenky Shankar <vshankar@redhat.com>2020-08-25 13:08:45 +0200
committerVenky Shankar <vshankar@redhat.com>2020-10-13 06:29:38 +0200
commita641e3c7600c7323532f95641a4b229c29985d55 (patch)
tree192571a5ac850f4d6cecadd57b329c0077f28524 /src/mds/Server.h
parentmds: introduce is_ceph_vxattr() helper (diff)
downloadceph-a641e3c7600c7323532f95641a4b229c29985d55.tar.xz
ceph-a641e3c7600c7323532f95641a4b229c29985d55.zip
mds: customize xattr handling using dispatch handlers
Signed-off-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'src/mds/Server.h')
-rw-r--r--src/mds/Server.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/mds/Server.h b/src/mds/Server.h
index 3a3305b06d5..ed58d7ad94e 100644
--- a/src/mds/Server.h
+++ b/src/mds/Server.h
@@ -30,6 +30,7 @@
#include "messages/MClientReclaimReply.h"
#include "messages/MLock.h"
+#include "CInode.h"
#include "MDSRank.h"
#include "Mutation.h"
#include "MDSContext.h"
@@ -318,6 +319,69 @@ private:
friend class ServerLogContext;
friend class Batch_Getattr_Lookup;
+ // placeholder for validation handler to store xattr specific
+ // data
+ struct XattrInfo {
+ virtual ~XattrInfo() {
+ }
+ };
+
+ struct XattrOp {
+ int op;
+ std::string xattr_name;
+ const bufferlist &xattr_value;
+ int flags = 0;
+
+ std::unique_ptr<XattrInfo> xinfo;
+
+ XattrOp(int op, std::string_view xattr_name, const bufferlist &xattr_value, int flags)
+ : op(op),
+ xattr_name(xattr_name),
+ xattr_value(xattr_value),
+ flags (flags) {
+ }
+ };
+
+ struct XattrHandler {
+ const std::string xattr_name;
+ const std::string description;
+
+ // basic checks are to be done in this handler. return -errno to
+ // reject xattr request (set or remove), zero to proceed. handlers
+ // may parse xattr value for verification if needed and have an
+ // option to store custom data in XattrOp::xinfo.
+ int (Server::*validate)(CInode *cur, const InodeStoreBase::xattr_map_const_ptr xattrs,
+ XattrOp *xattr_op);
+
+ // set xattr for an inode in xattr_map
+ void (Server::*setxattr)(CInode *cur, InodeStoreBase::xattr_map_ptr xattrs,
+ const XattrOp &xattr_op);
+
+ // remove xattr for an inode from xattr_map
+ void (Server::*removexattr)(CInode *cur, InodeStoreBase::xattr_map_ptr xattrs,
+ const XattrOp &xattr_op);
+ };
+
+ inline static const std::string DEFAULT_HANDLER = "<default>";
+ static const XattrHandler xattr_handlers[];
+
+ const XattrHandler* get_xattr_or_default_handler(std::string_view xattr_name);
+
+ // generic variant to set/remove xattr in/from xattr_map
+ int xattr_validate(CInode *cur, const InodeStoreBase::xattr_map_const_ptr xattrs,
+ const std::string &xattr_name, int op, int flags);
+ void xattr_set(InodeStoreBase::xattr_map_ptr xattrs, const std::string &xattr_name,
+ const bufferlist &xattr_value);
+ void xattr_rm(InodeStoreBase::xattr_map_ptr xattrs, const std::string &xattr_name);
+
+ // default xattr handlers
+ int default_xattr_validate(CInode *cur, const InodeStoreBase::xattr_map_const_ptr xattrs,
+ XattrOp *xattr_op);
+ void default_setxattr_handler(CInode *cur, InodeStoreBase::xattr_map_ptr xattrs,
+ const XattrOp &xattr_op);
+ void default_removexattr_handler(CInode *cur, InodeStoreBase::xattr_map_ptr xattrs,
+ const XattrOp &xattr_op);
+
static bool is_ceph_vxattr(std::string_view xattr_name) {
return xattr_name.rfind("ceph.dir.layout", 0) == 0 ||
xattr_name.rfind("ceph.file.layout", 0) == 0 ||