All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 4/7] btrfs-progs: check/original: Repair invalid inode mode in root tree
Date: Mon,  1 Apr 2019 13:55:48 +0800	[thread overview]
Message-ID: <20190401055551.6837-5-wqu@suse.com> (raw)
In-Reply-To: <20190401055551.6837-1-wqu@suse.com>

This patch will reuse the mode independent repair_imode() function, to
repair invalid inode mode.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/main.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/check/main.c b/check/main.c
index 553c93caa2c9..608fe7bb02fb 100644
--- a/check/main.c
+++ b/check/main.c
@@ -2698,6 +2698,30 @@ static int repair_mismatch_dir_hash(struct btrfs_trans_handle *trans,
 	return ret;
 }
 
+static int repair_imode_original(struct btrfs_trans_handle *trans,
+				 struct btrfs_root *root,
+				 struct btrfs_path *path,
+				 struct inode_record *rec)
+{
+	int ret;
+	u32 imode;
+
+	if (root->root_key.objectid != BTRFS_ROOT_TREE_OBJECTID)
+		return -ENOTTY;
+	if (rec->ino != BTRFS_ROOT_TREE_DIR_OBJECTID || !is_fstree(rec->ino))
+		return -ENOTTY;
+
+	if (rec->ino == BTRFS_ROOT_TREE_DIR_OBJECTID)
+		imode = 040755;
+	else
+		imode = 0100600;
+	ret = reset_imode(trans, root, path, rec->ino, imode);
+	if (ret < 0)
+		return ret;
+	rec->errors &= ~I_ERR_INVALID_IMODE;
+	return ret;
+}
+
 static int try_repair_inode(struct btrfs_root *root, struct inode_record *rec)
 {
 	struct btrfs_trans_handle *trans;
@@ -2745,6 +2769,8 @@ static int try_repair_inode(struct btrfs_root *root, struct inode_record *rec)
 		ret = repair_inode_nbytes(trans, root, &path, rec);
 	if (!ret && rec->errors & I_ERR_INLINE_RAM_BYTES_WRONG)
 		ret = repair_inline_ram_bytes(trans, root, &path, rec);
+	if (!ret && rec->errors & I_ERR_INVALID_IMODE)
+		ret = repair_imode_original(trans, root, &path, rec);
 	btrfs_commit_transaction(trans, root);
 	btrfs_release_path(&path);
 	return ret;
-- 
2.21.0


  parent reply	other threads:[~2019-04-01  5:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01  5:55 [PATCH v2 0/7] btrfs: check: Check and repair invalid free space cahce inode mode Qu Wenruo
2019-04-01  5:55 ` [PATCH v2 1/7] btrfs-progs: check/lowmem: Add inode mode check Qu Wenruo
2019-04-01  5:55 ` [PATCH v2 2/7] btrfs-progs: check/original: " Qu Wenruo
2019-04-01  5:55 ` [PATCH v2 3/7] btrfs-progs: check/lowmem: Repair invalid inode mode in root tree Qu Wenruo
2019-04-01  5:55 ` Qu Wenruo [this message]
2019-04-01  5:55 ` [PATCH v2 5/7] btrfs: check/lowmem: Check and repair free space cache inode mode Qu Wenruo
2019-04-01  5:55 ` [PATCH v2 6/7] btrfs: check/original: Check and repair free space cache inode item Qu Wenruo
2019-04-01  5:55 ` [PATCH v2 7/7] btrfs: tests/fsck: Add test image for free space cache mode repair 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=20190401055551.6837-5-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.