From patchwork Mon Jun 3 14:58:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 10972995 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 D2CAA912 for ; Mon, 3 Jun 2019 14:59:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C479A281DB for ; Mon, 3 Jun 2019 14:59:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B921A286C8; Mon, 3 Jun 2019 14:59:13 +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 69BB2286E6 for ; Mon, 3 Jun 2019 14:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729387AbfFCO7L (ORCPT ); Mon, 3 Jun 2019 10:59:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:60998 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729359AbfFCO7E (ORCPT ); Mon, 3 Jun 2019 10:59:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B82F5AF9A; Mon, 3 Jun 2019 14:59:02 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Linux BTRFS Mailinglist , Chris Mason , Richard Weinberger , David Gstir , Nikolay Borisov , Johannes Thumshirn Subject: [PATCH v4 08/13] btrfs: check for supported superblock checksum type before checksum validation Date: Mon, 3 Jun 2019 16:58:54 +0200 Message-Id: <20190603145859.7176-9-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190603145859.7176-1-jthumshirn@suse.de> References: <20190603145859.7176-1-jthumshirn@suse.de> 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 Now that we have factorerd out the superblock checksum type validation, we can check for supported superblock checksum types before doing the actual validation of the superblock read from disk. This leads the path to further simplifications of btrfs_check_super_csum() later on. Signed-off-by: Johannes Thumshirn Reviewed-by: Nikolay Borisov --- Changes to v3: - Pass csum_type to btrfs_supported_super_csum() (David) - Use %u to print on-disk checksum type if we encounter an unsupported type (David) Changes to v2: - Print on-disk checksum type if we encounter an unsupported type (David) --- fs/btrfs/disk-io.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index c2aba3dc33c5..b11091612074 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2821,6 +2821,16 @@ int open_ctree(struct super_block *sb, goto fail_alloc; } + if (!btrfs_supported_super_csum(btrfs_super_csum_type( + (struct btrfs_super_block *) bh->b_data))) { + btrfs_err(fs_info, "unsupported checksum algorithm: %u", + btrfs_super_csum_type((struct btrfs_super_block *) + bh->b_data)); + err = -EINVAL; + brelse(bh); + goto fail_alloc; + } + /* * We want to check superblock checksum, the type is stored inside. * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k).