From nobody Sun Oct 5 00:16:34 2025 Received: from neil.brown.name (neil.brown.name [103.29.64.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03A452D7396; Tue, 12 Aug 2025 23:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.29.64.221 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755042784; cv=none; b=RcuSZ3Wun1Gk5qajZLxMI4BouWWLJ0aROkai0F+QHoe3bLBwszIzETWiLFDt2LTsQH37ufwIJxtSk/jct1TP9jjyqW6rECl8zztD/HhEmHc7Rc7tHjwEXP2w3/u530ontQAfyD/Nzz7RhtFDhsAPsvCOqpRqszj94ua+yh+DIPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755042784; c=relaxed/simple; bh=ZRhRQQI6uo3FxzRK6qWDy6tEgqtjrrXxGIqMJAzbusg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JmKu/L0025t/mUsW4VuP9o6sT8Z7XcAhraAyMWW6vCG8gqIw10rwENfEt8vmzFKQfAELbgW8b+Yqr1uPhizGMfmavruDDFuSP6fiJg9cyjjZEL0Xey0iNRSya0Grdet4ypDK7lqr2xPWK0rK/wWM6sykKmL3/8gl9B0O0JfLzSQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brown.name; spf=pass smtp.mailfrom=neil.brown.name; arc=none smtp.client-ip=103.29.64.221 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=neil.brown.name Received: from 196.186.233.220.static.exetel.com.au ([220.233.186.196] helo=home.neil.brown.name) by neil.brown.name with esmtp (Exim 4.95) (envelope-from ) id 1ulynN-005Y25-0b; Tue, 12 Aug 2025 23:52:46 +0000 From: NeilBrown To: Alexander Viro , Christian Brauner , Jan Kara Cc: David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Tyler Hicks , Miklos Szeredi , Richard Weinberger , Anton Ivanov , Johannes Berg , Trond Myklebust , Anna Schumaker , Chuck Lever , Jeff Layton , Amir Goldstein , Steve French , Namjae Jeon , Carlos Maiolino , linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org, netfs@lists.linux.dev, ceph-devel@vger.kernel.org, ecryptfs@vger.kernel.org, linux-um@lists.infradead.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/11] VFS: unify old_mnt_idmap and new_mnt_idmap in renamedata Date: Tue, 12 Aug 2025 12:25:09 +1000 Message-ID: <20250812235228.3072318-7-neil@brown.name> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20250812235228.3072318-1-neil@brown.name> References: <20250812235228.3072318-1-neil@brown.name> 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 Content-Type: text/plain; charset="utf-8" A rename can only rename with a single mount. Callers of vfs_rename() must and do ensure this is the case. So there is no point in having two mnt_idmaps in renamedata as they are always the same. Only of of them is passed to ->rename in any case. This patch replaces both with a single "mnt_idmap" and changes all callers. Reviewed-by: Jeff Layton Signed-off-by: NeilBrown --- fs/cachefiles/namei.c | 3 +-- fs/ecryptfs/inode.c | 3 +-- fs/namei.c | 21 ++++++++++----------- fs/nfsd/vfs.c | 3 +-- fs/overlayfs/overlayfs.h | 3 +-- fs/smb/server/vfs.c | 3 +-- include/linux/fs.h | 6 ++---- 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 91dfd0231877..d1edb2ac3837 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -387,10 +387,9 @@ int cachefiles_bury_object(struct cachefiles_cache *ca= che, cachefiles_io_error(cache, "Rename security error %d", ret); } else { struct renamedata rd =3D { - .old_mnt_idmap =3D &nop_mnt_idmap, + .mnt_idmap =3D &nop_mnt_idmap, .old_parent =3D dir, .old_dentry =3D rep, - .new_mnt_idmap =3D &nop_mnt_idmap, .new_parent =3D cache->graveyard, .new_dentry =3D grave, }; diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 72fbe1316ab8..abd954c6a14e 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -634,10 +634,9 @@ ecryptfs_rename(struct mnt_idmap *idmap, struct inode = *old_dir, goto out_lock; } =20 - rd.old_mnt_idmap =3D &nop_mnt_idmap; + rd.mnt_idmap =3D &nop_mnt_idmap; rd.old_parent =3D lower_old_dir_dentry; rd.old_dentry =3D lower_old_dentry; - rd.new_mnt_idmap =3D &nop_mnt_idmap; rd.new_parent =3D lower_new_dir_dentry; rd.new_dentry =3D lower_new_dentry; rc =3D vfs_rename(&rd); diff --git a/fs/namei.c b/fs/namei.c index cead810d53c6..3f930811e952 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3702,13 +3702,13 @@ int rename_lookup(struct renamedata *rd, int lookup= _flags) int err; =20 if (!rd->old_dentry) { - err =3D lookup_one_common(rd->old_mnt_idmap, &rd->old_last, + err =3D lookup_one_common(rd->mnt_idmap, &rd->old_last, rd->old_parent); if (err) return err; } if (!rd->new_dentry) { - err =3D lookup_one_common(rd->new_mnt_idmap, &rd->new_last, + err =3D lookup_one_common(rd->mnt_idmap, &rd->new_last, rd->new_parent); if (err) return err; @@ -5418,20 +5418,20 @@ int vfs_rename(struct renamedata *rd) if (source =3D=3D target) return 0; =20 - error =3D may_delete(rd->old_mnt_idmap, old_dir, old_dentry, is_dir); + error =3D may_delete(rd->mnt_idmap, old_dir, old_dentry, is_dir); if (error) return error; =20 if (!target) { - error =3D may_create(rd->new_mnt_idmap, new_dir, new_dentry); + error =3D may_create(rd->mnt_idmap, new_dir, new_dentry); } else { new_is_dir =3D d_is_dir(new_dentry); =20 if (!(flags & RENAME_EXCHANGE)) - error =3D may_delete(rd->new_mnt_idmap, new_dir, + error =3D may_delete(rd->mnt_idmap, new_dir, new_dentry, is_dir); else - error =3D may_delete(rd->new_mnt_idmap, new_dir, + error =3D may_delete(rd->mnt_idmap, new_dir, new_dentry, new_is_dir); } if (error) @@ -5446,13 +5446,13 @@ int vfs_rename(struct renamedata *rd) */ if (new_dir !=3D old_dir) { if (is_dir) { - error =3D inode_permission(rd->old_mnt_idmap, source, + error =3D inode_permission(rd->mnt_idmap, source, MAY_WRITE); if (error) return error; } if ((flags & RENAME_EXCHANGE) && new_is_dir) { - error =3D inode_permission(rd->new_mnt_idmap, target, + error =3D inode_permission(rd->mnt_idmap, target, MAY_WRITE); if (error) return error; @@ -5520,7 +5520,7 @@ int vfs_rename(struct renamedata *rd) if (error) goto out; } - error =3D old_dir->i_op->rename(rd->new_mnt_idmap, old_dir, old_dentry, + error =3D old_dir->i_op->rename(rd->mnt_idmap, old_dir, old_dentry, new_dir, new_dentry, flags); if (error) goto out; @@ -5607,10 +5607,9 @@ int do_renameat2(int olddfd, struct filename *from, = int newdfd, =20 retry_deleg: rd.old_parent =3D old_path.dentry; - rd.old_mnt_idmap =3D mnt_idmap(old_path.mnt); + rd.mnt_idmap =3D mnt_idmap(old_path.mnt); rd.old_dentry =3D NULL; rd.new_parent =3D new_path.dentry; - rd.new_mnt_idmap =3D mnt_idmap(new_path.mnt); rd.new_dentry =3D NULL; rd.delegated_inode =3D &delegated_inode; rd.flags =3D flags; diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 98ab55ba3ced..5f3e99f956ca 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1943,10 +1943,9 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *f= fhp, char *fname, int flen, goto out_dput_old; } else { struct renamedata rd =3D { - .old_mnt_idmap =3D &nop_mnt_idmap, + .mnt_idmap =3D &nop_mnt_idmap, .old_parent =3D fdentry, .old_dentry =3D odentry, - .new_mnt_idmap =3D &nop_mnt_idmap, .new_parent =3D tdentry, .new_dentry =3D ndentry, }; diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index bb0d7ded8e76..4f84abaa0d68 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -361,10 +361,9 @@ static inline int ovl_do_rename(struct ovl_fs *ofs, st= ruct dentry *olddir, { int err; struct renamedata rd =3D { - .old_mnt_idmap =3D ovl_upper_mnt_idmap(ofs), + .mnt_idmap =3D ovl_upper_mnt_idmap(ofs), .old_parent =3D olddir, .old_dentry =3D olddentry, - .new_mnt_idmap =3D ovl_upper_mnt_idmap(ofs), .new_parent =3D newdir, .new_dentry =3D newdentry, .flags =3D flags, diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c index 04539037108c..07739055ac9f 100644 --- a/fs/smb/server/vfs.c +++ b/fs/smb/server/vfs.c @@ -770,10 +770,9 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, const st= ruct path *old_path, goto out4; } =20 - rd.old_mnt_idmap =3D mnt_idmap(old_path->mnt), + rd.mnt_idmap =3D mnt_idmap(old_path->mnt), rd.old_parent =3D old_parent, rd.old_dentry =3D old_child, - rd.new_mnt_idmap =3D mnt_idmap(new_path.mnt), rd.new_parent =3D new_path.dentry, rd.new_dentry =3D new_dentry, rd.flags =3D flags, diff --git a/include/linux/fs.h b/include/linux/fs.h index b12203afa0da..172c3d703c43 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2008,11 +2008,10 @@ int vfs_unlink(struct mnt_idmap *, struct inode *, = struct dentry *, =20 /** * struct renamedata - contains all information required for renaming - * @old_mnt_idmap: idmap of the old mount the inode was found from + * @mnt_idmap: idmap of the mount in which the rename is happening. * @old_parent: parent of source * @old_dentry: source * @old_last: name for old_dentry in old_dir, if old_dentry not g= iven - * @new_mnt_idmap: idmap of the new mount the inode was found from * @new_parent: parent of destination * @new_dentry: destination * @new_last: name for new_dentry in new_dir, if new_dentry not g= iven @@ -2020,11 +2019,10 @@ int vfs_unlink(struct mnt_idmap *, struct inode *, = struct dentry *, * @flags: rename flags */ struct renamedata { - struct mnt_idmap *old_mnt_idmap; + struct mnt_idmap *mnt_idmap; struct dentry *old_parent; struct dentry *old_dentry; struct qstr old_last; - struct mnt_idmap *new_mnt_idmap; struct dentry *new_parent; struct dentry *new_dentry; struct qstr new_last; --=20 2.50.0.107.gf914562f5916.dirty