Skip to content

Commit 4cc0bec

Browse files
committed
Do not crash when handling files of exactly maximum allowed size
Test case: 1) Mount geesefs with --part-sizes 5 2) Reproduce the bug with the following bash script: ``` perl -e 'open FD, ">test-will-die"; sleep 20' & dd if=/dev/zero of=test-will-die oflag=direct bs=1M seek=0 count=200 dd if=/dev/zero of=test-will-die oflag=direct bs=1M seek=49999 count=1 sleep 20 ``` I.e. to reproduce the bug, you should have the last write to an inode end at maximum possible file offset, it should also have more modified data than just the last part, and there should be an open file descriptor for that file. 3) GeeseFS will crash.
1 parent 5a517ef commit 4cc0bec

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/file.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func (fs *Goofys) partNum(offset uint64) uint64 {
6464
start += s.PartSize * s.PartCount
6565
n += s.PartCount
6666
}
67+
if offset == start {
68+
// Sometimes we use partNum() to calculate total part count from end offset - allow it
69+
return n
70+
}
6771
panic(fmt.Sprintf(
6872
"Offset too large: %v, max supported file size with current part size configuration is %v",
6973
offset, start,

0 commit comments

Comments
 (0)