git: e3bc87ab1b66 - main - vm_pageout: fix pageout_flush

From: Doug Moore <dougm_at_FreeBSD.org>
Date: Sat, 31 May 2025 18:03:59 UTC
The branch main has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=e3bc87ab1b66e8fff1cd3a069e858461349a0cab

commit e3bc87ab1b66e8fff1cd3a069e858461349a0cab
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2025-05-31 18:02:08 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2025-05-31 18:02:08 +0000

    vm_pageout: fix pageout_flush
    
    A change just made to vm_pageout_flush wrongly dismissed the variable
    'runlen' and used 'count' in its place, with the unintended
    consequence of terminating the main loop of the function prematurely
    when the first VM_PAGER_AGAIN pageout status was encountered.
    Reintroduce that variable, so that the loop runs to completion.
    
    Reported by:    alc
    Reviewed by:    alc
    Fixes:  f2a193a967e3 ("vm_pageout: reduce number of flush() params")
    Differential Revision:  https://reviews.freebsd.org/D50622
---
 sys/vm/vm_pageout.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index 624184d57442..6d3139e58c5a 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -462,7 +462,7 @@ vm_pageout_flush(vm_page_t *mc, int count, int flags, bool *eio)
 	vm_object_t object = mc[0]->object;
 	int pageout_status[count];
 	int numpagedout = 0;
-	int i;
+	int i, runlen;
 
 	VM_OBJECT_ASSERT_WLOCKED(object);
 
@@ -488,6 +488,7 @@ vm_pageout_flush(vm_page_t *mc, int count, int flags, bool *eio)
 
 	vm_pager_put_pages(object, mc, count, flags, pageout_status);
 
+	runlen = count;
 	if (eio != NULL)
 		*eio = false;
 	for (i = 0; i < count; i++) {
@@ -543,7 +544,8 @@ vm_pageout_flush(vm_page_t *mc, int count, int flags, bool *eio)
 				*eio = true;
 			break;
 		case VM_PAGER_AGAIN:
-			count = i;
+			if (runlen == count)
+				runlen = i;
 			break;
 		}
 
@@ -559,7 +561,7 @@ vm_pageout_flush(vm_page_t *mc, int count, int flags, bool *eio)
 		}
 	}
 	if (eio != NULL)
-		return (count);
+		return (runlen);
 	return (numpagedout);
 }