Commit c02b116d authored by Mike Hibler's avatar Mike Hibler

Add -w "wait for mountd to finish" option.

The heuristic we use here is that after ssh'ing to ops to HUP mountd,
we try to stat /proj/emulab-ops. We keep trying for 10 seconds or til
it works. In the new race-free NFS world, this stat will block until
mountd is done and then return success. In the old racy NFS world, the
stat should fail until mountd is done.
parent 21e9d6a7
......@@ -34,14 +34,16 @@ use Getopt::Std;
sub usage()
{
print(STDERR
"Usage: exports_setup [-n] [-d]\n".
"Usage: exports_setup [-n] [-d] [-w]\n".
"switches and arguments:\n".
"-w - wait mode; wait for mountd to finish before exiting\n".
"-n - impotent; dump exports to stdout\n");
exit(-1);
}
my $optlist = "nd";
my $optlist = "ndw";
my $impotent = 0;
my $debug = 0;
my $waittildone= 0;
#
# Function phototypes
......@@ -161,6 +163,9 @@ if (defined($options{"n"})) {
if (defined($options{"d"})) {
$debug = 1;
}
if (defined($options{"w"})) {
$waittildone = 1;
}
usage()
if (@ARGV);
......@@ -589,6 +594,24 @@ if (!$TESTMODE) {
fatal("Failed: $SSH $PROG < $smbconftail: $?");
unlink("$smbconftail");
}
#
# Attempt to see if mountd is done. The theory:
# with older mountd's ls will fail,
# with newer mountd's ls will hang til mountd is done.
#
if ($waittildone) {
print "WARNING: waiting for mountd to finish...\n";
my $testdir = "/proj/" . TBOPSPID();
my $tries = 10;
while ($tries-- > 0) {
if (system("/bin/ls $testdir >/dev/null 2>&1")) {
sleep(1);
next;
}
last;
}
}
}
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment