public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: fstests@vger.kernel.org, Amir Goldstein <amir73il@gmail.com>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Subject: [PATCH] seek_sanity_test: Repair check for unwritten extent support
Date: Wed,  7 Aug 2019 13:25:14 +0200	[thread overview]
Message-ID: <20190807112514.1903-1-agruenba@redhat.com> (raw)

In test_basic_support, commit f3c1bca7fb25 ("generic: Test that
SEEK_HOLE can find a punched hole") cleverly punched a hole in the test
file in the middle of the check for unwritten extent support, making
sure we would never detect when unwritten extent support is missing.
Fix that.

While at it, explicitly check for SEEK_DATA support as well:  so far, we
were assuming that SEEK_HOLE support implies SEEK_DATA support, but it
won't hurt to actually check.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 src/seek_sanity_test.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
index 30e996e2..080ca7eb 100644
--- a/src/seek_sanity_test.c
+++ b/src/seek_sanity_test.c
@@ -1156,7 +1156,16 @@ static int test_basic_support(void)
 	if (ret)
 		goto out;
 
-	/* Is SEEK_DATA and SEEK_HOLE supported in the kernel? */
+	/* Is SEEK_DATA supported in the kernel? */
+	pos = lseek(fd, 0, SEEK_DATA);
+	if (pos == -1) {
+		fprintf(stderr, "Kernel does not support llseek(2) extension "
+			"SEEK_DATA. Aborting.\n");
+		ret = -1;
+		goto out;
+	}
+
+	/* Is SEEK_HOLE supported in the kernel? */
 	pos = lseek(fd, 0, SEEK_HOLE);
 	if (pos == -1) {
 		fprintf(stderr, "Kernel does not support llseek(2) extension "
@@ -1186,19 +1195,21 @@ static int test_basic_support(void)
 			ret = -1;
 		}
 		goto out;
-	} else if (fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
-			     0, alloc_size) == -1) {
-		fprintf(stderr, "File system does not support punch hole.\n");
-	} else {
-		punch_hole = 1;
 	}
 
 	pos = lseek(fd, 0, SEEK_DATA);
 	if (pos == 0) {
 		fprintf(stderr, "File system does not support unwritten extents.\n");
-		goto out;
+	} else {
+		unwritten_extents = 1;
+	}
+
+	if (fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+			     0, alloc_size) == -1) {
+		fprintf(stderr, "File system does not support punch hole.\n");
+	} else {
+		punch_hole = 1;
 	}
-	unwritten_extents = 1;
 
 	printf("\n");
 
-- 
2.20.1

             reply	other threads:[~2019-08-07 11:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07 11:25 Andreas Gruenbacher [this message]
2019-08-11 14:33 ` [PATCH] seek_sanity_test: Repair check for unwritten extent support Eryu Guan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190807112514.1903-1-agruenba@redhat.com \
    --to=agruenba@redhat.com \
    --cc=amir73il@gmail.com \
    --cc=fstests@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox