From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/4] btrfs: inline checksum name and driver definitions
Date: Fri, 28 Feb 2020 16:38:44 +0800 [thread overview]
Message-ID: <690a6f32-d219-b3d6-a4b0-795ba6aeeef4@gmx.com> (raw)
In-Reply-To: <91753cb284a2dbce72e5b5b31b658e1c50ef084e.1582832619.git.dsterba@suse.com>
[-- Attachment #1.1: Type: text/plain, Size: 1509 bytes --]
On 2020/2/28 上午4:00, David Sterba wrote:
> There's an unnecessary indirection in the checksum definition table,
> pointer and the string itself. The strings are short and the overall
> size of one entry is now 24 bytes.
>
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
> fs/btrfs/ctree.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index f948435e87df..bfedbbe2311f 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -31,8 +31,8 @@ static void del_ptr(struct btrfs_root *root, struct btrfs_path *path,
>
> static const struct btrfs_csums {
> u16 size;
> - const char *name;
> - const char *driver;
> + const char name[10];
Just a nitpick, the longest name I haven seen is "xxhash64" which is
only 8 chars, +1 for '\n'.
Thus we can save one extra byte here.
Despite that.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> + const char driver[12];
> } btrfs_csums[] = {
> [BTRFS_CSUM_TYPE_CRC32] = { .size = 4, .name = "crc32c" },
> [BTRFS_CSUM_TYPE_XXHASH] = { .size = 8, .name = "xxhash64" },
> @@ -63,7 +63,8 @@ const char *btrfs_super_csum_name(u16 csum_type)
> const char *btrfs_super_csum_driver(u16 csum_type)
> {
> /* csum type is validated at mount time */
> - return btrfs_csums[csum_type].driver ?:
> + return btrfs_csums[csum_type].driver[0] ?
> + btrfs_csums[csum_type].driver :
> btrfs_csums[csum_type].name;
> }
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-02-28 8:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-27 20:00 [PATCH 0/4] Misc cleanups David Sterba
2020-02-27 20:00 ` [PATCH 1/4] btrfs: inline checksum name and driver definitions David Sterba
2020-02-27 22:31 ` Johannes Thumshirn
2020-02-28 8:38 ` Qu Wenruo [this message]
2020-02-27 20:00 ` [PATCH 2/4] btrfs: simplify tree block checksumming loop David Sterba
2020-02-27 22:52 ` Johannes Thumshirn
2020-02-28 8:41 ` Qu Wenruo
2020-02-27 20:00 ` [PATCH 3/4] btrfs: return void from csum_tree_block David Sterba
2020-02-27 22:32 ` Johannes Thumshirn
2020-02-28 8:41 ` Qu Wenruo
2020-02-27 20:00 ` [PATCH 4/4] btrfs: balance: factor out convert profile validation David Sterba
2020-02-27 22:33 ` Johannes Thumshirn
2020-02-28 8:43 ` Qu Wenruo
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=690a6f32-d219-b3d6-a4b0-795ba6aeeef4@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=dsterba@suse.com \
--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