mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-24 11:29:10 +00:00
In some cases, sf_buf_alloc() should sleep with pri PCATCH; in others, it
should not. Add a new parameter so that the caller can specify which is the case. Reported by: dillon
This commit is contained in:
parent
2cdafcbbe0
commit
121230a40d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127788
@ -405,7 +405,7 @@ sf_buf_init(void *arg)
|
||||
* Get an sf_buf from the freelist. Will block if none are available.
|
||||
*/
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m)
|
||||
sf_buf_alloc(struct vm_page *m, int pri)
|
||||
{
|
||||
struct sf_buf *sf;
|
||||
int error;
|
||||
@ -414,7 +414,7 @@ sf_buf_alloc(struct vm_page *m)
|
||||
while ((sf = SLIST_FIRST(&sf_freelist.sf_head)) == NULL) {
|
||||
sf_buf_alloc_want++;
|
||||
mbstat.sf_allocwait++;
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM|PCATCH,
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM | pri,
|
||||
"sfbufa", 0);
|
||||
sf_buf_alloc_want--;
|
||||
|
||||
|
@ -460,7 +460,7 @@ sf_buf_init(void *arg)
|
||||
* Get an sf_buf from the freelist. Will block if none are available.
|
||||
*/
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m)
|
||||
sf_buf_alloc(struct vm_page *m, int pri)
|
||||
{
|
||||
struct sf_buf *sf;
|
||||
int error;
|
||||
@ -469,7 +469,7 @@ sf_buf_alloc(struct vm_page *m)
|
||||
while ((sf = SLIST_FIRST(&sf_freelist.sf_head)) == NULL) {
|
||||
sf_buf_alloc_want++;
|
||||
mbstat.sf_allocwait++;
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM|PCATCH,
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM | pri,
|
||||
"sfbufa", 0);
|
||||
sf_buf_alloc_want--;
|
||||
|
||||
|
@ -546,7 +546,7 @@ mdstart_swap(struct md_s *sc, struct bio *bp)
|
||||
m = vm_page_grab(sc->object, i,
|
||||
VM_ALLOC_NORMAL|VM_ALLOC_RETRY);
|
||||
VM_OBJECT_UNLOCK(sc->object);
|
||||
sf = sf_buf_alloc(m);
|
||||
sf = sf_buf_alloc(m, 0);
|
||||
VM_OBJECT_LOCK(sc->object);
|
||||
if (bp->bio_cmd == BIO_READ) {
|
||||
if (m->valid != VM_PAGE_BITS_ALL)
|
||||
|
@ -92,7 +92,7 @@ uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
|
||||
cnt = n;
|
||||
page_offset = offset & PAGE_MASK;
|
||||
cnt = min(cnt, PAGE_SIZE - page_offset);
|
||||
sf = sf_buf_alloc(ma[offset >> PAGE_SHIFT]);
|
||||
sf = sf_buf_alloc(ma[offset >> PAGE_SHIFT], 0);
|
||||
cp = (char *)sf_buf_kva(sf) + page_offset;
|
||||
switch (uio->uio_segflg) {
|
||||
case UIO_USERSPACE:
|
||||
|
@ -606,7 +606,7 @@ sf_buf_init(void *arg)
|
||||
* Get an sf_buf from the freelist. Will block if none are available.
|
||||
*/
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m)
|
||||
sf_buf_alloc(struct vm_page *m, int pri)
|
||||
{
|
||||
struct sf_head *hash_list;
|
||||
struct sf_buf *sf;
|
||||
@ -628,7 +628,7 @@ sf_buf_alloc(struct vm_page *m)
|
||||
while ((sf = TAILQ_FIRST(&sf_buf_freelist)) == NULL) {
|
||||
sf_buf_alloc_want++;
|
||||
mbstat.sf_allocwait++;
|
||||
error = msleep(&sf_buf_freelist, &sf_buf_lock, PVM|PCATCH,
|
||||
error = msleep(&sf_buf_freelist, &sf_buf_lock, PVM | pri,
|
||||
"sfbufa", 0);
|
||||
sf_buf_alloc_want--;
|
||||
|
||||
|
@ -344,7 +344,7 @@ sf_buf_init(void *arg)
|
||||
* Get an sf_buf from the freelist. Will block if none are available.
|
||||
*/
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m)
|
||||
sf_buf_alloc(struct vm_page *m, int pri)
|
||||
{
|
||||
struct sf_buf *sf;
|
||||
int error;
|
||||
@ -353,7 +353,7 @@ sf_buf_alloc(struct vm_page *m)
|
||||
while ((sf = SLIST_FIRST(&sf_freelist.sf_head)) == NULL) {
|
||||
sf_buf_alloc_want++;
|
||||
mbstat.sf_allocwait++;
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM|PCATCH,
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM | pri,
|
||||
"sfbufa", 0);
|
||||
sf_buf_alloc_want--;
|
||||
|
||||
|
@ -138,7 +138,7 @@ socow_setup(struct mbuf *m0, struct uio *uio)
|
||||
/*
|
||||
* Allocate an sf buf
|
||||
*/
|
||||
sf = sf_buf_alloc(pp);
|
||||
sf = sf_buf_alloc(pp, PCATCH);
|
||||
if (!sf) {
|
||||
vm_page_lock_queues();
|
||||
vm_page_cowclear(pp);
|
||||
|
@ -1919,7 +1919,7 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
|
||||
* Get a sendfile buf. We usually wait as long as necessary,
|
||||
* but this wait can be interrupted.
|
||||
*/
|
||||
if ((sf = sf_buf_alloc(pg)) == NULL) {
|
||||
if ((sf = sf_buf_alloc(pg, PCATCH)) == NULL) {
|
||||
mbstat.sf_allocfail++;
|
||||
vm_page_lock_queues();
|
||||
vm_page_unwire(pg, 0);
|
||||
|
@ -259,7 +259,7 @@ sf_buf_init(void *arg)
|
||||
* Get an sf_buf from the freelist. Will block if none are available.
|
||||
*/
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m)
|
||||
sf_buf_alloc(struct vm_page *m, int pri)
|
||||
{
|
||||
struct sf_buf *sf;
|
||||
int error;
|
||||
@ -268,7 +268,7 @@ sf_buf_alloc(struct vm_page *m)
|
||||
while ((sf = SLIST_FIRST(&sf_freelist.sf_head)) == NULL) {
|
||||
sf_buf_alloc_want++;
|
||||
mbstat.sf_allocwait++;
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM|PCATCH,
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM | pri,
|
||||
"sfbufa", 0);
|
||||
sf_buf_alloc_want--;
|
||||
|
||||
|
@ -259,7 +259,7 @@ sf_buf_init(void *arg)
|
||||
* Get an sf_buf from the freelist. Will block if none are available.
|
||||
*/
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m)
|
||||
sf_buf_alloc(struct vm_page *m, int pri)
|
||||
{
|
||||
struct sf_buf *sf;
|
||||
int error;
|
||||
@ -268,7 +268,7 @@ sf_buf_alloc(struct vm_page *m)
|
||||
while ((sf = SLIST_FIRST(&sf_freelist.sf_head)) == NULL) {
|
||||
sf_buf_alloc_want++;
|
||||
mbstat.sf_allocwait++;
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM|PCATCH,
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM | pri,
|
||||
"sfbufa", 0);
|
||||
sf_buf_alloc_want--;
|
||||
|
||||
|
@ -101,7 +101,7 @@ uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
|
||||
m = ma[offset >> PAGE_SHIFT];
|
||||
pa = VM_PAGE_TO_PHYS(m);
|
||||
if (m->md.color != DCACHE_COLOR(pa)) {
|
||||
sf = sf_buf_alloc(m);
|
||||
sf = sf_buf_alloc(m, 0);
|
||||
cp = (char *)sf_buf_kva(sf) + page_offset;
|
||||
} else {
|
||||
sf = NULL;
|
||||
|
@ -389,7 +389,7 @@ sf_buf_init(void *arg)
|
||||
* Get an sf_buf from the freelist. Will block if none are available.
|
||||
*/
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m)
|
||||
sf_buf_alloc(struct vm_page *m, int pri)
|
||||
{
|
||||
struct sf_buf *sf;
|
||||
int error;
|
||||
@ -398,7 +398,7 @@ sf_buf_alloc(struct vm_page *m)
|
||||
while ((sf = SLIST_FIRST(&sf_freelist.sf_head)) == NULL) {
|
||||
sf_buf_alloc_want++;
|
||||
mbstat.sf_allocwait++;
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM|PCATCH,
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM | pri,
|
||||
"sfbufa", 0);
|
||||
sf_buf_alloc_want--;
|
||||
|
||||
|
@ -38,7 +38,7 @@ extern int nsfbufspeak; /* Peak of nsfbufsused */
|
||||
extern int nsfbufsused; /* Number of sendfile(2) bufs in use */
|
||||
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m);
|
||||
sf_buf_alloc(struct vm_page *m, int pri);
|
||||
void sf_buf_free(struct sf_buf *sf);
|
||||
void sf_buf_mext(void *addr, void *args);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user