diff mbox series

[v2] btrfs-progs: Make btrfs_lookup_dir_index in parity with kernel code

Message ID 20200822032331.5088-1-marcos@mpdesouza.com
State New, archived
Headers show
Series [v2] btrfs-progs: Make btrfs_lookup_dir_index in parity with kernel code | expand

Commit Message

Marcos Paulo de Souza Aug. 22, 2020, 3:23 a.m. UTC
From: Marcos Paulo de Souza <mpdesouza@suse.com>

This function exists in kernel side but using the _item suffix, and
objectid argument is placed before the name argument. Change the
function to reflect the kernel version.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---

 Changes from v1:
 * Added a reviewed-by tag from Josef
 * Put the return type in the same line of the function name (David)

 check/main.c             |  6 +++---
 kernel-shared/ctree.h    | 10 +++++-----
 kernel-shared/dir-item.c | 12 ++++++------
 kernel-shared/inode.c    | 14 +++++++-------
 4 files changed, 21 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/check/main.c b/check/main.c
index cc902e15..9a2ee2a0 100644
--- a/check/main.c
+++ b/check/main.c
@@ -2068,9 +2068,9 @@  static int delete_dir_index(struct btrfs_root *root,
 		(unsigned long long)root->objectid);
 
 	btrfs_init_path(&path);
-	di = btrfs_lookup_dir_index(trans, root, &path, backref->dir,
-				    backref->name, backref->namelen,
-				    backref->index, -1);
+	di = btrfs_lookup_dir_index_item(trans, root, &path, backref->dir,
+					 backref->index, backref->name,
+					 backref->namelen, -1);
 	if (IS_ERR(di)) {
 		ret = PTR_ERR(di);
 		btrfs_release_path(&path);
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index 11b77775..85c755f8 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -2760,11 +2760,11 @@  struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
 					     struct btrfs_path *path, u64 dir,
 					     const char *name, int name_len,
 					     int mod);
-struct btrfs_dir_item *btrfs_lookup_dir_index(struct btrfs_trans_handle *trans,
-					      struct btrfs_root *root,
-					      struct btrfs_path *path, u64 dir,
-					      const char *name, int name_len,
-					      u64 index, int mod);
+struct btrfs_dir_item * btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
+					struct btrfs_root *root,
+					struct btrfs_path *path, u64 dir,
+					u64 objectid, const char *name, int name_len,
+					int mod);
 int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
 			      struct btrfs_root *root,
 			      struct btrfs_path *path,
diff --git a/kernel-shared/dir-item.c b/kernel-shared/dir-item.c
index c0a1d025..7dc606c1 100644
--- a/kernel-shared/dir-item.c
+++ b/kernel-shared/dir-item.c
@@ -225,11 +225,11 @@  struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
 	return btrfs_match_dir_item_name(root, path, name, name_len);
 }
 
-struct btrfs_dir_item *btrfs_lookup_dir_index(struct btrfs_trans_handle *trans,
-					      struct btrfs_root *root,
-					      struct btrfs_path *path, u64 dir,
-					      const char *name, int name_len,
-					      u64 index, int mod)
+struct btrfs_dir_item *btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
+					struct btrfs_root *root,
+					struct btrfs_path *path, u64 dir,
+					u64 objectid, const char *name, int name_len,
+					int mod)
 {
 	int ret;
 	struct btrfs_key key;
@@ -238,7 +238,7 @@  struct btrfs_dir_item *btrfs_lookup_dir_index(struct btrfs_trans_handle *trans,
 
 	key.objectid = dir;
 	key.type = BTRFS_DIR_INDEX_KEY;
-	key.offset = index;
+	key.offset = objectid;
 
 	ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow);
 	if (ret < 0)
diff --git a/kernel-shared/inode.c b/kernel-shared/inode.c
index 1d6452cc..8dfe5b0d 100644
--- a/kernel-shared/inode.c
+++ b/kernel-shared/inode.c
@@ -136,8 +136,8 @@  int check_dir_conflict(struct btrfs_root *root, char *name, int namelen,
 	btrfs_release_path(path);
 
 	/* Index conflicting? */
-	dir_item = btrfs_lookup_dir_index(NULL, root, path, dir, name,
-					  namelen, index, 0);
+	dir_item = btrfs_lookup_dir_index_item(NULL, root, path, dir, index,
+					  name, namelen, 0);
 	if (IS_ERR(dir_item) && PTR_ERR(dir_item) == -ENOENT)
 		dir_item = NULL;
 	if (IS_ERR(dir_item)) {
@@ -311,8 +311,8 @@  int btrfs_unlink(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 		del_dir_item = 1;
 	btrfs_release_path(path);
 
-	dir_item = btrfs_lookup_dir_index(NULL, root, path, parent_ino,
-					  name, namelen, index, 0);
+	dir_item = btrfs_lookup_dir_index_item(NULL, root, path, parent_ino,
+					       index, name, namelen, 0);
 	/*
 	 * Since lookup_dir_index() will return -ENOENT when not found,
 	 * we need to do extra check.
@@ -369,9 +369,9 @@  int btrfs_unlink(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 	}
 
 	if (del_dir_index) {
-		dir_item = btrfs_lookup_dir_index(trans, root, path,
-						  parent_ino, name, namelen,
-						  index, -1);
+		dir_item = btrfs_lookup_dir_index_item(trans, root, path,
+						       parent_ino, index, name,
+						       namelen, -1);
 		if (IS_ERR(dir_item)) {
 			ret = PTR_ERR(dir_item);
 			goto out;