Re: [PATCH v3 03/10] btrfs: create a helper function, check_fsid(), to verify the tempfsid

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Sat, Feb 24, 2024 at 4:43 PM Anand Jain <anand.jain@xxxxxxxxxx> wrote:
>
> check_fsid() provides a method to verify if the given device is mounted
> with the tempfsid in the kernel. Function sb() is an internal only
> function.
>
> Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx>
> Reviewed-by: Filipe Manana <fdmanana@xxxxxxxx>
> ---
> v3:
>  add rb
>  add  _require_btrfs_command inspect-internal dump-super
> v2:
>  Fix typo in the commit log.
>  Fix array SCRATCH_DEV_POOL_SAVED handling.
>
>  common/btrfs | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
>
> diff --git a/common/btrfs b/common/btrfs
> index e1b29c613767..406be9574e32 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -792,3 +792,40 @@ _has_btrfs_sysfs_feature_attr()
>
>         test -e /sys/fs/btrfs/features/$feature_attr
>  }
> +
> +# Print the fsid and metadata uuid replaced with constant strings FSID and
> +# METADATA_UUID. Compare temp_fsid with fsid and metadata_uuid, then echo what
> +# it matches to or TEMP_FSID. This helps in comparing with the golden output.
> +check_fsid()
> +{
> +       local dev1=$1
> +       local fsid
> +       local metadata_uuid
> +
> +       _require_btrfs_command inspect-internal dump-super

So, as pointed out in the previous version of the patchset, the
function should do the require for everything it needs that may not be
available.
It's doing for the inspect-internal command, but it's missing a:

_require_btrfs_sysfs_fsid

Instead this is being called for every test case that calls this new
helper function, when those requirements should be hidden from the
tests themselves.

Thanks.

> +
> +       # on disk fsid
> +       fsid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
> +                               grep ^fsid | $AWK_PROG -d" " '{print $2}')
> +       echo -e "On disk fsid:\t\t$fsid" | sed -e "s/$fsid/FSID/g"
> +
> +       # Print FSID even if it is not the same as metadata_uuid because it has
> +       # to match in the golden output.
> +       metadata_uuid=$(cat /sys/fs/btrfs/$fsid/metadata_uuid)
> +       echo -e "Metadata uuid:\t\tFSID"
> +
> +       # This returns the temp_fsid if set
> +       tempfsid=$(_btrfs_get_fsid $dev1)
> +       if [[ $tempfsid == $fsid ]]; then
> +               echo -e "Temp fsid:\t\tFSID"
> +       elif [[ $tempfsid == $metadata_uuid ]]; then
> +               # If we are here, it means there is a bug; let it not match with
> +               # the golden output.
> +               echo -e "Temp fsid:\t\t$metadata_uuid"
> +       else
> +               echo -e "Temp fsid:\t\tTEMPFSID"
> +       fi
> +
> +       echo -e -n "Tempfsid status:\t"
> +       cat /sys/fs/btrfs/$tempfsid/temp_fsid
> +}
> --
> 2.39.3
>





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux