Some btrfs test cases use btrfs module-reload to unregister devices
in the btrfs kernel. The problem with the module-reload approach is,
if test system contains btrfs as rootfs, then you can't run these
test cases.
Patches [1] introduced btrfs forget feature which can unregister
devices without the module-reload approach.
[1]
btrfs-progs: device scan: add new option to forget one or all scanned devices
btrfs: introduce new ioctl to unregister a btrfs device
And this patch makes relevant changes in the fstests to use this new
feature, when available.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
$BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV |\
grep sectorsize | awk '{print $2}'
}
$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_or_module_loadable()
+{
+ _btrfs_supports_forget && return
+
+ _require_loadable_fs_module "btrfs"
+}
+
+_btrfs_forget_or_module_reload()
+{
+ _btrfs_supports_forget && return
+
+ _reload_fs_module "btrfs"
+}
_supported_os Linux
_require_scratch_dev_pool 2
_test_unmount
_supported_os Linux
_require_scratch_dev_pool 2
_test_unmount
-_require_loadable_fs_module "btrfs"
+_require_btrfs_forget_or_module_loadable
_scratch_unmount
# un-scan the btrfs devices
_scratch_unmount
# un-scan the btrfs devices
-_reload_fs_module "btrfs"
+_btrfs_forget_or_module_reload
echo >> $seqres.full
echo "-----Write degraded mount fill upto $max_fs_sz bytes-----" >> $seqres.full
echo >> $seqres.full
echo "-----Write degraded mount fill upto $max_fs_sz bytes-----" >> $seqres.full
echo "Mount degraded with the other dev"
_scratch_unmount
# un-scan the btrfs devices
echo "Mount degraded with the other dev"
_scratch_unmount
# un-scan the btrfs devices
-_reload_fs_module "btrfs"
+_btrfs_forget_or_module_reload
_mount -o degraded $dev2 $SCRATCH_MNT >>$seqres.full 2>&1
_run_btrfs_util_prog filesystem show
checkpoint3=`md5sum $SCRATCH_MNT/tf2`
_mount -o degraded $dev2 $SCRATCH_MNT >>$seqres.full 2>&1
_run_btrfs_util_prog filesystem show
checkpoint3=`md5sum $SCRATCH_MNT/tf2`
_supported_os Linux
_require_scratch_dev_pool 3
_test_unmount
_supported_os Linux
_require_scratch_dev_pool 3
_test_unmount
-_require_loadable_fs_module "btrfs"
+_require_btrfs_forget_or_module_loadable
_require_btrfs_fs_feature raid56
_scratch_dev_pool_get 3
_require_btrfs_fs_feature raid56
_scratch_dev_pool_get 3
_scratch_unmount
echo "clean btrfs ko" >> $seqres.full
# un-scan the btrfs devices
_scratch_unmount
echo "clean btrfs ko" >> $seqres.full
# un-scan the btrfs devices
-_reload_fs_module "btrfs"
+_btrfs_forget_or_module_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
_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
_scratch_unmount
# un-scan the btrfs devices
_scratch_unmount
# un-scan the btrfs devices
-_reload_fs_module "btrfs"
+_btrfs_forget_or_module_reload
_mount -o degraded,device=${dev2} $dev3 $SCRATCH_MNT >>$seqres.full 2>&1
_mount -o degraded,device=${dev2} $dev3 $SCRATCH_MNT >>$seqres.full 2>&1
_supported_fs btrfs
_supported_os Linux
_require_scratch_dev_pool 2
_supported_fs btrfs
_supported_os Linux
_require_scratch_dev_pool 2
-_require_loadable_fs_module "btrfs"
+_require_btrfs_forget_or_module_loadable
echo "clean btrfs ko" >> $seqres.full
# un-scan the btrfs devices
echo "clean btrfs ko" >> $seqres.full
# un-scan the btrfs devices
- _reload_fs_module "btrfs"
+ _btrfs_forget_or_module_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 \
_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 \
echo "unmount" >> $seqres.full
_scratch_unmount
echo "unmount" >> $seqres.full
_scratch_unmount
- _reload_fs_module "btrfs"
+ _btrfs_forget_or_module_reload
_mount -o degraded $DEV2 $SCRATCH_MNT >>$seqres.full 2>&1
verify_checkpoint1=`md5sum $SCRATCH_MNT/tf1`
verify_checkpoint2=`md5sum $SCRATCH_MNT/tf2`
_mount -o degraded $DEV2 $SCRATCH_MNT >>$seqres.full 2>&1
verify_checkpoint1=`md5sum $SCRATCH_MNT/tf1`
verify_checkpoint2=`md5sum $SCRATCH_MNT/tf2`
# Modify as appropriate.
_supported_fs btrfs
_supported_os Linux
# Modify as appropriate.
_supported_fs btrfs
_supported_os Linux
-_require_loadable_fs_module "btrfs"
+_require_btrfs_forget_or_module_loadable
_require_scratch_dev_pool 2
_scratch_dev_pool_get 2
_require_scratch_dev_pool 2
_scratch_dev_pool_get 2
{
_run_btrfs_util_prog device delete $dev_seed $SCRATCH_MNT
_scratch_unmount
{
_run_btrfs_util_prog device delete $dev_seed $SCRATCH_MNT
_scratch_unmount
- _reload_fs_module "btrfs"
+ _btrfs_forget_or_module_reload
run_check _mount $dev_sprout $SCRATCH_MNT
_run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
echo -- sprout --
run_check _mount $dev_sprout $SCRATCH_MNT
_run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
echo -- sprout --