Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_racct.c
Show First 20 Lines • Show All 617 Lines • ▼ Show 20 Lines | racct_add_cred_locked(struct ucred *cred, int resource, uint64_t amount) | ||||
for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) | for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) | ||||
racct_adjust_resource(pr->pr_prison_racct->prr_racct, resource, | racct_adjust_resource(pr->pr_prison_racct->prr_racct, resource, | ||||
amount); | amount); | ||||
racct_adjust_resource(cred->cr_loginclass->lc_racct, resource, amount); | racct_adjust_resource(cred->cr_loginclass->lc_racct, resource, amount); | ||||
} | } | ||||
/* | /* | ||||
* Increase allocation of 'resource' by 'amount' for credential 'cred'. | * Increase allocation of 'resource' by 'amount' for credential 'cred'. | ||||
* Doesn't check for limits and never fails. | * Return 0 if it's below limits, or errno, if it's not. | ||||
*/ | */ | ||||
void | int | ||||
racct_add_cred(struct ucred *cred, int resource, uint64_t amount) | racct_add_cred(struct ucred *cred, int resource, uint64_t amount) | ||||
{ | { | ||||
int error; | |||||
if (!racct_enable) | if (!racct_enable) | ||||
return; | return (0); | ||||
SDT_PROBE3(racct, , rusage, add__cred, cred, resource, amount); | SDT_PROBE3(racct, , rusage, add__cred, cred, resource, amount); | ||||
RACCT_LOCK(); | RACCT_LOCK(); | ||||
#ifdef RCTL | |||||
error = rctl_enforce_cred(cred, resource, amount); | |||||
if (error && RACCT_IS_DENIABLE(resource)) { | |||||
SDT_PROBE3(racct, , rusage, add__failure, cred, resource, amount); | |||||
return (error); | |||||
} | |||||
#endif | |||||
markj: There is some inconsistency in that racct_add_cred_locked() does not enforce limits, while… | |||||
racct_add_cred_locked(cred, resource, amount); | racct_add_cred_locked(cred, resource, amount); | ||||
RACCT_UNLOCK(); | RACCT_UNLOCK(); | ||||
return (0); | |||||
} | } | ||||
/* | /* | ||||
* Account for disk IO resource consumption. Checks for limits, | * Account for disk IO resource consumption. Checks for limits, | ||||
* but never fails, due to disk limits being undeniable. | * but never fails, due to disk limits being undeniable. | ||||
*/ | */ | ||||
void | void | ||||
racct_add_buf(struct proc *p, const struct buf *bp, int is_write) | racct_add_buf(struct proc *p, const struct buf *bp, int is_write) | ||||
▲ Show 20 Lines • Show All 719 Lines • Show Last 20 Lines |
There is some inconsistency in that racct_add_cred_locked() does not enforce limits, while racct_add_locked() does. I can see why you did it this way though.