]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: _getattr on quota_root before using in statfs
authorJohn Spray <john.spray@redhat.com>
Wed, 15 Mar 2017 17:51:44 +0000 (17:51 +0000)
committerJohn Spray <john.spray@redhat.com>
Fri, 14 Apr 2017 10:38:48 +0000 (06:38 -0400)
...so that after someone adjusts the quota settings
on an inode that another client is using as its mount root,
the change is visible immediately on the other client.

Signed-off-by: John Spray <john.spray@redhat.com>
src/client/Client.cc
src/client/Client.h

index 386650dfb240b7ea39e33ab6ca25d0827c6fdc7d..ccdd5c34f3fab510e1fbb623fa3e41d4560a20b2 100644 (file)
@@ -2110,6 +2110,19 @@ void Client::handle_client_session(MClientSession *m)
   m->put();
 }
 
+bool Client::_any_stale_sessions() const
+{
+  assert(client_lock.is_locked_by_me());
+
+  for (const auto &i : mds_sessions) {
+    if (i.second->state == MetaSession::STATE_STALE) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
 void Client::_kick_stale_sessions()
 {
   ldout(cct, 1) << "kick_stale_sessions" << dendl;
@@ -9336,6 +9349,21 @@ int Client::statfs(const char *path, struct statvfs *stbuf,
   assert(cct->_conf->client_quota == false || quota_root != nullptr);
 
   if (quota_root && cct->_conf->client_quota_df && quota_root->quota.max_bytes) {
+
+    // Skip the getattr if any sessions are stale, as we don't want to
+    // block `df` if this client has e.g. been evicted, or if the MDS cluster
+    // is unhealthy.
+    if (!_any_stale_sessions()) {
+      int r = _getattr(quota_root, 0, perms, true);
+      if (r != 0) {
+        // Ignore return value: error getting latest inode metadata is not a good
+        // reason to break "df".
+        lderr(cct) << "Error in getattr on quota root 0x"
+                   << std::hex << quota_root->ino << std::dec
+                   << " statfs result may be outdated" << dendl;
+      }
+    }
+
     // Special case: if there is a size quota set on the Inode acting
     // as the root for this client mount, then report the quota status
     // as the filesystem statistics.
index 412c00d419d6b89282ea252d450b7054c5d17b2a..236ca90d995e0cb4f0e2a5af572be512e575a775 100644 (file)
@@ -339,6 +339,7 @@ protected:
   MetaSession *_open_mds_session(mds_rank_t mds);
   void _close_mds_session(MetaSession *s);
   void _closed_mds_session(MetaSession *s);
+  bool _any_stale_sessions() const;
   void _kick_stale_sessions();
   void handle_client_session(MClientSession *m);
   void send_reconnect(MetaSession *s);