FSTests Archive on lore.kernel.org
 help / color / Atom feed
From: fdmanana@kernel.org
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, Filipe Manana <fdmanana@suse.com>
Subject: [PATCH 2/3] common: add helper to count number of exclusive extents in a file
Date: Tue,  5 Nov 2019 14:56:40 +0000
Message-ID: <20191105145640.11231-1-fdmanana@kernel.org> (raw)

From: Filipe Manana <fdmanana@suse.com>

Add a new helper that is similar to _count_extents() except that extents
that are shared several times by the file with itself (reflinked at
different file offsets) are accounted 1 time only, instead of N times.

This is motivated by a subsequent test for btrfs that will use this new
helper, to verify that send streams are issuing reflink operations.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
 common/rc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/common/rc b/common/rc
index 238ffef9..3c412178 100644
--- a/common/rc
+++ b/common/rc
@@ -3202,6 +3202,15 @@ _count_extents()
 	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
+# Similar to _count_extents() but if any extent is shared multiples times in
+# the file (reflinked to different file offsets), it is accounted as 1 extent
+# instead of N extents.
+	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep -v hole | \
+		cut -d ' ' -f 3 | sort | uniq | wc -l
 	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep hole | wc -l

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191105145640.11231-1-fdmanana@kernel.org \
    --to=fdmanana@kernel.org \
    --cc=fdmanana@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

FSTests Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/fstests/0 fstests/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 fstests fstests/ https://lore.kernel.org/fstests \
	public-inbox-index fstests

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git