[PATCH v1] Add btrfs fs_info checksum, generation and metadata

Dmitry V. Levin ldv at altlinux.org
Sun Dec 26 23:20:37 UTC 2021


On Fri, Dec 24, 2021 at 09:15:41PM -0800, Sahil Kang wrote:
> * src/xlat/btrfs_csum_types.in: New file.
> * src/xlat/btrfs_fs_info_flags.in: Likewise.
> * src/btrfs.c: Print csum_type, csum_size, flags, generation, and
> metadata_uuid fields of btrfs_ioctl_fs_info_args struct.
> * NEWS: Mention it.
> 
> Signed-off-by: Sahil Kang <sahil.kang at asilaycomputing.com>
> ---
>  src/btrfs.c                     | 20 ++++++++++++++++++++
>  src/xlat/btrfs_csum_types.in    |  7 +++++++
>  src/xlat/btrfs_fs_info_flags.in |  4 ++++
>  3 files changed, 31 insertions(+)
>  create mode 100644 src/xlat/btrfs_csum_types.in
>  create mode 100644 src/xlat/btrfs_fs_info_flags.in
> 
> diff --git a/src/btrfs.c b/src/btrfs.c
> index ab7e0d3c4..349fee657 100644
> --- a/src/btrfs.c
> +++ b/src/btrfs.c
> @@ -37,6 +37,7 @@ typedef struct btrfs_ioctl_vol_args_v2
>  #include "xlat/btrfs_balance_state.h"
>  #include "xlat/btrfs_compress_types.h"
>  #include "xlat/btrfs_cont_reading_from_srcdev_mode.h"
> +#include "xlat/btrfs_csum_types.h"
>  #include "xlat/btrfs_defrag_flags.h"
>  #include "xlat/btrfs_dev_replace_cmds.h"
>  #include "xlat/btrfs_dev_replace_results.h"
> @@ -46,6 +47,7 @@ typedef struct btrfs_ioctl_vol_args_v2
>  #include "xlat/btrfs_features_compat.h"
>  #include "xlat/btrfs_features_compat_ro.h"
>  #include "xlat/btrfs_features_incompat.h"
> +#include "xlat/btrfs_fs_info_flags.h"
>  #include "xlat/btrfs_key_types.h"
>  #include "xlat/btrfs_logical_ino_args_flags.h"
>  #include "xlat/btrfs_qgroup_ctl_cmds.h"
> @@ -790,6 +792,24 @@ MPERS_PRINTER_DECL(int, btrfs_ioctl,
>  		PRINT_FIELD_U(args, sectorsize);
>  		tprint_struct_next();
>  		PRINT_FIELD_U(args, clone_alignment);
> +		if (args.flags & BTRFS_FS_INFO_FLAG_CSUM_INFO) {
> +			tprint_struct_next();
> +			PRINT_FIELD_XVAL(args, csum_type, btrfs_csum_types,
> +					 "BTRFS_CSUM_TYPE_???");
> +			tprint_struct_next();
> +			PRINT_FIELD_U(args, csum_size);
> +		}
> +		tprint_struct_next();
> +		PRINT_FIELD_FLAGS(args, flags, btrfs_fs_info_flags,
> +				  "BTRFS_FS_INFO_FLAG_???");
> +		if (args.flags & BTRFS_FS_INFO_FLAG_GENERATION) {
> +			tprint_struct_next();
> +			PRINT_FIELD_U(args, generation);
> +		}
> +		if (args.flags & BTRFS_FS_INFO_FLAG_METADATA_UUID) {
> +			tprint_struct_next();
> +			PRINT_FIELD_UUID(args, metadata_uuid);
> +		}
>  		tprint_struct_end();
>  		break;
>  	}

Ideally every new piece of code should come with a test, but since the
btrfs_ioctl_fs_info_args decoder is not covered by tests yet, it wouldn't
be fair to require tests for the code that is not affected by the patch.

> diff --git a/src/xlat/btrfs_csum_types.in b/src/xlat/btrfs_csum_types.in
> new file mode 100644
> index 000000000..73b1c597a
> --- /dev/null
> +++ b/src/xlat/btrfs_csum_types.in
> @@ -0,0 +1,7 @@
> +#unconditional
> +#value_indexed
> +#enum

There is no need to use #enum along with #unconditional.


-- 
ldv


More information about the Strace-devel mailing list