All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs test scan but not register the single device fs
@ 2023-09-28  9:01 Anand Jain
  2023-10-05  8:12 ` Anand Jain
  2023-10-05 14:29 ` Zorro Lang
  0 siblings, 2 replies; 4+ messages in thread
From: Anand Jain @ 2023-09-28  9:01 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

Recently, in the kernel commit 0d9436739af2 ("btrfs: scan but don't
register device on single device filesystem"), we adopted an approach
where we scan the device to validate it. However, we do not register
it in the kernel memory since it is not required to be remembered.

However, the seed device should continue to be registered because
otherwise, the mount operation for the sprout device will fail.

This patch ensures that we honor the mount requirements and do not break
anything while making changes in this part of the code.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/btrfs/298     | 53 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/298.out |  2 ++
 2 files changed, 55 insertions(+)
 create mode 100755 tests/btrfs/298
 create mode 100644 tests/btrfs/298.out

diff --git a/tests/btrfs/298 b/tests/btrfs/298
new file mode 100755
index 000000000000..1d10d27c1354
--- /dev/null
+++ b/tests/btrfs/298
@@ -0,0 +1,53 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Oracle.  All Rights Reserved.
+#
+# FS QA Test 298
+#
+#   Check if the device scan registers for a single-device seed and drops
+#  it from the kernel if it is eventually marked as non-seed.
+#
+. ./common/preamble
+_begin_fstest auto quick seed
+
+_supported_fs btrfs
+_require_command "$BTRFS_TUNE_PROG" btrfstune
+_require_scratch_dev_pool 2
+_scratch_dev_pool_get 1
+_spare_dev_get
+
+$WIPEFS_PROG -a $SCRATCH_DEV
+$WIPEFS_PROG -a $SPARE_DEV
+
+echo "#setup seed sprout device" >> $seqres.full
+_scratch_mkfs "-b 300M" >> $seqres.full 2>&1
+$BTRFS_TUNE_PROG -S 1 $SCRATCH_DEV
+_scratch_mount >> $seqres.full 2>&1
+$BTRFS_UTIL_PROG device add $SPARE_DEV $SCRATCH_MNT
+_scratch_unmount
+$BTRFS_UTIL_PROG device scan --forget
+
+echo "#Scan seed device and check using mount" >> $seqres.full
+$BTRFS_UTIL_PROG device scan $SCRATCH_DEV >> $seqres.full
+_mount $SPARE_DEV $SCRATCH_MNT
+umount $SCRATCH_MNT
+
+echo "#check again, ensures seed device still in kernel" >> $seqres.full
+_mount $SPARE_DEV $SCRATCH_MNT
+umount $SCRATCH_MNT
+
+echo "#Now scan of non-seed device makes kernel forget" >> $seqres.full
+$BTRFS_TUNE_PROG -f -S 0 $SCRATCH_DEV >> $seqres.full 2>&1
+$BTRFS_UTIL_PROG device scan $SCRATCH_DEV >> $seqres.full
+
+echo "#Sprout mount must fail for missing seed device" >> $seqres.full
+_mount $SPARE_DEV $SCRATCH_MNT > /dev/null 2>&1
+[[ $? == 32 ]] || _fail "mount failed to fail"
+
+_spare_dev_put
+_scratch_dev_pool_put
+
+# success, all done
+echo Silence is golden
+status=0
+exit
diff --git a/tests/btrfs/298.out b/tests/btrfs/298.out
new file mode 100644
index 000000000000..634342678f11
--- /dev/null
+++ b/tests/btrfs/298.out
@@ -0,0 +1,2 @@
+QA output created by 298
+Silence is golden
-- 
2.39.3


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

* Re: [PATCH] btrfs test scan but not register the single device fs
  2023-09-28  9:01 [PATCH] btrfs test scan but not register the single device fs Anand Jain
@ 2023-10-05  8:12 ` Anand Jain
  2023-10-05 14:29 ` Zorro Lang
  1 sibling, 0 replies; 4+ messages in thread
From: Anand Jain @ 2023-10-05  8:12 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs



Added to Staged. If there's any RB, please feel free to send it. Thanks.


On 9/28/23 17:01, Anand Jain wrote:
> Recently, in the kernel commit 0d9436739af2 ("btrfs: scan but don't
> register device on single device filesystem"), we adopted an approach
> where we scan the device to validate it. However, we do not register
> it in the kernel memory since it is not required to be remembered.
> 
> However, the seed device should continue to be registered because
> otherwise, the mount operation for the sprout device will fail.
> 
> This patch ensures that we honor the mount requirements and do not break
> anything while making changes in this part of the code.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>   tests/btrfs/298     | 53 +++++++++++++++++++++++++++++++++++++++++++++
>   tests/btrfs/298.out |  2 ++
>   2 files changed, 55 insertions(+)
>   create mode 100755 tests/btrfs/298
>   create mode 100644 tests/btrfs/298.out
> 
> diff --git a/tests/btrfs/298 b/tests/btrfs/298
> new file mode 100755
> index 000000000000..1d10d27c1354
> --- /dev/null
> +++ b/tests/btrfs/298
> @@ -0,0 +1,53 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2023 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test 298
> +#
> +#   Check if the device scan registers for a single-device seed and drops
> +#  it from the kernel if it is eventually marked as non-seed.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick seed
> +
> +_supported_fs btrfs
> +_require_command "$BTRFS_TUNE_PROG" btrfstune
> +_require_scratch_dev_pool 2
> +_scratch_dev_pool_get 1
> +_spare_dev_get
> +
> +$WIPEFS_PROG -a $SCRATCH_DEV
> +$WIPEFS_PROG -a $SPARE_DEV
> +
> +echo "#setup seed sprout device" >> $seqres.full
> +_scratch_mkfs "-b 300M" >> $seqres.full 2>&1
> +$BTRFS_TUNE_PROG -S 1 $SCRATCH_DEV
> +_scratch_mount >> $seqres.full 2>&1
> +$BTRFS_UTIL_PROG device add $SPARE_DEV $SCRATCH_MNT
> +_scratch_unmount
> +$BTRFS_UTIL_PROG device scan --forget
> +
> +echo "#Scan seed device and check using mount" >> $seqres.full
> +$BTRFS_UTIL_PROG device scan $SCRATCH_DEV >> $seqres.full
> +_mount $SPARE_DEV $SCRATCH_MNT
> +umount $SCRATCH_MNT
> +
> +echo "#check again, ensures seed device still in kernel" >> $seqres.full
> +_mount $SPARE_DEV $SCRATCH_MNT
> +umount $SCRATCH_MNT
> +
> +echo "#Now scan of non-seed device makes kernel forget" >> $seqres.full
> +$BTRFS_TUNE_PROG -f -S 0 $SCRATCH_DEV >> $seqres.full 2>&1
> +$BTRFS_UTIL_PROG device scan $SCRATCH_DEV >> $seqres.full
> +
> +echo "#Sprout mount must fail for missing seed device" >> $seqres.full
> +_mount $SPARE_DEV $SCRATCH_MNT > /dev/null 2>&1
> +[[ $? == 32 ]] || _fail "mount failed to fail"
> +
> +_spare_dev_put
> +_scratch_dev_pool_put
> +
> +# success, all done
> +echo Silence is golden
> +status=0
> +exit
> diff --git a/tests/btrfs/298.out b/tests/btrfs/298.out
> new file mode 100644
> index 000000000000..634342678f11
> --- /dev/null
> +++ b/tests/btrfs/298.out
> @@ -0,0 +1,2 @@
> +QA output created by 298
> +Silence is golden

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

* Re: [PATCH] btrfs test scan but not register the single device fs
  2023-09-28  9:01 [PATCH] btrfs test scan but not register the single device fs Anand Jain
  2023-10-05  8:12 ` Anand Jain
@ 2023-10-05 14:29 ` Zorro Lang
  2023-10-06  0:08   ` Anand Jain
  1 sibling, 1 reply; 4+ messages in thread
From: Zorro Lang @ 2023-10-05 14:29 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs

On Thu, Sep 28, 2023 at 05:01:30PM +0800, Anand Jain wrote:
> Recently, in the kernel commit 0d9436739af2 ("btrfs: scan but don't
> register device on single device filesystem"), we adopted an approach
> where we scan the device to validate it. However, we do not register
> it in the kernel memory since it is not required to be remembered.
> 
> However, the seed device should continue to be registered because
> otherwise, the mount operation for the sprout device will fail.
> 
> This patch ensures that we honor the mount requirements and do not break
> anything while making changes in this part of the code.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  tests/btrfs/298     | 53 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/298.out |  2 ++
>  2 files changed, 55 insertions(+)
>  create mode 100755 tests/btrfs/298
>  create mode 100644 tests/btrfs/298.out
> 
> diff --git a/tests/btrfs/298 b/tests/btrfs/298
> new file mode 100755
> index 000000000000..1d10d27c1354
> --- /dev/null
> +++ b/tests/btrfs/298
> @@ -0,0 +1,53 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2023 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test 298
> +#
> +#   Check if the device scan registers for a single-device seed and drops
> +#  it from the kernel if it is eventually marked as non-seed.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick seed
> +
> +_supported_fs btrfs
> +_require_command "$BTRFS_TUNE_PROG" btrfstune
> +_require_scratch_dev_pool 2
> +_scratch_dev_pool_get 1
> +_spare_dev_get
> +
> +$WIPEFS_PROG -a $SCRATCH_DEV

_require_command "$WIPEFS_PROG" wipefs

> +$WIPEFS_PROG -a $SPARE_DEV
> +
> +echo "#setup seed sprout device" >> $seqres.full
> +_scratch_mkfs "-b 300M" >> $seqres.full 2>&1

Better to with "|| _fail "....."", if we give specific options to _scratch_mkfs.

Others look good to me, if no more review points from others, I'll merge
this patch with above changes, and with

Reviewed-by: Zorro Lang <zlang@redhat.com>

> +$BTRFS_TUNE_PROG -S 1 $SCRATCH_DEV
> +_scratch_mount >> $seqres.full 2>&1
> +$BTRFS_UTIL_PROG device add $SPARE_DEV $SCRATCH_MNT
> +_scratch_unmount
> +$BTRFS_UTIL_PROG device scan --forget
> +
> +echo "#Scan seed device and check using mount" >> $seqres.full
> +$BTRFS_UTIL_PROG device scan $SCRATCH_DEV >> $seqres.full
> +_mount $SPARE_DEV $SCRATCH_MNT
> +umount $SCRATCH_MNT
> +
> +echo "#check again, ensures seed device still in kernel" >> $seqres.full
> +_mount $SPARE_DEV $SCRATCH_MNT
> +umount $SCRATCH_MNT
> +
> +echo "#Now scan of non-seed device makes kernel forget" >> $seqres.full
> +$BTRFS_TUNE_PROG -f -S 0 $SCRATCH_DEV >> $seqres.full 2>&1
> +$BTRFS_UTIL_PROG device scan $SCRATCH_DEV >> $seqres.full
> +
> +echo "#Sprout mount must fail for missing seed device" >> $seqres.full
> +_mount $SPARE_DEV $SCRATCH_MNT > /dev/null 2>&1
> +[[ $? == 32 ]] || _fail "mount failed to fail"
> +
> +_spare_dev_put
> +_scratch_dev_pool_put
> +
> +# success, all done
> +echo Silence is golden
> +status=0
> +exit
> diff --git a/tests/btrfs/298.out b/tests/btrfs/298.out
> new file mode 100644
> index 000000000000..634342678f11
> --- /dev/null
> +++ b/tests/btrfs/298.out
> @@ -0,0 +1,2 @@
> +QA output created by 298
> +Silence is golden
> -- 
> 2.39.3
> 


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

* Re: [PATCH] btrfs test scan but not register the single device fs
  2023-10-05 14:29 ` Zorro Lang
@ 2023-10-06  0:08   ` Anand Jain
  0 siblings, 0 replies; 4+ messages in thread
From: Anand Jain @ 2023-10-06  0:08 UTC (permalink / raw)
  To: Zorro Lang; +Cc: fstests, linux-btrfs


>> +$WIPEFS_PROG -a $SCRATCH_DEV
> 
> _require_command "$WIPEFS_PROG" wipefs
> 
>> +$WIPEFS_PROG -a $SPARE_DEV
>> +
>> +echo "#setup seed sprout device" >> $seqres.full
>> +_scratch_mkfs "-b 300M" >> $seqres.full 2>&1
> 
> Better to with "|| _fail "....."", if we give specific options to _scratch_mkfs.
> 
> Others look good to me, if no more review points from others, I'll merge
> this patch with above changes, and with
> 
> Reviewed-by: Zorro Lang <zlang@redhat.com>
> 

Agreed to both of the changes.

Thanks, Anand

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

end of thread, other threads:[~2023-10-06  0:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-28  9:01 [PATCH] btrfs test scan but not register the single device fs Anand Jain
2023-10-05  8:12 ` Anand Jain
2023-10-05 14:29 ` Zorro Lang
2023-10-06  0:08   ` Anand Jain

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.