aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-08-15 15:35:31 -0700
committerchrislu <chris.lu@gmail.com>2022-08-15 15:35:31 -0700
commit93261f519999dc8e4898d4d3b8a3fee96efafb76 (patch)
tree3251c5a56ba98f9919b781658d47225bb16fd4c0
parent9c588d4010af9f89a0a50b1efb454b8e3cd498a5 (diff)
downloadseaweedfs-93261f519999dc8e4898d4d3b8a3fee96efafb76.tar.xz
seaweedfs-93261f519999dc8e4898d4d3b8a3fee96efafb76.zip
Revert "Refactor for Sync method (#3426)"
This reverts commit 670cb759f82815461bc854569542582da51a6199. with the pr weed/storage () - (master) > go test -count=1 ./... ok github.com/seaweedfs/seaweedfs/weed/storage 18.486s ? github.com/seaweedfs/seaweedfs/weed/storage/backend [no test files] ok github.com/seaweedfs/seaweedfs/weed/storage/backend/memory_map 0.025s ? github.com/seaweedfs/seaweedfs/weed/storage/backend/s3_backend [no test files] ok github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding 0.864s ? github.com/seaweedfs/seaweedfs/weed/storage/idx [no test files] ok github.com/seaweedfs/seaweedfs/weed/storage/needle 0.110s ok github.com/seaweedfs/seaweedfs/weed/storage/needle_map 24.414s ok github.com/seaweedfs/seaweedfs/weed/storage/super_block 0.203s ? github.com/seaweedfs/seaweedfs/weed/storage/types [no test files] ? github.com/seaweedfs/seaweedfs/weed/storage/volume_info [no test files] weed/storage () - (master) > weed/storage () - (master) > without the pr weed/storage () - (master) > weed/storage () - (master) > go test -count=1 ./... ok github.com/seaweedfs/seaweedfs/weed/storage 1.617s ? github.com/seaweedfs/seaweedfs/weed/storage/backend [no test files] ok github.com/seaweedfs/seaweedfs/weed/storage/backend/memory_map 0.026s ? github.com/seaweedfs/seaweedfs/weed/storage/backend/s3_backend [no test files] ok github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding 0.906s ? github.com/seaweedfs/seaweedfs/weed/storage/idx [no test files] ok github.com/seaweedfs/seaweedfs/weed/storage/needle 0.202s ok github.com/seaweedfs/seaweedfs/weed/storage/needle_map 24.533s ok github.com/seaweedfs/seaweedfs/weed/storage/super_block 0.280s ? github.com/seaweedfs/seaweedfs/weed/storage/types [no test files] ? github.com/seaweedfs/seaweedfs/weed/storage/volume_info [no test files]
-rw-r--r--weed/storage/backend/disk_file.go10
-rw-r--r--weed/storage/backend/disk_file_darwin.go43
-rw-r--r--weed/storage/backend/disk_file_linux.go14
-rw-r--r--weed/storage/backend/disk_file_others.go9
4 files changed, 7 insertions, 69 deletions
diff --git a/weed/storage/backend/disk_file.go b/weed/storage/backend/disk_file.go
index 93a2f8ccc..0dd153d5d 100644
--- a/weed/storage/backend/disk_file.go
+++ b/weed/storage/backend/disk_file.go
@@ -1,11 +1,10 @@
package backend
import (
- "os"
- "time"
-
"github.com/seaweedfs/seaweedfs/weed/glog"
. "github.com/seaweedfs/seaweedfs/weed/storage/types"
+ "os"
+ "time"
)
var (
@@ -80,3 +79,8 @@ func (df *DiskFile) GetStat() (datSize int64, modTime time.Time, err error) {
func (df *DiskFile) Name() string {
return df.fullFilePath
}
+
+func (df *DiskFile) Sync() error {
+ return nil
+ // return df.File.Sync()
+}
diff --git a/weed/storage/backend/disk_file_darwin.go b/weed/storage/backend/disk_file_darwin.go
deleted file mode 100644
index 76be810db..000000000
--- a/weed/storage/backend/disk_file_darwin.go
+++ /dev/null
@@ -1,43 +0,0 @@
-//go:build darwin
-// +build darwin
-
-package backend
-
-import (
- "syscall"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- // Using default File.Sync function, same as fcntl(fd, F_FULLFSYNC)
- DM_SYNC = 1
-
- // Using syscall.Fsync function, for MacOS this is not safe but is very fast.
- DM_FSYNC = 2
-
- // Using fcntl with F_BARRIERFSYNC parameter, for more details please refer:
- // https://developer.apple.com/documentation/xcode/reducing-disk-writes
- DM_BFSYNC = 3
-
- F_BARRIERFSYNC = 85
-)
-
-var (
- // By default using F_BARRIERFSYNC
- DarwinSyncMode = DM_BFSYNC
-)
-
-func (df *DiskFile) Sync() error {
- switch DarwinSyncMode {
- case DM_SYNC:
- return df.File.Sync()
- case DM_BFSYNC:
- fd := df.File.Fd()
- _, err := unix.FcntlInt(fd, F_BARRIERFSYNC, 0)
- return err
- default:
- fd := df.File.Fd()
- return syscall.Fsync(int(fd))
- }
-}
diff --git a/weed/storage/backend/disk_file_linux.go b/weed/storage/backend/disk_file_linux.go
deleted file mode 100644
index a38489dcf..000000000
--- a/weed/storage/backend/disk_file_linux.go
+++ /dev/null
@@ -1,14 +0,0 @@
-//go:build linux
-// +build linux
-
-package backend
-
-import (
- "syscall"
-)
-
-// Using Fdatasync to optimize file sync operation
-func (df *DiskFile) Sync() error {
- fd := df.File.Fd()
- return syscall.Fdatasync(int(fd))
-}
diff --git a/weed/storage/backend/disk_file_others.go b/weed/storage/backend/disk_file_others.go
deleted file mode 100644
index 08d29d217..000000000
--- a/weed/storage/backend/disk_file_others.go
+++ /dev/null
@@ -1,9 +0,0 @@
-//go:build !linux && !darwin
-// +build !linux,!darwin
-
-package backend
-
-// Using default sync operation
-func (df *DiskFile) Sync() error {
- return df.File.Sync()
-}