1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-20 02:38:43 +00:00

Finish the vm object locking in sendfile(2). More generally,

the vm locking in sendfile(2) is complete.
This commit is contained in:
Alan Cox 2003-06-12 05:52:09 +00:00
parent de52a6f7a6
commit c10c537816
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=116246

View File

@ -1841,12 +1841,14 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
vm_offset_t pgoff;
pindex = OFF_TO_IDX(off);
VM_OBJECT_LOCK(obj);
retry_lookup:
/*
* Calculate the amount to transfer. Not to exceed a page,
* the EOF, or the passed in nbytes.
*/
xfsize = obj->un_pager.vnp.vnp_size - off;
VM_OBJECT_UNLOCK(obj);
if (xfsize > PAGE_SIZE)
xfsize = PAGE_SIZE;
pgoff = (vm_offset_t)(off & PAGE_MASK);
@ -1868,6 +1870,7 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
sbunlock(&so->so_snd);
goto done;
}
VM_OBJECT_LOCK(obj);
/*
* Attempt to look up the page.
*
@ -1881,7 +1884,9 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
pg = vm_page_alloc(obj, pindex,
VM_ALLOC_NORMAL | VM_ALLOC_WIRED);
if (pg == NULL) {
VM_OBJECT_UNLOCK(obj);
VM_WAIT;
VM_OBJECT_LOCK(obj);
goto retry_lookup;
}
vm_page_lock_queues();
@ -1910,6 +1915,7 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
*/
vm_page_io_start(pg);
vm_page_unlock_queues();
VM_OBJECT_UNLOCK(obj);
/*
* Get the page from backing store.
@ -1948,7 +1954,8 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
sbunlock(&so->so_snd);
goto done;
}
}
} else
VM_OBJECT_UNLOCK(obj);
vm_page_unlock_queues();
/*