From: Askar Safin Date: Mon, 25 Aug 2025 18:12:30 +0000 (+0000) Subject: namei: move cross-device check to traverse_mounts X-Git-Tag: v6.18-rc1~242^2~15^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=11c2b7ec2e1865bbc6a65e7d7312a5043e3cc1aa;p=thirdparty%2Flinux.git namei: move cross-device check to traverse_mounts This is preparation to RESOLVE_NO_XDEV fix in following commits. No functional change intended Signed-off-by: Askar Safin Link: https://lore.kernel.org/20250825181233.2464822-2-safinaskar@zohomail.com Signed-off-by: Christian Brauner --- diff --git a/fs/namei.c b/fs/namei.c index 138a693c23461..f81fdc7bbfeda 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1518,6 +1518,7 @@ static inline int traverse_mounts(struct path *path, bool *jumped, int *count, unsigned lookup_flags) { unsigned flags = smp_load_acquire(&path->dentry->d_flags); + int ret; /* fastpath */ if (likely(!(flags & DCACHE_MANAGED_DENTRY))) { @@ -1526,7 +1527,11 @@ static inline int traverse_mounts(struct path *path, bool *jumped, return -ENOENT; return 0; } - return __traverse_mounts(path, flags, jumped, count, lookup_flags); + + ret = __traverse_mounts(path, flags, jumped, count, lookup_flags); + if (*jumped && unlikely(lookup_flags & LOOKUP_NO_XDEV)) + return -EXDEV; + return ret; } int follow_down_one(struct path *path) @@ -1631,9 +1636,7 @@ static inline int handle_mounts(struct nameidata *nd, struct dentry *dentry, } ret = traverse_mounts(path, &jumped, &nd->total_link_count, nd->flags); if (jumped) { - if (unlikely(nd->flags & LOOKUP_NO_XDEV)) - ret = -EXDEV; - else + if (!unlikely(nd->flags & LOOKUP_NO_XDEV)) nd->state |= ND_JUMPED; } if (unlikely(ret)) {