public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 1/4] btrfs: inline checksum name and driver definitions
Date: Thu, 27 Feb 2020 21:00:45 +0100	[thread overview]
Message-ID: <91753cb284a2dbce72e5b5b31b658e1c50ef084e.1582832619.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1582832619.git.dsterba@suse.com>

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];
+	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;
 }
 
-- 
2.25.0


  reply	other threads:[~2020-02-27 20:01 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 ` David Sterba [this message]
2020-02-27 22:31   ` [PATCH 1/4] btrfs: inline checksum name and driver definitions Johannes Thumshirn
2020-02-28  8:38   ` Qu Wenruo
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=91753cb284a2dbce72e5b5b31b658e1c50ef084e.1582832619.git.dsterba@suse.com \
    --to=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