fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: fdmanana@kernel.org
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, Filipe Manana <fdmanana@suse.com>
Subject: [PATCH 1/2] generic: test number of blocks used by a file after mwrite into a hole
Date: Wed,  4 Nov 2020 11:13:37 +0000	[thread overview]
Message-ID: <289e1444dc95cb86945126b2677ca25879fdb8dd.1604487838.git.fdmanana@suse.com> (raw)
In-Reply-To: <cover.1604487838.git.fdmanana@suse.com>

From: Filipe Manana <fdmanana@suse.com>

Test that after doing a memory mapped write to an empty file, a call to
stat(2) reports a non-zero number of used blocks.

This is motivated by a bug in btrfs where the number of blocks used does
not change. It currenly fails on btrfs and it is fixed by a patch that
has the following subject:

  "btrfs: fix missing delalloc new bit for new delalloc ranges"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 tests/generic/614     | 50 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/614.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 53 insertions(+)
 create mode 100755 tests/generic/614
 create mode 100644 tests/generic/614.out

diff --git a/tests/generic/614 b/tests/generic/614
new file mode 100755
index 00000000..80edf9cd
--- /dev/null
+++ b/tests/generic/614
@@ -0,0 +1,50 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
+#
+# FS QA Test No. 614
+#
+# Test that after doing a memory mapped write to an empty file, a call to
+# stat(2) reports a non-zero number of used blocks.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_require_scratch
+
+rm -f $seqres.full
+
+_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mount
+
+$XFS_IO_PROG -f -c "truncate 64K"      \
+	     -c "mmap -w 0 64K"        \
+	     -c "mwrite -S 0xab 0 64K" \
+	     -c "munmap"               \
+	     $SCRATCH_MNT/foobar | _filter_xfs_io
+
+blocks_used=$(stat -c %b $SCRATCH_MNT/foobar)
+if [ $blocks_used -eq 0 ]; then
+    echo "error: stat(2) reported 0 used blocks"
+fi
+
+echo "Silence is golden"
+
+status=0
+exit
diff --git a/tests/generic/614.out b/tests/generic/614.out
new file mode 100644
index 00000000..3db70236
--- /dev/null
+++ b/tests/generic/614.out
@@ -0,0 +1,2 @@
+QA output created by 614
+Silence is golden
diff --git a/tests/generic/group b/tests/generic/group
index 31057ac8..ab8ae74e 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -616,3 +616,4 @@
 611 auto quick attr
 612 auto quick clone
 613 auto quick encrypt
+614 auto quick rw
-- 
2.28.0


       reply	other threads:[~2020-11-04 11:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1604487838.git.fdmanana@suse.com>
2020-11-04 11:13 ` fdmanana [this message]
2020-11-06 16:55   ` [PATCH 1/2] generic: test number of blocks used by a file after mwrite into a hole Josef Bacik
2020-11-04 11:13 ` [PATCH 2/2] generic: test for non-zero used blocks while writing into a file fdmanana
2020-11-06 16:56   ` Josef Bacik
2020-11-08  9:17   ` Eryu Guan
2020-11-09 11:57     ` Filipe Manana

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=289e1444dc95cb86945126b2677ca25879fdb8dd.1604487838.git.fdmanana@suse.com \
    --to=fdmanana@kernel.org \
    --cc=fdmanana@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@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).