fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Eryu Guan <guaneryu@gmail.com>
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] fstest: btrfs/196: test for alien btrfs-devices
Date: Tue, 22 Oct 2019 17:23:40 +0800	[thread overview]
Message-ID: <81b63597-7afb-23d3-58be-1329d55dd06b@oracle.com> (raw)
In-Reply-To: <20191018091019.GK2622@desktop>



On 10/18/19 5:10 PM, Eryu Guan wrote:
> On Mon, Oct 07, 2019 at 05:41:00PM +0800, Anand Jain wrote:
>> Test if btrfs.ko sucessfully identifies and reports the missing device,
>> if the missed device contians someother btrfs.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   tests/btrfs/196     | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   tests/btrfs/196.out | 25 +++++++++++++++++
>>   tests/btrfs/group   |  1 +
>>   3 files changed, 103 insertions(+)
>>   create mode 100755 tests/btrfs/196
>>   create mode 100644 tests/btrfs/196.out
>>
>> diff --git a/tests/btrfs/196 b/tests/btrfs/196
>> new file mode 100755
>> index 000000000000..e35cdce492e5
>> --- /dev/null
>> +++ b/tests/btrfs/196
>> @@ -0,0 +1,77 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2019 Oracle.  All Rights Reserved.
>> +#
>> +# FS QA Test 196
>> +#
>> +# Test stale and alien btrfs-device in the fs devices list.
>> +#
>> +seq=`basename $0`
>> +seqres=$RESULT_DIR/$seq
>> +echo "QA output created by $seq"
>> +
>> +here=`pwd`
>> +tmp=/tmp/$$
>> +status=1	# failure is the default!
>> +trap "_cleanup; exit \$status" 0 1 2 3 15
>> +
>> +_cleanup()
>> +{
>> +	cd /
>> +	rm -f $tmp.*
>> +}
>> +
>> +# get standard environment, filters and checks
>> +. ./common/rc
>> +. ./common/filter
>> +. ./common/filter.btrfs
>> +
>> +# remove previous $seqres.full before test
>> +rm -f $seqres.full
>> +
>> +# real QA test starts here
>> +
>> +# Modify as appropriate.
>> +_supported_fs generic
>> +_supported_os Linux
> 
> _supported_os btrfs

  Thanks fixed in v2.

>> +_require_scratch
>> +_require_scratch_dev_pool 4
>> +
>> +workout()
>> +{
>> +	raid=$1
>> +	device_nr=$2
>> +
>> +	echo $raid
>> +	_scratch_dev_pool_get $device_nr
>> +
>> +	_scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
>> +							_fail "mkfs failed"
>> +
>> +	# Make device_1 an alien btrfs device for the raid created above by
>> +	# adding it to the $TEST_DIR
> 
> Instead of adding $device_1 to $TEST_DIR, does creating a new btrfs on
> $device_1 work? I'm a bit worried that changing $TEST_DIR/$TEST_DEV
> configuration would have some side effects, e.g. we add it to $TEST_DIR
> and cancle the test before removing it, the $TEST_DEV will end up in an
> unexpected state in next test run. (Though we could remove the device in
> _cleanup, this is just an example.)

  In v2 I am avoiding adding $device_1 to $TEST_DIR.
  Instead, I am using $SPARE_DEV to create a new btrfs and $device_1
  is added to it. I feel this is a better fix which shall completely
  avoid messing up the $TEST_DEV. Thanks.

>> +
>> +	# don't test with the first device as auto fs check (_check_scratch_fs)
>> +	# picks the first device
>> +	device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
>> +	$BTRFS_UTIL_PROG device add -f "$device_1" "$TEST_DIR"
>> +
>> +	device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
>> +	_mount -o degraded $device_2 $SCRATCH_MNT
>> +	# Check if missing device is reported as in the 196.out
> 
> Test could be renumbered, no need to hardcode 196.out, just ".out file"
> would be fine.

  Oh. Thanks this is fixed in v2.

>> +	$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
>> +						_filter_btrfs_filesystem_show
>> +
>> +	$BTRFS_UTIL_PROG device remove "$device_1" "$TEST_DIR"
> 
> I think we should remove $device_1 in _cleanup if it's not empty in case
> test exits unexpectly. But as mentioned above, better to avoid adding
> new device to $TEST_DIR.

  As I am not using $TEST_DIR to add the $device_1. So this won't be
  needed now.


Thanks, Anand

> Thanks,
> Eryu
> 
>> +	_scratch_unmount
>> +	_scratch_dev_pool_put
>> +}
>> +
>> +workout "raid1" "2"
>> +workout "raid5" "3"
>> +workout "raid6" "4"
>> +workout "raid10" "4"
>> +
>> +# success, all done
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/196.out b/tests/btrfs/196.out
>> new file mode 100644
>> index 000000000000..311ae9e2f46a
>> --- /dev/null
>> +++ b/tests/btrfs/196.out
>> @@ -0,0 +1,25 @@
>> +QA output created by 196
>> +raid1
>> +Label: none  uuid: <UUID>
>> +	Total devices <NUM> FS bytes used <SIZE>
>> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
>> +	*** Some devices missing
>> +
>> +raid5
>> +Label: none  uuid: <UUID>
>> +	Total devices <NUM> FS bytes used <SIZE>
>> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
>> +	*** Some devices missing
>> +
>> +raid6
>> +Label: none  uuid: <UUID>
>> +	Total devices <NUM> FS bytes used <SIZE>
>> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
>> +	*** Some devices missing
>> +
>> +raid10
>> +Label: none  uuid: <UUID>
>> +	Total devices <NUM> FS bytes used <SIZE>
>> +	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
>> +	*** Some devices missing
>> +
>> diff --git a/tests/btrfs/group b/tests/btrfs/group
>> index 3ce6fa4628d8..c86ea2516397 100644
>> --- a/tests/btrfs/group
>> +++ b/tests/btrfs/group
>> @@ -198,3 +198,4 @@
>>   193 auto quick qgroup enospc limit
>>   194 auto volume
>>   195 auto volume
>> +196 auto quick volume
>> -- 
>> 1.8.3.1
>>

  reply	other threads:[~2019-10-22  9:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-07  9:41 [PATCH 1/2] fstest: btrfs/196: test for alien btrfs-devices Anand Jain
2019-10-07  9:41 ` [PATCH 2/2] fstest: btrfs/197: test for alien devices Anand Jain
2019-10-18  9:13   ` Eryu Guan
2019-10-22  9:23     ` Anand Jain
2019-10-18  9:10 ` [PATCH 1/2] fstest: btrfs/196: test for alien btrfs-devices Eryu Guan
2019-10-22  9:23   ` Anand Jain [this message]
2019-10-22  9:24 ` [PATCH v2 1/2] fstest: btrfs/197: " Anand Jain
2019-10-22  9:24   ` [PATCH v2 2/2] fstest: btrfs/198: test for alien devices Anand Jain

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=81b63597-7afb-23d3-58be-1329d55dd06b@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-btrfs@vger.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).