From: Andreas Gruenbacher <agruenba@redhat.com>
To: fstests@vger.kernel.org
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Subject: [PATCH] src/seek_sanity_test: Fix for filesystems without delayed allocation
Date: Wed, 10 May 2017 13:46:04 +0200 [thread overview]
Message-ID: <1494416764-22528-1-git-send-email-agruenba@redhat.com> (raw)
src/seek_sanity_test (test generic/285) assumes that after fallocating
space in a file, fseek SEEK_HOLE / SEEK_DATA will still report the
allocated space as a hole. This isn't true on filesystems that don't
support delayed allocation, so skip the affected tests in that case.
Tested on xfs and gfs2 + patches for fseek SEEK_HOLE / SEEK_DATA.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
src/seek_sanity_test.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
index a6dd48c..86ddf1c 100644
--- a/src/seek_sanity_test.c
+++ b/src/seek_sanity_test.c
@@ -37,6 +37,7 @@
static blksize_t alloc_size;
int default_behavior = 0;
+int delayed_allocation = 1;
char *base_file_path;
static void get_file_system(int fd)
@@ -282,6 +283,12 @@ static int test09(int fd, int testnum)
int bufsz = alloc_size;
int filsz = 8 << 20;
+ if (!delayed_allocation) {
+ /* Report success if fs doesn't support delayed allocation */
+ fprintf(stdout, "Test skipped as fs doesn't support delayed allocation\n");
+ goto out;
+ }
+
/*
* HOLE - unwritten DATA in dirty page - HOLE -
* unwritten DATA in writeback page
@@ -338,6 +345,12 @@ static int test08(int fd, int testnum)
int bufsz = alloc_size;
int filsz = 4 << 20;
+ if (!delayed_allocation) {
+ /* Report success if fs doesn't support delayed allocation */
+ fprintf(stdout, "Test skipped as fs doesn't support delayed allocation\n");
+ goto out;
+ }
+
/* HOLE - unwritten DATA in writeback page */
/* Each unit is bufsz */
buf = do_malloc(bufsz);
@@ -387,6 +400,12 @@ static int test07(int fd, int testnum)
int bufsz = alloc_size;
int filsz = 4 << 20;
+ if (!delayed_allocation) {
+ /* Report success if fs doesn't support delayed allocation */
+ fprintf(stdout, "Test skipped as fs doesn't support delayed allocation\n");
+ goto out;
+ }
+
/* HOLE - unwritten DATA in dirty page */
/* Each unit is bufsz */
buf = do_malloc(bufsz);
@@ -776,6 +795,14 @@ static int test_basic_support(void)
fprintf(stderr, "File system supports the default behavior.\n");
}
+ ftruncate(fd, 0);
+ fallocate(fd, 0, 0, 1 << 20);
+ pos = lseek(fd, 0, SEEK_DATA);
+ if (pos == 0) {
+ fprintf(stderr, "File system does not support delayed allocation.\n");
+ delayed_allocation = 0;
+ }
+
printf("\n");
out:
--
2.7.4
next reply other threads:[~2017-05-10 11:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-10 11:46 Andreas Gruenbacher [this message]
2017-05-11 5:58 ` [PATCH] src/seek_sanity_test: Fix for filesystems without delayed allocation Eryu Guan
2017-05-11 11:28 ` Andreas Gruenbacher
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=1494416764-22528-1-git-send-email-agruenba@redhat.com \
--to=agruenba@redhat.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