From: Zorro Lang <zlang@redhat.com>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: fstests@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH V2 2/3] t_mmap_collision: fix hard-coded page size
Date: Fri, 21 Feb 2020 21:53:32 +0800 [thread overview]
Message-ID: <20200221135332.GK14282@dhcp-12-102.nay.redhat.com> (raw)
In-Reply-To: <20200220200632.14075-3-jmoyer@redhat.com>
On Thu, Feb 20, 2020 at 03:06:31PM -0500, Jeff Moyer wrote:
> Fix the test to run on non-4k page size systems.
>
> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
> ---
This patch looks good to me, and it's really helpful.
Thanks,
Zorro
Before patched:
FSTYP -- xfs (non-debug)
PLATFORM -- Linux/aarch64
MKFS_OPTIONS -- -f -b size=65536 -m crc=1,finobt=1,reflink=1,rmapbt=1 -i sparse=1 /dev/sda5
MOUNT_OPTIONS -- -o context=system_u:object_r:nfs_t:s0 /dev/sda5 /mnt/xfstests/mnt2
generic/503 14s ... - output mismatch (see /root/xfstests-dev/results//generic/503.out.bad)
--- tests/generic/503.out 2020-02-21 05:41:37.992675071 -0500
+++ /root/xfstests-dev/results//generic/503.out.bad 2020-02-21 08:20:19.736550319 -0500
@@ -1,2 +1,4 @@
QA output created by 503
+collapse_range_fn fallocate 2: Invalid argument
+collapse_range_fn fallocate 2: Invalid argument
...
After patched:
FSTYP -- xfs (non-debug)
PLATFORM -- Linux/aarch64
MKFS_OPTIONS -- -f -b size=65536 -m crc=1,finobt=1,reflink=1,rmapbt=1 -i sparse=1 /dev/sda5
MOUNT_OPTIONS -- -o context=system_u:object_r:nfs_t:s0 /dev/sda5 /mnt/xfstests/mnt2
generic/503 16s ... 16s
Ran: generic/503
Passed all 1 tests
> src/t_mmap_collision.c | 40 +++++++++++++++++++++-------------------
> 1 file changed, 21 insertions(+), 19 deletions(-)
>
> diff --git a/src/t_mmap_collision.c b/src/t_mmap_collision.c
> index d547bc05..c872f4e2 100644
> --- a/src/t_mmap_collision.c
> +++ b/src/t_mmap_collision.c
> @@ -25,13 +25,12 @@
> #include <sys/types.h>
> #include <unistd.h>
>
> -#define PAGE(a) ((a)*0x1000)
> -#define FILE_SIZE PAGE(4)
> -
> void *dax_data;
> int nodax_fd;
> int dax_fd;
> bool done;
> +static int pagesize;
> +static int file_size;
>
> #define err_exit(op) \
> { \
> @@ -49,18 +48,18 @@ void punch_hole_fn(void *ptr)
> read = 0;
>
> do {
> - rc = pread(nodax_fd, dax_data + read, FILE_SIZE - read,
> + rc = pread(nodax_fd, dax_data + read, file_size - read,
> read);
> if (rc > 0)
> read += rc;
> } while (rc > 0);
>
> - if (read != FILE_SIZE || rc != 0)
> + if (read != file_size || rc != 0)
> err_exit("pread");
>
> rc = fallocate(dax_fd,
> FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
> - 0, FILE_SIZE);
> + 0, file_size);
> if (rc < 0)
> err_exit("fallocate");
>
> @@ -81,18 +80,18 @@ void zero_range_fn(void *ptr)
> read = 0;
>
> do {
> - rc = pread(nodax_fd, dax_data + read, FILE_SIZE - read,
> + rc = pread(nodax_fd, dax_data + read, file_size - read,
> read);
> if (rc > 0)
> read += rc;
> } while (rc > 0);
>
> - if (read != FILE_SIZE || rc != 0)
> + if (read != file_size || rc != 0)
> err_exit("pread");
>
> rc = fallocate(dax_fd,
> FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE,
> - 0, FILE_SIZE);
> + 0, file_size);
> if (rc < 0)
> err_exit("fallocate");
>
> @@ -113,11 +112,11 @@ void truncate_down_fn(void *ptr)
>
> if (ftruncate(dax_fd, 0) < 0)
> err_exit("ftruncate");
> - if (fallocate(dax_fd, 0, 0, FILE_SIZE) < 0)
> + if (fallocate(dax_fd, 0, 0, file_size) < 0)
> err_exit("fallocate");
>
> do {
> - rc = pread(nodax_fd, dax_data + read, FILE_SIZE - read,
> + rc = pread(nodax_fd, dax_data + read, file_size - read,
> read);
> if (rc > 0)
> read += rc;
> @@ -142,15 +141,15 @@ void collapse_range_fn(void *ptr)
> while (!done) {
> read = 0;
>
> - if (fallocate(dax_fd, 0, 0, FILE_SIZE) < 0)
> + if (fallocate(dax_fd, 0, 0, file_size) < 0)
> err_exit("fallocate 1");
> - if (fallocate(dax_fd, FALLOC_FL_COLLAPSE_RANGE, 0, PAGE(1)) < 0)
> + if (fallocate(dax_fd, FALLOC_FL_COLLAPSE_RANGE, 0, pagesize) < 0)
> err_exit("fallocate 2");
> - if (fallocate(dax_fd, 0, 0, FILE_SIZE) < 0)
> + if (fallocate(dax_fd, 0, 0, file_size) < 0)
> err_exit("fallocate 3");
>
> do {
> - rc = pread(nodax_fd, dax_data + read, FILE_SIZE - read,
> + rc = pread(nodax_fd, dax_data + read, file_size - read,
> read);
> if (rc > 0)
> read += rc;
> @@ -192,6 +191,9 @@ int main(int argc, char *argv[])
> exit(0);
> }
>
> + pagesize = getpagesize();
> + file_size = 4 * pagesize;
> +
> dax_fd = open(argv[1], O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
> if (dax_fd < 0)
> err_exit("dax_fd open");
> @@ -202,15 +204,15 @@ int main(int argc, char *argv[])
>
> if (ftruncate(dax_fd, 0) < 0)
> err_exit("dax_fd ftruncate");
> - if (fallocate(dax_fd, 0, 0, FILE_SIZE) < 0)
> + if (fallocate(dax_fd, 0, 0, file_size) < 0)
> err_exit("dax_fd fallocate");
>
> if (ftruncate(nodax_fd, 0) < 0)
> err_exit("nodax_fd ftruncate");
> - if (fallocate(nodax_fd, 0, 0, FILE_SIZE) < 0)
> + if (fallocate(nodax_fd, 0, 0, file_size) < 0)
> err_exit("nodax_fd fallocate");
>
> - dax_data = mmap(NULL, FILE_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED,
> + dax_data = mmap(NULL, file_size, PROT_READ|PROT_WRITE, MAP_SHARED,
> dax_fd, 0);
> if (dax_data == MAP_FAILED)
> err_exit("mmap");
> @@ -220,7 +222,7 @@ int main(int argc, char *argv[])
> run_test(&truncate_down_fn);
> run_test(&collapse_range_fn);
>
> - if (munmap(dax_data, FILE_SIZE) != 0)
> + if (munmap(dax_data, file_size) != 0)
> err_exit("munmap");
>
> err = close(dax_fd);
> --
> 2.19.1
>
next prev parent reply other threads:[~2020-02-21 13:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-20 20:06 [PATCH V2 0/3] fstests: fixes for 64k pages and dax Jeff Moyer
2020-02-20 20:06 ` [PATCH V2 1/3] dax/dm: disable testing on devices that don't support dax Jeff Moyer
2020-02-21 9:48 ` Zorro Lang
2020-02-23 15:07 ` Eryu Guan
2020-02-24 6:15 ` Zorro Lang
2020-02-20 20:06 ` [PATCH V2 2/3] t_mmap_collision: fix hard-coded page size Jeff Moyer
2020-02-21 13:53 ` Zorro Lang [this message]
2020-02-20 20:06 ` [PATCH V2 3/3] xfs/300: modify test to work on any fs block size Jeff Moyer
2020-02-22 5:31 ` Zorro Lang
2020-02-24 13:46 ` Jeff Moyer
2020-02-26 7:42 ` Zorro Lang
2020-02-20 21:21 ` [PATCH V2 0/3] fstests: fixes for 64k pages and dax Darrick J. Wong
2020-02-21 20:11 ` Jeff Moyer
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=20200221135332.GK14282@dhcp-12-102.nay.redhat.com \
--to=zlang@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=jmoyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@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;
as well as URLs for NNTP newsgroup(s).