public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: "xuyang.jy" <xuyang.jy@cn.fujitsu.com>
Cc: guaneryu@gmail.com, david@fromorbit.com, fstests@vger.kernel.org
Subject: Re: [PATCH v2] common/xfs: Add require_xfs_db_write_array function
Date: Mon, 16 Apr 2018 21:06:41 -0700	[thread overview]
Message-ID: <20180417040641.GA5210@magnolia> (raw)
In-Reply-To: <5AD5721C.10709@cn.fujitsu.com>

On Tue, Apr 17, 2018 at 12:03:40PM +0800, xuyang.jy wrote:
> on 2018/4/17 1:22, Darrick J. Wong write:
> 
> >On Mon, Apr 16, 2018 at 05:07:35PM +0800, yang xu wrote:
> >>xfsprogs commit 4222d000ed("db: write via array indexing doesn't
> >>work") fixes a bug that xfs_db write can't support array indexing.
> >>This function will check whether the bug is fixed on the current
> >>xfsprogs.
> >>
> >>xfs/444 applies the function, and skips if this bug exists.
> >>
> >>Signed-off-by: yang xu<xuyang.jy@cn.fujitsu.com>
> >>---
> >>  common/xfs    | 18 ++++++++++++++++++
> >>  tests/xfs/444 |  1 +
> >>  2 files changed, 19 insertions(+)
> >>
> >>diff --git a/common/xfs b/common/xfs
> >>index 3169f87..c4611a1 100644
> >>--- a/common/xfs
> >>+++ b/common/xfs
> >>@@ -701,3 +701,21 @@ _scratch_xfs_set_sb_field()
> >>  {
> >>  	_scratch_xfs_set_metadata_field "$1" "$2" "sb 0"
> >>  }
> >>+
> >>+#Before xfsprogs commit 4222d000ed("db: write via array indexing doesn't work"),
> >>+#xfs_db command to write a specific AGFL index doesn't work.
> >>+_require_xfs_db_write_array()
> >>+{
> >>+	_scratch_xfs_set_metadata_field "bno[32]" "78" "agfl 0">/dev/null 2>&1
> >This is going to fail randomly unless the caller previously called
> >_require_scratch to make sure that there's some kind of xfs fs image
> >sitting on the scratch device (and that there even is a scratch device).
> >Please document that requirement.  Alternately, consider formatting a xfs
> >image file in $TEST_DIR and poking that with xfs_db so you don't have to
> >deal with formatting and cleaning up the scratch device.
> Hi Darrick
> 
> We want to create a xfs image file in /tmp/ and use it, as below:
> 
> [root@RHEL7U5Alpha_CLIENT xfstests-dev]# git diff common/xfs
> diff --git a/common/xfs b/common/xfs
> index 3169f87..39702f7 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -701,3 +701,19 @@ _scratch_xfs_set_sb_field()
>  {      	_scratch_xfs_set_metadata_field "$1" "$2" "sb 0"
>  }
> +
> +#Before xfsprogs commit 4222d000ed("db: write via array indexing doesn't work"),
> +##xfs_db command to write a specific AGFL index doesn't work.
> +_require_xfs_db_write_array()
> +{
> +       local supported=0
> +
> +       touch /tmp/$$.img
> +       $MKFS_XFS_PROG -d file,name=/tmp/$$.img,size=512m>/dev/null 2>&1
> +       $XFS_DB_PROG -x -c "agfl 0" -c "write bno[32] 78" /tmp/$$.img \
> +>/dev/null 2>&1
> +       $XFS_DB_PROG -x -c "agfl 0" -c "print bno[32]" /tmp/$$.img \
> +               | grep -q "bno\[32\] = 78"&&  supported=1
> +       rm -f /tmp/$$.img
> +       [ $supported -eq 0 ]&&  _notrun "xfs_db write can't support array"
> +}
> [root@RHEL7U5Alpha_CLIENT xfstests-dev]#
> 
> How about this modification?

$TEST_DIR/$seqres.img, not /tmp/$$.img

Don't assume anything's writable (and big enough for fs images) if it
isn't under $TEST_DIR or $SCRATCH_MNT.

--D

> 
> >>+
> >>+	# Before xfsprogs commit 0ebbf1d58898 ("db: limit AGFL bno
> >>+	# arrayi printing), When asking for a single agfl entry,
> >>+	# the result outputs the entire remainder of the array
> >>+	# starting at the given index.
> >>+	# It is difficult to extract single entry values.
> >>+	# So filter useless information.
> >>+	bno_value=$(_scratch_xfs_get_metadata_field "bno[32]" \
> >>+		"agfl 0" |sed -e 's/ .*$//g' | sed -e 's/^.*://g')
> >>+
> >>+	[ "${bno_value}" != "78" ]&&  _notrun "xfs_db write can't support array"
> >It seems like a bad idea to leave a potentially corrupt scratch fs lying
> >around after this helper exits.
> Agreed.  I will use a temp xfs image file.
> 
> Thanks
> Yang Xu
> 
> >--D
> >
> >>+}
> >>diff --git a/tests/xfs/444 b/tests/xfs/444
> >>index 141be52..9700422 100755
> >>--- a/tests/xfs/444
> >>+++ b/tests/xfs/444
> >>@@ -54,6 +54,7 @@ _supported_os Linux
> >>  _require_check_dmesg
> >>  _require_scratch
> >>  _require_test_program "punch-alternating"
> >>+_require_xfs_db_write_array
> >>
> >>  # This is only a v5 filesystem problem
> >>  _require_scratch_xfs_crc
> >>-- 
> >>1.8.3.1
> >>
> >>
> >>
> >>--
> >>To unsubscribe from this list: send the line "unsubscribe fstests" in
> >>the body of a message tomajordomo@vger.kernel.org
> >>More majordomo info athttp://vger.kernel.org/majordomo-info.html
> >.
> >
> 
> 
> 

  parent reply	other threads:[~2018-04-17  4:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-12 10:00 [PATCH] xfs/444: add check for xfs_db write bno array yang xu
2018-04-12 12:09 ` Dave Chinner
2018-04-12 13:00   ` Eryu Guan
2018-04-12 23:00     ` Dave Chinner
2018-04-13  4:36       ` Eryu Guan
2018-04-13 13:42         ` Dave Chinner
2018-04-16  6:00           ` Eryu Guan
2018-04-16  9:07             ` [PATCH v2] common/xfs: Add require_xfs_db_write_array function yang xu
2018-04-16 17:22               ` Darrick J. Wong
     [not found]                 ` <5AD5721C.10709@cn.fujitsu.com>
2018-04-17  4:06                   ` Darrick J. Wong [this message]
2018-04-17  6:11                     ` [PATCH v3] " yang xu
2018-04-17 17:59                       ` Darrick J. Wong
2018-04-18  4:29                         ` Eryu Guan

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=20180417040641.GA5210@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=xuyang.jy@cn.fujitsu.com \
    /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