mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Revert "Refactor for Sync method (#3426)"
This reverts commit 670cb759f8
.
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]
This commit is contained in:
parent
9c588d4010
commit
93261f5199
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
|
@ -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))
|
||||
}
|
|
@ -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()
|
||||
}
|
Loading…
Reference in a new issue