From 4da1620a86e6e9f96bca52aac0d2825c25df40a1 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 11 Jul 2016 10:43:50 +0200 Subject: [PATCH] Ensure that zero JobMedias are written for labelling Conflicts: bacula/src/stored/askdir.c --- bacula/src/stored/askdir.c | 8 ++++---- bacula/src/stored/block_util.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index d60ae101a7..af0da08ca1 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -520,17 +520,17 @@ bool dir_create_jobmedia_record(DCR *dcr, bool zero) JOBMEDIA_ITEM *item; bool ok = true;; - if (!dcr->WroteVol) { + if (!zero && !dcr->WroteVol) { return true; } - if (dcr->VolLastIndex == 0) { + if (!zero && dcr->VolLastIndex == 0) { Dmsg7(dbglvl, "JobMedia Vol=%s wrote=%d MediaId=%d FI=%d LI=%d StartBlock=%d EndBlock=%d Suppressed\n", dcr->VolumeName, dcr->WroteVol, dcr->VolMediaId, dcr->VolFirstIndex, dcr->VolLastIndex, dcr->StartBlock, dcr->EndBlock); return true; /* nothing written to the Volume */ } - if (dcr->StartFile == dcr->EndFile && dcr->EndBlock < dcr->StartBlock) { - Dmsg7(0/*dbglvl*/, "PROBLEM Vol=%s wrote=%d MediaId=%d FI=%d LI=%d StartBlock=%d EndBlock=%d Suppressed\n", + if (!zero && dcr->StartFile == dcr->EndFile && dcr->EndBlock < dcr->StartBlock) { + Dmsg7(dbglvl, "JobMedia Vol=%s wrote=%d MediaId=%d FI=%d LI=%d StartBlock=%d EndBlock=%d Suppressed\n", dcr->VolumeName, dcr->WroteVol, dcr->VolMediaId, dcr->VolFirstIndex, dcr->VolLastIndex, dcr->StartBlock, dcr->EndBlock); return true; diff --git a/bacula/src/stored/block_util.c b/bacula/src/stored/block_util.c index cedcc8d335..3d67de9208 100644 --- a/bacula/src/stored/block_util.c +++ b/bacula/src/stored/block_util.c @@ -621,8 +621,8 @@ bool check_for_newvol_or_newfile(DCR *dcr) Dmsg0(100, "Canceled\n"); return false; } - /* Create a jobmedia record for this job */ - if (!dir_create_jobmedia_record(dcr)) { + /* If we wrote on Volume create a last jobmedia record for this job */ + if (dcr->VolFirstIndex && !dir_create_jobmedia_record(dcr)) { dcr->dev->dev_errno = EIO; Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), dcr->getVolCatName(), jcr->Job); -- 2.39.5