struct hfsmount *hfsmp;
struct vnode *vp;
int error;
+ int drop_usrquota = false;
vp = cp->c_vp ? cp->c_vp : cp->c_rsrc_vp;
hfsmp = VTOHFS(vp);
* Set up the user quota based on file uid.
* EINVAL means that quotas are not enabled.
*/
- if (cp->c_dquot[USRQUOTA] == NODQUOT &&
- (error =
- dqget(cp->c_uid, &hfsmp->hfs_qfiles[USRQUOTA], USRQUOTA, &cp->c_dquot[USRQUOTA])) &&
- error != EINVAL)
- return (error);
+ if (cp->c_dquot[USRQUOTA] == NODQUOT) {
+ error = dqget(cp->c_uid, &hfsmp->hfs_qfiles[USRQUOTA], USRQUOTA, &cp->c_dquot[USRQUOTA]);
+ if ((error != 0) && (error != EINVAL)) {
+ return error;
+ } else if (error == 0) {
+ drop_usrquota = true;
+ }
+ }
+
/*
* Set up the group quota based on file gid.
* EINVAL means that quotas are not enabled.
*/
- if (cp->c_dquot[GRPQUOTA] == NODQUOT &&
- (error =
- dqget(cp->c_gid, &hfsmp->hfs_qfiles[GRPQUOTA], GRPQUOTA, &cp->c_dquot[GRPQUOTA])) &&
- error != EINVAL)
- return (error);
+ if (cp->c_dquot[GRPQUOTA] == NODQUOT) {
+ error = dqget(cp->c_gid, &hfsmp->hfs_qfiles[GRPQUOTA], GRPQUOTA, &cp->c_dquot[GRPQUOTA]);
+ if ((error != 0) && (error != EINVAL)) {
+ if (drop_usrquota == true) {
+ dqrele(cp->c_dquot[USRQUOTA]);
+ cp->c_dquot[USRQUOTA] = NODQUOT;
+ }
+ return error;
+ }
+ }
+
return (0);
}
goto out;
}
vfs_setflags(mp, (u_int64_t)((unsigned int)MNT_QUOTA));
- HFS_MOUNT_LOCK(hfsmp, TRUE)
+ hfs_lock_mount (hfsmp);
hfsmp->hfs_flags |= HFS_QUOTAS;
- HFS_MOUNT_UNLOCK(hfsmp, TRUE);
+ hfs_unlock_mount (hfsmp);
vnode_setnoflush(vp);
/*
* Save the credential of the process that turned on quotas.
break;
if (type == MAXQUOTAS) {
vfs_clearflags(mp, (u_int64_t)((unsigned int)MNT_QUOTA));
- HFS_MOUNT_LOCK(hfsmp, TRUE)
+ hfs_lock_mount (hfsmp);
hfsmp->hfs_flags &= ~HFS_QUOTAS;
- HFS_MOUNT_UNLOCK(hfsmp, TRUE);
+ hfs_unlock_mount (hfsmp);
}
qf_put(qfp, QTF_CLOSING);