mirror of
https://github.com/ceph/ceph
synced 2025-01-18 17:12:29 +00:00
Merge PR #35969 into master
* refs/pull/35969/head: mds: optimize random threshold lookup for dentry load Reviewed-by: Sidharth Anupkrishnan <sanupkri@redhat.com> Reviewed-by: Zheng Yan <zyan@redhat.com>
This commit is contained in:
commit
66b9bf0cd8
@ -1695,6 +1695,7 @@ CDentry *CDir::_load_dentry(
|
||||
bufferlist &bl,
|
||||
const int pos,
|
||||
const std::set<snapid_t> *snaps,
|
||||
double rand_threshold,
|
||||
bool *force_dirty)
|
||||
{
|
||||
auto q = bl.cbegin();
|
||||
@ -1857,7 +1858,7 @@ CDentry *CDir::_load_dentry(
|
||||
if (in->inode.is_dirty_rstat())
|
||||
in->mark_dirty_rstat();
|
||||
|
||||
in->maybe_ephemeral_rand(true);
|
||||
in->maybe_ephemeral_rand(true, rand_threshold);
|
||||
//in->hack_accessed = false;
|
||||
//in->hack_load_stamp = ceph_clock_now();
|
||||
//num_new_inodes_loaded++;
|
||||
@ -1969,6 +1970,7 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
|
||||
}
|
||||
|
||||
unsigned pos = omap.size() - 1;
|
||||
double rand_threshold = get_inode()->get_ephemeral_rand();
|
||||
for (map<string, bufferlist>::reverse_iterator p = omap.rbegin();
|
||||
p != omap.rend();
|
||||
++p, --pos) {
|
||||
@ -1980,7 +1982,7 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
|
||||
try {
|
||||
dn = _load_dentry(
|
||||
p->first, dname, last, p->second, pos, snaps,
|
||||
&force_dirty);
|
||||
rand_threshold, &force_dirty);
|
||||
} catch (const buffer::error &err) {
|
||||
cache->mds->clog->warn() << "Corrupt dentry '" << dname << "' in "
|
||||
"dir frag " << dirfrag() << ": "
|
||||
|
@ -646,6 +646,7 @@ protected:
|
||||
ceph::buffer::list &bl,
|
||||
int pos,
|
||||
const std::set<snapid_t> *snaps,
|
||||
double rand_threshold,
|
||||
bool *force_dirty);
|
||||
|
||||
/**
|
||||
|
@ -5388,7 +5388,7 @@ void CInode::set_ephemeral_rand(bool yes)
|
||||
}
|
||||
}
|
||||
|
||||
void CInode::maybe_ephemeral_rand(bool fresh)
|
||||
void CInode::maybe_ephemeral_rand(bool fresh, double threshold)
|
||||
{
|
||||
if (!mdcache->get_export_ephemeral_random_config()) {
|
||||
dout(15) << __func__ << " config false: cannot ephemeral random pin " << *this << dendl;
|
||||
@ -5410,7 +5410,13 @@ void CInode::maybe_ephemeral_rand(bool fresh)
|
||||
return;
|
||||
}
|
||||
|
||||
double threshold = get_ephemeral_rand();
|
||||
/* not precomputed? */
|
||||
if (threshold < 0.0) {
|
||||
threshold = get_ephemeral_rand();
|
||||
}
|
||||
if (threshold <= 0.0) {
|
||||
return;
|
||||
}
|
||||
double n = ceph::util::generate_random_number(0.0, 1.0);
|
||||
|
||||
dout(15) << __func__ << " rand " << n << " <?= " << threshold
|
||||
|
@ -942,7 +942,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
|
||||
|
||||
double get_ephemeral_rand(bool inherit=true) const;
|
||||
void set_ephemeral_rand(bool yes);
|
||||
void maybe_ephemeral_rand(bool fresh=false);
|
||||
void maybe_ephemeral_rand(bool fresh=false, double threshold=-1.0);
|
||||
void setxattr_ephemeral_rand(double prob=0.0);
|
||||
bool is_ephemeral_rand() const {
|
||||
return state_test(STATE_RANDEPHEMERALPIN);
|
||||
|
Loading…
Reference in New Issue
Block a user