From nobody Tue Dec 2 02:42:59 2025 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 DFC1736C580 for ; Tue, 18 Nov 2025 16:01:16 +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=1763481679; cv=none; b=dBHhsnpLUbAJsxnGaGokrKZDcA0zaj5Tzvyqt97ZhY/DnUIyUGgcyfsoJC0PZuwcwHscwst25TuGkvsqbzLfyL+P8lFMtHT5GieXeEjRvlJ8nzD6KXEYZiEdB6otOo5/8yXnQ2pOx5KwsmJHd9F9hraPoym9Z4Yu6k9jGpxXaOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763481679; c=relaxed/simple; bh=m7gqv6AHpo4wuSXhITwKxgAvq9/DMQj8c+yaNdePRx4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BfqeuA8T+e2YH7kIH0sY4vuJuBB5jzALb7xmwgcmRiYA0zWJNKL3EEehWUU4vWQ/oxLveAAoS+Iz5l/KC6S+f1/7uiXqCJS9DUdlpgYMmhLq5qos7k4YPI1e3LuqG6C+CMZAfOBE0v9JjTe4E6hYpVQnhCmcqgRv84RCAZhNdLM= 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; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=Ek4HUui2; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=Ek4HUui2; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Ek4HUui2"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Ek4HUui2" Received: from imap1.dmz-prg2.suse.org (unknown [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 E0F531FF87; Tue, 18 Nov 2025 16:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763481662; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h54qY6ZHmmICZIP2s70xxusIiZ9p13yrj+/XRx3+Rjs=; b=Ek4HUui2YbkNiW7teVytKOAEqTCC3FAHjLgJEXXW3IDog6vr/DpbHUDY7g8AaQ49wMvi9Q m3fy3M9CKMR0+ByYyi+RVsJC5OhhL21h4EwiKWuPGjgp3u7lBQ3d3+ao3qMXUk0NNrtJ52 O9cYrIzDYD2nu4skCmGzsgAx42JqcKg= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763481662; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h54qY6ZHmmICZIP2s70xxusIiZ9p13yrj+/XRx3+Rjs=; b=Ek4HUui2YbkNiW7teVytKOAEqTCC3FAHjLgJEXXW3IDog6vr/DpbHUDY7g8AaQ49wMvi9Q m3fy3M9CKMR0+ByYyi+RVsJC5OhhL21h4EwiKWuPGjgp3u7lBQ3d3+ao3qMXUk0NNrtJ52 O9cYrIzDYD2nu4skCmGzsgAx42JqcKg= 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 C86493EA61; Tue, 18 Nov 2025 16:01:02 +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 ECxrMD6YHGkSWgAAD6G6ig (envelope-from ); Tue, 18 Nov 2025 16:01:02 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Vacek 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 Message-ID: <20251118160043.3005684-7-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118160043.3005684-1-neelx@suse.com> References: <20251118160043.3005684-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-Spam-Level: X-Spamd-Result: default: False [-5.30 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[suse.com,vger.kernel.org,gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TAGGED_RCPT(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_SEVEN(0.00)[7]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Flag: NO X-Spam-Score: -5.30 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 Signed-off-by: Daniel Vacek --- 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 =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