aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2020-11-04 22:10:13 +0000
committerBrian Behlendorf <[email protected]>2020-12-23 14:34:59 -0800
commitb3d723fb0ede3a735a3b97c65898197973b0b8ff (patch)
tree5b78ef1cb4543f9f666b84d95b059ca36d9e24e0
parent3d40b655403235a0166efadc33def4dcdd46e2df (diff)
Factor uid, gid, and projid out of loop in zfs_write
Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matt Macy <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #11176
-rw-r--r--module/zfs/zfs_vnops.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
index 418aab098..e478f5634 100644
--- a/module/zfs/zfs_vnops.c
+++ b/module/zfs/zfs_vnops.c
@@ -337,6 +337,10 @@ zfs_write(znode_t *zp, uio_t *uio, int ioflag, cred_t *cr)
uint64_t end_size = MAX(zp->z_size, woff + n);
zilog_t *zilog = zfsvfs->z_log;
+ const uint64_t uid = KUID_TO_SUID(ZTOUID(zp));
+ const uint64_t gid = KGID_TO_SGID(ZTOGID(zp));
+ const uint64_t projid = zp->z_projid;
+
/*
* Write the file in reasonable size chunks. Each chunk is written
* in a separate transaction; this keeps the intent log records small
@@ -345,13 +349,11 @@ zfs_write(znode_t *zp, uio_t *uio, int ioflag, cred_t *cr)
while (n > 0) {
woff = uio->uio_loffset;
- if (zfs_id_overblockquota(zfsvfs, DMU_USERUSED_OBJECT,
- KUID_TO_SUID(ZTOUID(zp))) ||
- zfs_id_overblockquota(zfsvfs, DMU_GROUPUSED_OBJECT,
- KGID_TO_SGID(ZTOGID(zp))) ||
- (zp->z_projid != ZFS_DEFAULT_PROJID &&
+ if (zfs_id_overblockquota(zfsvfs, DMU_USERUSED_OBJECT, uid) ||
+ zfs_id_overblockquota(zfsvfs, DMU_GROUPUSED_OBJECT, gid) ||
+ (projid != ZFS_DEFAULT_PROJID &&
zfs_id_overblockquota(zfsvfs, DMU_PROJECTUSED_OBJECT,
- zp->z_projid))) {
+ projid))) {
error = SET_ERROR(EDQUOT);
break;
}
@@ -515,7 +517,6 @@ zfs_write(znode_t *zp, uio_t *uio, int ioflag, cred_t *cr)
* user 0 is not an ephemeral uid.
*/
mutex_enter(&zp->z_acl_lock);
- uint32_t uid = KUID_TO_SUID(ZTOUID(zp));
if ((zp->z_mode & (S_IXUSR | (S_IXUSR >> 3) |
(S_IXUSR >> 6))) != 0 &&
(zp->z_mode & (S_ISUID | S_ISGID)) != 0 &&