]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: log path with CDir damage messages 10996/head
authorJohn Spray <john.spray@redhat.com>
Tue, 6 Sep 2016 12:16:04 +0000 (13:16 +0100)
committerJohn Spray <john.spray@redhat.com>
Wed, 7 Sep 2016 14:02:51 +0000 (15:02 +0100)
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 <john.spray@redhat.com>
src/mds/CDir.cc
src/mds/CDir.h

index b5ef08b64718ac9664de3e381aac03dbad19b2d2..cb74fa02609c1db55ad9e862c1dd904279117b05 100644 (file)
@@ -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";
@@ -1729,7 +1727,9 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
 
   if (hdrbl.length() == 0) {
     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(complete);
     return;
@@ -1744,13 +1744,14 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
       derr << "Corrupt fnode in dirfrag " << dirfrag()
         << ": " << err << dendl;
       clog->warn() << "Corrupt fnode header in " << dirfrag() << ": "
-                 << err;
+                 << err << " (" << get_path() << ")";
       go_bad(complete);
       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(complete);
       return;
     }
@@ -1809,7 +1810,7 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& 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
@@ -2869,9 +2870,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);
@@ -3134,3 +3133,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;
+}
+
index 7db2a7d77e2341aa928e74e0c6edad16e9eb9d12..a914afb790d25cb866409ccfc991514d56496c3d 100644 (file)
@@ -41,6 +41,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!
@@ -509,6 +511,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; }