From nobody Mon Feb 9 11:28:37 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1DA834E74B for ; Wed, 12 Nov 2025 19:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762976227; cv=none; b=BqNay5L2tg59hUL0m6lW6i0T9dfrNXNYuPx9EAD0S8UNZkFiSmGTy48MEfMeYYx4tqJjeyugWAlwonYz/73WJdX2WxfVcWsD+MgpY8PdZvQAO8jSaYOsTtiOvm6vmDqbriR+U2y0fHTWL/0BpEEY0DLi3Wh19SymJlpNw7LqDYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762976227; c=relaxed/simple; bh=vQZZmF+r/N5FK4W+zNe8l6ZtC1vXlbuUXtui9c9aRZY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R5UUEkJtkm56fMEg55duwkn6gObS6VM+I+jtjbzSuYDvJipd7kBB9FQGXBaDwqMWl78Z/RVJsemM29/AUCi/XH0yeX3HGImCSApiXTCCaYQ5G5HViplwn4T90fXAWGFLgZTKM4BMhpJT/RIyy3ODjLUjd0v9KxPxbIAdnHkfnMQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E369E1F7CF; Wed, 12 Nov 2025 19:36:43 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CD5603EA61; Wed, 12 Nov 2025 19:36:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ED13McvhFGm+YgAAD6G6ig (envelope-from ); Wed, 12 Nov 2025 19:36:43 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 7/8] btrfs: don't search back for dir inode item in INO_LOOKUP_USER Date: Wed, 12 Nov 2025 20:36:07 +0100 Message-ID: <20251112193611.2536093-8-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251112193611.2536093-1-neelx@suse.com> References: <20251112193611.2536093-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: E369E1F7CF X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 Content-Type: text/plain; charset="utf-8" From: Josef Bacik 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 --- Since v5 resolved rebase merge conflicts due to changes in API, dropping the sb parameter in btrfs_iget(). --- 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 2973230f2988..d323fc351c00 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 =3D 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); =20 - /* Check the read+exec permission of this directory */ - ret =3D btrfs_previous_item(root, path, dirid, - BTRFS_INODE_ITEM_KEY); - if (ret < 0) { - goto out_put; - } else if (ret > 0) { - ret =3D -ENOENT; - goto out_put; - } - - leaf =3D path->nodes[0]; - slot =3D path->slots[0]; - btrfs_item_key_to_cpu(leaf, &key2, slot); - if (key2.objectid !=3D dirid) { - ret =3D -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 mn= t_idmap *idmap, * btree and lock the same leaf. */ btrfs_release_path(path); - temp_inode =3D btrfs_iget(key2.objectid, root); + temp_inode =3D btrfs_iget(key.offset, root); if (IS_ERR(temp_inode)) { ret =3D PTR_ERR(temp_inode); goto out_put; } + /* Check the read+exec permission of this directory */ ret =3D inode_permission(idmap, &temp_inode->vfs_inode, MAY_READ | MAY_EXEC); iput(&temp_inode->vfs_inode); --=20 2.51.0