Commit 5b28189b authored by Timothy Stack's avatar Timothy Stack

Wire the archiving stuff to the nfstracing stuff. I'm not sure if the

files are being added to the archive at the correct places, but it
seems to work.
parent 94dfc872
......@@ -959,6 +959,48 @@ sub TBExperimentArchiveAddFile($$$)
return ArchiveAdd($archive_idx, $pathname, $view);
}
#
# Add files picked up by NFS tracing to an experiment archive.
#
sub TBExperimentArchiveAddTracedFiles($$)
{
my ($pid, $eid) = @_;
my ($archive_idx, $view);
return 0
if (!$MAINSITE || $pid ne $ALLOWEDPID);
my $rval = TBExperimentArchiveInfo($pid, $eid, \$archive_idx, \$view);
return 0
if ($rval > 0);
return -1
if ($rval < 0);
my $query_result =
DBQueryFatal("SELECT e.idx,s.rsrcidx FROM experiments as e ".
"left join experiment_stats as s on e.idx=s.exptidx ".
"where e.pid='$pid' and e.eid='$eid'");
if ($query_result->num_rows() != 1) {
die("*** $0:\n".
" Experiment $pid/$eid has no stats!\n");
}
my ($exptidx, $rsrcidx) = $query_result->fetchrow_array();
$query_result =
DBQueryFatal("SELECT af.fn FROM fs_resources as fr ".
"LEFT JOIN accessed_files as af on af.idx=fr.fileidx ".
"WHERE fr.rsrcidx=$rsrcidx and fr.type!='l'");
while (my ($fn) = $query_result->fetchrow_array()) {
$rval = ArchiveAdd($archive_idx, $fn, $view);
return $rval
if ($rval != 0);
}
return 0;
}
#
# SavePoint an experiment archive.
#
......
......@@ -35,7 +35,7 @@ my @row;
# Handle command-line arguments
#
sub usage() {
warn "Usage: $0 <gc|get|transfer|stats> pid eid\n";
warn "Usage: $0 <gc|get|transfer|stats|add> pid eid\n";
return 1;
}
......@@ -45,7 +45,7 @@ if (!$cmd) {
}
# Check the operation type
if ($cmd !~ /^(gc|get|transfer|stats)$/) {
if ($cmd !~ /^(gc|get|transfer|stats|add)$/) {
exit usage();
} else {
# Untaint operation
......@@ -111,9 +111,14 @@ $| = 1;
use lib "@prefix@/lib";
use libdb;
use libtestbed;
use libArchive;
$UID = 0;
if ($cmd eq "add") {
exit libArchive::TBExperimentArchiveAddTracedFiles($pid, $eid);
}
if ($cmd ne "stats") {
my $expstate;
......@@ -196,6 +201,11 @@ sub InsertFile($)
my ($fn) = @_;
my $retval = -1;
$fn =~ s|^$FSDIR_GROUPS|/groups|;
$fn =~ s|^$FSDIR_PROJ|/proj|;
$fn =~ s|^$FSDIR_USERS|/users|;
$fn =~ s|^$FSDIR_SHARE|/share|;
$fn = DBQuoteSpecial($fn);
$query = "INSERT IGNORE INTO accessed_files (fn) VALUES ($fn)";
......
......@@ -847,6 +847,14 @@ if ($inout eq "out") {
$errorstat = $? >> 8;
fatal("tbswap out failed!");
}
#
# Add the files that have been detected by tracing to the archive.
#
if (libArchive::TBExperimentArchiveAddTracedFiles($pid, $eid) < 0) {
fatal("Failed to add traced files to the experiment archive!");
}
SetExpState($pid, $eid, EXPTSTATE_SWAPPED)
or fatal("Failed to set experiment state to " . EXPTSTATE_SWAPPED());
TBExptClearPanicBit($pid, $eid);
......@@ -967,6 +975,14 @@ elsif ($inout eq "modify") {
#
SetExpState($pid, $eid, EXPTSTATE_ACTIVE);
$estate = EXPTSTATE_ACTIVE;
#
# Add the files that have been detected by tracing to the archive.
#
if (libArchive::TBExperimentArchiveAddTracedFiles($pid,
$eid) < 0) {
fatal("Failed to add traced files to the experiment archive!");
}
}
else {
$modifyError = $errorstat = $? >> 8;
......
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