From 56ff97b6cedb532aa5ffec1c798ce1401d050677 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 12 May 2012 02:54:39 +0000 Subject: [PATCH] fsck: cleanup and reduce unnecessary devcount updates fix_fid(): we no longer rely blindly update devcount on every call. This is important because we call fix_fid() on checksum checks regardless, and devcount updates entail unnecessary updates to the `file' table. While we're at it, consolidate the places where we check the skip_devcount flag and log bad devcounts. --- lib/MogileFS/Worker/Fsck.pm | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/MogileFS/Worker/Fsck.pm b/lib/MogileFS/Worker/Fsck.pm index 36ca475..82afbc6 100644 --- a/lib/MogileFS/Worker/Fsck.pm +++ b/lib/MogileFS/Worker/Fsck.pm @@ -137,14 +137,9 @@ sub check_fid { } # This is a simple fixup case - unless (MogileFS::Config->server_setting_cached('skip_devcount') || scalar($fid->devids) == $fid->devcount) { - # log a bad count - $fid->fsck_log(EV_BAD_COUNT); - - # TODO: We could fix this without a complete fix pass - # $fid->update_devcount(); - return $fix->(); - } + # If we got here, we already know we have no policy violation and + # don't need to call $fix->() to just fix a devcount + $self->maybe_fix_devcount($fid); # missing checksum row if ($fid->class->hashtype && ! $fid->checksum) { @@ -217,9 +212,6 @@ sub fix_fid { my ($self, $fid) = @_; debug(sprintf("Fixing FID %d", $fid->id)); - # This should happen first, since the fid gets awkwardly reloaded... - $fid->update_devcount; - # make devfid objects from the devids that this fid is on, my @dfids = map { MogileFS::DevFID->new($_, $fid) } $fid->devids; @@ -332,10 +324,7 @@ sub fix_fid { } # Clean up the device count if it's wrong - unless(MogileFS::Config->server_setting_cached('skip_devcount') || scalar($fid->devids) == $fid->devcount) { - $fid->update_devcount(); - $fid->fsck_log(EV_BAD_COUNT); - } + $self->maybe_fix_devcount($fid); return HANDLED; } @@ -458,6 +447,17 @@ sub forget_bad_devs { } } +sub maybe_fix_devcount { + # don't even log BCNT errors if skip_devcount is enabled + return if MogileFS::Config->server_setting_cached('skip_devcount'); + + my ($self, $fid) = @_; + return if scalar($fid->devids) == $fid->devcount; + # log a bad count + $fid->fsck_log(EV_BAD_COUNT); + $fid->update_devcount(); +} + 1; # Local Variables: -- 2.11.4.GIT