mirror of
https://github.com/versity/scoutfs-go.git
synced 2026-01-05 03:24:07 +00:00
scoutfs: release size based on file size
This commit is contained in:
15
scoutfs.go
15
scoutfs.go
@@ -12,7 +12,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -29,6 +28,7 @@ const (
|
||||
leaderfile = "quorum/is_leader"
|
||||
serveraddr = "mount_options/server_addr"
|
||||
listattrBufsize = 256 * 1024
|
||||
scoutfsBS = 4096
|
||||
)
|
||||
|
||||
// Query to keep track of in-process query
|
||||
@@ -287,15 +287,24 @@ func ReleaseFile(path string, version uint64) error {
|
||||
|
||||
// FReleaseFile marks file offline and frees associated extents
|
||||
func FReleaseFile(f *os.File, version uint64) error {
|
||||
fi, err := f.Stat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r := iocRelease{
|
||||
Length: math.MaxUint64,
|
||||
Length: roundUp(uint64(fi.Size()), scoutfsBS),
|
||||
Version: version,
|
||||
}
|
||||
|
||||
_, err := scoutfsctl(f, IOCRELEASE, unsafe.Pointer(&r))
|
||||
_, err = scoutfsctl(f, IOCRELEASE, unsafe.Pointer(&r))
|
||||
return err
|
||||
}
|
||||
|
||||
func roundUp(size, bs uint64) uint64 {
|
||||
return ((size / bs) * bs) + bs
|
||||
}
|
||||
|
||||
// StageFile rehydrates offline file
|
||||
func StageFile(path string, version, offset uint64, b []byte) (int, error) {
|
||||
f, err := os.OpenFile(path, os.O_WRONLY, 0)
|
||||
|
||||
Reference in New Issue
Block a user