From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379604; b=z+6N8JB43Qsxd+BanDWgl8ePDZOfVph4BlsJ+N0CYKLhTBJKzAq3YRJoD9jV1pn47Yhv pH7wJY5m5GofiVRnhXLGrmjxVwiL0KCMqZl92aoiBdP0Vi5r/W35MCCmZXcpdz+q0Flu4 hPjUILRhomdxb7cpvzFUx1clGJUCYHj3BdvY6P4J3wM8DRW5aZlHekLO1Z0oWpOgJOIu+ TmKtg9fA74ijTIuPwoqAqukaw1l8fwCiK8QDJxtaeldrmsWp9wYpLw5jeUX5yK5+Amsz8 o+4EHn1NPDb4IiaH0opuIJySQ7Nf+3TpqHnTm5fneKPVYey1nZqZXeBE45kkfhjM1bQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379604; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=u4gDfBtbtaxyWxXjQxwSjBOTuJhBedj0flS7CTOLJ8M=; b=v0BMa9nsD1XuMxlaHn1X5HUg3lJZXbziR3EjZQolL+HxgvLnPpKxzvaSHI7bYqfYhQMs 2IQSGgUbA8AEQ4v1TBvwvvmx/KrIDeXFUkM9tObe39l7oyyFN5KPpHIxA/XtIFZ6Eq5ul YIlx/8xnco4LPICx8sKprte4l18T/Hoss9lf6kB1KgvsGRiGBAj1+NYciW5ekjqXIxspn 7OSUCTPiqo/1MmRpEfgWAgwEsb0uSzgUFoBJUPPqdISc5YIXmBt3V/5EywIsdVRFdGekJ CsIA3Pku429JE3ohJyQCv2LsCg8bXKOLutxZYqV7Wiy+ON1TEsW+afY53+t3gPhQHrw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JIEiCKfr; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0345606A322; Fri, 4 Dec 2026 10:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JIEiCKfr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07E601F000C2; Fri, 4 Dec 2026 10:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379604; bh=u4gDfBtbtaxyWxXjQxwSjBOTuJhBedj0flS7CTOLJ8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JIEiCKfrzO/POFzF+U8dq3BtL8QdAZF0CiV5L9q6PDcyh3k/FQ7iL9Hi2wD6+lQ4o ZRqO/1aEb64Ai4vqfrLJ6jK9kP8fwlvYhW4W3NT18xHmqBIhjetkJkM+KMbSwTqn91 XVUt1AMJUjglfV1Vxuoo895vO0QTeMZoPYXh3w8U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Van Hensbergen , Sasha Levin Subject: [PATCH 6.1 0025/1059] fs/9p: rework qid2ino logic Date: Fri, 4 Dec 2026 18:52:36 +0900 Message-ID: <20261204100644.685492895@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Van Hensbergen [ Upstream commit b91a26696ef38eae1442aa03104e60bb49d2ac99 ] This changes from a function to a macro because we can figure out if we are 32 or 64 bit at compile time. Signed-off-by: Eric Van Hensbergen Stable-dep-of: 8bb0279930cc ("9p: skip intermediate directory entry name copy in p9dirent_read()") Signed-off-by: Sasha Levin --- fs/9p/v9fs_vfs.h | 7 ++++++- fs/9p/vfs_dir.c | 4 ++-- fs/9p/vfs_inode.c | 26 ++------------------------ fs/9p/vfs_inode_dotl.c | 6 ++---- 4 files changed, 12 insertions(+), 31 deletions(-) diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index 633fe4f527b84..76b15e5261695 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h @@ -50,7 +50,12 @@ void v9fs_set_netfs_context(struct inode *inode); int v9fs_init_inode(struct v9fs_session_info *v9ses, struct inode *inode, umode_t mode, dev_t rdev); void v9fs_evict_inode(struct inode *inode); -ino_t v9fs_qid2ino(struct p9_qid *qid); +#if (BITS_PER_LONG == 32) +#define QID2INO(q) ((ino_t) (((q)->path+2) ^ (((q)->path) >> 32))) +#else +#define QID2INO(q) ((ino_t) ((q)->path+2)) +#endif + void v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, struct super_block *sb, unsigned int flags); void v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode, diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index 3be09b94a8e24..7ccfbef41bc82 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c @@ -135,7 +135,7 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx) } over = !dir_emit(ctx, st.name, strlen(st.name), - v9fs_qid2ino(&st.qid), dt_type(&st)); + QID2INO(&st.qid), dt_type(&st)); p9stat_free(&st); if (over) return 0; @@ -197,7 +197,7 @@ static int v9fs_dir_readdir_dotl(struct file *file, struct dir_context *ctx) if (!dir_emit(ctx, curdirent.d_name, strlen(curdirent.d_name), - v9fs_qid2ino(&curdirent.qid), + QID2INO(&curdirent.qid), curdirent.d_type)) return 0; diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index ba670d86894a9..ddf11ead64a59 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -456,7 +456,6 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, dev_t rdev; int retval; umode_t umode; - unsigned long i_ino; struct inode *inode; struct v9fs_session_info *v9ses = sb->s_fs_info; int (*test)(struct inode *inode, void *data); @@ -466,8 +465,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, else test = v9fs_test_inode; - i_ino = v9fs_qid2ino(qid); - inode = iget5_locked(sb, i_ino, test, v9fs_set_inode, st); + inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode, st); if (!inode) return ERR_PTR(-ENOMEM); if (!(inode->i_state & I_NEW)) @@ -477,7 +475,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, * FIXME!! we may need support for stale inodes * later. */ - inode->i_ino = i_ino; + inode->i_ino = QID2INO(qid); umode = p9mode2unixmode(v9ses, st, &rdev); retval = v9fs_init_inode(v9ses, inode, umode, rdev); if (retval) @@ -1221,26 +1219,6 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, v9inode->cache_validity &= ~V9FS_INO_INVALID_ATTR; } -/** - * v9fs_qid2ino - convert qid into inode number - * @qid: qid to hash - * - * BUG: potential for inode number collisions? - */ - -ino_t v9fs_qid2ino(struct p9_qid *qid) -{ - u64 path = qid->path + 2; - ino_t i = 0; - - if (sizeof(ino_t) == sizeof(path)) - memcpy(&i, &path, sizeof(ino_t)); - else - i = (ino_t) (path ^ (path >> 32)); - - return i; -} - /** * v9fs_vfs_get_link - follow a symlink path * @dentry: dentry for symlink diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 7c261b354379a..795a3aee5901d 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -102,7 +102,6 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, int new) { int retval; - unsigned long i_ino; struct inode *inode; struct v9fs_session_info *v9ses = sb->s_fs_info; int (*test)(struct inode *inode, void *data); @@ -112,8 +111,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, else test = v9fs_test_inode_dotl; - i_ino = v9fs_qid2ino(qid); - inode = iget5_locked(sb, i_ino, test, v9fs_set_inode_dotl, st); + inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode_dotl, st); if (!inode) return ERR_PTR(-ENOMEM); if (!(inode->i_state & I_NEW)) @@ -123,7 +121,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, * FIXME!! we may need support for stale inodes * later. */ - inode->i_ino = i_ino; + inode->i_ino = QID2INO(qid); retval = v9fs_init_inode(v9ses, inode, st->st_mode, new_decode_dev(st->st_rdev)); if (retval) -- 2.53.0