mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-24 07:49:15 +08:00
refactor
This commit is contained in:
parent
3942e3b2ef
commit
93e84a12f2
@ -2,6 +2,7 @@ package filesys
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -58,6 +59,16 @@ func (pages *ContinuousDirtyPages) flushAndSave(offset int64, data []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pages *ContinuousDirtyPages) FlushData() error {
|
||||||
|
|
||||||
|
pages.saveExistingPagesToStorage()
|
||||||
|
pages.writeWaitGroup.Wait()
|
||||||
|
if pages.lastErr != nil {
|
||||||
|
return fmt.Errorf("flush data: %v", pages.lastErr)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (pages *ContinuousDirtyPages) saveExistingPagesToStorage() {
|
func (pages *ContinuousDirtyPages) saveExistingPagesToStorage() {
|
||||||
for pages.saveExistingLargestPageToStorage() {
|
for pages.saveExistingLargestPageToStorage() {
|
||||||
}
|
}
|
||||||
|
@ -239,12 +239,8 @@ func (fh *FileHandle) doFlush(ctx context.Context, header fuse.Header) error {
|
|||||||
// send the data to the OS
|
// send the data to the OS
|
||||||
glog.V(4).Infof("doFlush %s fh %d", fh.f.fullpath(), fh.handle)
|
glog.V(4).Infof("doFlush %s fh %d", fh.f.fullpath(), fh.handle)
|
||||||
|
|
||||||
fh.dirtyPages.saveExistingPagesToStorage()
|
if err := fh.dirtyPages.FlushData(); err != nil {
|
||||||
|
glog.Errorf("%v doFlush: %v", fh.f.fullpath(), err)
|
||||||
fh.dirtyPages.writeWaitGroup.Wait()
|
|
||||||
|
|
||||||
if fh.dirtyPages.lastErr != nil {
|
|
||||||
glog.Errorf("%v doFlush last err: %v", fh.f.fullpath(), fh.dirtyPages.lastErr)
|
|
||||||
return fuse.EIO
|
return fuse.EIO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user