You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
526 B

5 years ago
5 years ago
5 years ago
  1. // +build linux
  2. package backend
  3. import (
  4. "os"
  5. "syscall"
  6. "github.com/chrislusf/seaweedfs/weed/glog"
  7. )
  8. func CreateVolumeFile(fileName string, preallocate int64, memoryMapSizeMB uint32) (BackendStorageFile, error) {
  9. file, e := os.OpenFile(fileName, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
  10. if e != nil {
  11. return nil, e
  12. }
  13. if preallocate != 0 {
  14. syscall.Fallocate(int(file.Fd()), 1, 0, preallocate)
  15. glog.V(1).Infof("Preallocated %d bytes disk space for %s", preallocate, fileName)
  16. }
  17. return NewDiskFile(file), nil
  18. }