aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-05-09 15:15:18 -0700
committerChris Lu <chris.lu@gmail.com>2021-05-09 15:15:18 -0700
commit93e84a12f25ecc9575d72424ea819d00d9b31475 (patch)
tree80ef553e1120381762ab14ec2210fc2c0250a3da
parent3942e3b2efefe674dbb5562022c8a34494cd92d9 (diff)
downloadseaweedfs-93e84a12f25ecc9575d72424ea819d00d9b31475.tar.xz
seaweedfs-93e84a12f25ecc9575d72424ea819d00d9b31475.zip
refactor
-rw-r--r--weed/filesys/dirty_page.go11
-rw-r--r--weed/filesys/filehandle.go8
2 files changed, 13 insertions, 6 deletions
diff --git a/weed/filesys/dirty_page.go b/weed/filesys/dirty_page.go
index 1719d68e6..0332629ad 100644
--- a/weed/filesys/dirty_page.go
+++ b/weed/filesys/dirty_page.go
@@ -2,6 +2,7 @@ package filesys
import (
"bytes"
+ "fmt"
"io"
"sync"
"time"
@@ -58,6 +59,16 @@ func (pages *ContinuousDirtyPages) flushAndSave(offset int64, data []byte) {
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() {
for pages.saveExistingLargestPageToStorage() {
}
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go
index 8cbaf6fd2..e66e340b3 100644
--- a/weed/filesys/filehandle.go
+++ b/weed/filesys/filehandle.go
@@ -239,12 +239,8 @@ func (fh *FileHandle) doFlush(ctx context.Context, header fuse.Header) error {
// send the data to the OS
glog.V(4).Infof("doFlush %s fh %d", fh.f.fullpath(), fh.handle)
- fh.dirtyPages.saveExistingPagesToStorage()
-
- fh.dirtyPages.writeWaitGroup.Wait()
-
- if fh.dirtyPages.lastErr != nil {
- glog.Errorf("%v doFlush last err: %v", fh.f.fullpath(), fh.dirtyPages.lastErr)
+ if err := fh.dirtyPages.FlushData(); err != nil {
+ glog.Errorf("%v doFlush: %v", fh.f.fullpath(), err)
return fuse.EIO
}