mirror of
https://github.com/versity/scoutfs-go.git
synced 2026-01-06 11:46:20 +00:00
fix incorrect size block alignment for release
This commit is contained in:
14
scoutfs.go
14
scoutfs.go
@@ -296,7 +296,7 @@ func OpenByID(dirfd *os.File, ino uint64, flags int, name string) (*os.File, err
|
|||||||
return os.NewFile(fd, name), nil
|
return os.NewFile(fd, name), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReleaseFile marks file offline and frees associated extents
|
// ReleaseFile sets file offline by freeing associated extents
|
||||||
func ReleaseFile(path string, version uint64) error {
|
func ReleaseFile(path string, version uint64) error {
|
||||||
f, err := os.OpenFile(path, os.O_WRONLY, 0)
|
f, err := os.OpenFile(path, os.O_WRONLY, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -307,7 +307,7 @@ func ReleaseFile(path string, version uint64) error {
|
|||||||
return FReleaseFile(f, version)
|
return FReleaseFile(f, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FReleaseFile marks file offline and frees associated extents
|
// FReleaseFile set file offline by freeing associated extents
|
||||||
func FReleaseFile(f *os.File, version uint64) error {
|
func FReleaseFile(f *os.File, version uint64) error {
|
||||||
fi, err := f.Stat()
|
fi, err := f.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -315,7 +315,7 @@ func FReleaseFile(f *os.File, version uint64) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := iocRelease{
|
r := iocRelease{
|
||||||
Length: roundUp(uint64(fi.Size()), scoutfsBS),
|
Length: divRoundUp(uint64(fi.Size()), scoutfsBS),
|
||||||
Version: version,
|
Version: version,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,8 +323,12 @@ func FReleaseFile(f *os.File, version uint64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func roundUp(size, bs uint64) uint64 {
|
func divRoundUp(size, bs uint64) uint64 {
|
||||||
return ((size / bs) * bs) + bs
|
d := (size / bs) * bs
|
||||||
|
if d == size {
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
return d + bs
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReleaseBlocks marks blocks offline and frees associated extents
|
// ReleaseBlocks marks blocks offline and frees associated extents
|
||||||
|
|||||||
Reference in New Issue
Block a user