From: John Spray Date: Tue, 6 Sep 2016 12:16:04 +0000 (+0100) Subject: mds: log path with CDir damage messages X-Git-Tag: v10.2.4~67^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F11418%2Fhead;p=ceph.git mds: log path with CDir damage messages Previously you just got the inode number, which wasn't terribly useful for e.g. a missing fragment object, as you couldn't readily resolve the parent path. Fixes: http://tracker.ceph.com/issues/16973 Signed-off-by: John Spray (cherry picked from commit 439cd5e1b4725e594786785189a37184243828d9) Conflicts: src/mds/CDir.cc: the go_bad() prototype which is part of the context of the patch has changed. --- diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index fcae684f677f..8b241e3b1a2a 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -78,9 +78,7 @@ boost::pool<> CDir::pool(sizeof(CDir)); ostream& operator<<(ostream& out, const CDir& dir) { - string path; - dir.get_inode()->make_path_string_projected(path); - out << "[dir " << dir.dirfrag() << " " << path << "/" + out << "[dir " << dir.dirfrag() << " " << dir.get_path() << "/" << " [" << dir.first << ",head]"; if (dir.is_auth()) { out << " auth"; @@ -1753,7 +1751,9 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, } dout(0) << "_fetched missing object for " << *this << dendl; - clog->error() << "dir " << dirfrag() << " object missing on disk; some files may be lost\n"; + + clog->error() << "dir " << dirfrag() << " object missing on disk; some " + "files may be lost (" << get_path() << ")"; go_bad(); return; @@ -1768,13 +1768,14 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, derr << "Corrupt fnode in dirfrag " << dirfrag() << ": " << err << dendl; clog->warn() << "Corrupt fnode header in " << dirfrag() << ": " - << err; + << err << " (" << get_path() << ")"; go_bad(); return; } if (!p.end()) { clog->warn() << "header buffer of dir " << dirfrag() << " has " - << hdrbl.length() - p.get_off() << " extra bytes\n"; + << hdrbl.length() - p.get_off() << " extra bytes (" + << get_path() << ")"; go_bad(); return; } @@ -1833,7 +1834,7 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, } catch (const buffer::error &err) { cache->mds->clog->warn() << "Corrupt dentry '" << dname << "' in " "dir frag " << dirfrag() << ": " - << err; + << err << "(" << get_path() << ")"; // Remember that this dentry is damaged. Subsequent operations // that try to act directly on it will get their EIOs, but this @@ -2887,9 +2888,7 @@ void CDir::dump(Formatter *f) const { assert(f != NULL); - string path; - get_inode()->make_path_string_projected(path); - f->dump_stream("path") << path; + f->dump_stream("path") << get_path(); f->dump_stream("dirfrag") << dirfrag(); f->dump_int("snapid_first", first); @@ -3152,3 +3151,11 @@ bool CDir::scrub_local() } return rval; } + +std::string CDir::get_path() const +{ + std::string path; + get_inode()->make_path_string_projected(path); + return path; +} + diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 7b6d4888f867..8533ba8c1d24 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -42,6 +42,8 @@ struct ObjectOperation; ostream& operator<<(ostream& out, const class CDir& dir); class CDir : public MDSCacheObject { + friend ostream& operator<<(ostream& out, const class CDir& dir); + /* * This class uses a boost::pool to handle allocation. This is *not* * thread-safe, so don't do allocations from multiple threads! @@ -510,6 +512,8 @@ private: */ mds_authority_t dir_auth; + std::string get_path() const; + public: mds_authority_t authority() const; mds_authority_t get_dir_auth() const { return dir_auth; }