mirror of
https://github.com/minio/minio.git
synced 2025-02-26 04:49:16 -05:00
fix: do not niladic p.writers upon failure (#12255)
p.writers is a verbatim value of bitrotWriter backed by a pipe() that should never be nil'ed, instead use the captured errors to skip the writes. additionally detect also short writes, and reject them as errors.
This commit is contained in:
parent
8b52d70012
commit
2d79d6d847
@ -42,13 +42,18 @@ func (p *parallelWriter) Write(ctx context.Context, blocks [][]byte) error {
|
||||
p.errs[i] = errDiskNotFound
|
||||
continue
|
||||
}
|
||||
|
||||
if p.errs[i] != nil {
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
go func(i int) {
|
||||
defer wg.Done()
|
||||
_, p.errs[i] = p.writers[i].Write(blocks[i])
|
||||
if p.errs[i] != nil {
|
||||
p.writers[i] = nil
|
||||
var n int
|
||||
n, p.errs[i] = p.writers[i].Write(blocks[i])
|
||||
if p.errs[i] == nil {
|
||||
if n != len(blocks[i]) {
|
||||
p.errs[i] = io.ErrShortWrite
|
||||
}
|
||||
}
|
||||
}(i)
|
||||
}
|
||||
@ -58,12 +63,7 @@ func (p *parallelWriter) Write(ctx context.Context, blocks [][]byte) error {
|
||||
// CreateFile with p.writeQuorum=1 to accommodate healing of single disk.
|
||||
// i.e if we do no return here in such a case, reduceWriteQuorumErrs() would
|
||||
// return a quorum error to HealFile().
|
||||
nilCount := 0
|
||||
for _, err := range p.errs {
|
||||
if err == nil {
|
||||
nilCount++
|
||||
}
|
||||
}
|
||||
nilCount := countErrs(p.errs, nil)
|
||||
if nilCount >= p.writeQuorum {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user