mirror of
https://github.com/ceph/ceph
synced 2025-02-24 19:47:44 +00:00
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:
commit
b092bdac82
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user