diff mbox series

[v2,07/10] btrfs: introduce helper for creating cloned devices with mkfs

Message ID 3b00cd9a28c6728ca2bf9c216fe67bf9c01cfc83.1708362842.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs: functional test cases for tempfsid | expand

Commit Message

Anand Jain Feb. 19, 2024, 7:48 p.m. UTC
Use newer mkfs.btrfs option to generate two cloned devices,
used in test cases.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:
 Organize changes to its right patch.
 Fix _fail erorr message.
 Declare local variables for fsid and uuid.

 common/btrfs | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Filipe Manana Feb. 20, 2024, 4:51 p.m. UTC | #1
On Mon, Feb 19, 2024 at 7:49 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> Use newer mkfs.btrfs option to generate two cloned devices,
> used in test cases.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v2:
>  Organize changes to its right patch.
>  Fix _fail erorr message.
>  Declare local variables for fsid and uuid.
>
>  common/btrfs | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/common/btrfs b/common/btrfs
> index f694afac3d13..c3e5827562d6 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -838,3 +838,24 @@ check_fsid()
>         echo -e -n "Tempfsid status:\t"
>         cat /sys/fs/btrfs/$tempfsid/temp_fsid
>  }
> +
> +mkfs_clone()
> +{
> +       local fsid
> +       local uuid
> +       local dev1=$1
> +       local dev2=$2
> +
> +       [[ -z $dev1 || -z $dev2 ]] && \
> +               _fail "mkfs_clone requires two devices as arguments"
> +
> +       _mkfs_dev -fq $dev1
> +
> +       fsid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
> +                                       grep -E ^fsid | $AWK_PROG '{print $2}')
> +       uuid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
> +                               grep -E ^dev_item.uuid | $AWK_PROG '{print $2}')
> +
> +       _mkfs_dev -fq --uuid $fsid --device-uuid $uuid $dev2

So this function should call:

_require_btrfs_command inspect-internal dump-super
_require_btrfs_mkfs_uuid_option

Instead of having all the test cases that use it to do those calls, as
mentioned in a previous patch.

> +}
> +>>>>>>> e22bb3c816c1 (btrfs: introduce helper for creating cloned devices with mkfs)

This isn't supposed to be here...

Thanks.

> --
> 2.39.3
>
Anand Jain Feb. 23, 2024, 5:44 p.m. UTC | #2
On 2/20/24 22:21, Filipe Manana wrote:
> On Mon, Feb 19, 2024 at 7:49 PM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Use newer mkfs.btrfs option to generate two cloned devices,
>> used in test cases.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> v2:
>>   Organize changes to its right patch.
>>   Fix _fail erorr message.
>>   Declare local variables for fsid and uuid.
>>
>>   common/btrfs | 21 +++++++++++++++++++++
>>   1 file changed, 21 insertions(+)
>>
>> diff --git a/common/btrfs b/common/btrfs
>> index f694afac3d13..c3e5827562d6 100644
>> --- a/common/btrfs
>> +++ b/common/btrfs
>> @@ -838,3 +838,24 @@ check_fsid()
>>          echo -e -n "Tempfsid status:\t"
>>          cat /sys/fs/btrfs/$tempfsid/temp_fsid
>>   }
>> +
>> +mkfs_clone()
>> +{
>> +       local fsid
>> +       local uuid
>> +       local dev1=$1
>> +       local dev2=$2
>> +
>> +       [[ -z $dev1 || -z $dev2 ]] && \
>> +               _fail "mkfs_clone requires two devices as arguments"
>> +
>> +       _mkfs_dev -fq $dev1
>> +
>> +       fsid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
>> +                                       grep -E ^fsid | $AWK_PROG '{print $2}')
>> +       uuid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
>> +                               grep -E ^dev_item.uuid | $AWK_PROG '{print $2}')
>> +
>> +       _mkfs_dev -fq --uuid $fsid --device-uuid $uuid $dev2
> 
> So this function should call:
> 
> _require_btrfs_command inspect-internal dump-super
> _require_btrfs_mkfs_uuid_option
> 

  Added these two perreq to the helper function.


> Instead of having all the test cases that use it to do those calls, as
> mentioned in a previous patch.
> 
>> +}
>> +>>>>>>> e22bb3c816c1 (btrfs: introduce helper for creating cloned devices with mkfs)
> 
> This isn't supposed to be here...

Oops. Now removed.

Thanks for the review.

-Anand

> 
> Thanks.
> 
>> --
>> 2.39.3
>>
diff mbox series

Patch

diff --git a/common/btrfs b/common/btrfs
index f694afac3d13..c3e5827562d6 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -838,3 +838,24 @@  check_fsid()
 	echo -e -n "Tempfsid status:\t"
 	cat /sys/fs/btrfs/$tempfsid/temp_fsid
 }
+
+mkfs_clone()
+{
+	local fsid
+	local uuid
+	local dev1=$1
+	local dev2=$2
+
+	[[ -z $dev1 || -z $dev2 ]] && \
+		_fail "mkfs_clone requires two devices as arguments"
+
+	_mkfs_dev -fq $dev1
+
+	fsid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
+					grep -E ^fsid | $AWK_PROG '{print $2}')
+	uuid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
+				grep -E ^dev_item.uuid | $AWK_PROG '{print $2}')
+
+	_mkfs_dev -fq --uuid $fsid --device-uuid $uuid $dev2
+}
+>>>>>>> e22bb3c816c1 (btrfs: introduce helper for creating cloned devices with mkfs)