mount: report error when Flush()

The error in Release() is not working.

See https://github.com/jaderhs/libfuse/blob/master/FAQ

related to https://github.com/chrislusf/seaweedfs/issues/1765
This commit is contained in:
Chris Lu
2021-01-28 04:46:37 -08:00
parent 9a06c35da4
commit cf252fc0cd
2 changed files with 16 additions and 32 deletions

View File

@@ -3,7 +3,6 @@ package filesys
import (
"bytes"
"io"
"runtime"
"sync"
"time"
@@ -16,8 +15,6 @@ type ContinuousDirtyPages struct {
f *File
writeWaitGroup sync.WaitGroup
chunkAddLock sync.Mutex
chunkSaveErrChan chan error
chunkSaveErrChanClosed bool
lastErr error
collection string
replication string
@@ -27,15 +24,7 @@ func newDirtyPages(file *File) *ContinuousDirtyPages {
dirtyPages := &ContinuousDirtyPages{
intervals: &ContinuousIntervals{},
f: file,
chunkSaveErrChan: make(chan error, runtime.NumCPU()),
}
go func() {
for t := range dirtyPages.chunkSaveErrChan {
if t != nil {
dirtyPages.lastErr = t
}
}
}()
return dirtyPages
}
@@ -94,15 +83,6 @@ func (pages *ContinuousDirtyPages) saveExistingLargestPageToStorage() (hasSavedD
func (pages *ContinuousDirtyPages) saveToStorage(reader io.Reader, offset int64, size int64) {
errChanSize := pages.f.wfs.option.ConcurrentWriters
if errChanSize == 0 {
errChanSize = runtime.NumCPU()
}
if pages.chunkSaveErrChanClosed {
pages.chunkSaveErrChan = make(chan error, errChanSize)
pages.chunkSaveErrChanClosed = false
}
mtime := time.Now().UnixNano()
pages.writeWaitGroup.Add(1)
writer := func() {
@@ -112,7 +92,7 @@ func (pages *ContinuousDirtyPages) saveToStorage(reader io.Reader, offset int64,
chunk, collection, replication, err := pages.f.wfs.saveDataAsChunk(pages.f.fullpath())(reader, pages.f.Name, offset)
if err != nil {
glog.V(0).Infof("%s saveToStorage [%d,%d): %v", pages.f.fullpath(), offset, offset+size, err)
pages.chunkSaveErrChan <- err
pages.lastErr = err
return
}
chunk.Mtime = mtime