From 963b15d7453d57aaa05dccb314ec34ceac31d01a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 9 May 2007 14:50:05 +0000 Subject: [PATCH] kes When backup fails, cancel SD before waiting for sd termination. kes If SD is waiting for FD to connect during cancel, wake up the thread. kes Fix fsf code so that errno is correctly reported. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4735 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ReleaseNotes | 3 +++ bacula/kernstodo | 15 +++++++++++++++ bacula/src/dird/backup.c | 4 ++++ bacula/src/dird/migrate.c | 24 +++++++++++++----------- bacula/src/stored/dev.c | 18 ++++++++++-------- bacula/src/stored/dircmd.c | 3 +++ bacula/src/version.h | 4 ++-- bacula/technotes-2.1 | 6 ++++++ 8 files changed, 56 insertions(+), 21 deletions(-) diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index deeb63f49a..dd064788d6 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -70,3 +70,6 @@ Other features or bug fixes: which the restore will be sent. The client keyword specifies the backup client. The restoreclient keyword is optional if it is not specified, the backup client will also be the restore client. +- The disk file size is now checked to ensure that it agrees with the + catalog value before Bacula will append to the disk (same as tape + and DVD). diff --git a/bacula/kernstodo b/bacula/kernstodo index f2f1b8fac8..777a1589c5 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -48,6 +48,7 @@ Professional Needs: - Detect state change of system (verify) Priority: +- Mention Eric and Marc's work + Marc's doc. - Add TLS to bat - When Pool specifies Storage command override does not work. - Implement wait_for_sysop() message display in wait_for_device(), which @@ -95,6 +96,20 @@ Priority: Projects: +- Average tape size from Eric + SELECT COALESCE(media_avg_size.volavg,0) * count(Media.MediaId) AS volmax, GROUP BY Media.MediaType, Media.PoolId, media_avg_size.volavg + count(Media.MediaId) AS volnum, + sum(Media.VolBytes) AS voltotal, + Media.PoolId AS PoolId, + Media.MediaType AS MediaType + FROM Media + LEFT JOIN (SELECT avg(Media.VolBytes) AS volavg, + Media.MediaType AS MediaType + FROM Media + WHERE Media.VolStatus = 'Full' + GROUP BY Media.MediaType + ) AS media_avg_size ON (Media.MediaType = media_avg_size.MediaType) + GROUP BY Media.MediaType, Media.PoolId, media_avg_size.volavg - GUI - Admin - Management reports diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 294b849bf2..5856a241ee 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -244,6 +244,10 @@ bool do_backup(JCR *jcr) bail_out: set_jcr_job_status(jcr, JS_ErrorTerminated); Dmsg1(400, "wait for sd. use=%d\n", jcr->use_count()); + /* Cancel SD */ + if (jcr->store_bsock) { + jcr->store_bsock->fsend("cancel Job=%s\n", jcr->Job); + } wait_for_storage_daemon_termination(jcr); Dmsg1(400, "after wait for sd. use=%d\n", jcr->use_count()); return false; diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index b820b8bce7..f7aec4eca3 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -519,14 +519,16 @@ const char *sql_jobids_from_vol = const char *sql_smallest_vol = - "SELECT MediaId FROM Media,Pool WHERE" - " VolStatus in ('Full','Used','Error') AND Media.Enabled=1 AND" + "SELECT Media.MediaId FROM Media,Pool,JobMedia WHERE" + " Media.MediaId in (SELECT DISTINCT MediaId from JobMedia) AND" + " Media.VolStatus in ('Full','Used','Error') AND Media.Enabled=1 AND" " Media.PoolId=Pool.PoolId AND Pool.Name='%s'" " ORDER BY VolBytes ASC LIMIT 1"; const char *sql_oldest_vol = - "SELECT MediaId FROM Media,Pool WHERE" - " VolStatus in ('Full','Used','Error') AND Media.Enabled=1 AND" + "SELECT Media.MediaId FROM Media,Pool,JobMedia WHERE" + " Media.MediaId in (SELECT DISTINCT MediaId from JobMedia) AND" + " Media.VolStatus in ('Full','Used','Error') AND Media.Enabled=1 AND" " Media.PoolId=Pool.PoolId AND Pool.Name='%s'" " ORDER BY LastWritten ASC LIMIT 1"; @@ -679,8 +681,8 @@ static int get_job_to_migrate(JCR *jcr) goto ok_out; } pool_bytes = ctx.value; - Dmsg2(dbglevel, "highbytes=%d pool=%d\n", (int)jcr->rpool->MigrationHighBytes, - (int)pool_bytes); + Dmsg2(dbglevel, "highbytes=%lld pool=%lld\n", jcr->rpool->MigrationHighBytes, + pool_bytes); if (pool_bytes < (int64_t)jcr->rpool->MigrationHighBytes) { Jmsg(jcr, M_INFO, 0, _("No Volumes found to migrate.\n")); goto ok_out; @@ -858,11 +860,11 @@ static void start_migration_job(JCR *jcr) edit_uint64(jcr->MigrateJobId, ed1)); Dmsg1(dbglevel, "=============== Migration cmd=%s\n", ua->cmd); parse_ua_args(ua); /* parse command */ - int stat = run_cmd(ua, ua->cmd); - if (stat == 0) { + int jobid = run_cmd(ua, ua->cmd); + if (jobid == 0) { Jmsg(jcr, M_ERROR, 0, _("Could not start migration job.\n")); } else { - Jmsg(jcr, M_INFO, 0, _("Migration JobId %d started.\n"), stat); + Jmsg(jcr, M_INFO, 0, _("Migration JobId %d started.\n"), jobid); } free_ua_context(ua); } @@ -881,7 +883,7 @@ static bool find_mediaid_then_jobids(JCR *jcr, idpkt *ids, const char *query1, goto bail_out; } if (ids->count == 0) { - Jmsg(jcr, M_INFO, 0, _("No %ss found to migrate.\n"), type); + Jmsg(jcr, M_INFO, 0, _("No %s found to migrate.\n"), type); ok = true; /* Not an error */ goto bail_out; } else if (ids->count != 1) { @@ -889,7 +891,7 @@ static bool find_mediaid_then_jobids(JCR *jcr, idpkt *ids, const char *query1, ids->count); goto bail_out; } - Dmsg1(dbglevel, "Smallest Vol Jobids=%s\n", ids->list); + Dmsg2(dbglevel, "%s MediaIds=%s\n", type, ids->list); ok = find_jobids_from_mediaid_list(jcr, ids, type); diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index eb1cd41c97..14637c81e1 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -1260,7 +1260,7 @@ bool DEVICE::offline_or_rewind() */ bool DEVICE::fsf(int num) { - int32_t os_file; + int32_t os_file = 0; struct mtop mt_com; int stat = 0; @@ -1294,24 +1294,26 @@ bool DEVICE::fsf(int num) * forward space past the end of the medium. */ if (has_cap(CAP_FSF) && has_cap(CAP_MTIOCGET) && has_cap(CAP_FASTFSF)) { - int errno_save; + int my_errno = 0; mt_com.mt_op = MTFSF; mt_com.mt_count = num; stat = tape_ioctl(m_fd, MTIOCTOP, (char *)&mt_com); - errno_save = errno; - if (stat < 0 || (os_file=get_os_tape_file()) < 0) { - if (os_file >= 0) { /* get_os_tape_file reset errno */ - errno = errno_save; - } + if (stat < 0) { + my_errno = errno; /* save errno */ + } else if ((os_file=get_os_tape_file()) < 0) { + my_errno = errno; /* save errno */ + } + if (my_errno != 0) { berrno be; set_eot(); Dmsg0(200, "Set ST_EOT\n"); clrerror(MTFSF); Mmsg2(errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"), - print_name(), be.bstrerror()); + print_name(), be.bstrerror(my_errno)); Dmsg1(200, "%s", errmsg); return false; } + Dmsg1(200, "fsf file=%d\n", os_file); set_ateof(); file = os_file; diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index d1ef1d4d30..fb30c52e96 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -303,6 +303,9 @@ static bool cancel_cmd(JCR *cjcr) jcr->unlock(); if (jcr->file_bsock) { bnet_sig(jcr->file_bsock, BNET_TERMINATE); + } else { + /* Still waiting for FD to connect, release it */ + pthread_cond_signal(&jcr->job_start_wait); /* wake waiting job */ } /* If thread waiting on mount, wake him */ if (jcr->dcr && jcr->dcr->dev && jcr->dcr->dev->waiting_for_mount()) { diff --git a/bacula/src/version.h b/bacula/src/version.h index 263dd69e6d..085613c739 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.1.8" -#define BDATE "08 May 2007" -#define LSMDATE "08May07" +#define BDATE "09 May 2007" +#define LSMDATE "09May07" #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n" #define BYEAR "2007" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index d3319b85f2..6c4ceedfcf 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,12 @@ Technical notes on version 2.1 General: +09May07 +kes When backup fails, cancel SD before waiting for sd termination. +kes If SD is waiting for FD to connect during cancel, wake up the + thread. +kes Fix fsf code so that errno is correctly reported. +kes Apply migration patch (with changes) from Sergey Svishchev 08May07 kes Make lack of Pool directive in Job an ERROR_TERM rather than FATAL so that Bacula doesn't later stumble into a seg fault. -- 2.39.5