From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: "Darrick J. Wong" <djwong@kernel.org>,
Nirjhar Roy <nirjhar@linux.ibm.com>
Cc: fstests@vger.kernel.org, linux-ext4@vger.kernel.org,
linux-xfs@vger.kernel.org, ojaswin@linux.ibm.com,
zlang@kernel.org
Subject: Re: [PATCH v2 1/2] common/rc,xfs/207: Adding a common helper function to check xflag bits on a given file
Date: Sat, 16 Nov 2024 00:36:26 +0530 [thread overview]
Message-ID: <87r07cco5p.fsf@gmail.com> (raw)
In-Reply-To: <20241115164548.GE9425@frogsfrogsfrogs>
"Darrick J. Wong" <djwong@kernel.org> writes:
> On Fri, Nov 15, 2024 at 09:45:58AM +0530, Nirjhar Roy wrote:
>> This patch defines a common helper function to test whether any of
>> fsxattr xflags field is set or not. We will use this helper in the next
>> patch for checking extsize (e) flag.
>>
>> Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
>> Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
>> Signed-off-by: Nirjhar Roy <nirjhar@linux.ibm.com>
>> ---
>> common/rc | 7 +++++++
>> tests/xfs/207 | 13 ++-----------
>> 2 files changed, 9 insertions(+), 11 deletions(-)
>>
>> diff --git a/common/rc b/common/rc
>> index 2af26f23..fc18fc94 100644
>> --- a/common/rc
>> +++ b/common/rc
>> @@ -41,6 +41,13 @@ _md5_checksum()
>> md5sum $1 | cut -d ' ' -f1
>> }
>>
>> +# Check whether a fsxattr xflags character ($2) field is set on a given file ($1).
>> +# e.g, fsxattr.xflags = 0x80000800 [----------e-----X]
>> +_test_fsx_xflags_field()
>
> How about we call this "_test_fsxattr_xflag" instead?
>
> fsx is already something else in fstests.
>
>> +{
>> + grep -q "fsxattr.xflags.*\[.*$2.*\]" <($XFS_IO_PROG -c "stat" "$1")
>> +}
>
> Not sure why this lost the xfs_io | grep -q structure. The return value
> of the whole expression will always be the return value of the last
> command in the pipeline.
>
I guess it was suggested here [1]
[1]: https://lore.kernel.org/all/20241025025651.okneano7d324nl4e@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
root-> grep -q "hello" <(echo "hello world"); echo $?
0
The cmd is not using the unnamed pipes ("|") any more. It's spawning the
process () which does echo "hello world" and creating a named pipe or
say temporary FD <() which is being read by grep now. So we still will
have the correct return value. Slightly inefficitent compared to unnamed
pipes though I agree.
> (Correct? I hate bash...)
>
root-> ls -la <(echo "hello world");
lr-x------ 1 root root 64 Nov 16 00:42 /dev/fd/63 -> 'pipe:[74211850]'
Did I make you hate it more? ;)
-ritesh
> --D
>
>> +
>> # Write a byte into a range of a file
>> _pwrite_byte() {
>> local pattern="$1"
>> diff --git a/tests/xfs/207 b/tests/xfs/207
>> index bbe21307..4f6826f3 100755
>> --- a/tests/xfs/207
>> +++ b/tests/xfs/207
>> @@ -21,15 +21,6 @@ _require_cp_reflink
>> _require_xfs_io_command "fiemap"
>> _require_xfs_io_command "cowextsize"
>>
>> -# Takes the fsxattr.xflags line,
>> -# i.e. fsxattr.xflags = 0x0 [--------------C-]
>> -# and tests whether a flag character is set
>> -test_xflag()
>> -{
>> - local flg=$1
>> - grep -q "\[.*${flg}.*\]" && echo "$flg flag set" || echo "$flg flag unset"
>> -}
>> -
>> echo "Format and mount"
>> _scratch_mkfs > $seqres.full 2>&1
>> _scratch_mount >> $seqres.full 2>&1
>> @@ -65,14 +56,14 @@ echo "Set cowextsize and check flag"
>> $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file3 | _filter_scratch
>> _scratch_cycle_mount
>>
>> -$XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
>> +_test_fsx_xflags_field "$testdir/file3" "C" && echo "C flag set" || echo "C flag unset"
>> $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
>>
>> echo "Unset cowextsize and check flag"
>> $XFS_IO_PROG -c "cowextsize 0" $testdir/file3 | _filter_scratch
>> _scratch_cycle_mount
>>
>> -$XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
>> +_test_fsx_xflags_field "$testdir/file3" "C" && echo "C flag set" || echo "C flag unset"
>> $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
>>
>> status=0
>> --
>> 2.43.5
>>
>>
next prev parent reply other threads:[~2024-11-15 19:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 4:15 [PATCH v2 0/2] Addition of new tests for extsize hints Nirjhar Roy
2024-11-15 4:15 ` [PATCH v2 1/2] common/rc,xfs/207: Adding a common helper function to check xflag bits on a given file Nirjhar Roy
2024-11-15 16:45 ` Darrick J. Wong
2024-11-15 19:06 ` Ritesh Harjani [this message]
2024-11-18 16:28 ` Darrick J. Wong
2024-11-18 18:06 ` Ritesh Harjani
2024-11-18 9:24 ` Nirjhar Roy
2024-11-15 4:15 ` [PATCH v2 2/2] generic: Addition of new tests for extsize hints Nirjhar Roy
2024-11-15 16:50 ` Darrick J. Wong
2024-11-18 9:24 ` Nirjhar Roy
2024-11-18 16:22 ` Darrick J. Wong
2024-11-18 17:40 ` Ritesh Harjani
2024-11-18 20:27 ` Darrick J. Wong
2024-11-19 3:08 ` Nirjhar Roy
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=87r07cco5p.fsf@gmail.com \
--to=ritesh.list@gmail.com \
--cc=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=nirjhar@linux.ibm.com \
--cc=ojaswin@linux.ibm.com \
--cc=zlang@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).