diff options
author | alc <alc@FreeBSD.org> | 2005-12-21 18:58:40 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2005-12-21 18:58:40 +0000 |
commit | 09b665597401a6c52abc7955a365036782ba772a (patch) | |
tree | 066b049cf2fd92477900e441cc41f4ec5bec897d /sys/kern/imgact_elf.c | |
parent | 8e66e4b3e190a92d0c89d4501486c8defb9d7578 (diff) | |
download | FreeBSD-src-09b665597401a6c52abc7955a365036782ba772a.zip FreeBSD-src-09b665597401a6c52abc7955a365036782ba772a.tar.gz |
Maintain the vnode lock throughout elfN_load_file() rather than releasing
it and reacquiring it in vrele(). Consequently, there is no reason to
increase the reference count on the vm object caching the file's pages.
Reviewed by: tegge
Eliminate unused parameters to elfN_load_file().
Diffstat (limited to 'sys/kern/imgact_elf.c')
-rw-r--r-- | sys/kern/imgact_elf.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 6eb3a91..a65be43 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -82,8 +82,7 @@ static Elf_Brandinfo *__elfN(get_brandinfo)(const Elf_Ehdr *hdr, const char *interp); static int __elfN(load_file)(struct proc *p, const char *file, u_long *addr, u_long *entry, size_t pagesize); -static int __elfN(load_section)(struct proc *p, - struct vmspace *vmspace, struct vnode *vp, vm_object_t object, +static int __elfN(load_section)(struct vmspace *vmspace, vm_object_t object, vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot, size_t pagesize); static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp); @@ -336,8 +335,8 @@ __elfN(map_insert)(vm_map_t map, vm_object_t object, vm_ooffset_t offset, } static int -__elfN(load_section)(struct proc *p, struct vmspace *vmspace, - struct vnode *vp, vm_object_t object, vm_offset_t offset, +__elfN(load_section)(struct vmspace *vmspace, + vm_object_t object, vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot, size_t pagesize) { @@ -520,25 +519,20 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr, * Check permissions, modes, uid, etc on the file, and "open" it. */ error = exec_check_permissions(imgp); - if (error) { - VOP_UNLOCK(nd->ni_vp, 0, curthread); /* XXXKSE */ + if (error) goto fail; - } error = exec_map_first_page(imgp); + if (error) + goto fail; + /* * Also make certain that the interpreter stays the same, so set * its VV_TEXT flag, too. */ - if (error == 0) - nd->ni_vp->v_vflag |= VV_TEXT; + nd->ni_vp->v_vflag |= VV_TEXT; imgp->object = nd->ni_vp->v_object; - vm_object_reference(imgp->object); - - VOP_UNLOCK(nd->ni_vp, 0, curthread); /* XXXKSE */ - if (error) - goto fail; hdr = (const Elf_Ehdr *)imgp->image_header; if ((error = __elfN(check_header)(hdr)) != 0) @@ -572,8 +566,8 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr, if (phdr[i].p_flags & PF_R) prot |= VM_PROT_READ; - if ((error = __elfN(load_section)(p, vmspace, - nd->ni_vp, imgp->object, phdr[i].p_offset, + if ((error = __elfN(load_section)(vmspace, + imgp->object, phdr[i].p_offset, (caddr_t)(uintptr_t)phdr[i].p_vaddr + rbase, phdr[i].p_memsz, phdr[i].p_filesz, prot, pagesize)) != 0) @@ -594,11 +588,9 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr, fail: if (imgp->firstpage) exec_unmap_first_page(imgp); - if (imgp->object) - vm_object_deallocate(imgp->object); if (nd->ni_vp) - vrele(nd->ni_vp); + vput(nd->ni_vp); VFS_UNLOCK_GIANT(vfslocked); free(tempdata, M_TEMP); @@ -700,8 +692,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) prot |= VM_PROT_EXECUTE; #endif - if ((error = __elfN(load_section)(imgp->proc, vmspace, - imgp->vp, imgp->object, phdr[i].p_offset, + if ((error = __elfN(load_section)(vmspace, + imgp->object, phdr[i].p_offset, (caddr_t)(uintptr_t)phdr[i].p_vaddr, phdr[i].p_memsz, phdr[i].p_filesz, prot, sv->sv_pagesize)) != 0) |