From 55b29e540572ed38ade913d3710119e30e6a3d75 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 27 Nov 2011 09:17:26 +0000 Subject: [PATCH] replication skips HTTPFile->digest if device can reject bad MD5s Rereading a large file is expensive. If we can monitor and observe our storage nodes for MD5 rejectionability, we can rely on that instead of having to have anybody reread the entire file to calculate its MD5. --- lib/MogileFS/Worker/Replicate.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/MogileFS/Worker/Replicate.pm b/lib/MogileFS/Worker/Replicate.pm index 7dbd712f..46c4a371 100644 --- a/lib/MogileFS/Worker/Replicate.pm +++ b/lib/MogileFS/Worker/Replicate.pm @@ -705,6 +705,12 @@ sub http_copy { if ($1 >= 200 && $1 <= 299) { if ($digest) { my $alg = $rfid->class->checksumname; + + if ($ddev->{reject_bad_md5} && ($alg eq "MD5")) { + # dest device would've rejected us with a error, + # no need to reread the file + return 1; + } my $durl = "http://$dhostip:$dport$dpath"; my $actual = MogileFS::HTTPFile->at($durl)->digest($alg); if ($actual ne $digest) {