Merge pull request #48 from filecoin-project/feat/log-and-ignore-falloc
Log and ignore if fallocate is not supported
This commit is contained in:
commit
0fea67f662
@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/detailyang/go-fallocate"
|
"github.com/detailyang/go-fallocate"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@ -63,6 +64,12 @@ func createPartialFile(maxPieceSize abi.PaddedPieceSize, path string) (*partialF
|
|||||||
|
|
||||||
err = func() error {
|
err = func() error {
|
||||||
err := fallocate.Fallocate(f, 0, int64(maxPieceSize))
|
err := fallocate.Fallocate(f, 0, int64(maxPieceSize))
|
||||||
|
if errno, ok := err.(syscall.Errno); ok {
|
||||||
|
if errno == syscall.EOPNOTSUPP || errno == syscall.ENOSYS {
|
||||||
|
log.Warnf("could not allocated space, ignoring: %v", errno)
|
||||||
|
err = nil // log and ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("fallocate '%s': %w", path, err)
|
return xerrors.Errorf("fallocate '%s': %w", path, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user