add '.healing.bin' for tracking currently healing disk (#10573)

add a hint on the disk to allow for tracking fresh disk
being healed, to allow for restartable heals, and also
use this as a way to track and remove disks.

There are more pending changes where we should move
all the disk formatting logic to backend drives, this
PR doesn't deal with this refactor instead makes it
easier to track healing in the future.
This commit is contained in:
Harshavardhana
2020-09-28 19:39:32 -07:00
committed by GitHub
parent 849fcf0127
commit 66174692a2
24 changed files with 521 additions and 172 deletions

View File

@@ -92,8 +92,7 @@ type xlStorage struct {
activeIOCount int32
diskPath string
hostname string
endpoint string
endpoint Endpoint
pool sync.Pool
@@ -249,7 +248,6 @@ func newLocalXLStorage(path string) (*xlStorage, error) {
// Initialize a new storage disk.
func newXLStorage(ep Endpoint) (*xlStorage, error) {
path := ep.Path
hostname := ep.Host
var err error
if path, err = getValidPath(path, true); err != nil {
return nil, err
@@ -262,8 +260,7 @@ func newXLStorage(ep Endpoint) (*xlStorage, error) {
p := &xlStorage{
diskPath: path,
hostname: hostname,
endpoint: ep.String(),
endpoint: ep,
pool: sync.Pool{
New: func() interface{} {
b := disk.AlignedBlock(readBlockSize)
@@ -319,7 +316,11 @@ func (s *xlStorage) String() string {
}
func (s *xlStorage) Hostname() string {
return s.hostname
return s.endpoint.Host
}
func (s *xlStorage) Endpoint() Endpoint {
return s.endpoint
}
func (*xlStorage) Close() error {
@@ -334,6 +335,13 @@ func (s *xlStorage) IsLocal() bool {
return true
}
func (s *xlStorage) Healing() bool {
healingFile := pathJoin(s.diskPath, minioMetaBucket,
bucketMetaPrefix, healingTrackerFilename)
_, err := os.Stat(healingFile)
return err == nil
}
func (s *xlStorage) waitForLowActiveIO() {
max := lowActiveIOWaitMaxN
for atomic.LoadInt32(&s.activeIOCount) >= s.maxActiveIOCount {
@@ -439,6 +447,7 @@ type DiskInfo struct {
Free uint64
Used uint64
RootDisk bool
Healing bool
Endpoint string
MountPath string
ID string
@@ -462,9 +471,10 @@ func (s *xlStorage) DiskInfo(context.Context) (info DiskInfo, err error) {
Total: di.Total,
Free: di.Free,
Used: di.Total - di.Free,
Healing: s.Healing(),
RootDisk: s.rootDisk,
MountPath: s.diskPath,
Endpoint: s.endpoint,
Endpoint: s.endpoint.String(),
}
diskID, err := s.GetDiskID()