[PATCH] fsstress: add support for FALLOC_FL_UNSHARE_RANGE

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Teach fsstress to try to unshare file blocks on filesystems, seeing how
the recent addition to fsx has uncovered a lot of bugs.

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 ltp/fsstress.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index b8d025d3a0..8cd45c7a85 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -139,6 +139,7 @@ typedef enum {
 	OP_TRUNCATE,
 	OP_UNLINK,
 	OP_UNRESVSP,
+	OP_UNSHARE,
 	OP_URING_READ,
 	OP_URING_WRITE,
 	OP_WRITE,
@@ -246,6 +247,7 @@ void	punch_f(opnum_t, long);
 void	zero_f(opnum_t, long);
 void	collapse_f(opnum_t, long);
 void	insert_f(opnum_t, long);
+void	unshare_f(opnum_t, long);
 void	read_f(opnum_t, long);
 void	readlink_f(opnum_t, long);
 void	readv_f(opnum_t, long);
@@ -339,6 +341,7 @@ struct opdesc	ops[OP_LAST]	= {
 	[OP_TRUNCATE]	   = {"truncate",      truncate_f,	2, 1 },
 	[OP_UNLINK]	   = {"unlink",	       unlink_f,	1, 1 },
 	[OP_UNRESVSP]	   = {"unresvsp",      unresvsp_f,	1, 1 },
+	[OP_UNSHARE]	   = {"unshare",       unshare_f,	1, 1 },
 	[OP_URING_READ]	   = {"uring_read",    uring_read_f,	-1, 0 },
 	[OP_URING_WRITE]   = {"uring_write",   uring_write_f,	-1, 1 },
 	[OP_WRITE]	   = {"write",	       write_f,		4, 1 },
@@ -3767,6 +3770,7 @@ struct print_flags falloc_flags [] = {
 	{ FALLOC_FL_COLLAPSE_RANGE, "COLLAPSE_RANGE"},
 	{ FALLOC_FL_ZERO_RANGE, "ZERO_RANGE"},
 	{ FALLOC_FL_INSERT_RANGE, "INSERT_RANGE"},
+	{ FALLOC_FL_UNSHARE_RANGE, "UNSHARE_RANGE"},
 	{ -1, NULL}
 };
 
@@ -4469,6 +4473,16 @@ insert_f(opnum_t opno, long r)
 #endif
 }
 
+void
+unshare_f(opnum_t opno, long r)
+{
+#ifdef HAVE_LINUX_FALLOC_H
+# ifdef FALLOC_FL_UNSHARE_RANGE
+	do_fallocate(opno, r, FALLOC_FL_UNSHARE_RANGE);
+# endif
+#endif
+}
+
 void
 read_f(opnum_t opno, long r)
 {




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux