storage: fallocate return interrupt err try again

Call fallocate, return code Interrupt error, should try again

Signed-off-by: YankunLi <liyankun01@58.com>
This commit is contained in:
YankunLi 2022-04-01 20:48:17 +08:00 committed by leonrayang
parent 239cdf31b3
commit c5a63ed8a2
2 changed files with 25 additions and 9 deletions

View File

@ -14,8 +14,23 @@
package storage
import "syscall"
import (
"syscall"
"github.com/cubefs/cubefs/util"
)
func fallocate(fd int, mode uint32, off int64, len int64) (err error) {
return syscall.Fallocate(fd, mode, off, len)
var tryCnt int
for {
err = syscall.Fallocate(fd, mode, off, len)
if err == syscall.EINTR {
tryCnt++
if tryCnt >= util.SyscallTryMaxTimes {
return
}
continue
}
return
}
}

View File

@ -32,13 +32,14 @@ const (
)
const (
BlockCount = 1024
BlockSize = 65536 * 2
ReadBlockSize = BlockSize
PerBlockCrcSize = 4
ExtentSize = BlockCount * BlockSize
PacketHeaderSize = 57
BlockHeaderSize = 4096
BlockCount = 1024
BlockSize = 65536 * 2
ReadBlockSize = BlockSize
PerBlockCrcSize = 4
ExtentSize = BlockCount * BlockSize
PacketHeaderSize = 57
BlockHeaderSize = 4096
SyscallTryMaxTimes = 3
)
const (