Commit a9c42f6a authored by Mike Hibler's avatar Mike Hibler

Add option for "incremental" mountd update.

parent f52df9ba
......@@ -34,16 +34,18 @@ use Getopt::Std;
sub usage()
{
print(STDERR
"Usage: exports_setup [-n] [-d] [-w]\n".
"Usage: exports_setup [-i] [-n] [-d] [-w]\n".
"switches and arguments:\n".
"-i - incremental (differential) update (if mounted supports it)\n".
"-w - wait mode; wait for mountd to finish before exiting\n".
"-n - impotent; dump exports to stdout\n");
exit(-1);
}
my $optlist = "ndw";
my $optlist = "indw";
my $impotent = 0;
my $debug = 0;
my $waittildone= 0;
my $incremental= 0;
#
# Function phototypes
......@@ -166,12 +168,17 @@ if (defined($options{"d"})) {
if (defined($options{"w"})) {
$waittildone = 1;
}
if (defined($options{"i"})) {
$incremental = 1;
}
usage()
if (@ARGV);
if ($ZFS_NOEXPORT && !$waittildone) {
print "WARNING: forcing wait mode\n";
$waittildone = 1;
#print "WARNING: forcing incremental updates\n";
#$incremental = 1;
}
#
......@@ -438,6 +445,10 @@ while ($row = $nodes_result->fetchrow_hashref) {
# Iterate through directory list dividing it according to filesystem.
foreach my $dir ( @dirlist ) {
my $fs = fsof($dir);
if (!$fs) {
print "WARNING: no filesystem for '$dir', ignored\n";
next;
}
if (! defined($fslist{$fs})) {
$fslist{$fs} = [ $dir ];
......@@ -500,7 +511,6 @@ sub sortbyip {
#
# Now spit out each group!
#
my $lastmount;
foreach my $str ( keys(%ipgroups) ) {
my @iplist = sort sortbyip @{ $ipgroups{$str} };
......@@ -514,7 +524,6 @@ foreach my $str ( keys(%ipgroups) ) {
print "$str -maproot=$NFSMAPTOUSER @iplist\n"
if ($debug);
}
$lastmount = $str;
}
if ($ZFS_NOEXPORT) {
# Build up filesystem sub-lists.
......@@ -523,6 +532,10 @@ if ($ZFS_NOEXPORT) {
foreach my $dir (keys(%bossexports)) {
my $fs = fsof($dir);
if (!$fs) {
print "WARNING: no filesystem for '$dir', ignored\n";
next;
}
if (! defined($bosslists{$fs})) {
$bosslists{$fs} = [ $dir ];
......@@ -544,11 +557,9 @@ if ($ZFS_NOEXPORT) {
print "$str -maproot=$NFSMAPTOUSER $BOSSNODE\n"
if ($debug);
}
$lastmount = $str;
}
}
print MAP "\n";
close(MAP);
#
......@@ -593,8 +604,10 @@ if (!$TESTMODE) {
}
}
else {
my $arg = ($incremental ? "-i" : "");
# First do the NFS exports
system("$SSH $PROG < $exportstail") == 0 or
system("$SSH $PROG $arg < $exportstail") == 0 or
fatal("Failed: $SSH $PROG < $exportstail: $?");
unlink("$exportstail");
......@@ -615,15 +628,9 @@ if (!$TESTMODE) {
# exports and wait for that FS!
#
if ($waittildone) {
# parse a FS out of the last line or /proj/emulab-ops if none
my $testdir;
if ($lastmount && $lastmount =~ /^(\S+)/) {
$testdir = $1;
} else {
$testdir = "/proj/" . TBOPSPID();
}
print "WARNING: waiting for mountd to finish ($testdir)...\n";
my $testdir = "/proj/" . TBOPSPID();
TBDebugTimeStampsOn();
TBDebugTimeStamp("Waiting for mountd to finish...");
my $tries = 10;
while ($tries-- > 0) {
if (system("/bin/ls $testdir >/dev/null 2>&1")) {
......@@ -632,6 +639,7 @@ if (!$TESTMODE) {
}
last;
}
TBDebugTimeStamp("Wait done");
}
}
......
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