diff mbox

[V2,1/5] Filter xfs_io and od's output in units of FS block size

Message ID 1448878620-16382-2-git-send-email-chandan@linux.vnet.ibm.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Chandan Rajendra Nov. 30, 2015, 10:16 a.m. UTC
The helpers introduced in this commit will be used to make btrfs tests that
assume 4k as the block size to work on non-4k blocksized filesystem instances
as well.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
 common/filter | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

Comments

Filipe Manana Dec. 10, 2015, 5:24 p.m. UTC | #1
On Mon, Nov 30, 2015 at 10:16 AM, Chandan Rajendra
<chandan@linux.vnet.ibm.com> wrote:
> The helpers introduced in this commit will be used to make btrfs tests that
> assume 4k as the block size to work on non-4k blocksized filesystem instances
> as well.
>
> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>

Thanks!

> ---
>  common/filter | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
>
> diff --git a/common/filter b/common/filter
> index af456c9..05f2fab 100644
> --- a/common/filter
> +++ b/common/filter
> @@ -229,6 +229,38 @@ _filter_xfs_io_unique()
>      common_line_filter | _filter_xfs_io
>  }
>
> +_filter_xfs_io_units_modified()
> +{
> +       UNIT=$1
> +       UNIT_SIZE=$2
> +
> +       $AWK_PROG -v unit="$UNIT" -v unit_size=$UNIT_SIZE '
> +               /wrote/ {
> +                       split($2, bytes, "/")
> +
> +                       bytes_written = strtonum(bytes[1])
> +
> +                       offset = strtonum($NF)
> +
> +                       unit_start = offset / unit_size
> +                       unit_start = int(unit_start)
> +                       unit_end = (offset + bytes_written - 1) / unit_size
> +                       unit_end = int(unit_end)
> +
> +                       printf("%ss modified: [%d - %d]\n", unit, unit_start, unit_end)
> +
> +                       next
> +               }
> +       '
> +}
> +
> +_filter_xfs_io_blocks_modified()
> +{
> +       BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
> +
> +       _filter_xfs_io_units_modified "Block" $BLOCK_SIZE
> +}
> +
>  _filter_test_dir()
>  {
>         sed -e "s,$TEST_DEV,TEST_DEV,g" -e "s,$TEST_DIR,TEST_DIR,g"
> @@ -323,5 +355,18 @@ _filter_ro_mount() {
>             -e "s/mount: cannot mount block device/mount: cannot mount/g"
>  }
>
> +_filter_od()
> +{
> +       BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
> +       $AWK_PROG -v block_size=$BLOCK_SIZE '
> +               /^[0-9]+/ {
> +                       offset = strtonum("0"$1);
> +                       $1 = sprintf("%o", offset / block_size);
> +                       print $0;
> +               }
> +               /\*/
> +       '
> +}
> +
>  # make sure this script returns success
>  /bin/true
> --
> 2.1.0
>
diff mbox

Patch

diff --git a/common/filter b/common/filter
index af456c9..05f2fab 100644
--- a/common/filter
+++ b/common/filter
@@ -229,6 +229,38 @@  _filter_xfs_io_unique()
     common_line_filter | _filter_xfs_io
 }
 
+_filter_xfs_io_units_modified()
+{
+	UNIT=$1
+	UNIT_SIZE=$2
+
+	$AWK_PROG -v unit="$UNIT" -v unit_size=$UNIT_SIZE '
+		/wrote/ {
+			split($2, bytes, "/")
+
+			bytes_written = strtonum(bytes[1])
+
+			offset = strtonum($NF)
+
+			unit_start = offset / unit_size
+			unit_start = int(unit_start)
+			unit_end = (offset + bytes_written - 1) / unit_size
+			unit_end = int(unit_end)
+
+			printf("%ss modified: [%d - %d]\n", unit, unit_start, unit_end)
+
+			next
+		}
+	'
+}
+
+_filter_xfs_io_blocks_modified()
+{
+	BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+
+	_filter_xfs_io_units_modified "Block" $BLOCK_SIZE
+}
+
 _filter_test_dir()
 {
 	sed -e "s,$TEST_DEV,TEST_DEV,g" -e "s,$TEST_DIR,TEST_DIR,g"
@@ -323,5 +355,18 @@  _filter_ro_mount() {
 	    -e "s/mount: cannot mount block device/mount: cannot mount/g"
 }
 
+_filter_od()
+{
+	BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
+	$AWK_PROG -v block_size=$BLOCK_SIZE '
+		/^[0-9]+/ {
+			offset = strtonum("0"$1);
+			$1 = sprintf("%o", offset / block_size);
+			print $0;
+		}
+		/\*/
+	'
+}
+
 # make sure this script returns success
 /bin/true