Received: by 10.223.164.202 with SMTP id h10csp2515493wrb; Thu, 16 Nov 2017 17:09:42 -0800 (PST) X-Google-Smtp-Source: AGs4zMbOVf/GokRV5M9ZziqoKsx5QSsABz34ZxK7Ghw50NZYFmsZR93ISk5yRQFxJN0vWbY2PQBU X-Received: by 10.101.75.204 with SMTP id p12mr3486048pgr.61.1510880982059; Thu, 16 Nov 2017 17:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510880982; cv=none; d=google.com; s=arc-20160816; b=ceYom75AxOaHj1bwPn+CXansfvSPyZQGMPmimsmxLVQpTk1JkZ0Ft3DYB/JQccoVbr MT8CfbjsGo9yWcyfOsOkLmtQ8LhVkmr+pQWwWpFXStCjSuYgX9KsY9N4ouy98EPHDJux XfT2EPhEsFnvoQmjnBzYnRlo3XXjTD6vV8r33UCDx6vq/8QWidctpYE1rFefC6770RYG 3yBMGZA7PORmsI5QCfVXI6EGuphww11KiyE2hD2DlJ4OtPpR/Raq2OTSeIpQ/uvKqYec 6/YUFsr3WThn/5uYtLirKD3LJzkz/9ovFC6u1dUhDRvPYIRWOjd6oQGgktVqpgn8S2+V ANpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:arc-authentication-results; bh=0l7v9NLMnFi91wIj56637LR8dA14eb2GidSwMBRNbEM=; b=dXXc5KdKwoZL/3aXY/cybIzcRmGVqCJSNAbMcMQl5WkoK0+Ql2qnnXqUd5HUyJwi61 zBt3gj3X/tO0JPoLawWpu83HAN8LQ4KNMbuMCqHgU037qIq8A+0y9JR3LjCsW5dOhYwp MC9p4VkIZvJfeb1/1PbiAtntpxGXiKLKcHOdnBoJPNXwnWk5OW6pEXKmWe43GyTUxmaA ap0Hr66GFfvcWBOK8oL3W6DoZZ99za5oeK1QOhCOWUvoZ3ss901dk5Ch3tokyVWiJ933 v9ZEb09pzwFCDn6S7pAie04tCsPzSxaU7r+REF4uwKxXJyRoOy9vHfsSSEAJ4QmXhj8A gqng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n24si1986860pfa.108.2017.11.16.17.09.29; Thu, 16 Nov 2017 17:09:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935102AbdKPV2Z (ORCPT + 92 others); Thu, 16 Nov 2017 16:28:25 -0500 Received: from mga11.intel.com ([192.55.52.93]:10900 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751599AbdKPV2Q (ORCPT ); Thu, 16 Nov 2017 16:28:16 -0500 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2017 13:28:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,405,1505804400"; d="scan'208";a="177098759" Received: from theros.lm.intel.com (HELO linux.intel.com) ([10.232.112.77]) by fmsmga006.fm.intel.com with ESMTP; 16 Nov 2017 13:28:15 -0800 Date: Thu, 16 Nov 2017 14:28:15 -0700 From: Ross Zwisler To: Dave Chinner Cc: Ross Zwisler , Amir Goldstein , Josef Bacik , Eryu Guan , fstests , linux-kernel , Alasdair Kergon , Dan Williams , Jan Kara , Mike Snitzer , Shaohua Li , dm-devel@redhat.com, linux-nvdimm@lists.01.org, linux-raid@vger.kernel.org, linux-fsdevel , Ext4 , linux-xfs , Christoph Hellwig Subject: Re: [fstests PATCH v3] generic: add test for DAX MAP_SYNC support Message-ID: <20171116212815.GA27448@linux.intel.com> Mail-Followup-To: Ross Zwisler , Dave Chinner , Amir Goldstein , Josef Bacik , Eryu Guan , fstests , linux-kernel , Alasdair Kergon , Dan Williams , Jan Kara , Mike Snitzer , Shaohua Li , dm-devel@redhat.com, linux-nvdimm@lists.01.org, linux-raid@vger.kernel.org, linux-fsdevel , Ext4 , linux-xfs , Christoph Hellwig References: <20171025204704.3382-1-ross.zwisler@linux.intel.com> <20171025215638.GA30335@dastard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171025215638.GA30335@dastard> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > ..... > > --- /dev/null > > +++ b/src/t_map_sync.c > > @@ -0,0 +1,92 @@ > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#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 \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. From 1582294931543745465@xxx Thu Oct 26 05:00:37 +0000 2017 X-GM-THRID: 1581753232979805473 X-Gmail-Labels: Inbox,Category Forums