Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Daniel Vacek <neelx@suse.com>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>
Cc: Daniel Vacek <neelx@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Daniel Vacek <neelx.g@gmail.com>
Subject: [PATCH v7 6/6] btrfs: don't search back for dir inode item in INO_LOOKUP_USER
Date: Tue, 18 Nov 2025 17:00:41 +0100	[thread overview]
Message-ID: <20251118160043.3005684-7-neelx@suse.com> (raw)
In-Reply-To: <20251118160043.3005684-1-neelx@suse.com>

From: Josef Bacik <josef@toxicpanda.com>

We don't need to search back to the inode item, the directory inode
number is in key.offset, so simply use that.  If we can't find the
directory we'll get an ENOENT at the iget.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Daniel Vacek <neelx.g@gmail.com>
---
 fs/btrfs/ioctl.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index c2d992f5ce7d..69df5765acfa 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1822,7 +1822,7 @@ static int btrfs_search_path_in_tree_user(struct mnt_idmap *idmap,
 	struct btrfs_root_ref *rref;
 	struct btrfs_root *root = NULL;
 	struct btrfs_path *path;
-	struct btrfs_key key, key2;
+	struct btrfs_key key;
 	struct extent_buffer *leaf;
 	char *ptr;
 	int slot;
@@ -1877,24 +1877,6 @@ static int btrfs_search_path_in_tree_user(struct mnt_idmap *idmap,
 			read_extent_buffer(leaf, ptr,
 					(unsigned long)(iref + 1), len);
 
-			/* Check the read+exec permission of this directory */
-			ret = btrfs_previous_item(root, path, dirid,
-						  BTRFS_INODE_ITEM_KEY);
-			if (ret < 0) {
-				goto out_put;
-			} else if (ret > 0) {
-				ret = -ENOENT;
-				goto out_put;
-			}
-
-			leaf = path->nodes[0];
-			slot = path->slots[0];
-			btrfs_item_key_to_cpu(leaf, &key2, slot);
-			if (key2.objectid != dirid) {
-				ret = -ENOENT;
-				goto out_put;
-			}
-
 			/*
 			 * We don't need the path anymore, so release it and
 			 * avoid deadlocks and lockdep warnings in case
@@ -1902,11 +1884,12 @@ static int btrfs_search_path_in_tree_user(struct mnt_idmap *idmap,
 			 * btree and lock the same leaf.
 			 */
 			btrfs_release_path(path);
-			temp_inode = btrfs_iget(key2.objectid, root);
+			temp_inode = btrfs_iget(key.offset, root);
 			if (IS_ERR(temp_inode)) {
 				ret = PTR_ERR(temp_inode);
 				goto out_put;
 			}
+			/* Check the read+exec permission of this directory */
 			ret = inode_permission(idmap, &temp_inode->vfs_inode,
 					       MAY_READ | MAY_EXEC);
 			iput(&temp_inode->vfs_inode);
-- 
2.51.0


  parent reply	other threads:[~2025-11-18 16:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18 16:00 [PATCH v7 0/7] btrfs: add fscrypt support, PART 1 Daniel Vacek
2025-11-18 16:00 ` [PATCH v7 1/6] btrfs: disable various operations on encrypted inodes Daniel Vacek
2025-11-18 16:00 ` [PATCH v7 2/6] btrfs: disable verity " Daniel Vacek
2025-11-18 16:00 ` [PATCH v7 3/6] btrfs: add orig_logical to btrfs_bio Daniel Vacek
2025-11-18 16:00 ` [PATCH v7 4/6] btrfs: don't rewrite ret from inode_permission Daniel Vacek
2025-11-18 16:00 ` [PATCH v7 5/6] btrfs: move inode_to_path higher in backref.c Daniel Vacek
2025-11-18 16:00 ` Daniel Vacek [this message]
2025-11-18 16:10 ` [PATCH v7 0/7] btrfs: add fscrypt support, PART 1 Daniel Vacek
  -- strict thread matches above, loose matches on Subject: below --
2025-11-18 16:08 [PATCH v8 0/6] " Daniel Vacek
2025-11-18 16:08 ` [PATCH v7 6/6] btrfs: don't search back for dir inode item in INO_LOOKUP_USER Daniel Vacek
2025-11-19 10:16   ` Johannes Thumshirn

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=20251118160043.3005684-7-neelx@suse.com \
    --to=neelx@suse.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neelx.g@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox