From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Thorsten Hirsch <t.hirsch@web.de>
Subject: [PATCH 2/7] btrfs-progs: check/original: Add inode mode check
Date: Mon, 25 Mar 2019 16:22:48 +0800 [thread overview]
Message-ID: <20190325082253.19583-3-wqu@suse.com> (raw)
In-Reply-To: <20190325082253.19583-1-wqu@suse.com>
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 <t.hirsch@web.de>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
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
next prev parent reply other threads:[~2019-03-25 8:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-25 8:22 [PATCH 0/7] btrfs: check: Check and repair invalid free space cahce inode mode Qu Wenruo
2019-03-25 8:22 ` [PATCH 1/7] btrfs-progs: check/lowmem: Add inode mode check Qu Wenruo
2019-03-25 15:40 ` Nikolay Borisov
2019-03-25 8:22 ` Qu Wenruo [this message]
2019-03-25 15:43 ` [PATCH 2/7] btrfs-progs: check/original: " Nikolay Borisov
2019-03-25 22:59 ` Qu Wenruo
2019-03-25 8:22 ` [PATCH 3/7] btrfs-progs: check/lowmem: Repair invalid inode mode in root tree Qu Wenruo
2019-03-29 9:36 ` Nikolay Borisov
2019-03-29 11:00 ` Qu Wenruo
2019-03-25 8:22 ` [PATCH 4/7] btrfs-progs: check/original: " Qu Wenruo
2019-03-25 8:22 ` [PATCH 5/7] btrfs: check/lowmem: Check and repair free space cache inode mode Qu Wenruo
2019-03-25 14:36 ` Su Yue
2019-03-25 14:39 ` Qu Wenruo
2019-03-29 9:40 ` Nikolay Borisov
2019-03-29 11:02 ` Qu Wenruo
2019-03-29 11:47 ` Nikolay Borisov
2019-03-25 8:22 ` [PATCH 6/7] btrfs: check/original: Check and repair free space cache inode item Qu Wenruo
2019-03-25 8:22 ` [PATCH 7/7] btrfs: tests/fsck: Add test image for free space cache mode repair Qu Wenruo
2019-03-29 12:05 ` Nikolay Borisov
2019-03-29 12:08 ` Qu Wenruo
2019-04-01 5:52 ` Qu Wenruo
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=20190325082253.19583-3-wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=t.hirsch@web.de \
/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;
as well as URLs for NNTP newsgroup(s).