Skip to content

Commit 812e91a

Browse files
mtelkabehlendorf
authored andcommitted
Illumos 4039 - zfs_rename()/zfs_link() needs stronger test for XDEV
4039 zfs_rename()/zfs_link() needs stronger test for XDEV Reviewed by: Gordon Ross <gordon.ross@nexenta.com> Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com> Reviewed by: Saso Kiselkov <skiselkov.ml@gmail.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@nexenta.com> References: https://www.illumos.org/issues/4039 illumos/illumos-gate@18e6497 Porting notes: - This check was updated in Linux in a similar fashion early on in the port. Therefore, this patch just reorders the function and updates the comment so it flows the same way as the upstream code. Ported-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #4218
1 parent 82f6f6e commit 812e91a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

module/zfs/zfs_vnops.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3207,13 +3207,18 @@ zfs_rename(struct inode *sdip, char *snm, struct inode *tdip, char *tnm,
32073207
ZFS_VERIFY_ZP(sdzp);
32083208
zilog = zsb->z_log;
32093209

3210+
tdzp = ITOZ(tdip);
3211+
ZFS_VERIFY_ZP(tdzp);
3212+
3213+
/*
3214+
* We check i_sb because snapshots and the ctldir must have different
3215+
* super blocks.
3216+
*/
32103217
if (tdip->i_sb != sdip->i_sb || zfsctl_is_node(tdip)) {
32113218
ZFS_EXIT(zsb);
32123219
return (SET_ERROR(EXDEV));
32133220
}
32143221

3215-
tdzp = ITOZ(tdip);
3216-
ZFS_VERIFY_ZP(tdzp);
32173222
if (zsb->z_utf8 && u8_validate(tnm,
32183223
strlen(tnm), NULL, U8_VALIDATE_ENTIRE, &error) < 0) {
32193224
ZFS_EXIT(zsb);
@@ -3751,14 +3756,18 @@ zfs_link(struct inode *tdip, struct inode *sip, char *name, cred_t *cr)
37513756
return (SET_ERROR(EPERM));
37523757
}
37533758

3759+
szp = ITOZ(sip);
3760+
ZFS_VERIFY_ZP(szp);
3761+
3762+
/*
3763+
* We check i_sb because snapshots and the ctldir must have different
3764+
* super blocks.
3765+
*/
37543766
if (sip->i_sb != tdip->i_sb || zfsctl_is_node(sip)) {
37553767
ZFS_EXIT(zsb);
37563768
return (SET_ERROR(EXDEV));
37573769
}
37583770

3759-
szp = ITOZ(sip);
3760-
ZFS_VERIFY_ZP(szp);
3761-
37623771
/* Prevent links to .zfs/shares files */
37633772

37643773
if ((error = sa_lookup(szp->z_sa_hdl, SA_ZPL_PARENT(zsb),

0 commit comments

Comments
 (0)