diff options
| author | chrislu <chris.lu@gmail.com> | 2022-04-26 13:03:43 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-04-26 13:03:43 -0700 |
| commit | 94f824e1ce4bc9400d8f3ede1a5420f65ba6b5aa (patch) | |
| tree | 090be215cd6930b9c0db1557939376db2964d0ef /weed/storage/volume.go | |
| parent | 3bce568c32f78a5bf12f0a31995d4098ca97fc6b (diff) | |
| download | seaweedfs-94f824e1ce4bc9400d8f3ede1a5420f65ba6b5aa.tar.xz seaweedfs-94f824e1ce4bc9400d8f3ede1a5420f65ba6b5aa.zip | |
volume: sync to disk before copying volume files
address https://github.com/chrislusf/seaweedfs/issues/2976
Diffstat (limited to 'weed/storage/volume.go')
| -rw-r--r-- | weed/storage/volume.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/weed/storage/volume.go b/weed/storage/volume.go index 6d48fbc83..f388c7d99 100644 --- a/weed/storage/volume.go +++ b/weed/storage/volume.go @@ -190,6 +190,21 @@ func (v *Volume) SetStopping() { } } +func (v *Volume) SyncToDisk() { + v.dataFileAccessLock.Lock() + defer v.dataFileAccessLock.Unlock() + if v.nm != nil { + if err := v.nm.Sync(); err != nil { + glog.Warningf("Volume Close fail to sync volume idx %d", v.Id) + } + } + if v.DataBackend != nil { + if err := v.DataBackend.Sync(); err != nil { + glog.Warningf("Volume Close fail to sync volume %d", v.Id) + } + } +} + // Close cleanly shuts down this volume func (v *Volume) Close() { v.dataFileAccessLock.Lock() |
