Fix Trucate() bug causing files to be too small
Uncovered by running xfstests generic/014 several times
This commit is contained in:
parent
089629442d
commit
b27edba2bb
|
@ -273,8 +273,8 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
|
||||||
// File shrinks
|
// File shrinks
|
||||||
} else {
|
} else {
|
||||||
blockNo := f.cfs.BlockNoPlainOff(newSize)
|
blockNo := f.cfs.BlockNoPlainOff(newSize)
|
||||||
lastBlockOff := blockNo * f.cfs.PlainBS()
|
lastBlockOff := blockNo * f.cfs.CipherBS()
|
||||||
lastBlockLen := newSize - lastBlockOff
|
lastBlockLen := newSize - blockNo * f.cfs.PlainBS()
|
||||||
var data []byte
|
var data []byte
|
||||||
if lastBlockLen > 0 {
|
if lastBlockLen > 0 {
|
||||||
var status fuse.Status
|
var status fuse.Status
|
||||||
|
|
Loading…
Reference in New Issue