aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/zfs_vnops.c
diff options
context:
space:
mode:
authorNikolay Borisov <[email protected]>2016-05-22 14:15:57 +0300
committerBrian Behlendorf <[email protected]>2016-07-25 13:21:49 -0700
commit2c6abf15ff5bcc979653eef0131f90d4f0fede21 (patch)
tree29bc74006a16d50335196ccd1e7459b569e48b57 /module/zfs/zfs_vnops.c
parent82a1b2d6289f9ceae0bee6f1e71d3bc29a8c5d16 (diff)
Remove znode's z_uid/z_gid member
Remove duplicate z_uid/z_gid member which are also held in the generic vfs inode struct. This is done by first removing the members from struct znode and then using the KUID_TO_SUID/KGID_TO_SGID macros to access the respective member from struct inode. In cases where the uid/gids are being marshalled from/to disk, use the newly introduced zfs_(uid|gid)_(read|write) functions to properly save the uids rather than the internal kernel representation. Signed-off-by: Nikolay Borisov <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue #4685 Issue #227
Diffstat (limited to 'module/zfs/zfs_vnops.c')
-rw-r--r--module/zfs/zfs_vnops.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
index bc3dd2166..bde2140d0 100644
--- a/module/zfs/zfs_vnops.c
+++ b/module/zfs/zfs_vnops.c
@@ -602,6 +602,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
int count = 0;
sa_bulk_attr_t bulk[4];
uint64_t mtime[2], ctime[2];
+ uint32_t uid;
ASSERTV(int iovcnt = uio->uio_iovcnt);
/*
@@ -862,11 +863,12 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
* user 0 is not an ephemeral uid.
*/
mutex_enter(&zp->z_acl_lock);
+ uid = KUID_TO_SUID(ip->i_uid);
if ((zp->z_mode & (S_IXUSR | (S_IXUSR >> 3) |
(S_IXUSR >> 6))) != 0 &&
(zp->z_mode & (S_ISUID | S_ISGID)) != 0 &&
secpolicy_vnode_setid_retain(cr,
- (zp->z_mode & S_ISUID) != 0 && zp->z_uid == 0) != 0) {
+ ((zp->z_mode & S_ISUID) != 0 && uid == 0)) != 0) {
uint64_t newmode;
zp->z_mode &= ~(S_ISUID | S_ISGID);
newmode = zp->z_mode;
@@ -2844,7 +2846,7 @@ top:
if (mask & ATTR_UID) {
new_uid = zfs_fuid_create(zsb,
(uint64_t)vap->va_uid, cr, ZFS_OWNER, &fuidp);
- if (new_uid != zp->z_uid &&
+ if (new_uid != KUID_TO_SUID(ZTOI(zp)->i_uid) &&
zfs_fuid_overquota(zsb, B_FALSE, new_uid)) {
if (attrzp)
iput(ZTOI(attrzp));
@@ -2856,7 +2858,7 @@ top:
if (mask & ATTR_GID) {
new_gid = zfs_fuid_create(zsb, (uint64_t)vap->va_gid,
cr, ZFS_GROUP, &fuidp);
- if (new_gid != zp->z_gid &&
+ if (new_gid != KGID_TO_SGID(ZTOI(zp)->i_gid) &&
zfs_fuid_overquota(zsb, B_TRUE, new_gid)) {
if (attrzp)
iput(ZTOI(attrzp));
@@ -2950,24 +2952,24 @@ top:
if (mask & ATTR_UID) {
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_UID(zsb), NULL,
&new_uid, sizeof (new_uid));
- zp->z_uid = new_uid;
+ ZTOI(zp)->i_uid = SUID_TO_KUID(new_uid);
if (attrzp) {
SA_ADD_BULK_ATTR(xattr_bulk, xattr_count,
SA_ZPL_UID(zsb), NULL, &new_uid,
sizeof (new_uid));
- attrzp->z_uid = new_uid;
+ ZTOI(attrzp)->i_uid = SUID_TO_KUID(new_uid);
}
}
if (mask & ATTR_GID) {
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_GID(zsb),
NULL, &new_gid, sizeof (new_gid));
- zp->z_gid = new_gid;
+ ZTOI(zp)->i_gid = SGID_TO_KGID(new_gid);
if (attrzp) {
SA_ADD_BULK_ATTR(xattr_bulk, xattr_count,
SA_ZPL_GID(zsb), NULL, &new_gid,
sizeof (new_gid));
- attrzp->z_gid = new_gid;
+ ZTOI(attrzp)->i_gid = SGID_TO_KGID(new_gid);
}
}
if (!(mask & ATTR_MODE)) {
@@ -3847,7 +3849,7 @@ zfs_link(struct inode *tdip, struct inode *sip, char *name, cred_t *cr,
return (SET_ERROR(EINVAL));
}
- owner = zfs_fuid_map_id(zsb, szp->z_uid, cr, ZFS_OWNER);
+ owner = zfs_fuid_map_id(zsb, KUID_TO_SUID(sip->i_uid), cr, ZFS_OWNER);
if (owner != crgetuid(cr) && secpolicy_basic_link(cr) != 0) {
ZFS_EXIT(zsb);
return (SET_ERROR(EPERM));