From nobody Tue Dec 2 02:49:40 2025 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 30ADF36B050 for ; Tue, 18 Nov 2025 16:09:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482150; cv=none; b=KPj5weenthDNSFqagWJD7HdkFt2m0bSbwn9AnvNIq+mm7T/Y1LAXL1bm/Da6m8DlHxOvy1rYVGyqqUM+ED9+/0YTObA+gA6gpaROJfF8Jyvp1Y4b0YY6C7dolgeB+1seWpO+5SmPAqitDXPjNqiYI8fzV3/LNTtfzht5PJRdsHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482150; c=relaxed/simple; bh=EqBXRxLaT5bXn9isFY1BGIkHkrg2gtWCsErmndXmkfQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gb9lcOb4DMrt2RZmGmJypfgJNq+GErM1SZVvh6HEkXo0VO4ZgBcGEVOPUWnAqVYqYw/fMfB6CX8KkuLI6p7X5vqEIZEgKlu63dP2s4G40E0xAspDglaNG5QasOa+oOKO/EXhOy46ZfoPRaP7Rfq5uBA1Is2ue0S2JEWxqYFwAX4= 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=XDR1rTrw; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=tbtVxzrG; arc=none smtp.client-ip=195.135.223.130 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="XDR1rTrw"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="tbtVxzrG" 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-out1.suse.de (Postfix) with ESMTPS id E64052126E; Tue, 18 Nov 2025 16:08:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763482135; 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=rGiyHM236mKp4HMdnwwzVRNs3LJ5NzSkeXvprHlui7E=; b=XDR1rTrw9UICaG8Gyc/NWxVpJ2akZ7338YXWmJgyiwb+yrNeDIdnBOLP0uMxvBIw+TK8+6 OBNrNIP9WOEV0ol6FQHcZk65EQ6OQtIRmPBPElsKp1uvKqOFP1Ro9P7G8GYppd5ukgj2cQ W+kIsnJ0aED8wwmt1bOJiaE0IOVZ3eM= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763482134; 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=rGiyHM236mKp4HMdnwwzVRNs3LJ5NzSkeXvprHlui7E=; b=tbtVxzrGcvbSvS+Jp/kA0lL1MmQUjWCxMxJahubj7//pS3zITOaA08MVEGes00iRlxuTLT Y8kjdkQj5IbrAS9n1RPt8fTWtA5W9jdFVykY1te8+Ytosi+cWmXSO2ginZh6BdxKjAac7D RgTnxrVK72Q7MBN0V0gtOwFmm6yqiLs= 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 D2BD83EA61; Tue, 18 Nov 2025 16:08:54 +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 qNjJMhaaHGlnYQAAD6G6ig (envelope-from ); Tue, 18 Nov 2025 16:08:54 +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 v7 6/6] btrfs: don't search back for dir inode item in INO_LOOKUP_USER Date: Tue, 18 Nov 2025 17:08:43 +0100 Message-ID: <20251118160845.3006733-7-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118160845.3006733-1-neelx@suse.com> References: <20251118160845.3006733-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 [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -6.80 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 Reviewed-by: Johannes Thumshirn --- 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