From a25f06febc03a2b847a415cff0547531fc50d9c3 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 15 Apr 2012 14:05:31 +0200 Subject: [PATCH] Backport new StorageId code --- bacula/src/cats/cats.h | 10 ++++++-- bacula/src/cats/sql_find.c | 4 ++-- bacula/src/dird/admin.c | 4 +--- bacula/src/dird/autoprune.c | 12 +++++----- bacula/src/dird/backup.c | 3 +-- bacula/src/dird/catreq.c | 40 ++++++++++++++++++-------------- bacula/src/dird/dird.c | 14 +++++------ bacula/src/dird/migrate.c | 3 +-- bacula/src/dird/mountreq.c | 41 ++++++++++++++++----------------- bacula/src/dird/newvol.c | 9 ++++---- bacula/src/dird/next_vol.c | 46 ++++++++++++++++++++++++++----------- bacula/src/dird/protos.h | 18 ++++++++++----- bacula/src/dird/pythondir.c | 1 - bacula/src/dird/recycle.c | 13 +++++++---- bacula/src/dird/ua_cmds.c | 5 ++-- bacula/src/dird/ua_label.c | 35 ++++++++++++---------------- bacula/src/dird/ua_output.c | 6 ++--- bacula/src/dird/ua_purge.c | 9 ++++---- bacula/src/dird/ua_select.c | 5 ++-- bacula/src/dird/ua_status.c | 5 ++-- bacula/src/dird/ua_update.c | 8 ++++--- bacula/src/dird/vbackup.c | 3 +-- 22 files changed, 161 insertions(+), 133 deletions(-) diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index d46ba164f9..b61d748c1e 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2011 Free Software Foundation Europe e.V. + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -282,7 +282,13 @@ public: /* Media record -- same as the database */ -struct MEDIA_DBR { +class MEDIA_DBR { +public: + MEDIA_DBR() { memset(this, 0, sizeof(MEDIA_DBR)); }; + ~MEDIA_DBR() { }; + void clear() { memset(this, 0, sizeof(MEDIA_DBR)); }; + void copy(MEDIA_DBR *omr) { memcpy(this, omr, sizeof(MEDIA_DBR)); }; + DBId_t MediaId; /* Unique volume id */ char VolumeName[MAX_NAME_LENGTH]; /* Volume name */ char MediaType[MAX_NAME_LENGTH]; /* Media type */ diff --git a/bacula/src/cats/sql_find.c b/bacula/src/cats/sql_find.c index d012d6e61b..a9b8020e0a 100644 --- a/bacula/src/cats/sql_find.c +++ b/bacula/src/cats/sql_find.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2010 Free Software Foundation Europe e.V. + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -381,7 +381,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr edit_int64(mr->PoolId, ed1), esc_type, esc_status, changer.c_str(), order, item); } - Dmsg1(050, "fnextvol=%s\n", mdb->cmd); + Dmsg1(100, "fnextvol=%s\n", mdb->cmd); if (!QUERY_DB(jcr, mdb, mdb->cmd)) { db_unlock(mdb); return 0; diff --git a/bacula/src/dird/admin.c b/bacula/src/dird/admin.c index fc41f78fac..18b4a860a2 100644 --- a/bacula/src/dird/admin.c +++ b/bacula/src/dird/admin.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2003-2007 Free Software Foundation Europe e.V. + Copyright (C) 2003-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -34,7 +34,6 @@ * Basic tasks done here: * Display the job report. * - * Version $Id$ */ #include "bacula.h" @@ -84,7 +83,6 @@ void admin_cleanup(JCR *jcr, int TermCode) MEDIA_DBR mr; Dmsg0(100, "Enter backup_cleanup()\n"); - memset(&mr, 0, sizeof(mr)); update_job_end(jcr, TermCode); diff --git a/bacula/src/dird/autoprune.c b/bacula/src/dird/autoprune.c index 86e5c7935e..737268768f 100644 --- a/bacula/src/dird/autoprune.c +++ b/bacula/src/dird/autoprune.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2002-2008 Free Software Foundation Europe e.V. + Copyright (C) 2002-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -32,7 +32,6 @@ * * Kern Sibbald, May MMII * - * Version $Id$ */ #include "bacula.h" @@ -85,7 +84,8 @@ void do_autoprune(JCR *jcr) * volume and no appendable volumes are available. * */ -void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr) +void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr, + STORE *store) { int count; int i; @@ -123,7 +123,7 @@ void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr) ed2[0] = 0; } - if(mr->ScratchPoolId) { + if (mr->ScratchPoolId) { edit_int64(mr->ScratchPoolId, ed3); bstrncat(ed2, ed3, sizeof(ed2)); bstrncat(ed2, ",", sizeof(ed2)); @@ -165,7 +165,6 @@ void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr) /* Visit each Volume and Prune it until we find one that is purged */ for (i=0; idb, &lmr)) { @@ -221,7 +220,8 @@ void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr) */ if (lmr.PoolId == mr->PoolId) { Dmsg2(100, "Got Vol=%s MediaId=%d purged.\n", lmr.VolumeName, (int)lmr.MediaId); - memcpy(mr, &lmr, sizeof(lmr)); + mr->copy(&lmr); + set_storageid_in_mr(store, mr); break; /* got a volume */ } } diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 8f0f7ec4e5..77a3845e2d 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2011 Free Software Foundation Europe e.V. + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -604,7 +604,6 @@ void backup_cleanup(JCR *jcr, int TermCode) } Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode); - memset(&mr, 0, sizeof(mr)); memset(&cr, 0, sizeof(cr)); #ifdef xxxx diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 14ef55d169..7d7b4d197f 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2010 Free Software Foundation Europe e.V. + Copyright (C) 2001-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -114,7 +114,6 @@ void catalog_request(JCR *jcr, BSOCK *bs) utime_t VolFirstWritten; utime_t VolLastWritten; - memset(&mr, 0, sizeof(mr)); memset(&sdmr, 0, sizeof(sdmr)); memset(&jm, 0, sizeof(jm)); Dsm_check(100); @@ -141,7 +140,7 @@ void catalog_request(JCR *jcr, BSOCK *bs) ok = db_get_pool_record(jcr, jcr->db, &pr); if (ok) { mr.PoolId = pr.PoolId; - mr.StorageId = jcr->wstore->StorageId; + set_storageid_in_mr(jcr->wstore, &mr); mr.ScratchPoolId = pr.ScratchPoolId; ok = find_next_volume_for_append(jcr, &mr, index, fnv_create_vol, fnv_prune); Dmsg3(050, "find_media ok=%d idx=%d vol=%s\n", ok, index, mr.VolumeName); @@ -276,20 +275,6 @@ 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 && 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")); - } else { - mr.StorageId = jcr->wstore->StorageId; - } - } /* Copy updated values to original media record */ mr.VolJobs = sdmr.VolJobs; @@ -310,6 +295,26 @@ 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 @@ -357,6 +362,7 @@ void catalog_request(JCR *jcr, BSOCK *bs) Jmsg1(jcr, M_FATAL, 0, _("Invalid Catalog request: %s"), omsg); free_memory(omsg); } + Dmsg1(400, ">CatReq response: %s", bs->msg); Dmsg1(400, "Leave catreq jcr 0x%x\n", jcr); return; diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 9f1667fc2c..c897b6e50c 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2010 Free Software Foundation Europe e.V. + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -1021,15 +1021,15 @@ static bool check_catalog(cat_op mode) STORE *store; foreach_res(store, R_STORAGE) { STORAGE_DBR sr; - MEDIATYPE_DBR mr; + MEDIATYPE_DBR mtr; memset(&sr, 0, sizeof(sr)); - memset(&mr, 0, sizeof(mr)); + memset(&mtr, 0, sizeof(mtr)); if (store->media_type) { - bstrncpy(mr.MediaType, store->media_type, sizeof(mr.MediaType)); - mr.ReadOnly = 0; - db_create_mediatype_record(NULL, db, &mr); + bstrncpy(mtr.MediaType, store->media_type, sizeof(mtr.MediaType)); + mtr.ReadOnly = 0; + db_create_mediatype_record(NULL, db, &mtr); } else { - mr.MediaTypeId = 0; + mtr.MediaTypeId = 0; } bstrncpy(sr.Name, store->name(), sizeof(sr.Name)); sr.AutoChanger = store->autochanger; diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index e355e7c68a..5193921145 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2004-2010 Free Software Foundation Europe e.V. + Copyright (C) 2004-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -1150,7 +1150,6 @@ void migration_cleanup(JCR *jcr, int TermCode) Dmsg2(100, "Enter migrate_cleanup %d %c\n", TermCode, TermCode); update_job_end(jcr, TermCode); - memset(&mr, 0, sizeof(mr)); /* * Check if we actually did something. diff --git a/bacula/src/dird/mountreq.c b/bacula/src/dird/mountreq.c index b577dd2f7f..35f57dfee8 100644 --- a/bacula/src/dird/mountreq.c +++ b/bacula/src/dird/mountreq.c @@ -1,21 +1,7 @@ -/* - * - * Bacula Director -- mountreq.c -- handles the message channel - * Mount request from the Storage daemon. - * - * Kern Sibbald, March MMI - * - * This routine runs as a thread and must be thread reentrant. - * - * Basic tasks done here: - * Handle Mount services. - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2006 Free Software Foundation Europe e.V. + Copyright (C) 2001-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -39,6 +25,19 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * + * Bacula Director -- mountreq.c -- handles the message channel + * Mount request from the Storage daemon. + * + * Kern Sibbald, March MMI + * + * This routine runs as a thread and must be thread reentrant. + * + * Basic tasks done here: + * Handle Mount services. + * + */ #include "bacula.h" #include "dird.h" @@ -69,15 +68,15 @@ typedef struct mnt_req_s { void mount_request(JCR *jcr, BSOCK *bs, char *buf) { - MNT_REQ *mr; + MNT_REQ *mreq; - mr = (MNT_REQ *) malloc(sizeof(MNT_REQ)); - memset(mr, 0, sizeof(MNT_REQ)); - mr->jcr = jcr; - mr->bs = bs; + mreq = (MNT_REQ *) malloc(sizeof(MNT_REQ)); + memset(mreq, 0, sizeof(MNT_REQ)); + mreq->jcr = jcr; + mreq->bs = bs; P(mutex); num_reqs++; - qinsert(&mountq, &mr->bq); + qinsert(&mountq, &mreq->bq); V(mutex); return; } diff --git a/bacula/src/dird/newvol.c b/bacula/src/dird/newvol.c index 2037ff4464..d1941cf771 100644 --- a/bacula/src/dird/newvol.c +++ b/bacula/src/dird/newvol.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2008 Free Software Foundation Europe e.V. + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -37,7 +37,6 @@ * Basic tasks done here: * If possible create a new Media entry * - * Version $Id$ */ #include "bacula.h" @@ -54,7 +53,7 @@ static bool perform_full_name_substitution(JCR *jcr, MEDIA_DBR *mr, POOL_DBR *pr * The media record must have the PoolId filled in when * calling this routine. */ -bool newVolume(JCR *jcr, MEDIA_DBR *mr) +bool newVolume(JCR *jcr, MEDIA_DBR *mr, STORE *store) { POOL_DBR pr; @@ -67,7 +66,7 @@ bool newVolume(JCR *jcr, MEDIA_DBR *mr) goto bail_out; } if (pr.MaxVols == 0 || pr.NumVols < pr.MaxVols) { - memset(mr, 0, sizeof(MEDIA_DBR)); + mr->clear(); set_pool_dbr_defaults_in_media_dbr(mr, &pr); jcr->VolumeName[0] = 0; bstrncpy(mr->MediaType, jcr->wstore->media_type, sizeof(mr->MediaType)); @@ -98,6 +97,7 @@ bool newVolume(JCR *jcr, MEDIA_DBR *mr) } pr.NumVols++; mr->Enabled = 1; + set_storageid_in_mr(store, mr); if (db_create_media_record(jcr, jcr->db, mr) && db_update_pool_record(jcr, jcr->db, &pr)) { db_unlock(jcr->db); @@ -133,7 +133,6 @@ static bool create_simple_name(JCR *jcr, MEDIA_DBR *mr, POOL_DBR *pr) } for (int i=(int)ctx.value+1; i<(int)ctx.value+100; i++) { MEDIA_DBR tmr; - memset(&tmr, 0, sizeof(tmr)); sprintf(num, "%04d", i); bstrncpy(tmr.VolumeName, name, sizeof(tmr.VolumeName)); bstrncat(tmr.VolumeName, num, sizeof(tmr.VolumeName)); diff --git a/bacula/src/dird/next_vol.c b/bacula/src/dird/next_vol.c index cb4a3397e3..ebae0779e9 100644 --- a/bacula/src/dird/next_vol.c +++ b/bacula/src/dird/next_vol.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2010 Free Software Foundation Europe e.V. + Copyright (C) 2001-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -40,10 +40,17 @@ static int const dbglvl = 50; /* debug level */ +/* Set storage id if possible */ +void set_storageid_in_mr(STORE *store, MEDIA_DBR *mr) +{ + if (store != NULL) { + mr->StorageId = store->StorageId; + } +} + /* * Items needed: * mr.PoolId must be set - * mr.StorageId should also be set * mr.ScratchPoolId could be set (used if create==true) * jcr->wstore * jcr->db @@ -76,37 +83,45 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, /* * 1. Look for volume with "Append" status. */ + set_storageid_in_mr(store, mr); /* put StorageId in new record */ ok = db_find_next_volume(jcr, jcr->db, index, InChanger, mr); if (!ok) { + /* + * No volume found, apply algorithm + */ Dmsg4(dbglvl, "after find_next_vol ok=%d index=%d InChanger=%d Vstat=%s\n", ok, index, InChanger, mr->VolStatus); /* * 2. Try finding a recycled volume */ - ok = find_recycled_volume(jcr, InChanger, mr); + ok = find_recycled_volume(jcr, InChanger, mr, store); + set_storageid_in_mr(store, mr); /* put StorageId in new record */ Dmsg2(dbglvl, "find_recycled_volume ok=%d FW=%d\n", ok, mr->FirstWritten); if (!ok) { /* * 3. Try recycling any purged volume */ - ok = recycle_oldest_purged_volume(jcr, InChanger, mr); + ok = recycle_oldest_purged_volume(jcr, InChanger, mr, store); + set_storageid_in_mr(store, mr); /* put StorageId in new record */ if (!ok) { /* * 4. Try pruning Volumes */ if (prune) { Dmsg0(dbglvl, "Call prune_volumes\n"); - prune_volumes(jcr, InChanger, mr); + prune_volumes(jcr, InChanger, mr, store); } - ok = recycle_oldest_purged_volume(jcr, InChanger, mr); + ok = recycle_oldest_purged_volume(jcr, InChanger, mr, store); + set_storageid_in_mr(store, mr); /* put StorageId in new record */ if (!ok && create) { Dmsg4(dbglvl, "after prune volumes_vol ok=%d index=%d InChanger=%d Vstat=%s\n", ok, index, InChanger, mr->VolStatus); /* * 5. Try pulling a volume from the Scratch pool */ - ok = get_scratch_volume(jcr, InChanger, mr); + ok = get_scratch_volume(jcr, InChanger, mr, store); + set_storageid_in_mr(store, mr); /* put StorageId in new record */ Dmsg4(dbglvl, "after get scratch volume ok=%d index=%d InChanger=%d Vstat=%s\n", ok, index, InChanger, mr->VolStatus); } @@ -126,7 +141,7 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, /* * 6. Try "creating" a new Volume */ - ok = newVolume(jcr, mr); + ok = newVolume(jcr, mr, store); } /* * Look at more drastic ways to find an Appendable Volume @@ -136,7 +151,9 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, Dmsg2(dbglvl, "No next volume found. PurgeOldest=%d\n RecyleOldest=%d", jcr->pool->purge_oldest_volume, jcr->pool->recycle_oldest_volume); /* Find oldest volume to recycle */ + set_storageid_in_mr(store, mr); /* update storage id */ ok = db_find_next_volume(jcr, jcr->db, -1, InChanger, mr); + set_storageid_in_mr(store, mr); /* update storageid */ Dmsg1(dbglvl, "Find oldest=%d Volume\n", ok); if (ok && prune) { UAContext *ua; @@ -245,6 +262,7 @@ bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr) if (expired) { /* Need to update media */ Dmsg1(dbglvl, "Vol=%s has expired update media record\n", mr->VolumeName); + set_storageid_in_mr(NULL, mr); if (!db_update_media_record(jcr, jcr->db, mr)) { Jmsg(jcr, M_ERROR, 0, _("Catalog error updating volume \"%s\". ERR=%s"), mr->VolumeName, db_strerror(jcr->db)); @@ -346,7 +364,8 @@ void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **r static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) +bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr, + STORE *store) { MEDIA_DBR smr; /* for searching scratch pool */ POOL_DBR spr, pr; @@ -365,7 +384,6 @@ bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) bstrncpy(spr.Name, "Scratch", sizeof(spr.Name)); spr.PoolId = mr->ScratchPoolId; if (db_get_pool_record(jcr, jcr->db, &spr)) { - memset(&smr, 0, sizeof(smr)); smr.PoolId = spr.PoolId; if (InChanger) { smr.StorageId = mr->StorageId; /* want only Scratch Volumes in changer */ @@ -378,13 +396,14 @@ bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) * recycling any existing purged volumes, then * try to take the oldest volume. */ + set_storageid_in_mr(store, &smr); /* put StorageId in new record */ if (db_find_next_volume(jcr, jcr->db, 1, InChanger, &smr)) { found = true; - } else if (find_recycled_volume(jcr, InChanger, &smr)) { + } else if (find_recycled_volume(jcr, InChanger, &smr, store)) { found = true; - } else if (recycle_oldest_purged_volume(jcr, InChanger, &smr)) { + } else if (recycle_oldest_purged_volume(jcr, InChanger, &smr, store)) { found = true; } @@ -411,7 +430,8 @@ bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) goto bail_out; } - memcpy(mr, &smr, sizeof(MEDIA_DBR)); + mr->copy(&smr); + set_storageid_in_mr(store, mr); /* Set default parameters from current pool */ set_pool_dbr_defaults_in_media_dbr(mr, &pr); diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index ee8ddad939..cd913c8df3 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2010 Free Software Foundation Europe e.V. + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -42,12 +42,16 @@ extern int authenticate_user_agent(UAContext *ua); /* autoprune.c */ extern void do_autoprune(JCR *jcr); -extern void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr); +extern void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr, + STORE *store); /* autorecycle.c */ -extern bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr); +extern bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, + MEDIA_DBR *mr, STORE *store); + extern int recycle_volume(JCR *jcr, MEDIA_DBR *mr); -extern bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr); +extern bool find_recycled_volume(JCR *jcr, bool InChanger, + MEDIA_DBR *mr, STORE *store); /* backup.c */ extern int wait_for_job_termination(JCR *jcr, int timeout=0); @@ -168,14 +172,16 @@ extern void wait_for_storage_daemon_termination(JCR *jcr); extern bool send_bootstrap_file(JCR *jcr, BSOCK *sd); /* next_vol.c */ +void set_storageid_in_mr(STORE *store, MEDIA_DBR *mr); int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create, bool purge); bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr); void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **reason); -bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr); +bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr, + STORE *store); /* newvol.c */ -bool newVolume(JCR *jcr, MEDIA_DBR *mr); +bool newVolume(JCR *jcr, MEDIA_DBR *mr, STORE *store); /* python.c */ int generate_job_event(JCR *jcr, const char *event); diff --git a/bacula/src/dird/pythondir.c b/bacula/src/dird/pythondir.c index d36b6afaae..1782e7fae4 100644 --- a/bacula/src/dird/pythondir.c +++ b/bacula/src/dird/pythondir.c @@ -381,7 +381,6 @@ static PyObject *job_does_vol_exist(PyObject *self, PyObject *args) MEDIA_DBR mr; int ok; JCR *jcr = get_jcr_from_PyObject(self); - memset(&mr, 0, sizeof(mr)); bstrncpy(mr.VolumeName, VolName, sizeof(mr.VolumeName)); ok = db_get_media_record(jcr, jcr->db, &mr); return Py_BuildValue("i", ok); diff --git a/bacula/src/dird/recycle.c b/bacula/src/dird/recycle.c index 3e8e4944ce..4ceaf0b4c6 100644 --- a/bacula/src/dird/recycle.c +++ b/bacula/src/dird/recycle.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2002-2008 Free Software Foundation Europe e.V. + Copyright (C) 2002-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -32,7 +32,6 @@ * * Kern Sibbald, May MMII * - * Version $Id$ */ @@ -42,13 +41,16 @@ /* Forward referenced functions */ -bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) +bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr, + STORE *store) { bstrncpy(mr->VolStatus, "Recycle", sizeof(mr->VolStatus)); + set_storageid_in_mr(store, mr); if (db_find_next_volume(jcr, jcr->db, 1, InChanger, mr)) { jcr->MediaId = mr->MediaId; Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->MediaId); pm_strcpy(jcr->VolumeName, mr->VolumeName); + set_storageid_in_mr(store, mr); return true; } return false; @@ -57,10 +59,12 @@ bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) /* * Look for oldest Purged volume */ -bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) +bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, + MEDIA_DBR *mr, STORE *store) { bstrncpy(mr->VolStatus, "Purged", sizeof(mr->VolStatus)); if (db_find_next_volume(jcr, jcr->db, 1, InChanger, mr)) { + set_storageid_in_mr(store, mr); if (recycle_volume(jcr, mr)) { Jmsg(jcr, M_INFO, 0, _("Recycled volume \"%s\"\n"), mr->VolumeName); Dmsg1(100, "return 1 recycle_oldest_purged_volume Vol=%s\n", mr->VolumeName); @@ -82,5 +86,6 @@ int recycle_volume(JCR *jcr, MEDIA_DBR *mr) mr->FirstWritten = mr->LastWritten = 0; mr->RecycleCount++; mr->set_first_written = true; + set_storageid_in_mr(NULL, mr); return db_update_media_record(jcr, jcr->db, mr); } diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 9ac584c70c..75b049bc43 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2011 Free Software Foundation Europe e.V. + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -294,7 +294,6 @@ static int add_cmd(UAContext *ua, const char *cmd) } memset(&pr, 0, sizeof(pr)); - memset(&mr, 0, sizeof(mr)); if (!get_pool_dbr(ua, &pr)) { return 1; @@ -398,8 +397,8 @@ static int add_cmd(UAContext *ua, const char *cmd) bsnprintf(mr.VolumeName, sizeof(mr.VolumeName), name, i); mr.Slot = Slot++; mr.InChanger = InChanger; - mr.StorageId = store->StorageId; mr.Enabled = 1; + set_storageid_in_mr(store, &mr); Dmsg1(200, "Create Volume %s\n", mr.VolumeName); if (!db_create_media_record(ua->jcr, ua->db, &mr)) { ua->error_msg("%s", db_strerror(ua->db)); diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index 8cf3592355..84ab3fe79d 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2003-2011 Free Software Foundation Europe e.V. + Copyright (C) 2003-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -243,11 +243,11 @@ void update_slots(UAContext *ua) Dmsg2(100, "Got Vol=%s from SD for Slot=%d\n", vl->VolName, vl->Slot); } slot_list[vl->Slot] = 0; /* clear Slot */ - memset(&mr, 0, sizeof(mr)); mr.Slot = vl->Slot; mr.InChanger = 1; - mr.StorageId = store.store->StorageId; + set_storageid_in_mr(store.store, &mr); /* Set InChanger to zero for this Slot */ + /**** ***FIXME**** */ db_lock(ua->db); db_make_inchanger_unique(ua->jcr, ua->db, &mr); db_unlock(ua->db); @@ -256,17 +256,16 @@ void update_slots(UAContext *ua) ua->info_msg(_("No VolName for Slot=%d InChanger set to zero.\n"), vl->Slot); continue; } - memset(&mr, 0, sizeof(mr)); - bstrncpy(mr.VolumeName, vl->VolName, sizeof(mr.VolumeName)); db_lock(ua->db); + bstrncpy(mr.VolumeName, vl->VolName, sizeof(mr.VolumeName)); if (db_get_media_record(ua->jcr, ua->db, &mr)) { if (mr.Slot != vl->Slot || !mr.InChanger || mr.StorageId != store.store->StorageId) { mr.Slot = vl->Slot; mr.InChanger = 1; - mr.StorageId = store.store->StorageId; if (have_enabled) { mr.Enabled = Enabled; } + set_storageid_in_mr(store.store, &mr); if (!db_update_media_record(ua->jcr, ua->db, &mr)) { ua->error_msg("%s", db_strerror(ua->db)); } else { @@ -286,9 +285,9 @@ void update_slots(UAContext *ua) } db_unlock(ua->db); } - memset(&mr, 0, sizeof(mr)); + mr.clear(); mr.InChanger = 1; - mr.StorageId = store.store->StorageId; + set_storageid_in_mr(store.store, &mr); db_lock(ua->db); for (int i=1; i <= max_slots; i++) { if (slot_list[i]) { @@ -363,7 +362,6 @@ static int do_label(UAContext *ua, const char *cmd, int relabel) /* Check for oldvolume=name */ i = find_arg_with_value(ua, "oldvolume"); if (i >= 0) { - memset(&omr, 0, sizeof(omr)); bstrncpy(omr.VolumeName, ua->argv[i], sizeof(omr.VolumeName)); if (db_get_media_record(ua->jcr, ua->db, &omr)) { goto checkVol; @@ -402,7 +400,6 @@ checkName: continue; } - memset(&mr, 0, sizeof(mr)); bstrncpy(mr.VolumeName, ua->cmd, sizeof(mr.VolumeName)); /* If VolBytes are zero the Volume is not labeled */ if (db_get_media_record(ua->jcr, ua->db, &mr)) { @@ -434,7 +431,7 @@ checkName: } mr.InChanger = mr.Slot > 0; /* if slot give assume in changer */ } - mr.StorageId = store.store->StorageId; + set_storageid_in_mr(store.store, &mr); bstrncpy(mr.MediaType, store.store->media_type, sizeof(mr.MediaType)); @@ -547,14 +544,13 @@ static void label_from_barcodes(UAContext *ua, int drive) if (!select_pool_dbr(ua, &pr)) { goto bail_out; } - memset(&omr, 0, sizeof(omr)); /* Fire off the label requests */ for (vl=vol_list; vl; vl=vl->next) { if (!vl->VolName || !slot_list[vl->Slot]) { continue; } - memset(&mr, 0, sizeof(mr)); + mr.clear(); bstrncpy(mr.VolumeName, vl->VolName, sizeof(mr.VolumeName)); media_record_exists = false; if (db_get_media_record(ua->jcr, ua->db, &mr)) { @@ -563,7 +559,7 @@ static void label_from_barcodes(UAContext *ua, int drive) vl->Slot, mr.VolumeName); mr.Slot = vl->Slot; mr.InChanger = mr.Slot > 0; /* if slot give assume in changer */ - mr.StorageId = store->StorageId; + set_storageid_in_mr(store, &mr); if (!db_update_media_record(ua->jcr, ua->db, &mr)) { ua->error_msg(_("Error setting InChanger: ERR=%s"), db_strerror(ua->db)); } @@ -572,7 +568,7 @@ static void label_from_barcodes(UAContext *ua, int drive) media_record_exists = true; } mr.InChanger = mr.Slot > 0; /* if slot give assume in changer */ - mr.StorageId = store->StorageId; + set_storageid_in_mr(store, &mr); /* * Deal with creating cleaning tape here. Normal tapes created in * send_label_request() below @@ -582,7 +578,7 @@ static void label_from_barcodes(UAContext *ua, int drive) mr.VolBytes = 1; /* any bytes to indicate it exists */ bstrncpy(mr.VolStatus, "Cleaning", sizeof(mr.VolStatus)); mr.MediaType[0] = 0; - mr.StorageId = store->StorageId; + set_storageid_in_mr(store, &mr); if (!db_update_media_record(ua->jcr, ua->db, &mr)) { ua->error_msg("%s", db_strerror(ua->db)); } @@ -594,6 +590,7 @@ static void label_from_barcodes(UAContext *ua, int drive) set_pool_dbr_defaults_in_media_dbr(&mr, &pr); bstrncpy(mr.VolStatus, "Cleaning", sizeof(mr.VolStatus)); mr.MediaType[0] = 0; + set_storageid_in_mr(store, &mr); if (db_create_media_record(ua->jcr, ua->db, &mr)) { ua->send_msg(_("Catalog record for cleaning tape \"%s\" successfully created.\n"), mr.VolumeName); @@ -721,7 +718,7 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, if (media_record_exists) { /* we update it */ mr->VolBytes = VolBytes; mr->InChanger = mr->Slot > 0; /* if slot give assume in changer */ - mr->StorageId = ua->jcr->wstore->StorageId; + set_storageid_in_mr(ua->jcr->wstore, mr); if (!db_update_media_record(ua->jcr, ua->db, mr)) { ua->error_msg("%s", db_strerror(ua->db)); ok = false; @@ -730,8 +727,8 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, set_pool_dbr_defaults_in_media_dbr(mr, pr); mr->VolBytes = VolBytes; mr->InChanger = mr->Slot > 0; /* if slot give assume in changer */ - mr->StorageId = ua->jcr->wstore->StorageId; mr->Enabled = 1; + set_storageid_in_mr(ua->jcr->wstore, mr); if (db_create_media_record(ua->jcr, ua->db, mr)) { ua->info_msg(_("Catalog record for Volume \"%s\", Slot %d successfully created.\n"), mr->VolumeName, mr->Slot); @@ -1041,7 +1038,6 @@ static void content_send_info(UAContext *ua, char type, int Slot, char *vol_name const char *slot_api_empty_format="%c|%i||||||||\n"; if (is_volume_name_legal(NULL, vol_name)) { - memset(&mr, 0, sizeof(mr)); bstrncpy(mr.VolumeName, vol_name, sizeof(mr.VolumeName)); if (db_get_media_record(ua->jcr, ua->db, &mr)) { memset(&pr, 0, sizeof(POOL_DBR)); @@ -1268,7 +1264,6 @@ void status_slots(UAContext *ua, STORE *store_r) } } - memset(&mr, 0, sizeof(mr)); bstrncpy(mr.VolumeName, vl->VolName, sizeof(mr.VolumeName)); db_lock(ua->db); if (mr.VolumeName[0] && db_get_media_record(ua->jcr, ua->db, &mr)) { diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 8c5a448ef4..d7e93d0795 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2009 Free Software Foundation Europe e.V. + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -280,7 +280,6 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) memset(&jr, 0, sizeof(jr)); memset(&pr, 0, sizeof(pr)); - memset(&mr, 0, sizeof(mr)); Dmsg1(20, "list: %s\n", cmd); @@ -536,7 +535,6 @@ static bool list_nextvol(UAContext *ua, int ndays) MEDIA_DBR mr; POOL_DBR pr; - memset(&mr, 0, sizeof(mr)); int i = find_arg_with_value(ua, "job"); if (i <= 0) { if ((job = select_job_resource(ua)) == NULL) { @@ -569,7 +567,7 @@ static bool list_nextvol(UAContext *ua, int ndays) } mr.PoolId = jcr->jr.PoolId; get_job_storage(&store, job, run); - mr.StorageId = store.store->StorageId; + set_storageid_in_mr(store.store, &mr); /* no need to set ScratchPoolId, since we use fnv_no_create_vol */ if (!find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_prune)) { ua->error_msg(_("Could not find next Volume for Job %s (Pool=%s, Level=%s).\n"), diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index 81c7ed493b..550ab37c38 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2002-2010 Free Software Foundation Europe e.V. + Copyright (C) 2002-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -618,6 +618,7 @@ static void do_truncate_on_purge(UAContext *ua, MEDIA_DBR *mr, if (ok) { mr->VolBytes = VolBytes; mr->VolFiles = 0; + set_storageid_in_mr(NULL, mr); if (!db_update_media_record(ua->jcr, ua->db, mr)) { ua->error_msg(_("Can't update volume size in the catalog\n")); } @@ -645,7 +646,6 @@ static int action_on_purge_cmd(UAContext *ua, const char *cmd) BSOCK *sd = NULL; memset(&pr, 0, sizeof(pr)); - memset(&mr, 0, sizeof(mr)); /* Look at arguments */ for (int i=1; iargc; i++) { @@ -674,7 +674,6 @@ static int action_on_purge_cmd(UAContext *ua, const char *cmd) if (!store) { goto bail_out; } - mr.StorageId = store->StorageId; if (!open_db(ua)) { Dmsg0(100, "Can't open db\n"); @@ -703,6 +702,7 @@ static int action_on_purge_cmd(UAContext *ua, const char *cmd) mr.Recycle = 1; mr.Enabled = 1; mr.VolBytes = 10000; + set_storageid_in_mr(store, &mr); bstrncpy(mr.VolStatus, "Purged", sizeof(mr.VolStatus)); if (!db_get_media_ids(ua->jcr, ua->db, &mr, &nb, &results)) { Dmsg0(100, "No results from db_get_media_ids\n"); @@ -723,7 +723,7 @@ static int action_on_purge_cmd(UAContext *ua, const char *cmd) * Loop over the candidate Volumes and actually truncate them */ for (int i=0; i < nb; i++) { - memset(&mr, 0, sizeof(mr)); + mr.clear(); mr.MediaId = results[i]; if (db_get_media_record(ua->jcr, ua->db, &mr)) { /* TODO: ask for drive and change Pool */ @@ -762,6 +762,7 @@ bool mark_media_purged(UAContext *ua, MEDIA_DBR *mr) strcmp(mr->VolStatus, "Used") == 0 || strcmp(mr->VolStatus, "Error") == 0) { bstrncpy(mr->VolStatus, "Purged", sizeof(mr->VolStatus)); + set_storageid_in_mr(NULL, mr); if (!db_update_media_record(jcr, ua->db, mr)) { return false; } diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index 5db0551d19..ffe1baac55 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2009 Free Software Foundation Europe e.V. + Copyright (C) 2001-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -602,8 +602,7 @@ int select_media_dbr(UAContext *ua, MEDIA_DBR *mr) POOLMEM *err = get_pool_memory(PM_FNAME); *err=0; - memset(mr, 0, sizeof(MEDIA_DBR)); - + mr->clear(); i = find_arg_with_value(ua, "volume"); if (i >= 0) { if (is_name_valid(ua->argv[i], &err)) { diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 3c5822935d..c2a2053e75 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2011 Free Software Foundation Europe e.V. + Copyright (C) 2001-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -453,7 +453,6 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp) int orig_jobtype; orig_jobtype = jcr->getJobType(); - memset(&mr, 0, sizeof(mr)); if (sp->job->JobType == JT_BACKUP) { jcr->db = NULL; ok = complete_jcr_for_job(jcr, sp->job, sp->pool); @@ -463,8 +462,8 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp) } if (ok) { mr.PoolId = jcr->jr.PoolId; - mr.StorageId = sp->store->StorageId; jcr->wstore = sp->store; + set_storageid_in_mr(jcr->wstore, &mr); Dmsg0(250, "call find_next_volume_for_append\n"); /* no need to set ScratchPoolId, since we use fnv_no_create_vol */ ok = find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_no_prune); diff --git a/bacula/src/dird/ua_update.c b/bacula/src/dird/ua_update.c index 44c2442ea5..7433147cbb 100644 --- a/bacula/src/dird/ua_update.c +++ b/bacula/src/dird/ua_update.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2010 Free Software Foundation Europe e.V. + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -299,6 +299,7 @@ static void update_volslot(UAContext *ua, char *val, MEDIA_DBR *mr) * Make sure to use db_update... rather than doing this directly, * so that any Slot is handled correctly. */ + set_storageid_in_mr(NULL, mr); if (!db_update_media_record(ua->jcr, ua->db, mr)) { ua->error_msg(_("Error updating media record Slot: ERR=%s"), db_strerror(ua->db)); } else { @@ -407,7 +408,6 @@ static void update_all_vols_from_pool(UAContext *ua, const char *pool_name) MEDIA_DBR mr; memset(&pr, 0, sizeof(pr)); - memset(&mr, 0, sizeof(mr)); bstrncpy(pr.Name, pool_name, sizeof(pr.Name)); if (!get_pool_dbr(ua, &pr)) { @@ -431,7 +431,6 @@ static void update_all_vols(UAContext *ua) MEDIA_DBR mr; memset(&pr, 0, sizeof(pr)); - memset(&mr, 0, sizeof(mr)); if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) { ua->error_msg(_("Error obtaining pool ids. ERR=%s\n"), db_strerror(ua->db)); @@ -465,6 +464,7 @@ static void update_volenabled(UAContext *ua, char *val, MEDIA_DBR *mr) if (mr->Enabled < 0) { return; } + set_storageid_in_mr(NULL, mr); if (!db_update_media_record(ua->jcr, ua->db, mr)) { ua->error_msg(_("Error updating media record Enabled: ERR=%s"), db_strerror(ua->db)); @@ -482,6 +482,7 @@ static void update_vol_actiononpurge(UAContext *ua, char *val, MEDIA_DBR *mr) mr->ActionOnPurge = 0; } + set_storageid_in_mr(NULL, mr); if (!db_update_media_record(ua->jcr, ua->db, mr)) { ua->error_msg(_("Error updating media record ActionOnPurge: ERR=%s"), db_strerror(ua->db)); @@ -722,6 +723,7 @@ static int update_volume(UAContext *ua) * Make sure to use db_update... rather than doing this directly, * so that any Slot is handled correctly. */ + set_storageid_in_mr(NULL, &mr); if (!db_update_media_record(ua->jcr, ua->db, &mr)) { ua->error_msg(_("Error updating media record Slot: ERR=%s"), db_strerror(ua->db)); } else { diff --git a/bacula/src/dird/vbackup.c b/bacula/src/dird/vbackup.c index 59c33efb6f..f24f9d61b2 100644 --- a/bacula/src/dird/vbackup.c +++ b/bacula/src/dird/vbackup.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2008-2011 Free Software Foundation Europe e.V. + Copyright (C) 2008-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -282,7 +282,6 @@ void vbackup_cleanup(JCR *jcr, int TermCode) POOL_MEM query(PM_MESSAGE); Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode); - memset(&mr, 0, sizeof(mr)); memset(&cr, 0, sizeof(cr)); jcr->setJobLevel(L_FULL); /* we want this to appear as a Full backup */ -- 2.39.5