aboutsummaryrefslogtreecommitdiff
path: root/weed/storage/volume_create_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/storage/volume_create_windows.go')
-rw-r--r--weed/storage/volume_create_windows.go32
1 files changed, 11 insertions, 21 deletions
diff --git a/weed/storage/volume_create_windows.go b/weed/storage/volume_create_windows.go
index 12826f613..81536810b 100644
--- a/weed/storage/volume_create_windows.go
+++ b/weed/storage/volume_create_windows.go
@@ -3,36 +3,26 @@
package storage
import (
- "os"
-
"github.com/chrislusf/seaweedfs/weed/storage/backend/memory_map"
"golang.org/x/sys/windows"
"github.com/chrislusf/seaweedfs/weed/glog"
+ "github.com/chrislusf/seaweedfs/weed/storage/backend"
"github.com/chrislusf/seaweedfs/weed/storage/backend/memory_map/os_overloads"
)
-func createVolumeFile(fileName string, preallocate int64, memoryMapSizeMB uint32) (*os.File, error) {
-
- mMap, exists := memory_map.FileMemoryMap[fileName]
- if !exists {
-
- if preallocate > 0 {
- glog.V(0).Infof("Preallocated disk space for %s is not supported", fileName)
- }
+func createVolumeFile(fileName string, preallocate int64, memoryMapSizeMB uint32) (backend.DataStorageBackend, error) {
- if memoryMapSizeMB > 0 {
- file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT, 0644, true)
- memory_map.FileMemoryMap[fileName] = new(memory_map.MemoryMap)
+ if preallocate > 0 {
+ glog.V(0).Infof("Preallocated disk space for %s is not supported", fileName)
+ }
- new_mMap := memory_map.FileMemoryMap[fileName]
- new_mMap.CreateMemoryMap(file, 1024*1024*uint64(memoryMapSizeMB))
- return file, e
- } else {
- file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT|windows.O_TRUNC, 0644, false)
- return file, e
- }
+ if memoryMapSizeMB > 0 {
+ file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT, 0644, true)
+ return memory_map.NewMemoryMappedFile(file, memoryMapSizeMB), e
} else {
- return mMap.File, nil
+ file, e := os_overloads.OpenFile(fileName, windows.O_RDWR|windows.O_CREAT|windows.O_TRUNC, 0644, false)
+ return backend.NewDiskFile(file), e
}
+
}