[sheepdog] [PATCH 10/10] vditest: limit the maximum number of outstanding aio

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Mon Oct 22 04:54:13 CEST 2012


When using '-a' option, vditest sends too many requests to sheep and
causes a 'too many open files' error.  This patch limits the number of
aio requests as a workaround.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 script/vditest |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/script/vditest b/script/vditest
index 001166f..8f6fbdd 100755
--- a/script/vditest
+++ b/script/vditest
@@ -19,6 +19,7 @@ my $program = "vditest";
 my ($vdiname, $vdisize);
 
 my $use_aio = 0;
+my $nr_outstanding_aio = 0;
 my ($lblk, $hblk) = (512, 1048576);
 my $cache = 'writethrough';
 my $runtime = 10;
@@ -142,6 +143,7 @@ sub vdi_read {
 	    # partial check is not supported
 	    print_qemu("aio_read $offset $length\n");
 	}
+	$nr_outstanding_aio++;
     } else {
 	if ($ptn_length > 0) {
 	    print_qemu("read -P $ptn -l $ptn_length $offset $length\n");
@@ -161,6 +163,7 @@ sub vdi_write {
 
     if ($use_aio) {
 	print_qemu("aio_write -P $ptn $offset $length\n");
+	$nr_outstanding_aio++;
     } else {
 	print_qemu("write -P $ptn $offset $length\n");
     }
@@ -370,6 +373,9 @@ sub vdi_main {
 	    vdi_flush();
 	} elsif ($flush_interval > 0 && $i % $flush_interval == 0) {
 	    vdi_flush();
+	} elsif ($nr_outstanding_aio > 500) { # FIXME
+	    vdi_flush();
+	    $nr_outstanding_aio = 0;
 	}
 
 	($sec, $microsec) = gettimeofday();
-- 
1.7.2.5




More information about the sheepdog mailing list