mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
Refactor inode->i_mode management
Refactor the code in such a way so that inode->i_mode is being set at the same time zp->z_mode is being changed. This has the effect of keeping both in sync without relying on zfs_inode_update. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Closes #5158
This commit is contained in:
parent
df7c4059cb
commit
12fa7f3436
@ -1166,7 +1166,8 @@ zfs_acl_chown_setattr(znode_t *zp)
|
||||
|
||||
error = zfs_acl_node_read(zp, B_TRUE, &aclp, B_FALSE);
|
||||
if (error == 0 && aclp->z_acl_count > 0)
|
||||
zp->z_mode = zfs_mode_compute(zp->z_mode, aclp,
|
||||
zp->z_mode = ZTOI(zp)->i_mode =
|
||||
zfs_mode_compute(zp->z_mode, aclp,
|
||||
&zp->z_pflags, KUID_TO_SUID(ZTOI(zp)->i_uid),
|
||||
KGID_TO_SGID(ZTOI(zp)->i_gid));
|
||||
|
||||
@ -1328,7 +1329,7 @@ zfs_aclset_common(znode_t *zp, zfs_acl_t *aclp, cred_t *cr, dmu_tx_t *tx)
|
||||
mode = zfs_mode_compute(mode, aclp, &zp->z_pflags,
|
||||
KUID_TO_SUID(ZTOI(zp)->i_uid), KGID_TO_SGID(ZTOI(zp)->i_gid));
|
||||
|
||||
zp->z_mode = mode;
|
||||
zp->z_mode = ZTOI(zp)->i_mode = mode;
|
||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MODE(zsb), NULL,
|
||||
&mode, sizeof (mode));
|
||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zsb), NULL,
|
||||
|
@ -871,7 +871,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
|
||||
((zp->z_mode & S_ISUID) != 0 && uid == 0)) != 0) {
|
||||
uint64_t newmode;
|
||||
zp->z_mode &= ~(S_ISUID | S_ISGID);
|
||||
newmode = zp->z_mode;
|
||||
ip->i_mode = newmode = zp->z_mode;
|
||||
(void) sa_update(zp->z_sa_hdl, SA_ZPL_MODE(zsb),
|
||||
(void *)&newmode, sizeof (uint64_t), tx);
|
||||
}
|
||||
@ -2993,7 +2993,7 @@ top:
|
||||
if (mask & ATTR_MODE) {
|
||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MODE(zsb), NULL,
|
||||
&new_mode, sizeof (new_mode));
|
||||
zp->z_mode = new_mode;
|
||||
zp->z_mode = ZTOI(zp)->i_mode = new_mode;
|
||||
ASSERT3P(aclp, !=, NULL);
|
||||
err = zfs_aclset_common(zp, aclp, cr, tx);
|
||||
ASSERT0(err);
|
||||
|
@ -523,7 +523,6 @@ zfs_inode_update(znode_t *zp)
|
||||
dmu_object_size_from_db(sa_get_db(zp->z_sa_hdl), &blksize, &i_blocks);
|
||||
|
||||
spin_lock(&ip->i_lock);
|
||||
ip->i_mode = zp->z_mode;
|
||||
zfs_set_inode_flags(zp, ip);
|
||||
ip->i_blocks = i_blocks;
|
||||
i_size_write(ip, zp->z_size);
|
||||
@ -604,7 +603,7 @@ zfs_znode_alloc(zfs_sb_t *zsb, dmu_buf_t *db, int blksz,
|
||||
goto error;
|
||||
}
|
||||
|
||||
zp->z_mode = mode;
|
||||
zp->z_mode = ip->i_mode = mode;
|
||||
ip->i_generation = (uint32_t)tmp_gen;
|
||||
ip->i_blkbits = SPA_MINBLOCKSHIFT;
|
||||
set_nlink(ip, (uint32_t)links);
|
||||
@ -917,7 +916,7 @@ zfs_mknode(znode_t *dzp, vattr_t *vap, dmu_tx_t *tx, cred_t *cr,
|
||||
}
|
||||
|
||||
(*zpp)->z_pflags = pflags;
|
||||
(*zpp)->z_mode = mode;
|
||||
(*zpp)->z_mode = ZTOI(*zpp)->i_mode = mode;
|
||||
(*zpp)->z_dnodesize = dnodesize;
|
||||
|
||||
if (obj_type == DMU_OT_ZNODE ||
|
||||
@ -1214,7 +1213,7 @@ zfs_rezget(znode_t *zp)
|
||||
return (SET_ERROR(EIO));
|
||||
}
|
||||
|
||||
zp->z_mode = mode;
|
||||
zp->z_mode = ZTOI(zp)->i_mode = mode;
|
||||
zfs_uid_write(ZTOI(zp), z_uid);
|
||||
zfs_gid_write(ZTOI(zp), z_gid);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user