fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] common/rc: Check SCRATCH_DEV in _require_dm_target()
@ 2021-09-07  7:41 Shin'ichiro Kawasaki
  2021-09-07  8:15 ` Dave Chinner
  0 siblings, 1 reply; 5+ messages in thread
From: Shin'ichiro Kawasaki @ 2021-09-07  7:41 UTC (permalink / raw)
  To: fstests
  Cc: Naohiro Aota, Johannes Thumshirn, Damien Le Moal, Shinichiro Kawasaki

When SCRATCH_DEV is not set and the test case does not call
_require_scratch*() before _require_dm_target(), _require_block_device()
called from _require_dm_target() fails to evaluate SCRATCH_DEV and
results in the test case failure. This failure was observed with
generic/628 and generic/629.

To avoid the failures, check SCRATCH_DEV in _require_dm_target(). With
this change, test cases do not need to call _require_scratch*() before
_require_dm_target(). To check SCRATCH_DEV, use simple variable check
instead of _require_scratch*() helper functions, so that each test case
can choose an appropriate function from _require_scratch*().

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 common/rc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/rc b/common/rc
index dda5da06..b4966af7 100644
--- a/common/rc
+++ b/common/rc
@@ -1971,6 +1971,9 @@ _require_dm_target()
 
 	# require SCRATCH_DEV to be a valid block device with sane BLKFLSBUF
 	# behaviour
+	if [ -z "$SCRATCH_DEV" ]; then
+		_notrun "This test requires a valid \$SCRATCH_DEV for dm $target"
+	fi
 	_require_block_device $SCRATCH_DEV
 	_require_sane_bdev_flush $SCRATCH_DEV
 	_require_command "$DMSETUP_PROG" dmsetup
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] common/rc: Check SCRATCH_DEV in _require_dm_target()
  2021-09-07  7:41 [PATCH] common/rc: Check SCRATCH_DEV in _require_dm_target() Shin'ichiro Kawasaki
@ 2021-09-07  8:15 ` Dave Chinner
  2021-09-07  9:28   ` Shinichiro Kawasaki
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Chinner @ 2021-09-07  8:15 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki
  Cc: fstests, Naohiro Aota, Johannes Thumshirn, Damien Le Moal

On Tue, Sep 07, 2021 at 04:41:16PM +0900, Shin'ichiro Kawasaki wrote:
> When SCRATCH_DEV is not set and the test case does not call
> _require_scratch*() before _require_dm_target(), _require_block_device()

That is the bug that needs fixing.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] common/rc: Check SCRATCH_DEV in _require_dm_target()
  2021-09-07  8:15 ` Dave Chinner
@ 2021-09-07  9:28   ` Shinichiro Kawasaki
  2021-09-07 10:36     ` Dave Chinner
  0 siblings, 1 reply; 5+ messages in thread
From: Shinichiro Kawasaki @ 2021-09-07  9:28 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, Naohiro Aota, Johannes Thumshirn, Damien Le Moal

On Sep 07, 2021 / 18:15, Dave Chinner wrote:
> On Tue, Sep 07, 2021 at 04:41:16PM +0900, Shin'ichiro Kawasaki wrote:
> > When SCRATCH_DEV is not set and the test case does not call
> > _require_scratch*() before _require_dm_target(), _require_block_device()
> 
> That is the bug that needs fixing.

Thanks for the comment. Do you mean the test cases (generic/628 and generic/629)
need fix to call _require_scratch*() before _require_dm_target()? I think that
fix approach will leave the possibility that the newly added test cases in the
future may have the same failure. IMO, the patch posted will be more effective
to prevent the failures.

