3220: Adjust disk corruption behavior: If both corrupt and intact
authorTom Clegg <tom@curoverse.com>
Thu, 10 Jul 2014 17:34:44 +0000 (13:34 -0400)
committerTom Clegg <tom@curoverse.com>
Thu, 10 Jul 2014 17:34:44 +0000 (13:34 -0400)
copies exist, log the corruption when noticed, but return the intact
copy to the client instead of an error.

services/keep/src/keep/keep.go

index 4be2f43cb821577332b7c84c56522b69a9a0b69e..de1c2401321f30763dcf8b6bb936a0be5965bf02 100644 (file)
@@ -572,12 +572,13 @@ func GetVolumeStatus(volume string) *VolumeStatus {
 
 func GetBlock(hash string) ([]byte, error) {
        // Attempt to read the requested hash from a keep volume.
+       error_to_caller := NotFoundError
+
        for _, vol := range KeepVM.Volumes() {
                if buf, err := vol.Get(hash); err != nil {
                        // IsNotExist is an expected error and may be ignored.
                        // (If all volumes report IsNotExist, we return a NotFoundError)
-                       // A CorruptError should be returned immediately.
-                       // Any other errors should be logged but we continue trying to
+                       // All other errors should be logged but we continue trying to
                        // read.
                        switch {
                        case os.IsNotExist(err):
@@ -597,14 +598,15 @@ func GetBlock(hash string) ([]byte, error) {
                                //
                                log.Printf("%s: checksum mismatch for request %s (actual %s)\n",
                                        vol, hash, filehash)
-                               return buf, CorruptError
+                               error_to_caller := DiskHashError
+                       } else {
+                               // Success!
+                               return buf, nil
                        }
-                       // Success!
-                       return buf, nil
                }
        }
 
-       return nil, NotFoundError
+       return nil, error_to_caller
 }
 
 /* PutBlock(block, hash)