Skip to content

Commit b3d723f

Browse files
Ryan Moellerbehlendorf
authored andcommitted
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
1 parent 3d40b65 commit b3d723f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

module/zfs/zfs_vnops.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ zfs_write(znode_t *zp, uio_t *uio, int ioflag, cred_t *cr)
337337
uint64_t end_size = MAX(zp->z_size, woff + n);
338338
zilog_t *zilog = zfsvfs->z_log;
339339

340+
const uint64_t uid = KUID_TO_SUID(ZTOUID(zp));
341+
const uint64_t gid = KGID_TO_SGID(ZTOGID(zp));
342+
const uint64_t projid = zp->z_projid;
343+
340344
/*
341345
* Write the file in reasonable size chunks. Each chunk is written
342346
* 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)
345349
while (n > 0) {
346350
woff = uio->uio_loffset;
347351

348-
if (zfs_id_overblockquota(zfsvfs, DMU_USERUSED_OBJECT,
349-
KUID_TO_SUID(ZTOUID(zp))) ||
350-
zfs_id_overblockquota(zfsvfs, DMU_GROUPUSED_OBJECT,
351-
KGID_TO_SGID(ZTOGID(zp))) ||
352-
(zp->z_projid != ZFS_DEFAULT_PROJID &&
352+
if (zfs_id_overblockquota(zfsvfs, DMU_USERUSED_OBJECT, uid) ||
353+
zfs_id_overblockquota(zfsvfs, DMU_GROUPUSED_OBJECT, gid) ||
354+
(projid != ZFS_DEFAULT_PROJID &&
353355
zfs_id_overblockquota(zfsvfs, DMU_PROJECTUSED_OBJECT,
354-
zp->z_projid))) {
356+
projid))) {
355357
error = SET_ERROR(EDQUOT);
356358
break;
357359
}
@@ -515,7 +517,6 @@ zfs_write(znode_t *zp, uio_t *uio, int ioflag, cred_t *cr)
515517
* user 0 is not an ephemeral uid.
516518
*/
517519
mutex_enter(&zp->z_acl_lock);
518-
uint32_t uid = KUID_TO_SUID(ZTOUID(zp));
519520
if ((zp->z_mode & (S_IXUSR | (S_IXUSR >> 3) |
520521
(S_IXUSR >> 6))) != 0 &&
521522
(zp->z_mode & (S_ISUID | S_ISGID)) != 0 &&

0 commit comments

Comments
 (0)