Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New FSCK work and error for BCNT for bad devcount values (they would …

…not otherwise be caught unless the triggered another fix).

git-svn-id: http://code.sixapart.com/svn/mogilefs/trunk@1283 f67b2e87-0811-0410-a7e0-dd94e48410d6
  • Loading branch information...
commit cc2d8b32154f67ef08df55e363e66a5c16b10e22 1 parent 52058b9
robbat2 authored
View
3  CHANGES
@@ -1,3 +1,6 @@
+ * New FSCK work and error for BCNT for bad devcount values (they would
+ not otherwise be caught unless the triggered another fix).
+
2009-01-12: Release version 2.30
* fsck will now fix broken 'devcount' cols.
View
3  TODO
@@ -93,8 +93,5 @@
:: [replicate(12648)] Copier failed replicating 15693848
......
--- fsck should catch weird state where file exists in 'file' table with
- devcount>0 but does not exist in file_on. Or count does not match.
-
-- fsck for case where row from file_to_replicate(fid,fromdevid) does not exist
in file_on(fid,devid). This is a byproduct of a failed inject.
View
1  lib/MogileFS/FID.pm
@@ -14,6 +14,7 @@ sub new {
dkey => undef,
length => undef,
classid => undef,
+ devcount => undef,
_loaded => 0,
_devids => undef, # undef, or pre-loaded arrayref devid list
}, $class;
View
6 lib/MogileFS/Store.pm
@@ -933,8 +933,8 @@ sub file_row_from_fidid {
# classid, devcount" provided a pair of $fidid or undef if no rows.
sub file_row_from_fidid_range {
my ($self, $fromfid, $tofid) = @_;
- my $sth = $self->dbh->prepare("SELECT fid, dmid, dkey, length, classid, devcount ".
- "FROM file WHERE fid BETWEEN ? AND ?");
+ my $sth = $self->dbh->prepare("SELECT fid, dmid, dkey, length, classid, devcount ".
+ "FROM file WHERE fid BETWEEN ? AND ?");
$sth->execute($fromfid,$tofid);
return $sth->fetchall_arrayref({});
}
@@ -1237,7 +1237,7 @@ sub get_fids_above_id {
my @ret;
my $dbh = $self->dbh;
- my $sth = $dbh->prepare("SELECT fid, dmid, dkey, length, classid ".
+ my $sth = $dbh->prepare("SELECT fid, dmid, dkey, length, classid, devcount ".
"FROM file ".
"WHERE fid > ? ".
"ORDER BY fid LIMIT $limit");
View
17 lib/MogileFS/Worker/Fsck.pm
@@ -25,6 +25,7 @@ use constant EV_CANT_FIX => "GONE";
use constant EV_START_SEARCH => "SRCH";
use constant EV_FOUND_FID => "FOND";
use constant EV_RE_REPLICATE => "REPL";
+use constant EV_BAD_COUNT => "BCNT";
use POSIX ();
@@ -200,6 +201,16 @@ sub check_fid {
return $fix->();
}
+ # This is a simple fixup case
+ unless (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->();
+ }
+
# in the fast case, do nothing else (don't check if assumed file
# locations are actually there). in the fast case, all we do is
# check the replication policy, which is already done, so finish.
@@ -341,6 +352,12 @@ sub fix_fid {
$fid->fsck_log(EV_RE_REPLICATE);
return HANDLED;
}
+
+ # Clean up the device count if it's wrong
+ unless(scalar($fid->devids) == $fid->devcount) {
+ $fid->update_devcount();
+ $fid->fsck_log(EV_BAD_COUNT);
+ }
return HANDLED;
}
Please sign in to comment.
Something went wrong with that request. Please try again.