From: Johannes Thumshirn <jthumshirn@suse.de>
To: David Sterba <dsterba@suse.com>
Cc: Linux BTRFS Mailinglist <linux-btrfs@vger.kernel.org>,
Johannes Thumshirn <jthumshirn@suse.de>
Subject: [PATCH v2 06/11] btrfs-progs: simplify update_block_csum() in btrfs-sb-mod.c
Date: Mon, 26 Aug 2019 13:48:48 +0200 [thread overview]
Message-ID: <20190826114853.14860-7-jthumshirn@suse.de> (raw)
In-Reply-To: <20190826114853.14860-1-jthumshirn@suse.de>
update_block_csum() in btrfs-sb-mod.c is always called with the 'is_sb'
argument set to 1.
Get rid of the special case for is_sb == 0.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
---
btrfs-sb-mod.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/btrfs-sb-mod.c b/btrfs-sb-mod.c
index d9630f187d0f..9e64b34d2b8f 100644
--- a/btrfs-sb-mod.c
+++ b/btrfs-sb-mod.c
@@ -46,24 +46,17 @@ static int check_csum_superblock(void *sb)
return !memcmp(sb, &result, csum_size);
}
-static void update_block_csum(void *block, int is_sb)
+static void update_block_csum(void *block)
{
u8 result[csum_size];
struct btrfs_header *hdr;
u32 crc = ~(u32)0;
u16 csum_type = btrfs_super_csum_type(block);
- if (is_sb) {
- crc = btrfs_csum_data(csum_type,
- (char *)block + BTRFS_CSUM_SIZE,
- (u8 *)&crc,
- BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
- } else {
- crc = btrfs_csum_data(csum_type,
- (char *)block + BTRFS_CSUM_SIZE,
- (u8 *)&crc,
- BLOCKSIZE - BTRFS_CSUM_SIZE);
- }
+ crc = btrfs_csum_data(csum_type, (char *)block + BTRFS_CSUM_SIZE,
+ (u8 *)&crc,
+ BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
+
btrfs_csum_final(csum_type, crc, result);
memset(block, 0, BTRFS_CSUM_SIZE);
hdr = (struct btrfs_header *)block;
@@ -354,7 +347,7 @@ int main(int argc, char **argv) {
if (changed) {
printf("Update csum\n");
- update_block_csum(buf, 1);
+ update_block_csum(buf);
ret = pwrite(fd, buf, BLOCKSIZE, off);
if (ret <= 0) {
printf("pwrite error %d at offset %llu\n",
--
2.16.4
next prev parent reply other threads:[~2019-08-26 11:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-26 11:48 [PATCH v2 00/11] btrfs-progs: support xxhash64 checksums Johannes Thumshirn
2019-08-26 11:48 ` [PATCH v2 01/11] btrfs-progs: don't blindly assume crc32c in csum_tree_block_size() Johannes Thumshirn
2019-08-27 16:33 ` David Sterba
2019-08-27 16:36 ` David Sterba
2019-08-28 7:48 ` Johannes Thumshirn
2019-08-26 11:48 ` [PATCH v2 02/11] btrfs-progs: cache csum_type in recover_control Johannes Thumshirn
2019-08-26 11:48 ` [PATCH v2 03/11] btrfs-progs: add checksum type to checksumming functions Johannes Thumshirn
2019-08-27 12:51 ` Nikolay Borisov
2019-08-26 11:48 ` [PATCH v2 04/11] btrfs-progs: don't assume checksums are always 4 bytes Johannes Thumshirn
2019-08-27 12:52 ` Nikolay Borisov
2019-08-26 11:48 ` [PATCH v2 05/11] btrfs-progs: pass checksum type to btrfs_csum_data()/btrfs_csum_final() Johannes Thumshirn
2019-08-27 12:53 ` Nikolay Borisov
2019-08-26 11:48 ` Johannes Thumshirn [this message]
2019-08-26 11:48 ` [PATCH v2 07/11] btrfs-progs: update checksumming api Johannes Thumshirn
2019-08-26 11:48 ` [PATCH v2 08/11] btrfs-progs: add option for checksum type to mkfs Johannes Thumshirn
2019-08-27 13:03 ` Nikolay Borisov
2019-08-26 11:48 ` [PATCH v2 09/11] btrfs-progs: add xxhash sources Johannes Thumshirn
2019-08-27 13:05 ` Nikolay Borisov
2019-08-27 16:20 ` David Sterba
2019-08-26 11:48 ` [PATCH v2 10/11] btrfs-progs: add xxhash64 as checksum algorithm Johannes Thumshirn
2019-08-27 14:16 ` Nikolay Borisov
2019-08-27 16:12 ` David Sterba
2019-08-30 9:33 ` Johannes Thumshirn
2019-08-26 11:48 ` [PATCH v2 11/11] btrfs-progs: add test-case for mkfs with xxhash64 Johannes Thumshirn
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=20190826114853.14860-7-jthumshirn@suse.de \
--to=jthumshirn@suse.de \
--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