From c70df522d2a78f3152fa61511bed9fafa7c495a3 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 15 Jul 2018 14:14:12 +0200 Subject: fusefrontend: doWrite: delete file header if first write fails xfstests generic/083 fills the filesystem almost completely while running fsstress in parallel. In fsck, these would show up: readFileID 2580: incomplete file, got 18 instead of 19 bytes This could happen when writing the file header works, but writing the actual data fails. Now we kill the header again by truncating the file to zero. --- internal/syscallcompat/helpers.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 internal/syscallcompat/helpers.go (limited to 'internal/syscallcompat/helpers.go') diff --git a/internal/syscallcompat/helpers.go b/internal/syscallcompat/helpers.go new file mode 100644 index 0000000..e2a2215 --- /dev/null +++ b/internal/syscallcompat/helpers.go @@ -0,0 +1,21 @@ +package syscallcompat + +import ( + "os" + "syscall" +) + +// IsENOSPC tries to find out if "err" is a (potentially wrapped) ENOSPC error. +func IsENOSPC(err error) bool { + // syscallcompat.EnospcPrealloc returns the naked syscall error + if err == syscall.ENOSPC { + return true + } + // os.File.WriteAt returns &PathError + if err2, ok := err.(*os.PathError); ok { + if err2.Err == syscall.ENOSPC { + return true + } + } + return false +} -- cgit v1.2.3