All of lore.kernel.org
 help / color / mirror / Atom feed
From: Su Yue <suy.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: <quwenruo@cn.fujitsu.com>
Subject: [PATCH 04/20] btrfs-progs: cmds-check.c: change find_inode_ref's arg
Date: Wed, 1 Mar 2017 11:13:47 +0800	[thread overview]
Message-ID: <20170301031403.23902-5-suy.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <20170301031403.23902-1-suy.fnst@cn.fujitsu.com>

For further lowmem repairs, change the index type u64 to u64 *.
So we could get the index of ref.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 cmds-check.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/cmds-check.c b/cmds-check.c
index fb239968..246f4735 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -4422,22 +4422,23 @@ next:
 }
 
 /*
- * Find INODE_REF/INODE_EXTREF for the given key and check it with the specified
- * DIR_ITEM/DIR_INDEX match.
+ * Find INODE_REF/INODE_EXTREF for the given key and check it with the
+ * specified DIR_ITEM/DIR_INDEX match.Returned with right @index.
  *
  * @root:	the root of the fs/file tree
  * @key:	the key of the INODE_REF/INODE_EXTREF
  * @name:	the name in the INODE_REF/INODE_EXTREF
  * @namelen:	the length of name in the INODE_REF/INODE_EXTREF
- * @index:	the index in the INODE_REF/INODE_EXTREF, for DIR_ITEM set index
- * to (u64)-1
+ * @index_ret:	the index in the INODE_REF/INODE_EXTREF,
+ *              value (64)-1 means do not check index and return
+ *              with matched index.
  * @ext_ref:	the EXTENDED_IREF feature
  *
  * Return 0 if no error occurred.
  * Return >0 for error bitmap
  */
 static int find_inode_ref(struct btrfs_root *root, struct btrfs_key *key,
-			  char *name, int namelen, u64 index,
+			  const char *name, int namelen, u64 *index_ret,
 			  unsigned int ext_ref)
 {
 	struct btrfs_path path;
@@ -4474,7 +4475,8 @@ static int find_inode_ref(struct btrfs_root *root, struct btrfs_key *key,
 
 		ref_namelen = btrfs_inode_ref_name_len(node, ref);
 		ref_index = btrfs_inode_ref_index(node, ref);
-		if (index != (u64)-1 && index != ref_index)
+		if (index_ret && *index_ret != (u64)-1 &&
+		    *index_ret != ref_index)
 			goto next_ref;
 
 		if (ref_namelen <= BTRFS_NAME_LEN) {
@@ -4492,7 +4494,8 @@ static int find_inode_ref(struct btrfs_root *root, struct btrfs_key *key,
 
 		if (len != namelen || strncmp(ref_namebuf, name, len))
 			goto next_ref;
-
+		if (index_ret)
+			*index_ret = ref_index;
 		ret = 0;
 		goto out;
 next_ref:
@@ -4533,7 +4536,8 @@ extref:
 		ref_namelen = btrfs_inode_extref_name_len(node, extref);
 		ref_index = btrfs_inode_extref_index(node, extref);
 		parent = btrfs_inode_extref_parent(node, extref);
-		if (index != (u64)-1 && index != ref_index)
+		if (index_ret && *index_ret != (u64)-1 &&
+		    *index_ret != ref_index)
 			goto next_extref;
 
 		if (parent != dir_id)
@@ -4555,6 +4559,8 @@ extref:
 		if (len != namelen || strncmp(ref_namebuf, name, len))
 			goto next_extref;
 
+		if (index_ret)
+			*index_ret = ref_index;
 		ret = 0;
 		goto out;
 
@@ -4668,7 +4674,7 @@ static int check_dir_item(struct btrfs_root *root, struct btrfs_key *key,
 		location.type = BTRFS_INODE_REF_KEY;
 		location.offset = key->objectid;
 		ret = find_inode_ref(root, &location, namebuf, len,
-				       index, ext_ref);
+				       &index, ext_ref);
 		err |= ret;
 		if (ret & INODE_REF_MISSING)
 			error("root %llu %s[%llu %llu] relative INODE_REF missing namelen %u filename %s filetype %d",
-- 
2.11.1




  parent reply	other threads:[~2017-03-01  3:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-01  3:13 [PATCH 00/20] Enable lowmem repair for fs/subvolume tree Su Yue
2017-03-01  3:13 ` [PATCH 01/20] btrfs-progs: cmds-check.c: supports inode nbytes fix in lowmem Su Yue
2017-03-01  3:13 ` [PATCH 02/20] btrfs-progs: cmds-check.c: supports dir isize " Su Yue
2017-03-01  3:13 ` [PATCH 03/20] btrfs-progs: cmds-check.c: inode orphan item repair Su Yue
2017-03-01  3:13 ` Su Yue [this message]
2017-03-01  3:13 ` [PATCH 05/20] btrfs-progs: cmds-check.c: modify check_fs_first_inode Su Yue
2017-03-01  3:13 ` [PATCH 06/20] btrfs-progs: cmds-check.c: change find_dir_index/item Su Yue
2017-03-01  3:13 ` [PATCH 07/20] btrfs-progs: cmds-check.c: introduce print_inode_ref Su Yue
2017-03-01  3:13 ` [PATCH 08/20] btrfs-progs: cmds-check.c: print_dir_item_err Su Yue
2017-03-01  3:13 ` [PATCH 09/20] btrfs-progs: cmds-check.c: introduce count_dir_isize Su Yue
2017-03-01  3:13 ` [PATCH 10/20] btrfs-progs: dir-item.c: modify btrfs_insert_dir_item Su Yue
2017-03-01  3:13 ` [PATCH 11/20] btrfs-progs: inode.c: alter btrfs_add_link Su Yue
2017-03-01  3:13 ` [PATCH 12/20] btrfs-progs: cmds-check.c: introduce __create_inode_item Su Yue
2017-03-01  3:13 ` [PATCH 13/20] btrfs-progs: cmds-check.c: repair_inode_item_missing Su Yue
2017-03-01  3:13 ` [PATCH 14/20] btrfs-progs: cmds-check.c: repair_fs_first_inode Su Yue
2017-03-01  3:13 ` [PATCH 15/20] btrfs-progs: cmds-check.c: introduce repair_ternary_lowmem Su Yue
2017-03-01  3:13 ` [PATCH 16/20] btrfs-progs: cmds-check.c: Introduce repair_dir_item Su Yue
2017-03-01  3:14 ` [PATCH 17/20] btrfs-progs: cmds-check.c: repair inode ref Su Yue
2017-03-01  3:14 ` [PATCH 18/20] btrfs-progs: cmds-check.c: repair nlinks lowmem Su Yue
2017-03-01  3:14 ` [PATCH 19/20] btrfs-progs: cmds-check.c: add punch_extent_hole Su Yue
2017-03-01  3:14 ` [PATCH 20/20] btrfs-progs: fsck-check: Allow fsck check test to repair in lowmem mode for certain test cases Su Yue
2017-03-30 16:44 ` [PATCH 00/20] Enable lowmem repair for fs/subvolume tree David Sterba
2017-03-31  1:49   ` Su Yue

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=20170301031403.23902-5-suy.fnst@cn.fujitsu.com \
    --to=suy.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo@cn.fujitsu.com \
    /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.