From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] fstests: btrfs use forget if not reload
Date: Fri, 12 Oct 2018 12:06:31 +0800 [thread overview]
Message-ID: <1539317191-9265-4-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1539317191-9265-1-git-send-email-anand.jain@oracle.com>
btrfs reload was introduced to cleanup the device list inside the btrfs
kernel module.
The problem with the reload approach is that you can't run btrfs test
cases 124,125, 154 and 164 on the system with btrfs as root fs.
Now as we are introducing the btrfs forget feature as an btrfs device
scan option [1], so here are its pertaining changes in the fstests.
So these changes ensures we use the forget feature where available and
if its not then falls back to the reload approach.
[1]
btrfs-progs: add cli to forget one or all scanned devices
btrfs: introduce feature to forget a btrfs device
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
common/btrfs | 20 ++++++++++++++++++++
tests/btrfs/124 | 6 +++---
tests/btrfs/125 | 6 +++---
tests/btrfs/154 | 6 +++---
tests/btrfs/164 | 4 ++--
5 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/common/btrfs b/common/btrfs
index 26dc0bb9600f..c7fbec11c8c1 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -374,3 +374,23 @@ _scratch_btrfs_sectorsize()
$BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV |\
grep sectorsize | awk '{print $2}'
}
+
+_btrfs_supports_forget()
+{
+ $BTRFS_UTIL_PROG device scan --help | grep -wq forget && \
+ $BTRFS_UTIL_PROG device scan --forget > /dev/null 2>&1
+}
+
+_require_btrfs_forget_if_not_fs_loadable()
+{
+ _btrfs_supports_forget && return
+
+ _require_loadable_fs_module "btrfs"
+}
+
+_btrfs_forget_if_not_fs_reload()
+{
+ _btrfs_supports_forget && return
+
+ _reload_fs_module "btrfs"
+}
diff --git a/tests/btrfs/124 b/tests/btrfs/124
index ce3ad6aa3a58..edbeff1443f5 100755
--- a/tests/btrfs/124
+++ b/tests/btrfs/124
@@ -51,7 +51,7 @@ _supported_fs btrfs
_supported_os Linux
_require_scratch_dev_pool 2
_test_unmount
-_require_loadable_fs_module "btrfs"
+_require_btrfs_forget_if_not_fs_loadable
_scratch_dev_pool_get 2
@@ -86,7 +86,7 @@ echo "clean btrfs ko" >> $seqres.full
_scratch_unmount
# un-scan the btrfs devices
-_reload_fs_module "btrfs"
+_btrfs_forget_if_not_fs_reload
echo >> $seqres.full
echo "-----Write degraded mount fill upto $max_fs_sz bytes-----" >> $seqres.full
@@ -125,7 +125,7 @@ echo
echo "Mount degraded with the other dev"
_scratch_unmount
# un-scan the btrfs devices
-_reload_fs_module "btrfs"
+_btrfs_forget_if_not_fs_reload
_mount -o degraded $dev2 $SCRATCH_MNT >>$seqres.full 2>&1
_run_btrfs_util_prog filesystem show
checkpoint3=`md5sum $SCRATCH_MNT/tf2`
diff --git a/tests/btrfs/125 b/tests/btrfs/125
index e38de264b28e..9161a2ddeaad 100755
--- a/tests/btrfs/125
+++ b/tests/btrfs/125
@@ -50,7 +50,7 @@ _supported_fs btrfs
_supported_os Linux
_require_scratch_dev_pool 3
_test_unmount
-_require_loadable_fs_module "btrfs"
+_require_btrfs_forget_if_not_fs_loadable
_scratch_dev_pool_get 3
@@ -102,7 +102,7 @@ echo "unmount" >> $seqres.full
_scratch_unmount
echo "clean btrfs ko" >> $seqres.full
# un-scan the btrfs devices
-_reload_fs_module "btrfs"
+_btrfs_forget_if_not_fs_reload
_mount -o degraded,device=$dev2 $dev1 $SCRATCH_MNT >>$seqres.full 2>&1
dd if=/dev/zero of="$SCRATCH_MNT"/tf2 bs=$bs count=$count \
>>$seqres.full 2>&1
@@ -138,7 +138,7 @@ echo "Mount degraded but with other dev"
_scratch_unmount
# un-scan the btrfs devices
-_reload_fs_module "btrfs"
+_btrfs_forget_if_not_fs_reload
_mount -o degraded,device=${dev2} $dev3 $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/154 b/tests/btrfs/154
index 99ea232aba4c..01745d20e9fc 100755
--- a/tests/btrfs/154
+++ b/tests/btrfs/154
@@ -36,7 +36,7 @@ rm -f $seqres.full
_supported_fs btrfs
_supported_os Linux
_require_scratch_dev_pool 2
-_require_loadable_fs_module "btrfs"
+_require_btrfs_forget_if_not_fs_loadable
_scratch_dev_pool_get 2
@@ -90,7 +90,7 @@ degrade_mount_write()
echo "clean btrfs ko" >> $seqres.full
# un-scan the btrfs devices
- _reload_fs_module "btrfs"
+ _btrfs_forget_if_not_fs_reload
_mount -o degraded $DEV1 $SCRATCH_MNT >>$seqres.full 2>&1
cnt=$(( $COUNT/10 ))
dd if=/dev/urandom of="$SCRATCH_MNT"/tf1 bs=$bs count=$cnt \
@@ -142,7 +142,7 @@ verify()
echo "unmount" >> $seqres.full
_scratch_unmount
- _reload_fs_module "btrfs"
+ _btrfs_forget_if_not_fs_reload
_mount -o degraded $DEV2 $SCRATCH_MNT >>$seqres.full 2>&1
verify_checkpoint1=`md5sum $SCRATCH_MNT/tf1`
verify_checkpoint2=`md5sum $SCRATCH_MNT/tf2`
diff --git a/tests/btrfs/164 b/tests/btrfs/164
index 097191a0e493..55042c4035e0 100755
--- a/tests/btrfs/164
+++ b/tests/btrfs/164
@@ -36,7 +36,7 @@ rm -f $seqres.full
# Modify as appropriate.
_supported_fs btrfs
_supported_os Linux
-_require_loadable_fs_module "btrfs"
+_require_btrfs_forget_if_not_fs_loadable
_require_scratch_dev_pool 2
_scratch_dev_pool_get 2
@@ -69,7 +69,7 @@ delete_seed()
{
_run_btrfs_util_prog device delete $dev_seed $SCRATCH_MNT
_scratch_unmount
- _reload_fs_module "btrfs"
+ _btrfs_forget_if_not_fs_reload
run_check _mount $dev_sprout $SCRATCH_MNT
_run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
echo -- sprout --
--
1.8.3.1
next prev parent reply other threads:[~2018-10-12 4:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-12 4:06 [PATCH v9] Add cli and ioctl to forget scanned device(s) Anand Jain
2018-10-12 4:06 ` [PATCH] btrfs: introduce feature to forget a btrfs device Anand Jain
2018-10-12 8:48 ` Nikolay Borisov
2018-10-24 4:31 ` Anand Jain
2018-10-12 4:06 ` [PATCH] btrfs-progs: add cli to forget one or all scanned devices Anand Jain
2018-10-12 9:03 ` Nikolay Borisov
2018-10-24 4:31 ` Anand Jain
2018-10-12 4:06 ` Anand Jain [this message]
2018-10-24 4:31 [PATCH v10] Add cli and ioctl to forget scanned device(s) Anand Jain
2018-10-24 4:31 ` [PATCH] fstests: btrfs use forget if not reload Anand Jain
2018-11-22 5:18 [PATCH v12] Add cli and ioctl to forget scanned device(s) Anand Jain
2018-11-22 5:18 ` [PATCH] fstests: btrfs use forget if not reload 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=1539317191-9265-4-git-send-email-anand.jain@oracle.com \
--to=anand.jain@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.