Merge PR #36560 into master

* refs/pull/36560/head:
	client: choose a random replica mds to send the request

Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
This commit is contained in:
Patrick Donnelly 2020-08-21 18:44:46 -07:00
commit b092bdac82
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB
2 changed files with 16 additions and 3 deletions

View File

@ -84,6 +84,7 @@
#include "include/lru.h"
#include "include/compat.h"
#include "include/stringify.h"
#include "include/random.h"
#include "Client.h"
#include "Inode.h"
@ -1078,7 +1079,11 @@ void Client::update_dir_dist(Inode *in, DirStat *dst)
}
// replicated
in->dir_replicated = !dst->dist.empty(); // FIXME that's just one frag!
in->dir_replicated = !dst->dist.empty();
if (!dst->dist.empty())
in->frag_repmap[dst->frag].assign(dst->dist.begin(), dst->dist.end()) ;
else
in->frag_repmap.erase(dst->frag);
}
void Client::clear_dir_complete_and_ordered(Inode *diri, bool complete)
@ -1503,9 +1508,16 @@ mds_rank_t Client::choose_target_mds(MetaRequest *req, Inode** phash_diri)
ldout(cct, 20) << __func__ << " " << *in << " is_hash=" << is_hash
<< " hash=" << hash << dendl;
if (is_hash && S_ISDIR(in->mode) && !in->fragmap.empty()) {
if (is_hash && S_ISDIR(in->mode) && (!in->fragmap.empty() || !in->frag_repmap.empty())) {
frag_t fg = in->dirfragtree[hash];
if (in->fragmap.count(fg)) {
if (!req->auth_is_best()) {
auto repmapit = in->frag_repmap.find(fg);
if (repmapit != in->frag_repmap.end()) {
auto& repmap = repmapit->second;
auto r = ceph::util::generate_random_number<uint64_t>(0, repmap.size()-1);
mds = repmap.at(r);
}
} else if (in->fragmap.count(fg)) {
mds = in->fragmap[fg];
if (phash_diri)
*phash_diri = in;

View File

@ -227,6 +227,7 @@ struct Inode {
string symlink; // symlink content, if it's a symlink
map<string,bufferptr> xattrs;
map<frag_t,int> fragmap; // known frag -> mds mappings
map<frag_t, std::vector<mds_rank_t>> frag_repmap; // non-auth mds mappings
std::list<ceph::condition_variable*> waitfor_caps;
std::list<ceph::condition_variable*> waitfor_commit;