-- 
Best Regards,
Shin'ichiro Kawasaki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] common/rc: Check SCRATCH_DEV in _require_dm_target()
  2021-09-07  9:28   ` Shinichiro Kawasaki
@ 2021-09-07 10:36     ` Dave Chinner
  2021-09-08  2:57       ` Shin'ichiro Kawasaki
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Chinner @ 2021-09-07 10:36 UTC (permalink / raw)
  To: Shinichiro Kawasaki
  Cc: fstests, Naohiro Aota, Johannes Thumshirn, Damien Le Moal

On Tue, Sep 07, 2021 at 09:28:44AM +0000, Shinichiro Kawasaki wrote:
> On Sep 07, 2021 / 18:15, Dave Chinner wrote:
> > On Tue, Sep 07, 2021 at 04:41:16PM +0900, Shin'ichiro Kawasaki wrote:
> > > When SCRATCH_DEV is not set and the test case does not call
> > > _require_scratch*() before _require_dm_target(), _require_block_device()
> > 
> > That is the bug that needs fixing.
> 
> Thanks for the comment. Do you mean the test cases (generic/628 and generic/629)
> need fix to call _require_scratch*() before _require_dm_target()? I think that

Yes.

Indeed,  generic/628 does:

_require_dm_target error
_require_scratch_reflink

and g629 does:

_supported_fs generic
_require_dm_target error
_require_xfs_io_command "chattr" "s"
_require_xfs_io_command "copy_range"
_require_scratch

i.e. these two cases are just incorrectly ordered require rules.

Oh, and a quick check of all the dm_target tests:

$ git grep -l _require_dm_target tests/ > t.t
$ git grep -l _require_scratch `cat t.t` > t.tt
$ diff -u t.t t.tt
$

Every test that has require_dm_target rule also has a
_require_scratch rule in it somewhere...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] common/rc: Check SCRATCH_DEV in _require_dm_target()
  2021-09-07 10:36     ` Dave Chinner
@ 2021-09-08  2:57       ` Shin'ichiro Kawasaki
  0 siblings, 0 replies; 5+ messages in thread
From: Shin'ichiro Kawasaki @ 2021-09-08  2:57 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Shinichiro Kawasaki, fstests, Naohiro Aota, Johannes Thumshirn,
	Damien Le Moal

On Sep 07, 2021 / 20:36, Dave Chinner wrote:
> On Tue, Sep 07, 2021 at 09:28:44AM +0000, Shinichiro Kawasaki wrote:
> > On Sep 07, 2021 / 18:15, Dave Chinner wrote:
> > > On Tue, Sep 07, 2021 at 04:41:16PM +0900, Shin'ichiro Kawasaki wrote:
> > > > When SCRATCH_DEV is not set and the test case does not call
> > > > _require_scratch*() before _require_dm_target(), _require_block_device()
> > > 
> > > That is the bug that needs fixing.
> > 
> > Thanks for the comment. Do you mean the test cases (generic/628 and generic/629)
> > need fix to call _require_scratch*() before _require_dm_target()? I think that
> 
> Yes.
> 
> Indeed,  generic/628 does:
> 
> _require_dm_target error
> _require_scratch_reflink
> 
> and g629 does:
> 
> _supported_fs generic
> _require_dm_target error
> _require_xfs_io_command "chattr" "s"
> _require_xfs_io_command "copy_range"
> _require_scratch
> 
> i.e. these two cases are just incorrectly ordered require rules.
> 
> Oh, and a quick check of all the dm_target tests:
> 
> $ git grep -l _require_dm_target tests/ > t.t
> $ git grep -l _require_scratch `cat t.t` > t.tt
> $ diff -u t.t t.tt
> $
> 
> Every test that has require_dm_target rule also has a
> _require_scratch rule in it somewhere...

Thanks for the clarification. I will repost a patch to fix the order of
_require_scratch* and _require_dm_target in generic/{628,629}.

Regarding the future test cases, I think we can improve error check and error
message in _require_dm_target. I will post another patch for it. Comment on it
will be appreciated also.

-- 
Best Regards,
Shin'ichiro Kawasaki

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-08  2:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07  7:41 [PATCH] common/rc: Check SCRATCH_DEV in _require_dm_target() Shin'ichiro Kawasaki
2021-09-07  8:15 ` Dave Chinner
2021-09-07  9:28   ` Shinichiro Kawasaki
2021-09-07 10:36     ` Dave Chinner
2021-09-08  2:57       ` Shin'ichiro Kawasaki

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).