linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] src/fiemap-tester: fix getting blocksize on overlayfs
@ 2018-10-11 14:41 Amir Goldstein
  0 siblings, 0 replies; only message in thread
From: Amir Goldstein @ 2018-10-11 14:41 UTC (permalink / raw)
  To: Eryu Guan; +Cc: Miklos Szeredi, linux-unionfs, fstests

There was a regression in v4.19-rc1 that caused FIGETBSZ ioctl
to return 0 on an overlayfs file.

That regression went unnoticed because the xfstests that run
fiemap-tester program terminated in success status after not doing
much instead of failing.

Check for invalid value of block size returned by FIGETBSZ ioctl,
so these tests can detect the regression.

Fallback to statfs(2) for getting the filesystem blocksize if
FIGETBSZ ioctl fails (i.e. on overlayfs).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 src/fiemap-tester.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/fiemap-tester.c b/src/fiemap-tester.c
index 97ac5ad0..3db24daa 100644
--- a/src/fiemap-tester.c
+++ b/src/fiemap-tester.c
@@ -14,6 +14,7 @@
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/statfs.h>
 #include <sys/vfs.h>
 #include <linux/fs.h>
 #include <linux/types.h>
@@ -556,7 +557,19 @@ main(int argc, char **argv)
 	}
 
 	if (ioctl(fd, FIGETBSZ, &blocksize) < 0) {
-		perror("Can't get filesystem block size");
+		struct statfs buf;
+
+		if (fstatfs(fd, &buf) == 0) {
+			blocksize = buf.f_bsize;
+		} else {
+			perror("Can't get filesystem block size");
+			close(fd);
+			exit(1);
+		}
+	}
+
+	if (blocksize <= 0) {
+		printf("Illegal filesystem block size\n");
 		close(fd);
 		exit(1);
 	}
-- 
2.17.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-10-11 14:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-11 14:41 [PATCH v2] src/fiemap-tester: fix getting blocksize on overlayfs Amir Goldstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).