Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/common/options/mds.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -1555,3 +1555,27 @@ options:
- mds
flags:
- runtime
- name: mds_damage_log_to_file
type: bool
level: advanced
desc: send mds damage lines to a file
fmt_desc: Determines if damages should appear in a file.
default: false
see_also:
- log_file
with_legacy: true
- name: mds_damage_log_file
type: str
level: advanced
desc: path to log file where damage will be written
fmt_desc: The location of the logging file for where damage of mds will be written.
daemon_default: /var/log/ceph/$cluster-$name-damages.log
with_legacy: true
- name: mds_scrub_hard_link
type: bool
level: advanced
desc: force scrubbing hard link
default: false
services:
- mds
with_legacy: true
25 changes: 13 additions & 12 deletions src/mds/CDir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1585,8 +1585,8 @@ void CDir::fetch(std::string_view dname, snapid_t last,
mdcache->mds->balancer->hit_dir(this, META_POP_FETCH);
}

void CDir::fetch_keys(const std::vector<dentry_key_t>& keys, MDSContext *c)
{
void CDir::fetch_keys(const std::vector<dentry_key_t> &keys, MDSContext *c,
bool from_scrub) {
dout(10) << __func__ << " " << keys.size() << " keys on " << *this << dendl;
ceph_assert(is_auth());
ceph_assert(!is_complete());
Expand Down Expand Up @@ -1643,7 +1643,7 @@ void CDir::fetch_keys(const std::vector<dentry_key_t>& keys, MDSContext *c)
}

auth_pin(this);
_omap_fetch(&str_keys, c);
_omap_fetch(&str_keys, c, from_scrub);

if (mdcache->mds->logger)
mdcache->mds->logger->inc(l_mds_dir_fetch_keys);
Expand Down Expand Up @@ -1698,6 +1698,7 @@ class C_IO_Dir_OMAP_Fetched : public CDirIOContext {
map<string, bufferlist> omap;
bufferlist btbl;
int ret1, ret2, ret3;
bool from_scrub = false;

C_IO_Dir_OMAP_Fetched(CDir *d, MDSContext *f) :
CDirIOContext(d), fin(f),
Expand All @@ -1719,7 +1720,7 @@ class C_IO_Dir_OMAP_Fetched : public CDirIOContext {
return;
}

dir->_omap_fetched(hdrbl, omap, complete, keys, r);
dir->_omap_fetched(hdrbl, omap, complete, keys, r, from_scrub);
if (fin)
fin->complete(r);
}
Expand All @@ -1728,15 +1729,15 @@ class C_IO_Dir_OMAP_Fetched : public CDirIOContext {
}
};

