From 15ce36b348d3cce99b732520e14db568d866f992 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Thu, 5 Apr 2018 08:44:12 +0800 Subject: [PATCH] mds: automatically create snaprealm for old format quota The new quota format requires that quota inodes have snaprealm. Signed-off-by: Yan, Zheng Fixes: http://tracker.ceph.com/issues/23491 --- src/mds/MDCache.cc | 8 +++++++- src/mds/Server.cc | 17 +++++++++++++++++ src/mds/Server.h | 3 ++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 0222f41d4c3d6..80244b4745c8b 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -1975,14 +1975,20 @@ void MDCache::project_rstat_frag_to_inode(nest_info_t& rstat, nest_info_t& accou void MDCache::broadcast_quota_to_client(CInode *in) { + if (!(mds->is_active() || mds->is_stopping())) + return; + if (!in->is_auth() || in->is_frozen()) return; auto i = in->get_projected_inode(); - if (!i->quota.is_enable()) return; + // creaete snaprealm for quota inode (quota was set before mimic) + if (!in->get_projected_srnode()) + mds->server->create_quota_realm(in); + for (map::iterator it = in->client_caps.begin(); it != in->client_caps.end(); ++it) { diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 2fdc623855a82..34e22ff0c7304 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -4581,6 +4581,10 @@ int Server::parse_quota_vxattr(string name, string value, quota_info_t *quota) if (name == "quota") { string::iterator begin = value.begin(); string::iterator end = value.end(); + if (begin == end) { + // keep quota unchanged. (for create_quota_realm()) + return 0; + } keys_and_values p; // create instance of parser std::map m; // map to receive results if (!qi::parse(begin, end, p, m)) { // returns true if successful @@ -4621,6 +4625,19 @@ int Server::parse_quota_vxattr(string name, string value, quota_info_t *quota) return 0; } +void Server::create_quota_realm(CInode *in) +{ + dout(10) << __func__ << " " << *in << dendl; + + MClientRequest *req = new MClientRequest(CEPH_MDS_OP_SETXATTR); + req->set_filepath(filepath(in->ino())); + req->set_string2("ceph.quota"); + // empty vxattr value + req->set_tid(mds->issue_tid()); + + mds->send_message_mds(req, in->authority().first); +} + /* * Verify that the file layout attribute carried by client * is well-formatted. diff --git a/src/mds/Server.h b/src/mds/Server.h index 467aaccfd7cca..d57be3dd1c286 100644 --- a/src/mds/Server.h +++ b/src/mds/Server.h @@ -204,9 +204,10 @@ public: void handle_client_setlayout(MDRequestRef& mdr); void handle_client_setdirlayout(MDRequestRef& mdr); + int parse_quota_vxattr(string name, string value, quota_info_t *quota); + void create_quota_realm(CInode *in); int parse_layout_vxattr(string name, string value, const OSDMap& osdmap, file_layout_t *layout, bool validate=true); - int parse_quota_vxattr(string name, string value, quota_info_t *quota); int check_layout_vxattr(MDRequestRef& mdr, string name, string value, -- 2.39.5