]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: automatically create snaprealm for old format quota 21255/head
authorYan, Zheng <zyan@redhat.com>
Thu, 5 Apr 2018 00:44:12 +0000 (08:44 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 5 Apr 2018 03:12:35 +0000 (11:12 +0800)
The new quota format requires that quota inodes have snaprealm.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
Fixes: http://tracker.ceph.com/issues/23491
src/mds/MDCache.cc
src/mds/Server.cc
src/mds/Server.h

index 0222f41d4c3d6e0b5692d4b5a1ce0cc09aafc926..80244b4745c8b0a19afe025f51d94ff667131a50 100644 (file)
@@ -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<client_t,Capability*>::iterator it = in->client_caps.begin();
        it != in->client_caps.end();
        ++it) {
index 2fdc623855a825208b1f3352071106fa7b93c55d..34e22ff0c7304755fc5d29ee362bc3be4f41714e 100644 (file)
@@ -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<string::iterator> p;    // create instance of parser
       std::map<string, string> 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.
index 467aaccfd7ccae4169d1cbaa77f459f6bf778de5..d57be3dd1c286a3ab3aa72fefe49a1a586d57840 100644 (file)
@@ -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,