From patchwork Thu Jul 25 09:34:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11058343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52DBD13A0 for ; Thu, 25 Jul 2019 09:34:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41FD928999 for ; Thu, 25 Jul 2019 09:34:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 367912899D; Thu, 25 Jul 2019 09:34:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7F9628999 for ; Thu, 25 Jul 2019 09:34:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403827AbfGYJeZ (ORCPT ); Thu, 25 Jul 2019 05:34:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:52362 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2403782AbfGYJeL (ORCPT ); Thu, 25 Jul 2019 05:34:11 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 89B2DAFF9 for ; Thu, 25 Jul 2019 09:34:09 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Linux BTRFS Mailinglist , Johannes Thumshirn Subject: [RFC PATCH 13/17] btrfs-progs: pass checksum type to btrfs_csum_data() Date: Thu, 25 Jul 2019 11:34:00 +0200 Message-Id: X-Mailer: git-send-email 2.16.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Johannes Thumshirn --- btrfs-sb-mod.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/btrfs-sb-mod.c b/btrfs-sb-mod.c index 932c2a0432ef..d9630f187d0f 100644 --- a/btrfs-sb-mod.c +++ b/btrfs-sb-mod.c @@ -35,11 +35,13 @@ static int check_csum_superblock(void *sb) { u8 result[csum_size]; u32 crc = ~(u32)0; + u16 csum_type = btrfs_super_csum_type(sb); - crc = btrfs_csum_data((char *)sb + BTRFS_CSUM_SIZE, + crc = btrfs_csum_data(csum_type, + (char *)sb + BTRFS_CSUM_SIZE, (u8 *)&crc, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); - btrfs_csum_final(crc, result); + btrfs_csum_final(csum_type, crc, result); return !memcmp(sb, &result, csum_size); } @@ -49,17 +51,20 @@ static void update_block_csum(void *block, int is_sb) 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((char *)block + BTRFS_CSUM_SIZE, + 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((char *)block + BTRFS_CSUM_SIZE, + crc = btrfs_csum_data(csum_type, + (char *)block + BTRFS_CSUM_SIZE, (u8 *)&crc, BLOCKSIZE - BTRFS_CSUM_SIZE); } - btrfs_csum_final(crc, result); + btrfs_csum_final(csum_type, crc, result); memset(block, 0, BTRFS_CSUM_SIZE); hdr = (struct btrfs_header *)block; memcpy(&hdr->csum, result, csum_size);