From 9a961e607a9c8465b67a42e1279d6936c9678b32 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 20 Oct 2016 11:49:42 +0100 Subject: [PATCH] mds: repair backtraces during scrub Fixes: http://tracker.ceph.com/issues/17639 Signed-off-by: John Spray --- src/mds/CInode.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 5dcdcb1577f2f..a4fc03b1403c9 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -3813,6 +3813,9 @@ void CInode::validate_disk_state(CInode::validated_data *results, bool equivalent, divergent; int memory_newer; + MDCache *mdcache = in->mdcache; // For the benefit of dout + const inode_t& inode = in->inode; // For the benefit of dout + // Ignore rval because it's the result of a FAILOK operation // from fetch_backtrace_and_tag: the real result is in // backtrace.ondisk_read_retval @@ -3825,6 +3828,7 @@ void CInode::validate_disk_state(CInode::validated_data *results, try { bufferlist::iterator p = bl.begin(); ::decode(results->backtrace.ondisk_value, p); + dout(10) << "decoded " << bl.length() << " bytes of backtrace successfully" << dendl; } catch (buffer::error&) { if (results->backtrace.ondisk_read_retval == 0 && rval != 0) { // Cases where something has clearly gone wrong with the overall @@ -3851,11 +3855,19 @@ void CInode::validate_disk_state(CInode::validated_data *results, } } next: + + if (!results->backtrace.passed && in->scrub_infop->header->get_repair()) { + std::string path; + in->make_path_string(path); + in->mdcache->mds->clog->warn() << "bad backtrace on inode " << *in + << ", rewriting it at " << path; + in->_mark_dirty_parent(in->mdcache->mds->mdlog->get_current_segment(), + false); + } + // If the inode's number was free in the InoTable, fix that // (#15619) { - const inode_t& inode = in->inode; - MDCache *mdcache = in->mdcache; InoTable *inotable = mdcache->mds->inotable; dout(10) << "scrub: inotable ino = 0x" << std::hex << inode.ino << dendl; -- 2.39.5