Date: Sat, 15 Aug 2009 13:58:04 GMT From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 167363 for review Message-ID: <200908151358.n7FDw4b0072935@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=167363 Change 167363 by trasz@trasz_anger on 2009/08/15 13:57:32 Rename hrl_{alloc,allocated_free}_proc() to hrl_{alloc,allocated,free}(), fix a few thinkos in the process. Affected files ... .. //depot/projects/soc2009/trasz_limits/sys/compat/linux/linux_misc.c#8 edit .. //depot/projects/soc2009/trasz_limits/sys/compat/svr4/imgact_svr4.c#4 edit .. //depot/projects/soc2009/trasz_limits/sys/compat/svr4/svr4_filio.c#4 edit .. //depot/projects/soc2009/trasz_limits/sys/fs/msdosfs/msdosfs_vnops.c#5 edit .. //depot/projects/soc2009/trasz_limits/sys/fs/nfsclient/nfs_clbio.c#10 edit .. //depot/projects/soc2009/trasz_limits/sys/fs/nwfs/nwfs_io.c#5 edit .. //depot/projects/soc2009/trasz_limits/sys/fs/smbfs/smbfs_io.c#6 edit .. //depot/projects/soc2009/trasz_limits/sys/fs/tmpfs/tmpfs_vnops.c#7 edit .. //depot/projects/soc2009/trasz_limits/sys/fs/unionfs/union_subr.c#5 edit .. //depot/projects/soc2009/trasz_limits/sys/gnu/fs/ext2fs/ext2_readwrite.c#4 edit .. //depot/projects/soc2009/trasz_limits/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c#5 edit .. //depot/projects/soc2009/trasz_limits/sys/i386/linux/imgact_linux.c#4 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/imgact_aout.c#4 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/imgact_elf.c#4 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/init_main.c#12 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_exit.c#11 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_fork.c#10 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#56 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/tty_pts.c#8 edit .. //depot/projects/soc2009/trasz_limits/sys/nfsclient/nfs_bio.c#11 edit .. //depot/projects/soc2009/trasz_limits/sys/sys/hrl.h#32 edit .. //depot/projects/soc2009/trasz_limits/sys/ufs/ffs/ffs_vnops.c#5 edit .. //depot/projects/soc2009/trasz_limits/sys/vm/vm_map.c#7 edit .. //depot/projects/soc2009/trasz_limits/sys/vm/vm_unix.c#4 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/sys/compat/linux/linux_misc.c#8 (text+ko) ==== @@ -363,7 +363,7 @@ error = ENOMEM; goto cleanup; } - error = hrl_allocated_proc(td->td_proc, HRL_RESOURCE_DATASIZE, + error = hrl_allocated(td->td_proc, HRL_RESOURCE_DATASIZE, a_out->a_data + bss_size); if (error) { error = ENOMEM; ==== //depot/projects/soc2009/trasz_limits/sys/compat/svr4/imgact_svr4.c#4 (text+ko) ==== @@ -109,7 +109,7 @@ */ if (a_out->a_text > maxtsiz) return (ENOMEM); - error = hrl_allocated_proc(imgp->proc, HRL_RESOURCE_DATASIZE, + error = hrl_allocated(imgp->proc, HRL_RESOURCE_DATASIZE, a_out->a_data + bss_size); if (error) return (ENOMEM); ==== //depot/projects/soc2009/trasz_limits/sys/compat/svr4/svr4_filio.c#4 (text+ko) ==== @@ -78,7 +78,7 @@ } PROC_UNLOCK(td->td_proc); - hrl_alloc(HRL_RESOURCE_FILEDESCRIPTORS, uap->nfds); + hrl_alloc(td->td_proc, HRL_RESOURCE_FILEDESCRIPTORS, uap->nfds); pa.fds = uap->fds; pa.nfds = uap->nfds; @@ -105,7 +105,7 @@ forget to update it if I add more code */ } done: - hrl_free(HRL_RESOURCE_FILEDESCRIPTORS, uap->nfds); + hrl_free(td->td_proc, HRL_RESOURCE_FILEDESCRIPTORS, uap->nfds); free(pfd, M_TEMP); return error; } ==== //depot/projects/soc2009/trasz_limits/sys/fs/msdosfs/msdosfs_vnops.c#5 (text+ko) ==== @@ -701,7 +701,7 @@ * If they've exceeded their filesize limit, tell them about it. */ if (td != NULL) { - error = hrl_allocated_proc(td->td_proc, HRL_RESOURCE_FILESIZE, + error = hrl_allocated(td->td_proc, HRL_RESOURCE_FILESIZE, (uoff_t)uio->uio_offset + uio->uio_resid); if (error) return (EFBIG); ==== //depot/projects/soc2009/trasz_limits/sys/fs/nfsclient/nfs_clbio.c#10 (text+ko) ==== @@ -1055,7 +1055,7 @@ * file servers have no limits, i don't think it matters */ if (p != NULL) { - error = hrl_allocated_proc(p, HRL_RESOURCE_FILESIZE, + error = hrl_allocated(p, HRL_RESOURCE_FILESIZE, (uoff_t)uio->uio_offset + uio->uio_resid); if (error) return (EFBIG); ==== //depot/projects/soc2009/trasz_limits/sys/fs/nwfs/nwfs_io.c#5 (text+ko) ==== @@ -237,7 +237,7 @@ } if (uiop->uio_resid == 0) return 0; if (td != NULL) { - error = hrl_allocated_proc(td->td_proc, HRL_RESOURCE_FILESIZE, + error = hrl_allocated(td->td_proc, HRL_RESOURCE_FILESIZE, (uoff_t)uiop->uio_offset + uiop->uio_resid); if (error) return (EFBIG); ==== //depot/projects/soc2009/trasz_limits/sys/fs/smbfs/smbfs_io.c#6 (text+ko) ==== @@ -279,7 +279,7 @@ if (uiop->uio_resid == 0) return 0; if (p != NULL) { - error = hrl_allocated_proc(p, HRL_RESOURCE_FILESIZE, + error = hrl_allocated(p, HRL_RESOURCE_FILESIZE, (uoff_t)uiop->uio_offset + uiop->uio_resid); if (error) return (EFBIG); ==== //depot/projects/soc2009/trasz_limits/sys/fs/tmpfs/tmpfs_vnops.c#7 (text+ko) ==== @@ -659,7 +659,7 @@ return (EFBIG); if (vp->v_type == VREG && td != NULL) { - error = hrl_allocated_proc(td->td_proc, HRL_RESOURCE_FILESIZE, + error = hrl_allocated(td->td_proc, HRL_RESOURCE_FILESIZE, (uoff_t)uio->uio_offset + uio->uio_resid); if (error) return (EFBIG); ==== //depot/projects/soc2009/trasz_limits/sys/fs/unionfs/union_subr.c#5 (text+ko) ==== @@ -777,8 +777,10 @@ rootinfo = uifind((uid_t)0); cred = crdup(cnp->cn_cred); chgproccnt(cred->cr_ruidinfo, 1, 0); +#ifdef notyet /* XXX: What about the return value? And what's the purpose of this, anyway? */ hrl_alloc(HRL_RESOURCE_MAXPROCESSES, 1); +#endif change_euid(cred, rootinfo); change_ruid(cred, rootinfo); change_svuid(cred, (uid_t)0); @@ -829,7 +831,9 @@ unionfs_mkshadowdir_abort: cnp->cn_cred = credbk; chgproccnt(cred->cr_ruidinfo, -1, 0); +#ifdef notyet hrl_free(HRL_RESOURCE_MAXPROCESSES, 1); +#endif crfree(cred); return (error); ==== //depot/projects/soc2009/trasz_limits/sys/gnu/fs/ext2fs/ext2_readwrite.c#4 (text+ko) ==== @@ -210,7 +210,7 @@ */ td = uio->uio_td; if (vp->v_type == VREG && td != NULL) { - error = hrl_allocated_proc(td->td_proc, HRL_RESOURCE_FILESIZE, + error = hrl_allocated(td->td_proc, HRL_RESOURCE_FILESIZE, (uoff_t)uio->uio_offset + uio->uio_resid); if (error) return (EFBIG); ==== //depot/projects/soc2009/trasz_limits/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c#5 (text+ko) ==== @@ -600,7 +600,7 @@ #if 0 td = uio->uio_td; if (vp->v_type == VREG && td != NULL) { - error = hrl_allocated_proc(td->td_proc, HRL_RESOURCE_FILESIZE, + error = hrl_allocated(td->td_proc, HRL_RESOURCE_FILESIZE, (uoff_t)uio->uio_offset + uio->uio_resid); if (error) return (EFBIG); ==== //depot/projects/soc2009/trasz_limits/sys/i386/linux/imgact_linux.c#4 (text+ko) ==== @@ -107,7 +107,7 @@ */ if (a_out->a_text > maxtsiz) return (ENOMEM); - error = hrl_allocated_proc(imgp->proc, HRL_RESOURCE_DATASIZE, + error = hrl_allocated(imgp->proc, HRL_RESOURCE_DATASIZE, a_out->a_data + bss_size); if (error) return (ENOMEM); ==== //depot/projects/soc2009/trasz_limits/sys/kern/imgact_aout.c#4 (text+ko) ==== @@ -184,7 +184,7 @@ if (/* text can't exceed maximum text size */ a_out->a_text > maxtsiz) return (ENOMEM); - error = hrl_allocated_proc(imgp->proc, HRL_RESOURCE_DATASIZE, + error = hrl_allocated(imgp->proc, HRL_RESOURCE_DATASIZE, a_out->a_data + bss_size); if (error) return (ENOMEM); ==== //depot/projects/soc2009/trasz_limits/sys/kern/imgact_elf.c#4 (text+ko) ==== @@ -790,11 +790,11 @@ */ if (text_size > maxtsiz) return (ENOMEM); - error = hrl_allocated_proc(imgp->proc, HRL_RESOURCE_DATASIZE, + error = hrl_allocated(imgp->proc, HRL_RESOURCE_DATASIZE, data_size); if (error) return (ENOMEM); - error = hrl_allocated_proc(imgp->proc, HRL_RESOURCE_VMEMORYUSE, + error = hrl_allocated(imgp->proc, HRL_RESOURCE_VMEMORYUSE, total_size); if (error) return (ENOMEM); ==== //depot/projects/soc2009/trasz_limits/sys/kern/init_main.c#12 (text+ko) ==== @@ -517,7 +517,7 @@ * Charge root for one process. */ (void)chgproccnt(p->p_ucred->cr_ruidinfo, 1, 0); - error = hrl_alloc_proc(p, HRL_RESOURCE_MAXPROCESSES, 1); + error = hrl_alloc(p, HRL_RESOURCE_MAXPROCESSES, 1); KASSERT(error == 0, ("hrl_alloc failed")); } SYSINIT(p0init, SI_SUB_INTRINSIC, SI_ORDER_FIRST, proc0_init, NULL); ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_exit.c#11 (text+ko) ==== @@ -761,7 +761,7 @@ * Decrement the count of procs running with this uid. */ (void)chgproccnt(p->p_ucred->cr_ruidinfo, -1, 0); - hrl_free_proc(p->p_pptr, HRL_RESOURCE_MAXPROCESSES, 1); + hrl_free(p->p_pptr, HRL_RESOURCE_MAXPROCESSES, 1); hrl_proc_exiting(p); /* @@ -923,9 +923,9 @@ if (child->p_pptr == parent) return; - hrl_free_proc(child->p_pptr, HRL_RESOURCE_MAXPROCESSES, 1); + hrl_free(child->p_pptr, HRL_RESOURCE_MAXPROCESSES, 1); /* XXX: What about return value? */ - hrl_alloc_proc(parent, HRL_RESOURCE_MAXPROCESSES, 1); + hrl_alloc(parent, HRL_RESOURCE_MAXPROCESSES, 1); PROC_LOCK(child->p_pptr); sigqueue_take(child->p_ksi); ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_fork.c#10 (text+ko) ==== @@ -223,7 +223,7 @@ p1 = td->td_proc; - error = hrl_alloc_proc(p1, HRL_RESOURCE_MAXPROCESSES, 1); + error = hrl_alloc(p1, HRL_RESOURCE_MAXPROCESSES, 1); if (error) return (error); @@ -237,7 +237,7 @@ PROC_LOCK(p1); if (thread_single(SINGLE_BOUNDARY)) { PROC_UNLOCK(p1); - hrl_free_proc(p1, HRL_RESOURCE_MAXPROCESSES, 1); + hrl_free(p1, HRL_RESOURCE_MAXPROCESSES, 1); return (ERESTART); } PROC_UNLOCK(p1); @@ -272,7 +272,7 @@ } *procp = NULL; if (error) - hrl_free_proc(p1, HRL_RESOURCE_MAXPROCESSES, 1); + hrl_free(p1, HRL_RESOURCE_MAXPROCESSES, 1); return (error); } @@ -801,7 +801,7 @@ vmspace_free(vm2); uma_zfree(proc_zone, newproc); pause("fork", hz / 2); - hrl_free_proc(p1, HRL_RESOURCE_MAXPROCESSES, 1); + hrl_free(p1, HRL_RESOURCE_MAXPROCESSES, 1); return (error); } ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#56 (text+ko) ==== @@ -168,9 +168,9 @@ /* * XXX: Free these three some other way. */ - hrl_allocated_proc(p, HRL_RESOURCE_FILESIZE, 0); - hrl_allocated_proc(p, HRL_RESOURCE_COREDUMPSIZE, 0); - hrl_allocated_proc(p, HRL_RESOURCE_PTY, 0); + hrl_allocated(p, HRL_RESOURCE_FILESIZE, 0); + hrl_allocated(p, HRL_RESOURCE_COREDUMPSIZE, 0); + hrl_allocated(p, HRL_RESOURCE_PTY, 0); mtx_lock(&hrl_lock); for (i = 0; i < HRL_RESOURCE_MAX; i++) { @@ -471,17 +471,17 @@ * Return 0 if it's below limits, or errno, if it's not. */ int -hrl_alloc_proc(struct proc *p, int resource, uint64_t amount) +hrl_alloc(struct proc *p, int resource, uint64_t amount) { int i, j, error; struct ucred *cred; struct prison *pr; - KASSERT(amount > 0, ("hrl_alloc_proc: invalid amount for %s: %lld", + KASSERT(amount > 0, ("hrl_alloc: invalid amount for %s: %lld", hrl_resource_name(resource), amount)); #if 0 - printf("hrl_alloc_proc: allocating %lld of %s for %s (pid %d)\n", amount, hrl_resource_name(resource), p->p_comm, p->p_pid); + printf("hrl_alloc: allocating %lld of %s for %s (pid %d)\n", amount, hrl_resource_name(resource), p->p_comm, p->p_pid); #endif mtx_lock(&hrl_lock); @@ -531,18 +531,18 @@ * even if it's above the limit. */ int -hrl_allocated_proc(struct proc *p, int resource, uint64_t amount) +hrl_allocated(struct proc *p, int resource, uint64_t amount) { int i, j, error; int64_t diff; struct ucred *cred; struct prison *pr; - KASSERT(amount >= 0, ("hrl_allocated_proc: invalid amount for %s: %lld", + KASSERT(amount >= 0, ("hrl_allocated: invalid amount for %s: %lld", hrl_resource_name(resource), amount)); #if 0 - printf("hrl_allocated_proc: allocated %lld of %s for %s (pid %d)\n", amount, hrl_resource_name(resource), p->p_comm, p->p_pid); + printf("hrl_allocated: allocated %lld of %s for %s (pid %d)\n", amount, hrl_resource_name(resource), p->p_comm, p->p_pid); #endif mtx_lock(&hrl_lock); @@ -591,22 +591,22 @@ * Decrease allocation of 'resource' by 'amount' for process 'p'. */ void -hrl_free_proc(struct proc *p, int resource, uint64_t amount) +hrl_free(struct proc *p, int resource, uint64_t amount) { int i, j; struct ucred *cred; struct prison *pr; - KASSERT(amount > 0, ("hrl_free_proc: invalid amount for %s: %lld", + KASSERT(amount > 0, ("hrl_free: invalid amount for %s: %lld", hrl_resource_name(resource), amount)); #if 0 - printf("hrl_free_proc: freeing %lld of %s for %s (pid %d)\n", amount, hrl_resource_name(resource), p->p_comm, p->p_pid); + printf("hrl_free: freeing %lld of %s for %s (pid %d)\n", amount, hrl_resource_name(resource), p->p_comm, p->p_pid); #endif mtx_lock(&hrl_lock); KASSERT(amount <= p->p_usage.hu_resources[resource], - ("hrl_free_proc: freeing %lld of %s, which is more than allocated " + ("hrl_free: freeing %lld of %s, which is more than allocated " "%lld for %s (pid %d)", amount, hrl_resource_name(resource), p->p_usage.hu_resources[resource], p->p_comm, p->p_pid)); p->p_usage.hu_resources[resource] -= amount; @@ -1741,7 +1741,7 @@ for (i = 0; i < HRL_RESOURCE_MAX; i++) { if (parent->p_usage.hu_resources[i] != 0 && hrl_resource_inheritable(i)) - hrl_allocated_proc(child, i, + hrl_allocated(child, i, parent->p_usage.hu_resources[i]); } ==== //depot/projects/soc2009/trasz_limits/sys/kern/tty_pts.c#8 (text+ko) ==== @@ -724,7 +724,7 @@ /* Resource limiting. */ PROC_LOCK(p); ok = chgptscnt(uid, 1, lim_cur(p, RLIMIT_NPTS)); - error = hrl_alloc_proc(p, HRL_RESOURCE_PTY, 1); + error = hrl_alloc(p, HRL_RESOURCE_PTY, 1); PROC_UNLOCK(p); if (ok != !error) printf("pts_alloc: ok = %d, error = %d\n", ok, error); @@ -735,13 +735,13 @@ unit = alloc_unr(pts_pool); if (unit < 0) { chgptscnt(uid, -1, 0); - hrl_free_proc(p, HRL_RESOURCE_PTY, 1); + hrl_free(p, HRL_RESOURCE_PTY, 1); return (EAGAIN); } if (unit > pts_maxdev) { free_unr(pts_pool, unit); chgptscnt(uid, -1, 0); - hrl_free_proc(p, HRL_RESOURCE_PTY, 1); + hrl_free(p, HRL_RESOURCE_PTY, 1); return (EAGAIN); } @@ -780,7 +780,7 @@ /* Resource limiting. */ PROC_LOCK(p); ok = chgptscnt(uid, 1, lim_cur(p, RLIMIT_NPTS)); - error = hrl_alloc_proc(p, HRL_RESOURCE_PTY, 1); + error = hrl_alloc(p, HRL_RESOURCE_PTY, 1); PROC_UNLOCK(p); if (ok != !error) printf("pts_alloc: ok = %d, error = %d\n", ok, error); ==== //depot/projects/soc2009/trasz_limits/sys/nfsclient/nfs_bio.c#11 (text+ko) ==== @@ -952,7 +952,7 @@ * file servers have no limits, i don't think it matters */ if (p != NULL) { - error = hrl_allocated_proc(p, HRL_RESOURCE_FILESIZE, + error = hrl_allocated(p, HRL_RESOURCE_FILESIZE, (uoff_t)uio->uio_offset + uio->uio_resid); if (error) return (EFBIG); ==== //depot/projects/soc2009/trasz_limits/sys/sys/hrl.h#32 (text+ko) ==== @@ -131,9 +131,9 @@ struct proc; -int hrl_alloc_proc(struct proc *p, int object, uint64_t amount); -int hrl_allocated_proc(struct proc *p, int object, uint64_t amount); -void hrl_free_proc(struct proc *p, int object, uint64_t amount); +int hrl_alloc(struct proc *p, int object, uint64_t amount); +int hrl_allocated(struct proc *p, int object, uint64_t amount); +void hrl_free(struct proc *p, int object, uint64_t amount); void hrl_usage_add(struct hrl_usage *dest, const struct hrl_usage *src); void hrl_usage_subtract(struct hrl_usage *dest, const struct hrl_usage *src); ==== //depot/projects/soc2009/trasz_limits/sys/ufs/ffs/ffs_vnops.c#5 (text+ko) ==== @@ -706,7 +706,7 @@ */ td = uio->uio_td; if (vp->v_type == VREG && td != NULL) { - error = hrl_allocated_proc(td->td_proc, HRL_RESOURCE_FILESIZE, + error = hrl_allocated(td->td_proc, HRL_RESOURCE_FILESIZE, (uoff_t)uio->uio_offset + uio->uio_resid); if (error) return (EFBIG); ==== //depot/projects/soc2009/trasz_limits/sys/vm/vm_map.c#7 (text+ko) ==== @@ -415,11 +415,11 @@ pmap_activate(td); vmspace_dofree(vm); } - hrl_allocated_proc(p, HRL_RESOURCE_DATASIZE, 0); - hrl_allocated_proc(p, HRL_RESOURCE_STACKSIZE, 0); - hrl_allocated_proc(p, HRL_RESOURCE_MEMORYUSE, 0); - hrl_allocated_proc(p, HRL_RESOURCE_MEMORYLOCKED, 0); - hrl_allocated_proc(p, HRL_RESOURCE_VMEMORYUSE, 0); + hrl_allocated(p, HRL_RESOURCE_DATASIZE, 0); + hrl_allocated(p, HRL_RESOURCE_STACKSIZE, 0); + hrl_allocated(p, HRL_RESOURCE_MEMORYUSE, 0); + hrl_allocated(p, HRL_RESOURCE_MEMORYLOCKED, 0); + hrl_allocated(p, HRL_RESOURCE_VMEMORYUSE, 0); } /* Acquire reference to vmspace owned by another process. */ ==== //depot/projects/soc2009/trasz_limits/sys/vm/vm_unix.c#4 (text+ko) ==== @@ -85,7 +85,7 @@ base = round_page((vm_offset_t) vm->vm_daddr); old = base + ctob(vm->vm_dsize); if (new > base) { - error = hrl_allocated_proc(td->td_proc, HRL_RESOURCE_DATASIZE, + error = hrl_allocated(td->td_proc, HRL_RESOURCE_DATASIZE, new - base); if (error) { error = ENOMEM; @@ -105,7 +105,7 @@ goto done; } if (new > old) { - error = hrl_allocated_proc(td->td_proc, HRL_RESOURCE_VMEMORYUSE, + error = hrl_allocated(td->td_proc, HRL_RESOURCE_VMEMORYUSE, vm->vm_map.size + (new - old)); if (error) { error = ENOMEM;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908151358.n7FDw4b0072935>