Skip to content

Commit

Permalink
* amandad-src/amandad.c: Add krb5 to exit_on_qlength
Browse files Browse the repository at this point in the history
* application-src/amgtar.c: Improve debugging
* perl/Amanda/FetchDump.pm: Uncompress the state file
* server-src/amidxtaped.pl: Uncompress the state file
* server-src/dumper.c: Compress the state file
* xfer-src/dest-application.c: Improve XMSG
* xfer-src/filter-process.c: Improve XMSG


git-svn-id: https://svn.code.sf.net/p/amanda/code/amanda/trunk@6278 a8d146d6-cc15-0410-8900-af154a0219e0
  • Loading branch information
Jean-Louis Martineau committed Jul 15, 2015
1 parent dfe7419 commit c4c6213
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 27 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2015-07-15 Jean-Louis Martineau <martineau@zmanda.com>
* amandad-src/amandad.c: Add krb5 to exit_on_qlength
* application-src/amgtar.c: Improve debugging
* perl/Amanda/FetchDump.pm: Uncompress the state file
* server-src/amidxtaped.pl: Uncompress the state file
* server-src/dumper.c: Compress the state file
* xfer-src/dest-application.c: Improve XMSG
* xfer-src/filter-process.c: Improve XMSG

2015-07-14 Jean-Louis Martineau <martineau@zmanda.com>
* server-src/driver.c (dump_match_selection): A dle without tag must
go on all storages
Expand Down
1 change: 1 addition & 0 deletions amandad-src/amandad.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ main(

if(strcasecmp(auth, "rsh") == 0 ||
strcasecmp(auth, "ssh") == 0 ||
strcasecmp(auth, "krb5") == 0 ||
strcasecmp(auth, "local") == 0 ||
strcasecmp(auth, "bsdtcp") == 0 ||
strcasecmp(auth, "ssl") == 0) {
Expand Down
6 changes: 4 additions & 2 deletions application-src/amgtar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,8 @@ amgtar_restore(
dar_fd, strerror(save_errno));
exit(1);
}
if (argument->recover_dump_state_file) {
if (argument->recover_dump_state_file &&
include_array->len > 0) {
char line[32768];
FILE *recover_state_file = fopen(argument->recover_dump_state_file,
"r");
Expand Down Expand Up @@ -1589,14 +1590,15 @@ amgtar_restore(
}
fclose(recover_state_file);
if (previous_block >= 0) {
g_debug("restore block %lld (%lld) to END\n",
g_debug("restore block %lld (%lld) to END",
(long long)previous_block * 512,
(long long)previous_block);
fprintf(dar_file, "DAR %lld:-1\n",
(long long)previous_block * 512);
}
} else {
fprintf(dar_file,"DAR 0:-1\n");
g_debug("full dar: 0:-1");
}
fflush(dar_file);
fclose(dar_file);
Expand Down
27 changes: 21 additions & 6 deletions perl/Amanda/FetchDump.pm
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ sub local_message {
} elsif ($self->{'code'} == 3300017) {
return "Not decompressing because the backup image is not decrypted";
} elsif ($self->{'code'} == 3300018) {
return "filter stderr: $self->{'line'}\n";
return "filter stderr: $self->{'line'}";
} elsif ($self->{'code'} == 3300019) {
return "amndmp stdout: $self->{'line'}\n";
return "amndmp stdout: $self->{'line'}";
} elsif ($self->{'code'} == 3300020) {
return "amndmp stderr: $self->{'line'}\n";
return "amndmp stderr: $self->{'line'}";
} elsif ($self->{'code'} == 3300021) {
return "'compress' is not compatible with 'compress-best'";
} elsif ($self->{'code'} == 3300022) {
Expand Down Expand Up @@ -188,6 +188,7 @@ use POSIX qw(strftime);
use File::Basename;
use XML::Simple;
use IPC::Open3;
use IPC::Open2;
use IO::Handle;

use Amanda::Device qw( :constants );
Expand Down Expand Up @@ -624,7 +625,7 @@ sub restore {
my $size;
my $xfer;
my $use_dar = $params{'use_dar'} || 0;
my $xfer_waiting_dar;
my $xfer_waiting_dar = 0;

my $steps = define_steps
cb_ref => \$params{'finished_cb'},
Expand Down Expand Up @@ -1134,6 +1135,19 @@ sub restore {
if (-e $state_filename) {
push @argv, "--recover-dump-state-file",
$state_filename;
} else {
my $state_filename_gz = $state_filename . $Amanda::Constants::COMPRESS_SUFFIX;
if (-e $state_filename_gz) {
open STATEFILE, '>', $state_filename;
my $pid = open2(">&STATEFILE", undef,
$Amanda::Constants::UNCOMPRESS_PATH,
$Amanda::Constants::UNCOMPRESS_OPT,
$state_filename_gz);
close STATEFILE;
waitpid($pid, 0);
push @argv, "--recover-dump-state-file",
$state_filename;
}
}
}

Expand Down Expand Up @@ -1386,7 +1400,8 @@ sub restore {
xfer => $xfer,
recovery_cb => $steps->{'recovery_cb'});

$steps->{'xfer_range'}->();
$xfer_waiting_dar = 1;
$steps->{'xfer_range'}->();
if ($self->{'feedback'}->can('start_msg')) {
$self->{'feedback'}->start_msg($steps->{'dar_data'});
}
Expand All @@ -1406,7 +1421,7 @@ sub restore {
};

step xfer_range => sub {
#return if !$xfer_waiting_dar;
return if !$xfer_waiting_dar;
my $range = shift @{$current_dump->{'range'}};
if (defined $range) {
($offset, my $range1) = split ':', $range;
Expand Down
18 changes: 16 additions & 2 deletions server-src/amidxtaped.pl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ package amidxtaped;
@ISA = qw( Amanda::ClientService Amanda::Recovery::Clerk::Feedback);

use Sys::Hostname;
use IPC::Open2;

use Amanda::Debug qw( debug info warning );
use Amanda::MainLoop qw( :GIOCondition );
Expand Down Expand Up @@ -591,15 +592,28 @@ sub send_state_file {
my $state_filename = getconf($CNF_INDEXDIR) . '/' . $host .
'/' . $disk . '/' . $header->{'datestamp'} . '_' .
$header->{'dumplevel'} . '.state';
if (-e $state_filename) {
open STATEFILE, '<', $state_filename;
my $state_filename_gz = $state_filename . $Amanda::Constants::COMPRESS_SUFFIX;
if (-e $state_filename || -e $state_filename_gz) {
my $pid;
if (-e $state_filename_gz) {
$pid = open2(\*STATEFILE, undef,
$Amanda::Constants::UNCOMPRESS_PATH,
$Amanda::Constants::UNCOMPRESS_OPT,
$state_filename_gz);
} elsif (-e $state_filename) {
open STATEFILE, '<', $state_filename;
}
my $block;
my $length;
while ($length = sysread(STATEFILE, $block, 32768)) {
Amanda::Util::full_write($self->wfd($self->{'state_stream'}),
$block, $length)
or die "writing to $self->{state_stream}: $!";
}
if ($pid) {
waitpid($pid, 0);
}
close(STATEFILE);
}
$self->close($self->{'state_stream'}, 'w');

Expand Down
49 changes: 34 additions & 15 deletions server-src/dumper.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct databuf {
pid_t compresspid; /* valid if fd is pipe to compress */
pid_t encryptpid; /* valid if fd is pipe to encrypt */
};
pid_t statepid = -1;

struct databuf *g_databuf = NULL;

Expand Down Expand Up @@ -141,7 +142,8 @@ static crc_t native_crc;
static crc_t client_crc;
static char *log_filename = NULL;
static char *state_filename = NULL;
static FILE *statefile_in_mesg = NULL;
static char *state_filename_gz = NULL;
static int statefile_in_mesg = -1;
static int statefile_in_stream = -1;
static int retry_delay;
static int retry_level;
Expand Down Expand Up @@ -1034,14 +1036,23 @@ process_dumpline(
} else {
tok = strtok(NULL, "");
if (tok) {
if (!statefile_in_mesg) {
statefile_in_mesg = fopen(state_filename, "w");
if (!statefile_in_mesg) {
g_debug("Can't open statefile '%s': %s", state_filename, strerror(errno));
if (statefile_in_mesg == -1) {
statefile_in_mesg = open(state_filename_gz,
O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (statefile_in_mesg == -1) {
g_debug("Can't open statefile '%s': %s",
state_filename_gz, strerror(errno));
} else {
if (runcompress(statefile_in_mesg, &statepid, COMP_BEST, "state compress") < 0) {
aclose(statefile_in_mesg);
}
}
}
if (statefile_in_mesg) {
fprintf(statefile_in_mesg, "%s\n", tok);
if (statefile_in_mesg != -1) {
int len = strlen(tok);
tok[len] = '\n';
write(statefile_in_mesg, tok, len+1);
tok[len] = '\0';
}
} else {
g_debug("Invalid state");
Expand Down Expand Up @@ -1470,6 +1481,8 @@ do_dump(
state_filename = g_strdup_printf("%s/%s/%s/%s_%d.state",
getconf_str(CNF_INDEXDIR), shostname,
sdiskname, dumper_timestamp, level);
state_filename_gz = g_strdup_printf("%s%s", state_filename,
COMPRESS_SUFFIX);
amfree(shostname);
amfree(sdiskname);

Expand Down Expand Up @@ -1732,6 +1745,7 @@ do_dump(
aclose(db->fd);

amfree(state_filename);
amfree(state_filename_gz);
amfree(errstr);
dumpfile_free_data(&file);

Expand Down Expand Up @@ -1836,8 +1850,7 @@ read_statefd(
switch (size) {
case -1:
if (statefile_in_stream) {
close(statefile_in_stream);
statefile_in_stream = -1;
aclose(statefile_in_stream);
}

g_free(errstr);
Expand All @@ -1852,8 +1865,7 @@ read_statefd(
* EOF. Just shut down the state stream.
*/
if (statefile_in_stream) {
close(statefile_in_stream);
statefile_in_stream = -1;
aclose(statefile_in_stream);
}
security_stream_close(streams[STATEFD].fd);
streams[STATEFD].fd = NULL;
Expand All @@ -1870,8 +1882,16 @@ read_statefd(
default:
assert(buf != NULL);
if (statefile_in_stream == -1) {
statefile_in_stream = open(state_filename,
statefile_in_stream = open(state_filename_gz,
O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (statefile_in_stream == -1) {
g_debug("Can't open statefile '%s': %s", state_filename_gz,
strerror(errno));
} else {
if (runcompress(statefile_in_stream, &statepid, COMP_BEST, "state compress") < 0) {
aclose(statefile_in_stream);
}
}
}
if (statefile_in_stream != -1) {
full_write(statefile_in_stream, buf, size);
Expand Down Expand Up @@ -1909,9 +1929,8 @@ read_mesgfd(
process_dumpeof();
security_stream_close(streams[MESGFD].fd);
streams[MESGFD].fd = NULL;
if (statefile_in_mesg) {
fclose(statefile_in_mesg);
statefile_in_mesg = NULL;
if (statefile_in_mesg != -1) {
aclose(statefile_in_mesg);
}
/*
* If the data fd and index fd has also shut down, then we're done.
Expand Down
2 changes: 1 addition & 1 deletion xfer-src/dest-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ child_watch_callback(

if (errmsg) {
msg = xmsg_new(XFER_ELEMENT(self), XMSG_INFO, 0);
msg->message = g_strdup("ERROR");
msg->message = g_strdup(errmsg);
xfer_queue_message(XFER_ELEMENT(self)->xfer, msg);
} else {
msg = xmsg_new(XFER_ELEMENT(self), XMSG_INFO, 0);
Expand Down
2 changes: 1 addition & 1 deletion xfer-src/filter-process.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ child_watch_callback(

if (errmsg) {
msg = xmsg_new(XFER_ELEMENT(self), XMSG_INFO, 0);
msg->message = g_strdup("ERROR");
msg->message = g_strdup(errmsg);
xfer_queue_message(XFER_ELEMENT(self)->xfer, msg);
} else {
msg = xmsg_new(XFER_ELEMENT(self), XMSG_INFO, 0);
Expand Down

0 comments on commit c4c6213

Please sign in to comment.