From b79f5623c214ab78f6771207d5676e176d060e9d Mon Sep 17 00:00:00 2001 From: Zhi Zhang Date: Wed, 16 May 2018 11:21:48 +0800 Subject: [PATCH] mds: broadcast quota to relevant clients when quota is explicitly set Try to broadcast quota to relevant clients proactively if quota is explicitly set by someone, in case that client won't get quota update for a long time. Fixes: http://tracker.ceph.com/issues/24133 Signed-off-by: Zhi Zhang (cherry picked from commit b2a7643b102dbbb8221dcb8a785db5e4276ac284) --- src/mds/MDCache.cc | 6 +++++- src/mds/MDCache.h | 2 +- src/mds/Server.cc | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index c10cc2fe4f8d5..3e338076d7999 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -1963,7 +1963,7 @@ void MDCache::project_rstat_frag_to_inode(nest_info_t& rstat, nest_info_t& accou } } -void MDCache::broadcast_quota_to_client(CInode *in) +void MDCache::broadcast_quota_to_client(CInode *in, client_t exclude_ct) { if (!in->is_auth() || in->is_frozen()) return; @@ -1982,6 +1982,10 @@ void MDCache::broadcast_quota_to_client(CInode *in) continue; Capability *cap = it->second; + + if (exclude_ct >= 0 && exclude_ct != it->first) + goto update; + if (cap->last_rbytes == i->rstat.rbytes && cap->last_rsize == i->rstat.rsize()) continue; diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 3d3f9686414b3..e554264c47b09 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -402,7 +402,7 @@ public: void project_rstat_frag_to_inode(nest_info_t& rstat, nest_info_t& accounted_rstat, snapid_t ofirst, snapid_t last, CInode *pin, bool cow_head); - void broadcast_quota_to_client(CInode *in); + void broadcast_quota_to_client(CInode *in, client_t exclude_ct = -1); void predirty_journal_parents(MutationRef mut, EMetaBlob *blob, CInode *in, CDir *parent, int flags, int linkunlink=0, diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 5132ece9e57cd..c437d68aa0703 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -4675,6 +4675,9 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur, mdr->no_early_reply = true; pip = &pi.inode; + + client_t exclude_ct = mdr->get_client(); + mdcache->broadcast_quota_to_client(cur, exclude_ct); } else if (name.find("ceph.dir.pin") == 0) { if (!cur->is_dir() || cur->is_root()) { respond_to_request(mdr, -EINVAL); -- 2.39.5