From: Kern Sibbald Date: Mon, 30 Apr 2012 19:12:32 +0000 (+0200) Subject: Ensure that StorageId is updated after write X-Git-Tag: Release-7.0.0~243 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b8b676cb931d086d62902f5d10a62181adcce322;p=bacula%2Fbacula Ensure that StorageId is updated after write --- diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 7d7b4d197f..e193bff464 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -275,6 +275,20 @@ void catalog_request(JCR *jcr, BSOCK *bs) mr.LastWritten = VolLastWritten; } + /* + * Update to point to the last device used to write the Volume. + * However, do so only if we are writing the tape, i.e. + * the number of VolWrites has increased. + */ + if (jcr->wstore && sdmr.VolWrites > mr.VolWrites) { + Dmsg2(050, "Update StorageId old=%d new=%d\n", + mr.StorageId, jcr->wstore->StorageId); + /* Update StorageId after write */ + set_storageid_in_mr(jcr->wstore, &mr); + } else { + /* Nothing written, reset same StorageId */ + set_storageid_in_mr(NULL, &mr); + } /* Copy updated values to original media record */ mr.VolJobs = sdmr.VolJobs; @@ -295,26 +309,6 @@ void catalog_request(JCR *jcr, BSOCK *bs) mr.VolWriteTime = sdmr.VolWriteTime; } - /* - * Update to point to the last device used to write the Volume. - * However, do so only if we are writing the tape, i.e. - * the number of VolWrites has increased. - */ - if (jcr->wstore && jcr->wstore->StorageId && sdmr.VolWrites > mr.VolWrites) { - Dmsg2(050, "Update StorageId old=%d new=%d\n", - mr.StorageId, jcr->wstore->StorageId); - if (jcr->wstore->StorageId == 0) { - Jmsg(jcr, M_ERROR, 0, _("Attempt to set StorageId to zero.\n")); - db_unlock(jcr->db); - return; - } else { - set_storageid_in_mr(jcr->wstore, &mr); - } - } else { - /* ***FIXME*** is this correct? */ - set_storageid_in_mr(NULL, &mr); - } - Dmsg2(400, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName); /* * Update the database, then before sending the response to the