|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [OSSTEST PATCH 3/5] cr-ensure-disk-space: Break out check_space
Break out the df check into its own subroutine. iteration_proceed now
becomes iteration_continue and doesn't return a booleanish.
No functional change.
Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
cr-ensure-disk-space | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/cr-ensure-disk-space b/cr-ensure-disk-space
index a1f838f..63e92f4 100755
--- a/cr-ensure-disk-space
+++ b/cr-ensure-disk-space
@@ -49,7 +49,20 @@ csreadconfig();
logs_select $cfgbase or exit 0;
-open LOCK, "> $c{GlobalLockDir}/publish-lock" or die $!;
+sub check_space () {
+ open P, "-|", onloghost "df --block-size=1M -P $logdir" or die $!;
+ $_= <P>;
+ m/^filesystem/i or die "$_ ?";
+ $_= <P>;
+ m,^\S+\s+\d+\s+\d+\s+(\d+)\s+, or die "$_ ?";
+ $!=0; $?=0; close P or die "$! $?";
+ my $space= $1;
+ printf "space: %8d, wanted: %8d ", $space, logcfg('MinSpaceMby');
+ return $space >= logcfg('MinSpaceMby');
+}
+
+my $lock = "$c{GlobalLockDir}/publish-lock";
+open LOCK, "> $lock" or die "$lock $!";
flock LOCK, LOCK_EX or die $!;
$|=1;
@@ -67,17 +80,7 @@ END
our @flights;
our %latestref;
-sub iteration_continue () {
- open P, "-|", onloghost "df --block-size=1M -P $logdir" or die $!;
- $_= <P>;
- m/^filesystem/i or die "$_ ?";
- $_= <P>;
- m,^\S+\s+\d+\s+\d+\s+(\d+)\s+, or die "$_ ?";
- $!=0; $?=0; close P or die "$! $?";
- my $space= $1;
- printf "space: %8d, wanted: %8d ", $space, logcfg('MinSpaceMby');
- return 0 if $space >= logcfg('MinSpaceMby');
-
+sub iteration_proceed () {
if (!@flights) {
%latestref = ();
open P, "-|", onloghost "ls -1 $logdir" or die $!;
@@ -141,15 +144,13 @@ sub iteration_continue () {
END
printf "done.\n";
-
- return 1;
}
db_retry($dbh_tests,[], sub {
@flights = ();
for (;;) {
- iteration_continue()
- or last;
+ last if check_space();
+ iteration_continue();
}
});
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |