mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 07:43:29 +03:00
XL: CreateFile/ReadFile should write and read from all disks in parallel. (#1612)
* XL: CreateFile should write to all disks in parallel. * XL: ReadFile should read from all disks in parallel.
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
7264cd2ab3
commit
025054fb36
+23
-12
@@ -20,6 +20,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
slashpath "path"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
@@ -199,24 +200,34 @@ func (xl XL) writeErasure(volume, path string, reader *io.PipeReader, wcloser *w
|
||||
return
|
||||
}
|
||||
|
||||
var wg = &sync.WaitGroup{}
|
||||
var wErrs = make([]error, len(writers))
|
||||
// Loop through and write encoded data to quorum disks.
|
||||
for index, writer := range writers {
|
||||
if writer == nil {
|
||||
continue
|
||||
}
|
||||
encodedData := dataBlocks[index]
|
||||
_, err = writers[index].Write(encodedData)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": volume,
|
||||
"path": path,
|
||||
"diskIndex": index,
|
||||
}).Errorf("Writing encoded blocks failed with %s", err)
|
||||
// Remove all temp writers upon error.
|
||||
xl.cleanupCreateFileOps(volume, path, append(writers, metadataWriters...)...)
|
||||
reader.CloseWithError(err)
|
||||
return
|
||||
wg.Add(1)
|
||||
go func(index int, writer io.Writer) {
|
||||
defer wg.Done()
|
||||
encodedData := dataBlocks[index]
|
||||
_, wErr := writers[index].Write(encodedData)
|
||||
wErrs[index] = wErr
|
||||
}(index, writer)
|
||||
}
|
||||
wg.Wait()
|
||||
for _, wErr := range wErrs {
|
||||
if wErr == nil {
|
||||
continue
|
||||
}
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": volume,
|
||||
"path": path,
|
||||
}).Errorf("Writing encoded blocks failed with %s", wErr)
|
||||
// Remove all temp writers upon error.
|
||||
xl.cleanupCreateFileOps(volume, path, append(writers, metadataWriters...)...)
|
||||
reader.CloseWithError(wErr)
|
||||
return
|
||||
}
|
||||
|
||||
// Update total written.
|
||||
|
||||
Reference in New Issue
Block a user