From 200d327737d4020c5a0caa0ee04b558247a2193a Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Wed, 24 Aug 2016 18:13:01 +0100 Subject: [PATCH] List only objects that need healing (#2546) --- cmd/xl-v1-healing.go | 2 +- cmd/xl-v1-list-objects-heal.go | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/xl-v1-healing.go b/cmd/xl-v1-healing.go index a9c5b9d1d..d7ba14990 100644 --- a/cmd/xl-v1-healing.go +++ b/cmd/xl-v1-healing.go @@ -134,7 +134,7 @@ func xlLatestMetadata(partsMetadata []xlMetaV1, errs []error) (latestMeta xlMeta func xlShouldHeal(partsMetadata []xlMetaV1, errs []error) bool { modTime := commonTime(listObjectModtimes(partsMetadata, errs)) for index := range partsMetadata { - if errs[index] == errFileNotFound { + if errs[index] == errDiskNotFound { return true } if errs[index] != nil { diff --git a/cmd/xl-v1-list-objects-heal.go b/cmd/xl-v1-list-objects-heal.go index 577ad453f..148ce666a 100644 --- a/cmd/xl-v1-list-objects-heal.go +++ b/cmd/xl-v1-list-objects-heal.go @@ -137,12 +137,18 @@ func (xl xlObjects) listObjectsHeal(bucket, prefix, marker, delimiter string, ma result.Prefixes = append(result.Prefixes, objInfo.Name) continue } - result.Objects = append(result.Objects, ObjectInfo{ - Name: objInfo.Name, - ModTime: objInfo.ModTime, - Size: objInfo.Size, - IsDir: false, - }) + // Check if the current object needs healing + nsMutex.RLock(bucket, objInfo.Name) + partsMetadata, errs := readAllXLMetadata(xl.storageDisks, bucket, objInfo.Name) + if xlShouldHeal(partsMetadata, errs) { + result.Objects = append(result.Objects, ObjectInfo{ + Name: objInfo.Name, + ModTime: objInfo.ModTime, + Size: objInfo.Size, + IsDir: false, + }) + } + nsMutex.RUnlock(bucket, objInfo.Name) } return result, nil }