From patchwork Mon Nov 19 09:16:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Lyahkov X-Patchwork-Id: 999672 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YNOVhxfM"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42z3C06N7dz9s3x for ; Mon, 19 Nov 2018 20:17:32 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727266AbeKSTkd (ORCPT ); Mon, 19 Nov 2018 14:40:33 -0500 Received: from mail-io1-f52.google.com ([209.85.166.52]:36083 "EHLO mail-io1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbeKSTkd (ORCPT ); Mon, 19 Nov 2018 14:40:33 -0500 Received: by mail-io1-f52.google.com with SMTP id m19so16035343ioh.3 for ; Mon, 19 Nov 2018 01:17:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3NzYZJQaPpcWmNqLPRafAruGFvRUjXxdHXB5+jgqXFg=; b=YNOVhxfMOXQChjoFTZqcct6p2vgT51ULaKHtxyAah459htK99d/puM6yBV+UaWAQt9 E5rJQH2xf8oxmeelhgZFqJF8CgLhfF4gtLkBf7EgwutwXi9ajRVqKpa6O7TE0b+/DJig bWA+8uqJZfkP4Nz+VYy1OZjCdTUTXYkyf8WLVjGg1o5PmiLygnptX7tFD+P9c3Jp63zY AgWTuwDu7aW5I0ct8s7xjsR1h3erlGoxF2gl77937YCchf23oEU3B+DyykIbSCEGk7aW cP/xyC5eMR9OJnxEFZ4qU+j+Ud2YruiG7QkYIGvaDV0pvcI4L9N+GCDXFdaBHUudmWET YjtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3NzYZJQaPpcWmNqLPRafAruGFvRUjXxdHXB5+jgqXFg=; b=tbFfg3SNGOQtfNn2Fx2pFLbGo1I2llNqX553OrmnMN7LZ639hK+kpQM1B/GY3KE2aU 6KDnNdTERJidoyvIbUoe0YvVrJJL5x8lLL1e+PjBOOaSCBMVBlkeMc8KpePVCJ2o+QSq RFeLbtTb8vPA43eg69rRv2LNu+5DjzGhyBVrrO9Sh1nFio0i9VwqB6fINVkiNzxqkWBE c6mPVEa4Rkr9+Yo1PAX1vXFojKUvap6Gzwvvsiji/DPvdi50N4iy5NXWlMlh6ezW6IdL LSZw2+iRv7X3Yblw4HmsSyExEvswG6UTKddMsSKXWnT93NUCeCDUbwH+zEcWfTgn0vNW O2IQ== X-Gm-Message-State: AA+aEWaagXeTGfVH37hQtO+XFFJ038ldq89GUUyHM6dGqAaKvq4W62o3 scYhgUUmC/zSq9hlRdWpaaUd7yz1 X-Google-Smtp-Source: AFSGD/V3IDIYuIPlzJYAeDg3TB2BnyCdLbQSGN7pQcm6lq595XkVthrWJjK7EgqaO1elz57AhvdPqg== X-Received: by 2002:a6b:3f06:: with SMTP id m6mr7833062ioa.117.1542619050547; Mon, 19 Nov 2018 01:17:30 -0800 (PST) Received: from C02TNAJHHTD6.us.cray.com (seattle-nat.cray.com. [136.162.66.1]) by smtp.gmail.com with ESMTPSA id y76sm13303364ita.18.2018.11.19.01.17.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 01:17:29 -0800 (PST) From: alexey.lyashkov@gmail.com To: linux-ext4@vger.kernel.org Cc: Alexey Lyashkov Subject: [PATCH 1/3] block number output fix. Date: Mon, 19 Nov 2018 12:16:48 +0300 Message-Id: <20181119091650.81803-2-alexey.lyashkov@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119091650.81803-1-alexey.lyashkov@gmail.com> References: <20181119091650.81803-1-alexey.lyashkov@gmail.com> MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org debugfs lack a support journal tag v3 and block numbers over 2^32 fix it. --- debugfs/logdump.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/debugfs/logdump.c b/debugfs/logdump.c index e286ae83..84108a6e 100644 --- a/debugfs/logdump.c +++ b/debugfs/logdump.c @@ -58,11 +58,11 @@ static void dump_descriptor_block(FILE *, struct journal_source *, unsigned int *, int, tid_t); static void dump_revoke_block(FILE *, char *, journal_superblock_t *, - unsigned int, int, tid_t); + blk64_t, int, tid_t); static void dump_metadata_block(FILE *, struct journal_source *, journal_superblock_t*, - unsigned int, unsigned int, unsigned int, + unsigned int, blk64_t, unsigned int, int, tid_t); static void do_hexdump (FILE *, char *, int); @@ -496,6 +496,16 @@ static inline size_t journal_super_tag_bytes(journal_superblock_t *jsb) return sz - sizeof(__u32); } +static blk64_t tag_blocknr(journal_superblock_t *jsb, + journal_block_tag_t *tag) +{ + blk64_t block = be32_to_cpu(tag->t_blocknr); + + if (JSB_HAS_INCOMPAT_FEATURE(jsb, JFS_FEATURE_INCOMPAT_64BIT)) + block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32; + return block; +} + static void dump_descriptor_block(FILE *out_file, struct journal_source *source, char *buf, @@ -507,7 +517,7 @@ static void dump_descriptor_block(FILE *out_file, char *tagp; journal_block_tag_t *tag; unsigned int blocknr; - __u32 tag_block; + blk64_t tag_block; __u32 tag_flags; tag_size = journal_super_tag_bytes(jsb); @@ -537,7 +547,7 @@ static void dump_descriptor_block(FILE *out_file, if (offset > blocksize - csum_size) break; - tag_block = be32_to_cpu(tag->t_blocknr); + tag_block = tag_blocknr(jsb, tag); tag_flags = be16_to_cpu(tag->t_flags); if (!(tag_flags & JFS_FLAG_SAME_UUID)) @@ -558,7 +568,7 @@ static void dump_descriptor_block(FILE *out_file, static void dump_revoke_block(FILE *out_file, char *buf, journal_superblock_t *jsb EXT2FS_ATTR((unused)), - unsigned int blocknr, + blk64_t blocknr, int blocksize EXT2FS_ATTR((unused)), tid_t transaction) { @@ -569,9 +579,9 @@ static void dump_revoke_block(FILE *out_file, char *buf, if (dump_all) fprintf(out_file, "Dumping revoke block, sequence %u, at " - "block %u:\n", transaction, blocknr); + "block %llu:\n", transaction, blocknr); - if (be32_to_cpu(jsb->s_feature_incompat) & JFS_FEATURE_INCOMPAT_64BIT) + if (JSB_HAS_INCOMPAT_FEATURE(jsb, JFS_FEATURE_INCOMPAT_64BIT)) tag_size = sizeof(__u64); header = (journal_revoke_header_t *) buf; @@ -591,7 +601,7 @@ static void dump_revoke_block(FILE *out_file, char *buf, if (dump_all) fprintf(out_file, "\n"); else - fprintf(out_file," at block %u, sequence %u\n", + fprintf(out_file," at block %llu, sequence %u\n", blocknr, transaction); } offset += tag_size; @@ -617,7 +627,7 @@ static void show_indirect(FILE *out_file, const char *name, __u32 where) static void dump_metadata_block(FILE *out_file, struct journal_source *source, journal_superblock_t *jsb EXT2FS_ATTR((unused)), unsigned int log_blocknr, - unsigned int fs_blocknr, + blk64_t fs_blocknr, unsigned int log_tag_flags, int blocksize, tid_t transaction) @@ -631,7 +641,7 @@ static void dump_metadata_block(FILE *out_file, struct journal_source *source, || (fs_blocknr == bitmap_to_dump))) return; - fprintf(out_file, " FS block %u logged at ", fs_blocknr); + fprintf(out_file, " FS block %llu logged at ", fs_blocknr); if (!dump_all) fprintf(out_file, "sequence %u, ", transaction); fprintf(out_file, "journal block %u (flags 0x%x)\n", log_blocknr, From patchwork Mon Nov 19 09:16:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Lyahkov X-Patchwork-Id: 999673 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VoqvXryl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42z3C2319Xz9s3x for ; Mon, 19 Nov 2018 20:17:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727286AbeKSTkf (ORCPT ); Mon, 19 Nov 2018 14:40:35 -0500 Received: from mail-it1-f178.google.com ([209.85.166.178]:39226 "EHLO mail-it1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727272AbeKSTkf (ORCPT ); Mon, 19 Nov 2018 14:40:35 -0500 Received: by mail-it1-f178.google.com with SMTP id m15so6431653itl.4 for ; Mon, 19 Nov 2018 01:17:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RB+PdC6YJsgEZAubNL3cQsohT8inV2xHgWi/DeQSm0A=; b=VoqvXryl9t00GCFsjvtb8O/88Rpjv1ncL6EcLwaJNGzS3BHwcFZdeD2BY8seIg0Ujq Ej2SEzSNK9J70iUZUwnIe8a5v4Zq3NFqhaSvtrM145XY9x1hHaBvXbgPadh6U09asera 7mlMLbNgEGrlK6OdtS6qL8lGi3NEqvNosXyyNsy7IhJhkLJ8oRC1KrJn00ph43IkYkFS 1+SKtkrO4vg+C//+nDWdO1KIssiVn6Yto92JGin7FtBgT99sAws8LjeMPAS0vNaC5T9h vKF4aOchC9/MruAM/qQ1VQfm42reEP8gXaCzm86yXSrKZekRlUSeZgHgctscEIuF9HjT xyuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RB+PdC6YJsgEZAubNL3cQsohT8inV2xHgWi/DeQSm0A=; b=CdV28f5XCLetFS6j8XICiDSqZk895J8V8raNN4NV3+Ar71/NOJimCkdrkc4XeZlijb r8Z5JcAnolWEtm07YsAG3A0Aes45/g0OK972WHdg8YWofpfji+2lNmYsaQCxuJ1eSd5F gcjfmwaWN5rXocVVVPf74nPpbkVpyPI4t28gif+WPKYkS0eukLw1enuSmozFlgMX3dG5 tPArXsa8JJxWWz7aLoBZdAK+RcnhwkAD5GV0fL/iW1XgEhvKqW5xGgY5muBUUo8S4RRW NnLHaDo70qcFkP/wesHI7qMNh49QI4FHCcTskYjgfhuKg7dze/CLsoniTMND4oX9gVtj CvrQ== X-Gm-Message-State: AGRZ1gIcIXWZYV5fLuza26dJUN+I0UyZqyMgpXrlgEAEn61cgNtUCEAM Ry8vwrHrj5CmSi/cgqeoszHTbCh7 X-Google-Smtp-Source: AJdET5diJNT91hoADD0wGWdQqMJ+qlHhSu4oqDMtMhhB2X/XMrlhrJ77juagMBVbt+Vi4bxnU706zw== X-Received: by 2002:a02:7fca:: with SMTP id r193mr19981883jac.63.1542619053200; Mon, 19 Nov 2018 01:17:33 -0800 (PST) Received: from C02TNAJHHTD6.us.cray.com (seattle-nat.cray.com. [136.162.66.1]) by smtp.gmail.com with ESMTPSA id y76sm13303364ita.18.2018.11.19.01.17.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 01:17:32 -0800 (PST) From: alexey.lyashkov@gmail.com To: linux-ext4@vger.kernel.org Cc: Alexey Lyashkov Subject: [PATCH 2/3] Fix panic with journal superblock flags printing. Date: Mon, 19 Nov 2018 12:16:49 +0300 Message-Id: <20181119091650.81803-3-alexey.lyashkov@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119091650.81803-1-alexey.lyashkov@gmail.com> References: <20181119091650.81803-1-alexey.lyashkov@gmail.com> MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Signed-off-by: Alexey Lyashkov --- debugfs/logdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debugfs/logdump.c b/debugfs/logdump.c index 84108a6e..c88f6f9c 100644 --- a/debugfs/logdump.c +++ b/debugfs/logdump.c @@ -388,9 +388,9 @@ static void dump_journal(char *cmdname, FILE *out_file, if (retval) return; - if (dump_super) { + if (dump_all || dump_super) { e2p_list_journal_super(out_file, jsb_buffer, - current_fs->blocksize, 0); + 1024, 0); fputc('\n', out_file); } From patchwork Mon Nov 19 09:16:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Lyahkov X-Patchwork-Id: 999674 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="is8CV0G7"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42z3C850qdz9s9m for ; Mon, 19 Nov 2018 20:17:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727413AbeKSTkj (ORCPT ); Mon, 19 Nov 2018 14:40:39 -0500 Received: from mail-it1-f176.google.com ([209.85.166.176]:55275 "EHLO mail-it1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbeKSTkj (ORCPT ); Mon, 19 Nov 2018 14:40:39 -0500 Received: by mail-it1-f176.google.com with SMTP id a205-v6so7124617itd.4 for ; Mon, 19 Nov 2018 01:17:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u8CpBByMP6lWgpSQ5l+aGhsgzOvjZW1oO9qPqGdzhp4=; b=is8CV0G7rA9HAAfJTE3Po1tIDESGApfi91fHwU3MnPHEEbH/2gj8hYdS174A4+/xft GGlrfVc8UDfzhMhjyPqW+oSKTR35+o5FFDafYOutXuX4Fs1Rcv5yULElRbImYQodFb9v 41PRs0BJPHlllV1ECqw/fDq8nML7XdhLM/Sa5PZPBVSN42rBPgFsEPnIFgZ+w9IcwUDQ ZrRdjo+uEMfJU9DR26hVBj+UCOZXEoe8cb9mcdsfZY1/lA0JrEUL79C/sl600MYTqJoR 97MdPCZKfmAqZSJ7M2vQS1NemT0v1Mx6DRtf+84X3DasHWq8+ANdv/q1AElIe54f6uxr H4zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u8CpBByMP6lWgpSQ5l+aGhsgzOvjZW1oO9qPqGdzhp4=; b=o7fLtlQSJSbaOjDqvuzRCFTyOsN75BCusPmNgbqFc3LpXO/kjTttDd6m8ujtY3m/MK Q9QK4TsVv0BE8PozmiL3uWPQGIHy+1+Z2cLMxJFA7KVy8kUe+IY0lyyPkGgY7lOhMwOD NKNTK8jyjOl5+f/TaRvdkqbXRyJ3wWvdev8ps+WANhQBtXHy/9IsuhKQ7Jk0liypUx2l U0n1TMNybYA7ipSyTDA62+VckkpI6p0fCWaLY4S5c6v4DBzsN+gnJt4VcZ0CqmChPJQq XcHd8YmAlYTIpo2Wt9giSIlo7Mc4LPgHjUqBVYNmprzSF9Nbz0hVZhP7rYT35dmmcoAe W5Rg== X-Gm-Message-State: AA+aEWYn7c/eMyYtpYguadCX1ubRg7Mw7HAGJoPz4wUkyR+InotFmXCB FAjUDynOG0/7cDoWR6bQlbW3gz2W X-Google-Smtp-Source: AFSGD/WAYpT+j0J2F68sVOhAkJZpXZBcwGxGfAnPJD4PdwGCHs4Ho1FZyGCChJa9nd8RaxKwY7SMGw== X-Received: by 2002:a05:660c:781:: with SMTP id h1mr5629373itk.52.1542619056542; Mon, 19 Nov 2018 01:17:36 -0800 (PST) Received: from C02TNAJHHTD6.us.cray.com (seattle-nat.cray.com. [136.162.66.1]) by smtp.gmail.com with ESMTPSA id y76sm13303364ita.18.2018.11.19.01.17.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 01:17:35 -0800 (PST) From: alexey.lyashkov@gmail.com To: linux-ext4@vger.kernel.org Cc: Alexey Lyashkov Subject: [PATCH 3/3] add support to check a journal checksum v1 while journal dump. Date: Mon, 19 Nov 2018 12:16:50 +0300 Message-Id: <20181119091650.81803-4-alexey.lyashkov@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119091650.81803-1-alexey.lyashkov@gmail.com> References: <20181119091650.81803-1-alexey.lyashkov@gmail.com> MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org journal checksum v1 cover an all blocks in journal descriptor. This checksum stored into commit block and check with commit block reading. Signed-off-by: Alexey Lyashkov --- debugfs/logdump.c | 69 ++++++++++++++++++++++++++++++++++++++--------- e2fsck/jfs_user.h | 5 ++++ 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/debugfs/logdump.c b/debugfs/logdump.c index c88f6f9c..3dd04789 100644 --- a/debugfs/logdump.c +++ b/debugfs/logdump.c @@ -55,7 +55,7 @@ static void dump_journal(char *, FILE *, struct journal_source *); static void dump_descriptor_block(FILE *, struct journal_source *, char *, journal_superblock_t *, - unsigned int *, int, tid_t); + unsigned int *, int, tid_t, __u32 *); static void dump_revoke_block(FILE *, char *, journal_superblock_t *, blk64_t, int, tid_t); @@ -63,10 +63,14 @@ static void dump_revoke_block(FILE *, char *, journal_superblock_t *, static void dump_metadata_block(FILE *, struct journal_source *, journal_superblock_t*, unsigned int, blk64_t, unsigned int, - int, tid_t); + int, tid_t, __u32 *); static void do_hexdump (FILE *, char *, int); +static void jbd2_check_commit_cksum(FILE *, struct journal_source *, + journal_superblock_t *, + unsigned int , int , __u32); + #define WRAP(jsb, blocknr) \ if (blocknr >= be32_to_cpu((jsb)->s_maxlen)) \ blocknr -= (be32_to_cpu((jsb)->s_maxlen) - \ @@ -353,6 +357,7 @@ static void dump_journal(char *cmdname, FILE *out_file, journal_header_t *header; tid_t transaction; unsigned int blocknr = 0; + __u32 crc32_sum = ~0; /* First, check to see if there's an ext2 superblock header */ retval = read_journal_block(cmdname, source, 0, buf, 2048); @@ -453,12 +458,16 @@ static void dump_journal(char *cmdname, FILE *out_file, case JFS_DESCRIPTOR_BLOCK: dump_descriptor_block(out_file, source, buf, jsb, &blocknr, blocksize, - transaction); + transaction, &crc32_sum); continue; case JFS_COMMIT_BLOCK: + jbd2_check_commit_cksum(out_file, source, + jsb, blocknr, blocksize, + crc32_sum); transaction++; blocknr++; + crc32_sum = ~0; WRAP(jsb, blocknr); continue; @@ -511,7 +520,7 @@ static void dump_descriptor_block(FILE *out_file, char *buf, journal_superblock_t *jsb, unsigned int *blockp, int blocksize, - tid_t transaction) + tid_t transaction, __u32 *crc32_sum) { int offset, tag_size, csum_size = 0; char *tagp; @@ -535,6 +544,9 @@ static void dump_descriptor_block(FILE *out_file, ++blocknr; WRAP(jsb, blocknr); + if (JSB_HAS_COMPAT_FEATURE(jsb, JFS_FEATURE_COMPAT_CHECKSUM)) + *crc32_sum = ext2fs_crc32_be(*crc32_sum, buf, blocksize); + do { /* Work out the location of the current tag, and skip to * the next one... */ @@ -555,7 +567,7 @@ static void dump_descriptor_block(FILE *out_file, dump_metadata_block(out_file, source, jsb, blocknr, tag_block, tag_flags, blocksize, - transaction); + transaction, crc32_sum); ++blocknr; WRAP(jsb, blocknr); @@ -630,7 +642,7 @@ static void dump_metadata_block(FILE *out_file, struct journal_source *source, blk64_t fs_blocknr, unsigned int log_tag_flags, int blocksize, - tid_t transaction) + tid_t transaction, __u32 *crc32_sum) { int retval; char buf[8192]; @@ -659,18 +671,21 @@ static void dump_metadata_block(FILE *out_file, struct journal_source *source, * structure symbolically. */ - if (!(dump_contents && dump_all) - && fs_blocknr != block_to_dump - && fs_blocknr != bitmap_to_dump - && fs_blocknr != inode_block_to_dump) - return; - retval = read_journal_block("logdump", source, ((ext2_loff_t) log_blocknr) * blocksize, buf, blocksize); if (retval) return; + if (JSB_HAS_COMPAT_FEATURE(jsb, JFS_FEATURE_COMPAT_CHECKSUM)) + *crc32_sum = ext2fs_crc32_be(*crc32_sum, buf, blocksize); + + if (!(dump_contents && dump_all) + && fs_blocknr != block_to_dump + && fs_blocknr != bitmap_to_dump + && fs_blocknr != inode_block_to_dump) + return; + if (fs_blocknr == bitmap_to_dump) { struct ext2_super_block *super; int offset; @@ -751,3 +766,33 @@ static void do_hexdump (FILE *out_file, char *buf, int blocksize) } } +static void jbd2_check_commit_cksum(FILE *out_file, struct journal_source *source, + journal_superblock_t *jsb, + unsigned int blocknr, int blocksize, + __u32 crc32_sum) +{ + char buf[8192]; + struct commit_header *h = (void *)&buf[0]; + int retval; + + if (!dump_all) + return; + + retval = read_journal_block("logdump", source, + ((ext2_loff_t) blocknr) * blocksize, + buf, blocksize); + if (retval) + return; + + if (JSB_HAS_COMPAT_FEATURE(jsb, JFS_FEATURE_COMPAT_CHECKSUM)) { + if (h->h_chksum_type != JBD2_CRC32_CHKSUM) + fprintf(out_file, "Unknow commit checksum %u\n", + h->h_chksum); + if (h->h_chksum_size != JBD2_CRC32_CHKSUM_SIZE) + fprintf(out_file, "Unknown checksum size %u\n", + h->h_chksum_size); + if (h->h_chksum[0] != cpu_to_be32(crc32_sum)) + fprintf(out_file, "Wrong checksum %u <> %u\n", + h->h_chksum[0], cpu_to_be32(crc32_sum)); + } +} diff --git a/e2fsck/jfs_user.h b/e2fsck/jfs_user.h index a1c6951c..6e42a2a6 100644 --- a/e2fsck/jfs_user.h +++ b/e2fsck/jfs_user.h @@ -204,6 +204,11 @@ void wait_on_buffer(struct buffer_head *bh); #define JSB_HAS_INCOMPAT_FEATURE(jsb, mask) \ ((jsb)->s_header.h_blocktype == ext2fs_cpu_to_be32(JFS_SUPERBLOCK_V2) && \ ((jsb)->s_feature_incompat & ext2fs_cpu_to_be32((mask)))) + +#define JSB_HAS_COMPAT_FEATURE(jsb, mask) \ + ((jsb)->s_header.h_blocktype == ext2fs_cpu_to_be32(JFS_SUPERBLOCK_V2) && \ + ((jsb)->s_feature_compat & ext2fs_cpu_to_be32((mask)))) + #else /* !DEBUGFS */ extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */