From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw0-x242.google.com (mail-yw0-x242.google.com [IPv6:2607:f8b0:4002:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A006B2217CE2D for ; Wed, 6 Dec 2017 05:36:53 -0800 (PST) Received: by mail-yw0-x242.google.com with SMTP id y187so1549026ywg.6 for ; Wed, 06 Dec 2017 05:41:25 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20171206003744.28587-3-ross.zwisler@linux.intel.com> References: <20171206003744.28587-1-ross.zwisler@linux.intel.com> <20171206003744.28587-3-ross.zwisler@linux.intel.com> From: Amir Goldstein Date: Wed, 6 Dec 2017 15:41:24 +0200 Message-ID: Subject: Re: [fstests PATCH v5 2/2] generic: add test for DAX MAP_SYNC support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Ross Zwisler Cc: Jan Kara , Eryu Guan , linux-nvdimm , Dave Chinner , fstests , linux-xfs List-ID: On Wed, Dec 6, 2017 at 2:37 AM, Ross Zwisler wrote: > 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 1 MiB 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 removing the "-S" flag to xfs_io 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 > --- > common/dmlogwrites | 20 +++++++++++++ > tests/generic/999 | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ > tests/generic/999.out | 3 ++ > tests/generic/group | 1 + > 4 files changed, 106 insertions(+) > create mode 100755 tests/generic/999 > create mode 100644 tests/generic/999.out > > diff --git a/common/dmlogwrites b/common/dmlogwrites > index 05829dbc..2b697bec 100644 > --- a/common/dmlogwrites > +++ b/common/dmlogwrites > @@ -28,6 +28,26 @@ _require_log_writes() > _require_test_program "log-writes/replay-log" > } > > +_require_log_writes_dax() > +{ > + [ -z "$LOGWRITES_DEV" -o ! -b "$LOGWRITES_DEV" ] && \ > + _notrun "This test requires a valid \$LOGWRITES_DEV" > + > + _require_dm_target log-writes > + _require_test_program "log-writes/replay-log" > + > + _scratch_unmount > + _log_writes_init > + _log_writes_mkfs > /dev/null 2>&1 > + _log_writes_mount -o dax > + # Check options to be sure. XFS ignores dax option > + # and goes on if dev underneath does not support dax. > + _fs_options $LOGWRITES_DMDEV | grep -qw "dax" || \ > + _notrun "$LOGWRITES_DMDEV $FSTYP does not support -o dax" > + _log_writes_unmount > + _log_writes_remove > +} > + > _log_writes_init() > { > local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV` > diff --git a/tests/generic/999 b/tests/generic/999 > new file mode 100755 > index 00000000..ca5772da > --- /dev/null > +++ b/tests/generic/999 > @@ -0,0 +1,82 @@ > +#! /bin/bash > +# FS QA Test No. 999 > +# > +# Use dm-log-writes to verify that MAP_SYNC actually syncs metadata during > +# page faults. > +# > +#----------------------------------------------------------------------- > +# Copyright (c) 2017 Intel Corporation. All Rights Reserved. > +# > +# This program is free software; you can redistribute it and/or > +# modify it under the terms of the GNU General Public License as > +# published by the Free Software Foundation. > +# > +# This program is distributed in the hope that it would be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program; if not, write the Free Software Foundation, > +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > +#----------------------------------------------------------------------- > +# > + > +seq=`basename $0` > +seqres=$RESULT_DIR/$seq > +echo "QA output created by $seq" > + > +here=`pwd` > +status=1 # failure is the default! > +trap "_cleanup; exit \$status" 0 1 2 3 15 > + > +_cleanup() > +{ > + _log_writes_cleanup > +} > + > +# get standard environment, filters and checks > +. ./common/rc > +. ./common/filter > +. ./common/dmlogwrites > + > +# remove previous $seqres.full before test > +rm -f $seqres.full > + > +# real QA test starts here > +_supported_fs generic > +_supported_os Linux > +_require_log_writes_dax > +_require_xfs_io_command "log_writes" > + > +_log_writes_init > +_log_writes_mkfs >> $seqres.full 2>&1 > +_log_writes_mount -o dax > + > +LEN=$((1024 * 1024)) # 1 MiB > + > +xfs_io -t -c "truncate $LEN" -c "mmap -S 0 $LEN" -c "mwrite 0 $LEN" \ > + -c "log_writes -d $LOGWRITES_NAME -m preunmap" \ > + -f $SCRATCH_MNT/test > + > +# Unmount the scratch dir and tear down the log writes target > +_log_writes_unmount > +_log_writes_remove > +_check_scratch_fs > + > +# destroy previous filesystem so we can be sure our rebuild works > +_scratch_mkfs >> $seqres.full 2>&1 > + > +# check pre-unmap state > +_log_writes_replay_log preunmap > +_scratch_mount > + > +# We should see $SCRATCH_MNT/test as having 1 MiB in block allocations > +du -sh $SCRATCH_MNT/test | _filter_scratch | _filter_spaces > + > +_scratch_unmount > +_check_scratch_fs > + > +echo "Silence is golden" > +status=0 > +exit > diff --git a/tests/generic/999.out b/tests/generic/999.out > new file mode 100644 > index 00000000..c7b8f8a2 > --- /dev/null > +++ b/tests/generic/999.out > @@ -0,0 +1,3 @@ > +QA output created by 999 > +1.0M SCRATCH_MNT/test > +Silence is golden You test is not silent ;) Otherwise looks good Amir. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw0-f195.google.com ([209.85.161.195]:42391 "EHLO mail-yw0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752141AbdLFNlZ (ORCPT ); Wed, 6 Dec 2017 08:41:25 -0500 MIME-Version: 1.0 In-Reply-To: <20171206003744.28587-3-ross.zwisler@linux.intel.com> References: <20171206003744.28587-1-ross.zwisler@linux.intel.com> <20171206003744.28587-3-ross.zwisler@linux.intel.com> From: Amir Goldstein Date: Wed, 6 Dec 2017 15:41:24 +0200 Message-ID: Subject: Re: [fstests PATCH v5 2/2] generic: add test for DAX MAP_SYNC support Content-Type: text/plain; charset="UTF-8" Sender: fstests-owner@vger.kernel.org To: Ross Zwisler Cc: fstests , Eryu Guan , linux-xfs , linux-nvdimm , Jan Kara , Dave Chinner , Dan Williams List-ID: On Wed, Dec 6, 2017 at 2:37 AM, Ross Zwisler wrote: > 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 1 MiB 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 removing the "-S" flag to xfs_io 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 > --- > common/dmlogwrites | 20 +++++++++++++ > tests/generic/999 | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ > tests/generic/999.out | 3 ++ > tests/generic/group | 1 + > 4 files changed, 106 insertions(+) > create mode 100755 tests/generic/999 > create mode 100644 tests/generic/999.out > > diff --git a/common/dmlogwrites b/common/dmlogwrites > index 05829dbc..2b697bec 100644 > --- a/common/dmlogwrites > +++ b/common/dmlogwrites > @@ -28,6 +28,26 @@ _require_log_writes() > _require_test_program "log-writes/replay-log" > } > > +_require_log_writes_dax() > +{ > + [ -z "$LOGWRITES_DEV" -o ! -b "$LOGWRITES_DEV" ] && \ > + _notrun "This test requires a valid \$LOGWRITES_DEV" > + > + _require_dm_target log-writes > + _require_test_program "log-writes/replay-log" > + > + _scratch_unmount > + _log_writes_init > + _log_writes_mkfs > /dev/null 2>&1 > + _log_writes_mount -o dax > + # Check options to be sure. XFS ignores dax option > + # and goes on if dev underneath does not support dax. > + _fs_options $LOGWRITES_DMDEV | grep -qw "dax" || \ > + _notrun "$LOGWRITES_DMDEV $FSTYP does not support -o dax" > + _log_writes_unmount > + _log_writes_remove > +} > + > _log_writes_init() > { > local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV` > diff --git a/tests/generic/999 b/tests/generic/999 > new file mode 100755 > index 00000000..ca5772da > --- /dev/null > +++ b/tests/generic/999 > @@ -0,0 +1,82 @@ > +#! /bin/bash > +# FS QA Test No. 999 > +# > +# Use dm-log-writes to verify that MAP_SYNC actually syncs metadata during > +# page faults. > +# > +#----------------------------------------------------------------------- > +# Copyright (c) 2017 Intel Corporation. All Rights Reserved. > +# > +# This program is free software; you can redistribute it and/or > +# modify it under the terms of the GNU General Public License as > +# published by the Free Software Foundation. > +# > +# This program is distributed in the hope that it would be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program; if not, write the Free Software Foundation, > +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > +#----------------------------------------------------------------------- > +# > + > +seq=`basename $0` > +seqres=$RESULT_DIR/$seq > +echo "QA output created by $seq" > + > +here=`pwd` > +status=1 # failure is the default! > +trap "_cleanup; exit \$status" 0 1 2 3 15 > + > +_cleanup() > +{ > + _log_writes_cleanup > +} > + > +# get standard environment, filters and checks > +. ./common/rc > +. ./common/filter > +. ./common/dmlogwrites > + > +# remove previous $seqres.full before test > +rm -f $seqres.full > + > +# real QA test starts here > +_supported_fs generic > +_supported_os Linux > +_require_log_writes_dax > +_require_xfs_io_command "log_writes" > + > +_log_writes_init > +_log_writes_mkfs >> $seqres.full 2>&1 > +_log_writes_mount -o dax > + > +LEN=$((1024 * 1024)) # 1 MiB > + > +xfs_io -t -c "truncate $LEN" -c "mmap -S 0 $LEN" -c "mwrite 0 $LEN" \ > + -c "log_writes -d $LOGWRITES_NAME -m preunmap" \ > + -f $SCRATCH_MNT/test > + > +# Unmount the scratch dir and tear down the log writes target > +_log_writes_unmount > +_log_writes_remove > +_check_scratch_fs > + > +# destroy previous filesystem so we can be sure our rebuild works > +_scratch_mkfs >> $seqres.full 2>&1 > + > +# check pre-unmap state > +_log_writes_replay_log preunmap > +_scratch_mount > + > +# We should see $SCRATCH_MNT/test as having 1 MiB in block allocations > +du -sh $SCRATCH_MNT/test | _filter_scratch | _filter_spaces > + > +_scratch_unmount > +_check_scratch_fs > + > +echo "Silence is golden" > +status=0 > +exit > diff --git a/tests/generic/999.out b/tests/generic/999.out > new file mode 100644 > index 00000000..c7b8f8a2 > --- /dev/null > +++ b/tests/generic/999.out > @@ -0,0 +1,3 @@ > +QA output created by 999 > +1.0M SCRATCH_MNT/test > +Silence is golden You test is not silent ;) Otherwise looks good Amir.