public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: fdmanana@kernel.org
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 11/11] btrfs: use the flags of an extent map to identify the compression type
Date: Tue, 5 Dec 2023 15:43:51 +0100	[thread overview]
Message-ID: <20231205144351.GF2751@twin.jikos.cz> (raw)
In-Reply-To: <64a0b8f04f170d4e1f0219bd975a6246e7b61b35.1701706418.git.fdmanana@suse.com>

On Mon, Dec 04, 2023 at 04:20:33PM +0000, fdmanana@kernel.org wrote:
> +	else if (type == BTRFS_COMPRESS_LZO)
> +		em->flags |= EXTENT_FLAG_COMPRESS_LZO;
> +	else if (type == BTRFS_COMPRESS_ZSTD)
> +		em->flags |= EXTENT_FLAG_COMPRESS_ZSTD;
> +}
> +
> +static inline enum btrfs_compression_type extent_map_compression(const struct extent_map *em)
> +{
> +	if (em->flags & EXTENT_FLAG_COMPRESS_ZLIB)
> +		return BTRFS_COMPRESS_ZLIB;
> +
> +	if (em->flags & EXTENT_FLAG_COMPRESS_LZO)
> +		return BTRFS_COMPRESS_LZO;
> +
> +	if (em->flags & EXTENT_FLAG_COMPRESS_ZSTD)
> +		return BTRFS_COMPRESS_ZSTD;
> +
> +	return BTRFS_COMPRESS_NONE;
> +}
> +
> +/*
> + * More efficient way to determine if extent is compressed, instead of using
> + * 'extent_map_compression() != BTRFS_COMPRESS_NONE'.
> + */
> +static inline bool extent_map_is_compressed(const struct extent_map *em)
> +{
> +	return (em->flags & (EXTENT_FLAG_COMPRESS_ZLIB |
> +			     EXTENT_FLAG_COMPRESS_LZO |
> +			     EXTENT_FLAG_COMPRESS_ZSTD)) != 0;

As a minor optimizations, you could add another bit flag when any of the
zlib/lzo/std is set and test just that.

Otherwise, I like the changes and space savings.

  reply	other threads:[~2023-12-05 14:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04 16:20 [PATCH 00/11] btrfs: some cleanups and optimizations for extent maps fdmanana
2023-12-04 16:20 ` [PATCH 01/11] btrfs: assert extent map is not in a list when setting it up fdmanana
2023-12-04 16:20 ` [PATCH 02/11] btrfs: tests: fix error messages for test case 4 of extent map tests fdmanana
2023-12-04 16:20 ` [PATCH 03/11] btrfs: tests: do not ignore NULL extent maps for extent maps tests fdmanana
2023-12-04 16:20 ` [PATCH 04/11] btrfs: tests: print all values as decimal in messages for extent map tests fdmanana
2023-12-04 16:20 ` [PATCH 05/11] btrfs: unexport add_extent_mapping() fdmanana
2023-12-04 16:20 ` [PATCH 06/11] btrfs: remove redundant value assignment at btrfs_add_extent_mapping() fdmanana
2023-12-04 16:20 ` [PATCH 07/11] btrfs: log messages at unpin_extent_range() during unexpected cases fdmanana
2023-12-04 16:20 ` [PATCH 08/11] btrfs: avoid useless rbtree iterations when attempting to merge extent map fdmanana
2023-12-04 16:20 ` [PATCH 09/11] btrfs: make extent_map_end() argument const fdmanana
2023-12-04 16:20 ` [PATCH 10/11] btrfs: refactor mergable_maps() for more readability fdmanana
2023-12-04 16:20 ` [PATCH 11/11] btrfs: use the flags of an extent map to identify the compression type fdmanana
2023-12-05 14:43   ` David Sterba [this message]
2023-12-05 15:01     ` Filipe Manana
2023-12-05 15:00       ` David Sterba
2023-12-05 15:58 ` [PATCH 00/11] btrfs: some cleanups and optimizations for extent maps David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231205144351.GF2751@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox