From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Dave Chinner <david@fromorbit.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>,
Amir Goldstein <amir73il@gmail.com>, Josef Bacik <jbacik@fb.com>,
Eryu Guan <eguan@redhat.com>, fstests <fstests@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Alasdair Kergon <agk@redhat.com>,
Dan Williams <dan.j.williams@intel.com>, Jan Kara <jack@suse.cz>,
Mike Snitzer <snitzer@redhat.com>, Shaohua Li <shli@kernel.org>,
dm-devel@redhat.com, linux-nvdimm@lists.01.org,
linux-raid@vger.kernel.org,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Ext4 <linux-ext4@vger.kernel.org>,
linux-xfs <linux-xfs@vger.kernel.org>,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [fstests PATCH v3] generic: add test for DAX MAP_SYNC support
Date: Thu, 16 Nov 2017 14:28:15 -0700 [thread overview]
Message-ID: <20171116212815.GA27448@linux.intel.com> (raw)
In-Reply-To: <20171025215638.GA30335@dastard>
On Thu, Oct 26, 2017 at 08:56:38AM +1100, Dave Chinner wrote:
> On Wed, Oct 25, 2017 at 02:47:04PM -0600, Ross Zwisler wrote:
> > Add a test that exercises DAX's new MAP_SYNC flag.
> >
> > This test creates a file and writes to it via an mmap(), but never syncs
> > via fsync/msync. This process is tracked via dm-log-writes, then replayed.
> >
> > If MAP_SYNC is working the dm-log-writes replay will show the test file
> > with 1MiB of on-media block allocations. This is because each allocating
> > page fault included an implicit metadata sync. If MAP_SYNC isn't working
> > (which you can test by fiddling with the parameters to mmap()) the file
> > will be smaller or missing entirely.
> >
> > Note that dm-log-writes doesn't track the data that we write via the
> > mmap(), so we can't do any data integrity checking. We can only verify
> > that the metadata writes for the page faults happened.
> >
> > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> .....
> > --- /dev/null
> > +++ b/src/t_map_sync.c
> > @@ -0,0 +1,92 @@
> > +#include <errno.h>
> > +#include <fcntl.h>
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <string.h>
> > +#include <sys/mman.h>
> > +#include <sys/stat.h>
> > +#include <sys/types.h>
> > +#include <unistd.h>
> > +
> > +#define MiB(a) ((a)*1024*1024)
> > +
> > +/*
> > + * These two defines were added to the kernel via commits entitled
> > + * "mm: Define MAP_SYNC and VM_SYNC flags" and
> > + * "mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap
> > + * flags", respectively.
> > + */
> > +#ifndef MAP_SYNC
> > +#define MAP_SYNC 0x80000
> > +#endif
> > +
> > +#ifndef MAP_SHARED_VALIDATE
> > +#define MAP_SHARED_VALIDATE 0x3
> > +#endif
>
> Autoconf rules for detecting supported functionality, please...
Yep, that's better. As you've suggested down below I'm adding this
functionality to xfs_io instead, and I've added autoconf rules there.
> > +
> > +void err_exit(char *op)
> > +{
> > + fprintf(stderr, "%s: %s\n", op, strerror(errno));
> > + exit(1);
> > +}
> > +
> > +void mark_log(char *logwrites_name, char *mark_name)
> > +{
> > + char command[256];
> > +
> > + snprintf(command, 256, "dmsetup message %s 0 mark %s",
> > + logwrites_name, mark_name);
> > +
> > + if (system(command))
> > + err_exit("mark_log");
> > +}
> > +
> > +int main(int argc, char *argv[])
> > +{
> > + int page_size = getpagesize();
> > + int len = MiB(1);
> > + int i, fd, err;
> > + char *data;
> > +
> > + if (argc < 4) {
> > + printf("Usage: %s <file> <logwrites_name> <mark_name>\n",
> > + basename(argv[0]));
> > + exit(0);
> > + }
> > +
> > + fd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
> > + if (fd < 0)
> > + err_exit("fd");
> > +
> > + ftruncate(fd, len);
> > +
> > + data = mmap(NULL, len, PROT_READ|PROT_WRITE,
> > + MAP_SHARED_VALIDATE|MAP_SYNC, fd, 0);
> > + if (data == MAP_FAILED)
> > + err_exit("mmap");
>
> As I say to all these sorts of one-off test prgrams: please add the
> new MAP_SYNC flag to xfs_io rather than writing a one-off
> test program to set it and write some data.
>
> And if we're going to be adding special custom tests just because
> we need to insert dm-log marks, add that functionality to xfs_io,
> too.
>
> That way we can create complex custom dm logwrite tests without
> needing one-off test programs for them all...
Yep, that was a better path. I've got things working - need to clean up and
I'll send out soon.
> > +#! /bin/bash
> > +# FS QA Test No. 466
> > +#
> > +# Use md_log_writes to verify that MAP_SYNC actually syncs metadata during
>
> dm_log_writes?
Fixed.
> > +# We should see $SCRATCH_MNT/test as having 1MiB in block allocations
> > +du -sh $SCRATCH_MNT/test | _filter_scratch | _filter_spaces
>
> Perhaps stat -c %b $SCRATCH_MNT/test ?
Maybe, but doesn't the output of 'stat -c %b' depend on the block size the
filesystem is using? I think to use stat I'd have to check both %b and %B,
and account for different block sizes, or do some shell math. I think it may
be easier to just use du.
Thank you for the review, sorry for the delayed response.
next prev parent reply other threads:[~2017-11-16 21:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-20 5:24 [PATCH 1/2] dm log writes: Add support for inline data buffers Ross Zwisler
2017-10-20 5:24 ` [PATCH 2/2] dm log writes: add support for DAX Ross Zwisler
2017-10-23 17:34 ` Josef Bacik
2017-10-23 18:59 ` Ross Zwisler
2017-10-24 19:22 ` Mike Snitzer
2017-10-24 19:30 ` Ross Zwisler
2017-10-20 5:29 ` [fstests PATCH] generic: add test for DAX MAP_SYNC support Ross Zwisler
2017-10-20 6:51 ` Amir Goldstein
2017-10-20 21:25 ` [fstests PATCH v2] " Ross Zwisler
2017-10-22 6:56 ` Amir Goldstein
2017-10-25 12:19 ` Amir Goldstein
2017-10-25 17:12 ` Ross Zwisler
2017-10-25 20:47 ` [fstests PATCH v3] " Ross Zwisler
2017-10-25 21:56 ` Dave Chinner
2017-11-16 21:28 ` Ross Zwisler [this message]
2017-11-16 21:31 ` Ross Zwisler
2017-10-26 4:59 ` Amir Goldstein
2017-11-16 22:59 ` Ross Zwisler
2017-10-24 19:14 ` [PATCH 1/2] dm log writes: Add support for inline data buffers Mike Snitzer
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=20171116212815.GA27448@linux.intel.com \
--to=ross.zwisler@linux.intel.com \
--cc=agk@redhat.com \
--cc=amir73il@gmail.com \
--cc=dan.j.williams@intel.com \
--cc=david@fromorbit.com \
--cc=dm-devel@redhat.com \
--cc=eguan@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=jbacik@fb.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=linux-raid@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=shli@kernel.org \
--cc=snitzer@redhat.com \
/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).