Skip to content

Commit

Permalink
osd: Add stat_error for regular scrub handling
Browse files Browse the repository at this point in the history
Signed-off-by: David Zafman <dzafman@redhat.com>
  • Loading branch information
dzafman committed Nov 23, 2015
1 parent 00a4af9 commit 6221382
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
19 changes: 10 additions & 9 deletions src/osd/PGBackend.cc
Expand Up @@ -353,7 +353,7 @@ void PGBackend::be_scan_list(
dout(25) << __func__ << " " << poid << " got " << r
<< ", read_error" << dendl;
ScrubMap::object &o = map.objects[poid];
o.read_error = true;
o.stat_error = true;
} else {
derr << __func__ << " got: " << cpp_strerror(r) << dendl;
assert(0);
Expand All @@ -370,9 +370,11 @@ enum scrub_error_type PGBackend::be_compare_scrub_objects(
ostream &errorstream)
{
enum scrub_error_type error = CLEAN;
if (candidate.stat_error) {
error = SHALLOW_ERROR;
errorstream << "candidate had a stat error";
}
if (candidate.read_error) {
// This can occur on stat() of a shallow scrub, but in that case size will
// be invalid, and this will be over-ridden below.
error = DEEP_ERROR;
errorstream << "candidate had a read error";
}
Expand Down Expand Up @@ -404,9 +406,7 @@ enum scrub_error_type PGBackend::be_compare_scrub_objects(
<< " from auth shard " << auth_shard;
}
}
// Shallow error takes precendence because this will be seen by
// both types of scrubs.
if (auth.size != candidate.size) {
if (!candidate.stat_error && auth.size != candidate.size) {
if (error != CLEAN)
errorstream << ", ";
if (error != DEEP_ERROR)
Expand Down Expand Up @@ -464,11 +464,12 @@ map<pg_shard_t, ScrubMap *>::const_iterator
if (i == j->second->objects.end()) {
continue;
}
if (i->second.read_error) {
// scrub encountered read error, probably corrupt
if (i->second.read_error || i->second.stat_error) {
// scrub encountered read error or stat_error, probably corrupt
dout(10) << __func__ << ": rejecting osd " << j->first
<< " for obj " << obj
<< ", read_error"
<< "," << (i->second.read_error ? " read_error" : "")
<< (i->second.stat_error ? " stat_error" : "")
<< dendl;
continue;
}
Expand Down
8 changes: 6 additions & 2 deletions src/osd/osd_types.cc
Expand Up @@ -5089,7 +5089,7 @@ void ScrubMap::generate_test_instances(list<ScrubMap*>& o)

void ScrubMap::object::encode(bufferlist& bl) const
{
ENCODE_START(6, 2, bl);
ENCODE_START(7, 2, bl);
::encode(size, bl);
::encode(negative, bl);
::encode(attrs, bl);
Expand All @@ -5100,12 +5100,13 @@ void ScrubMap::object::encode(bufferlist& bl) const
::encode(omap_digest, bl);
::encode(omap_digest_present, bl);
::encode(read_error, bl);
::encode(stat_error, bl);
ENCODE_FINISH(bl);
}

void ScrubMap::object::decode(bufferlist::iterator& bl)
{
DECODE_START_LEGACY_COMPAT_LEN(6, 2, 2, bl);
DECODE_START_LEGACY_COMPAT_LEN(7, 2, 2, bl);
::decode(size, bl);
::decode(negative, bl);
::decode(attrs, bl);
Expand All @@ -5128,6 +5129,9 @@ void ScrubMap::object::decode(bufferlist::iterator& bl)
if (struct_v >= 6) {
::decode(read_error, bl);
}
if (struct_v >= 7) {
::decode(stat_error, bl);
}
DECODE_FINISH(bl);
}

Expand Down
3 changes: 2 additions & 1 deletion src/osd/osd_types.h
Expand Up @@ -3697,12 +3697,13 @@ struct ScrubMap {
__u32 omap_digest; ///< omap crc32c
bool omap_digest_present;
bool read_error;
bool stat_error;

object() :
// Init invalid size so it won't match if we get a stat EIO error
size(-1), negative(false), digest(0), digest_present(false),
nlinks(0), omap_digest(0), omap_digest_present(false),
read_error(false) {}
read_error(false), stat_error(false) {}

void encode(bufferlist& bl) const;
void decode(bufferlist::iterator& bl);
Expand Down

0 comments on commit 6221382

Please sign in to comment.