Skip to contentSkip to conversation

XFS Add Punch Hole Testing to FSX

PATCH Superseded Allison Henderson 4 participants 7 messages May 2, 2011 – May 3, 2011 VFS

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 XFS Add Punch Hole Testing to FSX

This patch adds punch hole tests to the fsx stress test. The test is performed through the fallocate call by randomly choosing to use the punch hole flag when running the fallocate test. Regions that have been punched out should contain zeros, so the expected file contents buffer is updated to contain zeros when a hole is punched out.

---
:100644 100644 32cd380... d424941... M ltp/Makefile
:100644 100644 fe072d3... 4f54ef6... M ltp/fsx.c

 ltp/Makefile |    2 +-
 ltp/fsx.c    |   73 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 62 insertions(+), 13 deletions(-)
ltp/Makefile +1 -1
index 32cd380..d424941 100644
@@ -27,7 +27,7 @@ LCFLAGS += -DAIO
 LLDLIBS += -laio -lpthread
 endif
 
-ifeq ($(HAVE_FALLOCATE), true)
+ifeq ($(HAVE_FALLOCATE), yes)
 LCFLAGS += -DFALLOCATE
 endif
 
ltp/fsx.c +61 -12

112 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw
Quoted 8 lines · Allison Henderson

This patch adds punch hole tests to the fsx stress test. The test is performed through the fallocate call by randomly choosing to use the punch hole flag when running the fallocate test. Regions that have been punched out should contain zeros, so the expected file contents buffer is updated to contain zeros when a hole is punched out.

I'll cc: the xfs list since this would live in xfstests.

Thanks,
-Eric

Quoted 132 lines

---
:100644 100644 32cd380... d424941... M ltp/Makefile
:100644 100644 fe072d3... 4f54ef6... M ltp/fsx.c

 ltp/Makefile |    2 +-
 ltp/fsx.c    |   73 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 62 insertions(+), 13 deletions(-)
ltp/Makefile +1 -1
index 32cd380..d424941 100644
@@ -27,7 +27,7 @@ LCFLAGS += -DAIO
 LLDLIBS += -laio -lpthread
 endif
 
-ifeq ($(HAVE_FALLOCATE), true)
+ifeq ($(HAVE_FALLOCATE), yes)
 LCFLAGS += -DFALLOCATE
 endif
 
