From: John Spray Date: Wed, 15 Mar 2017 17:51:44 +0000 (+0000) Subject: client: _getattr on quota_root before using in statfs X-Git-Tag: v10.2.8~24^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8b8ee392b8093b9b140dbbe895691f69ae40440f;p=ceph.git client: _getattr on quota_root before using in statfs ...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 (cherry picked from commit 3d25941aadd223669448d0f5d3c0bd1fefa72308) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 840958e528a9..0a124b370ce1 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2102,6 +2102,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; @@ -8916,6 +8929,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. diff --git a/src/client/Client.h b/src/client/Client.h index 51376c0e51ee..31231329783c 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -345,6 +345,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);