From 746e08e7178abb40b550df0c6529cd20758eb97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 17 Dec 2019 14:47:08 +0100 Subject: [PATCH] sectorbuilder: Improve not enough space error --- lib/sectorbuilder/fs.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/sectorbuilder/fs.go b/lib/sectorbuilder/fs.go index c12935b96..fa0734368 100644 --- a/lib/sectorbuilder/fs.go +++ b/lib/sectorbuilder/fs.go @@ -86,14 +86,19 @@ func (f *fs) reserve(typ dataType, size uint64) error { return err } - avail := int64(fsstat.Bavail) * int64(fsstat.Bsize) + fsavail := int64(fsstat.Bavail) * int64(fsstat.Bsize) - avail -= f.reservedBytes() + avail := fsavail - f.reservedBytes() need := overheadMul[typ] * size if int64(need) > avail { - return xerrors.Errorf("not enough space in '%s', need %s, available %s", f.path, types.NewInt(need).SizeStr(), types.NewInt(uint64(avail)).SizeStr()) + return xerrors.Errorf("not enough space in '%s', need %s, available %s (fs: %s, reserved: %s)", + f.path, + types.NewInt(need).SizeStr(), + types.NewInt(uint64(avail)).SizeStr(), + types.NewInt(uint64(fsavail)).SizeStr(), + types.NewInt(uint64(f.reservedBytes()))) } f.reserved[typ] += need