void CDir::_omap_fetch(std::set<string> *keys, MDSContext *c)
{
void CDir::_omap_fetch(std::set<string> *keys, MDSContext *c, bool from_scrub) {
C_IO_Dir_OMAP_Fetched *fin = new C_IO_Dir_OMAP_Fetched(this, c);
object_t oid = get_ondisk_object();
object_locator_t oloc(mdcache->mds->mdsmap->get_metadata_pool());
ObjectOperation rd;
rd.omap_get_header(&fin->hdrbl, &fin->ret1);
if (keys) {
fin->complete = false;
fin->from_scrub = from_scrub;
fin->keys.swap(*keys);
rd.omap_get_vals_by_keys(fin->keys, &fin->omap, &fin->ret2);
} else {
Expand Down Expand Up @@ -1989,9 +1990,9 @@ CDentry *CDir::_load_dentry(
return dn;
}

void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
bool complete, const std::set<string>& keys, int r)
{
void CDir::_omap_fetched(bufferlist &hdrbl, map<string, bufferlist> &omap,
bool complete, const std::set<string> &keys, int r,
bool from_scrub) {
LogChannelRef clog = mdcache->mds->clog;
dout(10) << "_fetched header " << hdrbl.length() << " bytes "
<< omap.size() << " keys for " << *this << dendl;
Expand All @@ -2006,7 +2007,7 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
clog->error() << "dir " << dirfrag() << " object missing on disk; some "
"files may be lost (" << get_path() << ")";

go_bad(complete);
go_bad(complete | from_scrub);
return;
}

Expand All @@ -2020,14 +2021,14 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
<< ": " << err.what() << dendl;
clog->warn() << "Corrupt fnode header in " << dirfrag() << ": "
<< err.what() << " (" << get_path() << ")";
go_bad(complete);
go_bad(complete | from_scrub);
return;
}
if (!p.end()) {
clog->warn() << "header buffer of dir " << dirfrag() << " has "
<< hdrbl.length() - p.get_off() << " extra bytes ("
<< get_path() << ")";
go_bad(complete);
go_bad(complete | from_scrub);
return;
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/mds/CDir.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
void fetch(MDSContext *c, bool ignore_authpinnability=false) {
fetch("", CEPH_NOSNAP, c, ignore_authpinnability);
}
void fetch_keys(const std::vector<dentry_key_t>& keys, MDSContext *c);
void fetch_keys(const std::vector<dentry_key_t> &keys, MDSContext *c,
bool from_scrub = false);

#if 0 // unused?
void wait_for_commit(Context *c, version_t v=0);
Expand Down Expand Up @@ -653,7 +654,8 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
friend class C_IO_Dir_Committed;
friend class C_IO_Dir_Commit_Ops;

void _omap_fetch(std::set<std::string> *keys, MDSContext *fin=nullptr);
void _omap_fetch(std::set<std::string> *keys, MDSContext *fin = nullptr,
bool from_scrub = false);
void _omap_fetch_more(version_t omap_version, bufferlist& hdrbl,
std::map<std::string, bufferlist>& omap, MDSContext *fin);
CDentry *_load_dentry(
Expand All @@ -671,8 +673,10 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
*/
void go_bad(bool complete);

void _omap_fetched(ceph::buffer::list& hdrbl, std::map<std::string, ceph::buffer::list>& omap,
bool complete, const std::set<std::string>& keys, int r);
void _omap_fetched(ceph::buffer::list &hdrbl,
std::map<std::string, ceph::buffer::list> &omap,
bool complete, const std::set<std::string> &keys, int r,
bool from_scrub = false);

// -- commit --
void _commit(version_t want, int op_prio);
Expand Down
28 changes: 25 additions & 3 deletions src/mds/CInode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5198,7 +5198,6 @@ void CInode::scrub_info_create() const
{
dout(25) << __func__ << dendl;
ceph_assert(!scrub_infop);

// break out of const-land to set up implicit initial state
CInode *me = const_cast<CInode*>(this);
const auto& pi = me->get_projected_inode();
Expand Down Expand Up @@ -5231,23 +5230,46 @@ void CInode::scrub_initialize(ScrubHeaderRef& header)
// right now we don't handle remote inodes
}

void CInode::set_forward_scrub(bool forward_scrub) {
scrub_infop->forward_scrub = forward_scrub;
}

void CInode::scrub_add_remote_link(
std::vector<std::pair<std::string, inodeno_t>> &&remote_links) {

for (auto& [remote_link_path, remote_ino]: remote_links) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using a whole pair:
for (auto& p : remote_links) {
emplace_back(std::move(p));
}

scrub_infop->remote_links.emplace_back(std::move(remote_link_path),
remote_ino);
}
}

void CInode::scrub_reset_remote_links() {
scrub_infop->remote_links.clear();
}

std::vector<std::pair<std::string, inodeno_t>> &&
CInode::scrub_move_remote_links() {
return std::move(scrub_infop->remote_links);
}

void CInode::scrub_aborted() {
dout(20) << __func__ << dendl;
ceph_assert(scrub_is_in_progress());

scrub_infop->scrub_in_progress = false;
scrub_infop->header->dec_num_pending();
scrub_infop->remote_links.clear();
scrub_maybe_delete_info();
}

void CInode::scrub_finished() {
dout(20) << __func__ << dendl;
ceph_assert(scrub_is_in_progress());

scrub_infop->last_scrub_version = get_version();
scrub_infop->last_scrub_stamp = ceph_clock_now();
scrub_infop->last_scrub_dirty = true;
scrub_infop->scrub_in_progress = false;
scrub_infop->remote_links.clear();
scrub_infop->forward_scrub = true;
scrub_infop->header->dec_num_pending();
}

Expand Down
11 changes: 11 additions & 0 deletions src/mds/CInode.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno

bool last_scrub_dirty = false; /// are our stamps dirty with respect to disk state?
bool scrub_in_progress = false; /// are we currently scrubbing?
std::vector<std::pair<std::string, inodeno_t>> remote_links;
bool forward_scrub = true;

fragset_t queued_frags;

Expand Down Expand Up @@ -458,6 +460,15 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno

void scrub_aborted();

void scrub_add_remote_link(
std::vector<std::pair<std::string, inodeno_t>> &&remote_links);

void scrub_reset_remote_links();

std::vector<std::pair<std::string, inodeno_t>> &&scrub_move_remote_links();

void set_forward_scrub(bool forward_scrub);

fragset_t& scrub_queued_frags() {
ceph_assert(scrub_infop);
return scrub_infop->queued_frags;
Expand Down
Loading
Loading