* [PATCH] src/seek_sanity_test: Fix for filesystems without delayed allocation
@ 2017-05-10 11:46 Andreas Gruenbacher
2017-05-11 5:58 ` Eryu Guan
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Gruenbacher @ 2017-05-10 11:46 UTC (permalink / raw)
To: fstests; +Cc: Andreas Gruenbacher
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] src/seek_sanity_test: Fix for filesystems without delayed allocation
2017-05-10 11:46 [PATCH] src/seek_sanity_test: Fix for filesystems without delayed allocation Andreas Gruenbacher
@ 2017-05-11 5:58 ` Eryu Guan
2017-05-11 11:28 ` Andreas Gruenbacher
0 siblings, 1 reply; 3+ messages in thread
From: Eryu Guan @ 2017-05-11 5:58 UTC (permalink / raw)
To: Andreas Gruenbacher; +Cc: fstests
On Wed, May 10, 2017 at 01:46:04PM +0200, Andreas Gruenbacher wrote:
> 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.
I'm not sure if this is really about delayed allocation, I tried
nodelalloc mounted ext4, test still passed. And the following test
reported fallocated space as HOLE, on both delalloc and nodelalloc
mounted ext4:
[root@bootp-73-5-205 xfstests]# grep vda6 /proc/mounts
/dev/vda6 /mnt/ext4 ext4 rw,seclabel,relatime,nodelalloc,data=ordered 0 0
[root@bootp-73-5-205 xfstests]# rm /mnt/ext4/testfile
[root@bootp-73-5-205 xfstests]# xfs_io -fc "falloc 0 1m" -c "seek -h 0" -c "seek -d 0" /mnt/ext4/testfile
Whence Result
HOLE 0
Whence Result
DATA EOF
[root@bootp-73-5-205 xfstests]# mount -o remount,delalloc /mnt/ext4
[root@bootp-73-5-205 xfstests]# grep vda6 /proc/mounts
/dev/vda6 /mnt/ext4 ext4 rw,seclabel,relatime,data=ordered 0 0
[root@bootp-73-5-205 xfstests]# rm /mnt/ext4/testfile
[root@bootp-73-5-205 xfstests]# xfs_io -fc "falloc 0 1m" -c "seek -h 0" -c "seek -d 0" /mnt/ext4/testfile
Whence Result
HOLE 0
Whence Result
DATA EOF
I noticed that test07/8/9 are the only three that test unwritten
extents, perhaps not supporting unwritten extents are the reason?
Thanks,
Eryu
>
> 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
>
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] src/seek_sanity_test: Fix for filesystems without delayed allocation
2017-05-11 5:58 ` Eryu Guan
@ 2017-05-11 11:28 ` Andreas Gruenbacher
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Gruenbacher @ 2017-05-11 11:28 UTC (permalink / raw)
To: Eryu Guan; +Cc: fstests
Eryu,
thanks for the review.
On Thu, May 11, 2017 at 7:58 AM, Eryu Guan <eguan@redhat.com> wrote:
> On Wed, May 10, 2017 at 01:46:04PM +0200, Andreas Gruenbacher wrote:
>> 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.
>
> I'm not sure if this is really about delayed allocation, I tried
> nodelalloc mounted ext4, test still passed. And the following test
> reported fallocated space as HOLE, on both delalloc and nodelalloc
> mounted ext4:
>
> [root@bootp-73-5-205 xfstests]# grep vda6 /proc/mounts
> /dev/vda6 /mnt/ext4 ext4 rw,seclabel,relatime,nodelalloc,data=ordered 0 0
> [root@bootp-73-5-205 xfstests]# rm /mnt/ext4/testfile
> [root@bootp-73-5-205 xfstests]# xfs_io -fc "falloc 0 1m" -c "seek -h 0" -c "seek -d 0" /mnt/ext4/testfile
> Whence Result
> HOLE 0
> Whence Result
> DATA EOF
> [root@bootp-73-5-205 xfstests]# mount -o remount,delalloc /mnt/ext4
> [root@bootp-73-5-205 xfstests]# grep vda6 /proc/mounts
> /dev/vda6 /mnt/ext4 ext4 rw,seclabel,relatime,data=ordered 0 0
> [root@bootp-73-5-205 xfstests]# rm /mnt/ext4/testfile
> [root@bootp-73-5-205 xfstests]# xfs_io -fc "falloc 0 1m" -c "seek -h 0" -c "seek -d 0" /mnt/ext4/testfile
> Whence Result
> HOLE 0
> Whence Result
> DATA EOF
>
> I noticed that test07/8/9 are the only three that test unwritten
> extents, perhaps not supporting unwritten extents are the reason?
You are right, unwritten extents is the correct term for that
particular technique. I noticed that some additional error checking
makes sense as well, so I'll repost.
Thanks,
Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-11 11:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-10 11:46 [PATCH] src/seek_sanity_test: Fix for filesystems without delayed allocation Andreas Gruenbacher
2017-05-11 5:58 ` Eryu Guan
2017-05-11 11:28 ` Andreas Gruenbacher
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.