ltp/fsx.c +54 -12
index fe072d3..4f54ef6 100644
@@ -207,7 +207,8 @@ logdump(void)
 {
 	int	i, count, down;
 	struct log_entry	*lp;
-	char *falloc_type[3] = {"PAST_EOF", "EXTENDING", "INTERIOR"};
+	char *falloc_type[4] = {"PAST_EOF", "EXTENDING", "INTERIOR",
+				"PUNCH_HOLE"};
 
 	prt("LOG DUMP (%d total operations):\n", logcount);
 	if (logcount < LOGSIZE) {
@@ -791,7 +792,11 @@ dofallocate(unsigned offset, unsigned length)
 {
 	unsigned end_offset;
 	int keep_size;
-
+	int max_offset = 0;
+	int max_len = 0;
+	int punch_hole = 0;
+	int mode = 0;
+	char *op_name;
         if (length == 0) {
                 if (!quiet && testcalls > simulatedopcount)
                         prt("skipping zero length fallocate\n");
@@ -799,11 +804,31 @@ dofallocate(unsigned offset, unsigned length)
                 return;
         }
 
+#ifdef FALLOC_FL_PUNCH_HOLE
+	punch_hole = random() % 2;
+	/* Keep size must be set for punch hole */
+	if (punch_hole) {
+		keep_size = 1;
+		mode = FALLOC_FL_PUNCH_HOLE;
+	} else
+		keep_size = random() % 2;
+#else
 	keep_size = random() % 2;
+#endif
+
+	if (keep_size)
+		mode |= FALLOC_FL_KEEP_SIZE;
+
+	if (punch_hole && file_size <= (loff_t)offset) {
+		if (!quiet && testcalls > simulatedopcount)
+			prt("skipping hole punch off the end of the file\n");
+		log4(OP_SKIPPED, OP_FALLOCATE, offset, length);
+		return;
+	}
 
 	end_offset = keep_size ? 0 : offset + length;
 
-	if (end_offset > biggest) {
+	if ((end_offset > biggest) && !punch_hole) {
 		biggest = end_offset;
 		if (!quiet && testcalls > simulatedopcount)
 			prt("fallocating to largest ever: 0x%x\n", end_offset);
@@ -811,13 +836,15 @@ dofallocate(unsigned offset, unsigned length)
 
 	/*
 	 * last arg:
-	 * 	1: allocate past EOF
-	 * 	2: extending prealloc
-	 * 	3: interior prealloc
+	 *      0: allocate past EOF
+	 *      1: extending prealloc
+	 *      2: interior prealloc
+	 *      3: punch hole
 	 */
-	log4(OP_FALLOCATE, offset, length, (end_offset > file_size) ? (keep_size ? 1 : 2) : 3);
+	log4(OP_FALLOCATE, offset, length, punch_hole ? 3 :
+			(end_offset > file_size) ? (keep_size ? 0 : 1) : 2);
 
-	if (end_offset > file_size) {
+	if (((loff_t)end_offset > file_size) && !punch_hole) {
 		memset(good_buf + file_size, '\0', end_offset - file_size);
 		file_size = end_offset;
 	}
@@ -827,13 +854,35 @@ dofallocate(unsigned offset, unsigned length)
 
 	if ((progressinterval && testcalls % progressinterval == 0) ||
 	    (debug && (monitorstart == -1 || monitorend == -1 ||
-		      end_offset <= monitorend)))
-		prt("%lu falloc\tfrom 0x%x to 0x%x\n", testcalls, offset, length);
-	if (fallocate(fd, keep_size ? FALLOC_FL_KEEP_SIZE : 0, (loff_t)offset, (loff_t)length) == -1) {
-	        prt("fallocate: %x to %x\n", offset, length);
+		      end_offset <= monitorend))) {
+#ifdef FALLOC_FL_PUNCH_HOLE
+		op_name = (mode & FALLOC_FL_PUNCH_HOLE) ?
+			"punch hole" : "falloc";
+#else
+		op_name = "falloc";
+#endif
+		prt("%lu %s\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
+			op_name, offset, offset+length, length);
+	}
+	if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
+#ifdef FALLOC_FL_PUNCH_HOLE
+		op_name = (mode & FALLOC_FL_PUNCH_HOLE) ?
+			"punch hole" : "fallocate";
+#else
+		op_name = "fallocate";
+#endif
+
+		prt("%s: %x to %x\n", op_name, offset, length);
 		prterr("dofallocate: fallocate");
 		report_failure(161);
 	}

ltp/fsx.c dofallocate(unsigned offset, unsigned length) · line 888

Quoted 10 lines
ltp/fsx.c +7 -0
+
+	if (punch_hole) {
+		max_offset = offset < file_size ? offset : file_size;
+		max_len = max_offset + length <= file_size ? length :
+				file_size - max_offset;
+		memset(good_buf + max_offset, '\0', max_len);
+	}
 }
 #else
 void

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 31 lines · Eric Sandeen
Quoted 8 lines · Allison Henderson

This patch adds punch hole tests to the fsx stress test. The test is performed through the fallocate call by randomly choosing to use the punch hole flag when running the fallocate test. Regions that have been punched out should contain zeros, so the expected file contents buffer is updated to contain zeros when a hole is punched out.

I'll cc: the xfs list since this would live in xfstests.

Thanks,
-Eric

Quoted 16 lines

---
:100644 100644 32cd380... d424941... M ltp/Makefile
:100644 100644 fe072d3... 4f54ef6... M ltp/fsx.c

 ltp/Makefile |    2 +-
 ltp/fsx.c    |   73 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 62 insertions(+), 13 deletions(-)
ltp/Makefile +0 -0
index 32cd380..d424941 100644
@@ -27,7 +27,7 @@ LCFLAGS += -DAIO
 LLDLIBS += -laio -lpthread
 endif
 
Quoted 2 lines

ltp/Makefile LCFLAGS += -DAIO · line 30

Quoted 2 lines
ltp/Makefile +1 -1
-ifeq ($(HAVE_FALLOCATE), true)
+ifeq ($(HAVE_FALLOCATE), yes)

argh I ended up with 2 fallocate tests in aclocal.m4, need to tidy that up, I'll do that in a separate patch.

Quoted 121 lines
Quoted 121 lines
ltp/Makefile +0 -0
 LCFLAGS += -DFALLOCATE
 endif
 
ltp/fsx.c +61 -12
index fe072d3..4f54ef6 100644
@@ -207,7 +207,8 @@ logdump(void)
 {
 	int	i, count, down;
 	struct log_entry	*lp;
-	char *falloc_type[3] = {"PAST_EOF", "EXTENDING", "INTERIOR"};
+	char *falloc_type[4] = {"PAST_EOF", "EXTENDING", "INTERIOR",
+				"PUNCH_HOLE"};
 
 	prt("LOG DUMP (%d total operations):\n", logcount);
 	if (logcount < LOGSIZE) {
@@ -791,7 +792,11 @@ dofallocate(unsigned offset, unsigned length)
 {
 	unsigned end_offset;
 	int keep_size;
-
+	int max_offset = 0;
+	int max_len = 0;
+	int punch_hole = 0;
+	int mode = 0;
+	char *op_name;
         if (length == 0) {
                 if (!quiet && testcalls > simulatedopcount)
                         prt("skipping zero length fallocate\n");
@@ -799,11 +804,31 @@ dofallocate(unsigned offset, unsigned length)
                 return;
         }
 
+#ifdef FALLOC_FL_PUNCH_HOLE
+	punch_hole = random() % 2;
+	/* Keep size must be set for punch hole */
+	if (punch_hole) {
+		keep_size = 1;
+		mode = FALLOC_FL_PUNCH_HOLE;
+	} else
+		keep_size = random() % 2;
+#else
 	keep_size = random() % 2;
+#endif
+
+	if (keep_size)
+		mode |= FALLOC_FL_KEEP_SIZE;
+
+	if (punch_hole && file_size <= (loff_t)offset) {
+		if (!quiet && testcalls > simulatedopcount)
+			prt("skipping hole punch off the end of the file\n");
+		log4(OP_SKIPPED, OP_FALLOCATE, offset, length);
+		return;
+	}
 
 	end_offset = keep_size ? 0 : offset + length;
 
-	if (end_offset > biggest) {
+	if ((end_offset > biggest) && !punch_hole) {
 		biggest = end_offset;
 		if (!quiet && testcalls > simulatedopcount)
 			prt("fallocating to largest ever: 0x%x\n", end_offset);
@@ -811,13 +836,15 @@ dofallocate(unsigned offset, unsigned length)
 
 	/*
 	 * last arg:
-	 * 	1: allocate past EOF
-	 * 	2: extending prealloc
-	 * 	3: interior prealloc
+	 *      0: allocate past EOF
+	 *      1: extending prealloc
+	 *      2: interior prealloc
+	 *      3: punch hole
 	 */
-	log4(OP_FALLOCATE, offset, length, (end_offset > file_size) ? (keep_size ? 1 : 2) : 3);
+	log4(OP_FALLOCATE, offset, length, punch_hole ? 3 :
+			(end_offset > file_size) ? (keep_size ? 0 : 1) : 2);
 
-	if (end_offset > file_size) {
+	if (((loff_t)end_offset > file_size) && !punch_hole) {
 		memset(good_buf + file_size, '\0', end_offset - file_size);
 		file_size = end_offset;
 	}
@@ -827,13 +854,35 @@ dofallocate(unsigned offset, unsigned length)
 
 	if ((progressinterval && testcalls % progressinterval == 0) ||
 	    (debug && (monitorstart == -1 || monitorend == -1 ||
-		      end_offset <= monitorend)))
-		prt("%lu falloc\tfrom 0x%x to 0x%x\n", testcalls, offset, length);
-	if (fallocate(fd, keep_size ? FALLOC_FL_KEEP_SIZE : 0, (loff_t)offset, (loff_t)length) == -1) {
-	        prt("fallocate: %x to %x\n", offset, length);
+		      end_offset <= monitorend))) {
+#ifdef FALLOC_FL_PUNCH_HOLE
+		op_name = (mode & FALLOC_FL_PUNCH_HOLE) ?
+			"punch hole" : "falloc";
+#else
+		op_name = "falloc";
+#endif
+		prt("%lu %s\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
+			op_name, offset, offset+length, length);
+	}
+	if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
+#ifdef FALLOC_FL_PUNCH_HOLE
+		op_name = (mode & FALLOC_FL_PUNCH_HOLE) ?
+			"punch hole" : "fallocate";
+#else
+		op_name = "fallocate";
+#endif
+
+		prt("%s: %x to %x\n", op_name, offset, length);
 		prterr("dofallocate: fallocate");
 		report_failure(161);
 	}
+
+	if (punch_hole) {
+		max_offset = offset < file_size ? offset : file_size;
+		max_len = max_offset + length <= file_size ? length :
+				file_size - max_offset;
+		memset(good_buf + max_offset, '\0', max_len);
+	}
Quoted 8 lines

ltp/fsx.c dofallocate(unsigned offset, unsigned length) · line 888

Quoted 3 lines
ltp/fsx.c +0 -0
 }
 #else
 void

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 74 lines · Allison Henderson

This patch adds punch hole tests to the fsx stress test. The test is performed through the fallocate call by randomly choosing to use the punch hole flag when running the fallocate test. Regions that have been punched out should contain zeros, so the expected file contents buffer is updated to contain zeros when a hole is punched out.

---
:100644 100644 32cd380... d424941... M ltp/Makefile
:100644 100644 fe072d3... 4f54ef6... M ltp/fsx.c
ltp/Makefile | 2 +-
ltp/fsx.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++---------

2 files changed, 62 insertions(+), 13 deletions(-)
ltp/Makefile +0 -0
index 32cd380..d424941 100644
@@ -27,7 +27,7 @@ LCFLAGS += -DAIO

LLDLIBS += -laio -lpthread
endif

ltp/Makefile +1 -1
-ifeq ($(HAVE_FALLOCATE), true)
+ifeq ($(HAVE_FALLOCATE), yes)

LCFLAGS += -DFALLOCATE
endif

ltp/fsx.c +17 -2
index fe072d3..4f54ef6 100644
@@ -207,7 +207,8 @@ logdump(void)
 {
 	int	i, count, down;
 	struct log_entry	*lp;
-	char *falloc_type[3] = {"PAST_EOF", "EXTENDING", "INTERIOR"};
+	char *falloc_type[4] = {"PAST_EOF", "EXTENDING", "INTERIOR",
+				"PUNCH_HOLE"};
 
 	prt("LOG DUMP (%d total operations):\n", logcount);
 	if (logcount < LOGSIZE) {
@@ -791,7 +792,11 @@ dofallocate(unsigned offset, unsigned length)
 {
 	unsigned end_offset;
 	int keep_size;
-
+	int max_offset = 0;
+	int max_len = 0;
+	int punch_hole = 0;
+	int mode = 0;
+	char *op_name;
        if (length == 0) {
                if (!quiet && testcalls > simulatedopcount)
                        prt("skipping zero length fallocate\n");
@@ -799,11 +804,31 @@ dofallocate(unsigned offset, unsigned length)
                return;
        }
 
+#ifdef FALLOC_FL_PUNCH_HOLE
+	punch_hole = random() % 2;
+	/* Keep size must be set for punch hole */
+	if (punch_hole) {
+		keep_size = 1;
+		mode = FALLOC_FL_PUNCH_HOLE;
+	} else
+		keep_size = random() % 2;
+#else
 	keep_size = random() % 2;
+#endif

ltp/fsx.c dofallocate(unsigned offset, unsigned length) · line 827

Quoted 10 lines
ltp/fsx.c +10 -0
+
+	if (keep_size)
+		mode |= FALLOC_FL_KEEP_SIZE;
+
+	if (punch_hole && file_size <= (loff_t)offset) {
+		if (!quiet && testcalls > simulatedopcount)
+			prt("skipping hole punch off the end of the file\n");
+		log4(OP_SKIPPED, OP_FALLOCATE, offset, length);
+		return;
+	}

Isn't a hole punch off the end of the file is just a truncate? I think that is a valid test case, since punch(newsize, ~0ULL) should be identical to truncate(newsize). In that case, "keep_size" would affect whether the file size is left alone, or it is now "newsize", so I don't think it should always be set to run with keep_size = 1 for FALLOC_FL_PUNCH_HOLE operations.

Quoted 67 lines
ltp/fsx.c +34 -10
 	end_offset = keep_size ? 0 : offset + length;
 
-	if (end_offset > biggest) {
+	if ((end_offset > biggest) && !punch_hole) {
 		biggest = end_offset;
 		if (!quiet && testcalls > simulatedopcount)
 			prt("fallocating to largest ever: 0x%x\n", end_offset);
@@ -811,13 +836,15 @@ dofallocate(unsigned offset, unsigned length)
 
 	/*
 	 * last arg:
-	 * 	1: allocate past EOF
-	 * 	2: extending prealloc
-	 * 	3: interior prealloc
+	 *      0: allocate past EOF
+	 *      1: extending prealloc
+	 *      2: interior prealloc
+	 *      3: punch hole
 	 */
-	log4(OP_FALLOCATE, offset, length, (end_offset > file_size) ? (keep_size ? 1 : 2) : 3);
+	log4(OP_FALLOCATE, offset, length, punch_hole ? 3 :
+			(end_offset > file_size) ? (keep_size ? 0 : 1) : 2);
 
-	if (end_offset > file_size) {
+	if (((loff_t)end_offset > file_size) && !punch_hole) {
 		memset(good_buf + file_size, '\0', end_offset - file_size);
 		file_size = end_offset;
 	}
@@ -827,13 +854,35 @@ dofallocate(unsigned offset, unsigned length)
 
 	if ((progressinterval && testcalls % progressinterval == 0) ||
 	    (debug && (monitorstart == -1 || monitorend == -1 ||
-		      end_offset <= monitorend)))
-		prt("%lu falloc\tfrom 0x%x to 0x%x\n", testcalls, offset, length);
-	if (fallocate(fd, keep_size ? FALLOC_FL_KEEP_SIZE : 0, (loff_t)offset, (loff_t)length) == -1) {
-	        prt("fallocate: %x to %x\n", offset, length);
+		      end_offset <= monitorend))) {
+#ifdef FALLOC_FL_PUNCH_HOLE
+		op_name = (mode & FALLOC_FL_PUNCH_HOLE) ?
+			"punch hole" : "falloc";
+#else
+		op_name = "falloc";
+#endif
+		prt("%lu %s\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
+			op_name, offset, offset+length, length);
+	}
+	if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
+#ifdef FALLOC_FL_PUNCH_HOLE
+		op_name = (mode & FALLOC_FL_PUNCH_HOLE) ?
+			"punch hole" : "fallocate";
+#else
+		op_name = "fallocate";
+#endif
+
+		prt("%s: %x to %x\n", op_name, offset, length);
 		prterr("dofallocate: fallocate");
 		report_failure(161);
 	}
+
+	if (punch_hole) {
+		max_offset = offset < file_size ? offset : file_size;
+		max_len = max_offset + length <= file_size ? length :
+				file_size - max_offset;
+		memset(good_buf + max_offset, '\0', max_len);
+	}
 }
 #else
Quoted 1 line

void

Cheers, Andreas

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw
Quoted 79 lines · Andreas Dilger
Quoted 78 lines · Allison Henderson

This patch adds punch hole tests to the fsx stress test. The test is performed through the fallocate call by randomly choosing to use the punch hole flag when running the fallocate test. Regions that have been punched out should contain zeros, so the expected file contents buffer is updated to contain zeros when a hole is punched out.

---
:100644 100644 32cd380... d424941... M ltp/Makefile
:100644 100644 fe072d3... 4f54ef6... M ltp/fsx.c
ltp/Makefile | 2 +-
ltp/fsx.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++---------

2 files changed, 62 insertions(+), 13 deletions(-)
ltp/Makefile +0 -0
index 32cd380..d424941 100644
@@ -27,7 +27,7 @@ LCFLAGS += -DAIO

LLDLIBS += -laio -lpthread
endif

ltp/Makefile +1 -1
-ifeq ($(HAVE_FALLOCATE), true)
+ifeq ($(HAVE_FALLOCATE), yes)

LCFLAGS += -DFALLOCATE
endif

ltp/fsx.c +21 -2
index fe072d3..4f54ef6 100644
@@ -207,7 +207,8 @@ logdump(void)
 {
 	int	i, count, down;
 	struct log_entry	*lp;
-	char *falloc_type[3] = {"PAST_EOF", "EXTENDING", "INTERIOR"};
+	char *falloc_type[4] = {"PAST_EOF", "EXTENDING", "INTERIOR",
+				"PUNCH_HOLE"};
 
 	prt("LOG DUMP (%d total operations):\n", logcount);
 	if (logcount<  LOGSIZE) {
@@ -791,7 +792,11 @@ dofallocate(unsigned offset, unsigned length)
 {
 	unsigned end_offset;
 	int keep_size;
-
+	int max_offset = 0;
+	int max_len = 0;
+	int punch_hole = 0;
+	int mode = 0;
+	char *op_name;
         if (length == 0) {
                 if (!quiet&&  testcalls>  simulatedopcount)
                         prt("skipping zero length fallocate\n");
@@ -799,11 +804,31 @@ dofallocate(unsigned offset, unsigned length)
                 return;
         }
 
+#ifdef FALLOC_FL_PUNCH_HOLE
+	punch_hole = random() % 2;
+	/* Keep size must be set for punch hole */
+	if (punch_hole) {
+		keep_size = 1;
+		mode = FALLOC_FL_PUNCH_HOLE;
+	} else
+		keep_size = random() % 2;
+#else
 	keep_size = random() % 2;
+#endif
+
+	if (keep_size)
+		mode |= FALLOC_FL_KEEP_SIZE;
+
Quoted 8 lines

ltp/fsx.c dofallocate(unsigned offset, unsigned length) · line 827

Quoted 6 lines
ltp/fsx.c +6 -0
+	if (punch_hole&&  file_size<= (loff_t)offset) {
+		if (!quiet&&  testcalls>  simulatedopcount)
+			prt("skipping hole punch off the end of the file\n");
+		log4(OP_SKIPPED, OP_FALLOCATE, offset, length);
+		return;
+	}

Isn't a hole punch off the end of the file is just a truncate? I think that is a valid test case, since punch(newsize, ~0ULL) should be identical to truncate(newsize). In that case, "keep_size" would affect whether the file size is left alone, or it is now "newsize", so I don't think it should always be set to run with keep_size = 1 for FALLOC_FL_PUNCH_HOLE operations.

Hi there,

Well actually punch hole requires that the keep size flag be set when using the punch hole flag, so it's not quite the same as truncate. The punch hole operation does not modify the length of the file, it only changes whether or not the specified blocks are allocated. So a hole that extends off the end of the file would cause the last few blocks of the file to be released, but the length of the file would not shrink. The above code snippet though is checking to see if the entire hole is off the edge of the file. For example, the file is 3 blocks in length, but we are trying to punch out blocks 5 though 7. This operation would have no effect, so we skip it here.

Allison Henderson

Quoted 64 lines
Quoted 64 lines
ltp/fsx.c +32 -10
 	end_offset = keep_size ? 0 : offset + length;
 
-	if (end_offset>  biggest) {
+	if ((end_offset>  biggest)&&  !punch_hole) {
 		biggest = end_offset;
 		if (!quiet&&  testcalls>  simulatedopcount)
 			prt("fallocating to largest ever: 0x%x\n", end_offset);
@@ -811,13 +836,15 @@ dofallocate(unsigned offset, unsigned length)
 
 	/*
 	 * last arg:
-	 * 	1: allocate past EOF
-	 * 	2: extending prealloc
-	 * 	3: interior prealloc
+	 *      0: allocate past EOF
+	 *      1: extending prealloc
+	 *      2: interior prealloc
+	 *      3: punch hole
 	 */
-	log4(OP_FALLOCATE, offset, length, (end_offset>  file_size) ? (keep_size ? 1 : 2) : 3);
+	log4(OP_FALLOCATE, offset, length, punch_hole ? 3 :
+			(end_offset>  file_size) ? (keep_size ? 0 : 1) : 2);
 
-	if (end_offset>  file_size) {
+	if (((loff_t)end_offset>  file_size)&&  !punch_hole) {
 		memset(good_buf + file_size, '\0', end_offset - file_size);
 		file_size = end_offset;
 	}
@@ -827,13 +854,35 @@ dofallocate(unsigned offset, unsigned length)
 
 	if ((progressinterval&&  testcalls % progressinterval == 0) ||
 	    (debug&&  (monitorstart == -1 || monitorend == -1 ||
-		      end_offset<= monitorend)))
-		prt("%lu falloc\tfrom 0x%x to 0x%x\n", testcalls, offset, length);
-	if (fallocate(fd, keep_size ? FALLOC_FL_KEEP_SIZE : 0, (loff_t)offset, (loff_t)length) == -1) {
-	        prt("fallocate: %x to %x\n", offset, length);
+		      end_offset<= monitorend))) {
+#ifdef FALLOC_FL_PUNCH_HOLE
+		op_name = (mode&  FALLOC_FL_PUNCH_HOLE) ?
+			"punch hole" : "falloc";
+#else
+		op_name = "falloc";
+#endif
+		prt("%lu %s\tfrom 0x%x to 0x%x, (0x%x bytes)\n", testcalls,
+			op_name, offset, offset+length, length);
+	}
+	if (fallocate(fd, mode, (loff_t)offset, (loff_t)length) == -1) {
+#ifdef FALLOC_FL_PUNCH_HOLE
+		op_name = (mode&  FALLOC_FL_PUNCH_HOLE) ?
+			"punch hole" : "fallocate";
+#else
+		op_name = "fallocate";
+#endif
+
+		prt("%s: %x to %x\n", op_name, offset, length);
 		prterr("dofallocate: fallocate");
 		report_failure(161);
 	}
+
+	if (punch_hole) {
+		max_offset = offset<  file_size ? offset : file_size;
+		max_len = max_offset + length<= file_size ? length :
+				file_size - max_offset;
Quoted 13 lines
Quoted 5 lines
ltp/fsx.c +2 -0
+		memset(good_buf + max_offset, '\0', max_len);
+	}
 }
 #else

void

Cheers, Andreas

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw
In reply to Allison Henderson
Quoted 9 lines · Allison Henderson

This patch adds punch hole tests to the fsx stress test. The test is performed through the fallocate call by randomly choosing to use the punch hole flag when running the fallocate test. Regions that have been punched out should contain zeros, so the expected file contents buffer is updated to contain zeros when a hole is punched out.

It doesn't look like you have anything to detect if the hole punching failed to disable it, how does this behave on say btrfs where we don't do hole punching yet? Thanks,

Josef

#6 lore raw
Quoted 11 lines · Josef Bacik
Quoted 9 lines · Allison Henderson

This patch adds punch hole tests to the fsx stress test. The test is performed through the fallocate call by randomly choosing to use the punch hole flag when running the fallocate test. Regions that have been punched out should contain zeros, so the expected file contents buffer is updated to contain zeros when a hole is punched out.

Quoted 5 lines

It doesn't look like you have anything to detect if the hole punching failed to disable it, how does this behave on say btrfs where we don't do hole punching yet? Thanks,

Josef

Hi there,

Oh it looks like I need to add a check for that. I was so busy using it to test ext4 that I forgot to put that in. Thx!

Allison Henderson