From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B921C43381 for ; Mon, 25 Mar 2019 08:23:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6BEA720879 for ; Mon, 25 Mar 2019 08:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729914AbfCYIXF (ORCPT ); Mon, 25 Mar 2019 04:23:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:36560 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729996AbfCYIXF (ORCPT ); Mon, 25 Mar 2019 04:23:05 -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 21FB8AE7F; Mon, 25 Mar 2019 08:23:04 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: Thorsten Hirsch Subject: [PATCH 2/7] btrfs-progs: check/original: Add inode mode check Date: Mon, 25 Mar 2019 16:22:48 +0800 Message-Id: <20190325082253.19583-3-wqu@suse.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190325082253.19583-1-wqu@suse.com> References: <20190325082253.19583-1-wqu@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Just like lowmem mode, check inode mode, specially for S_IFMT bits and beyond. Please note that, this check only applies to inodes in fs/subvol trees. It doesn't apply to free space cache inodes. Reported-by: Thorsten Hirsch Signed-off-by: Qu Wenruo --- check/main.c | 5 +++++ check/mode-original.h | 1 + 2 files changed, 6 insertions(+) diff --git a/check/main.c b/check/main.c index 7547209c5604..553c93caa2c9 100644 --- a/check/main.c +++ b/check/main.c @@ -616,6 +616,9 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec) fprintf(stderr, ", odd inode flags"); if (errors & I_ERR_INLINE_RAM_BYTES_WRONG) fprintf(stderr, ", invalid inline ram bytes"); + if (errors & I_ERR_INVALID_IMODE) + fprintf(stderr, ", invalid inode mode bit 0%o", + rec->imode & ~07777); fprintf(stderr, "\n"); /* Print the orphan extents if needed */ if (errors & I_ERR_FILE_EXTENT_ORPHAN) @@ -811,6 +814,8 @@ static void maybe_free_inode_rec(struct cache_tree *inode_cache, if (!rec->checked || rec->merging) return; + if (!is_valid_imode(rec->imode)) + rec->errors |= I_ERR_INVALID_IMODE; if (S_ISDIR(rec->imode)) { if (rec->found_size != rec->isize) rec->errors |= I_ERR_DIR_ISIZE_WRONG; diff --git a/check/mode-original.h b/check/mode-original.h index 25ca274118a7..e40a12930a6f 100644 --- a/check/mode-original.h +++ b/check/mode-original.h @@ -189,6 +189,7 @@ struct file_extent_hole { #define I_ERR_ODD_INODE_FLAGS (1 << 16) #define I_ERR_INLINE_RAM_BYTES_WRONG (1 << 17) #define I_ERR_MISMATCH_DIR_HASH (1 << 18) +#define I_ERR_INVALID_IMODE (1 << 19) struct inode_record { struct list_head backrefs; -- 2.21.0