From: Kern Sibbald Date: Sat, 24 Jun 2006 07:53:36 +0000 (+0000) Subject: - ========= Remove Accept Any Volume ========= directive. X-Git-Tag: Release-2.0.0~826 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6d08fc344f5dac7f1291ff116f621ffc51ae1346;p=bacula%2Fbacula - ========= Remove Accept Any Volume ========= directive. - Major cleanup and simplification of regress using shell functions (more tests to be converted to new format) - Add detection of 64 bit Irix as indicated by user. - Increment catalog database id from 9 to 10. - Add a few of the new database fields to the various C++ structures. - Implement code to fill in the most important new fields (e.g. Media Enable). - Ensure that most of the new fields are in create/get/insert/update. More work to be done. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3067 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/autoconf/bacula-macros/os.m4 b/bacula/autoconf/bacula-macros/os.m4 index 0b1a3573c9..25cfc69b65 100644 --- a/bacula/autoconf/bacula-macros/os.m4 +++ b/bacula/autoconf/bacula-macros/os.m4 @@ -134,7 +134,7 @@ else BA_CONDITIONAL(HAVE_SGI_OS, $FALSEPRG) fi -if test $HAVE_UNAME=yes -a x`uname -s` = xIRIX +if test $HAVE_UNAME=yes -a x`uname -s` = xIRIX -o x`uname -s` = xIRIX64 then BA_CONDITIONAL(HAVE_IRIX_OS, $TRUEPRG) AC_DEFINE(HAVE_IRIX_OS) diff --git a/bacula/kernstodo b/bacula/kernstodo index 7f1169c55f..af6ae94c72 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -42,6 +42,17 @@ For 1.39: Volume marked as purged. - Print warning message if LANG environment variable does not specify UTF-8. +- New dot commands from Arno. + .update volume [enabled|disabled|*see below] + .show device=xxx lists information from one storage device, including + devices (I'm not even sure that information exists in the DIR...) + .move eject device=xxx mostly the same as 'unmount xxx' but perhaps with + better machine-readable output like "Ok" or "Error busy" + .move eject device=xxx toslot=yyy the same as above, but with a new + target slot. The catalog should be updated accordingly. + .move transfer device=xxx fromslot=yyy toslot=zzz + + === Migration from David === What I'd like to see: diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index 8570c3da75..750b5d8616 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -2,6 +2,18 @@ Kern Sibbald General: +24Jun06 +- ========= Remove Accept Any Volume ========= directive. +- Major cleanup and simplification of regress using shell functions + (more tests to be converted to new format) +- Add detection of 64 bit Irix as indicated by user. +- Increment catalog database id from 9 to 10. +- Add a few of the new database fields to the various C++ + structures. +- Implement code to fill in the most important new fields (e.g. + Media Enable). +- Ensure that most of the new fields are in create/get/insert/update. + More work to be done. 22Jun06 - Update some very old licenses in src/cats. - Modify the database format for handling Migration jobs: diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index 598d514a05..c4766fc55c 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -67,7 +67,7 @@ typedef int (DB_RESULT_HANDLER)(void *, int, char **); #ifdef HAVE_SQLITE -#define BDB_VERSION 9 +#define BDB_VERSION 10 #include @@ -175,7 +175,7 @@ SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb); #ifdef HAVE_SQLITE3 -#define BDB_VERSION 9 +#define BDB_VERSION 10 #include @@ -290,7 +290,7 @@ SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb); #ifdef HAVE_MYSQL -#define BDB_VERSION 9 +#define BDB_VERSION 10 #include @@ -355,7 +355,7 @@ struct B_DB { #ifdef HAVE_POSTGRESQL -#define BDB_VERSION 9 +#define BDB_VERSION 10 #include @@ -564,6 +564,7 @@ struct JOB_DBR { char cSchedTime[MAX_TIME_LENGTH]; char cStartTime[MAX_TIME_LENGTH]; char cEndTime[MAX_TIME_LENGTH]; + char cRealEndTime[MAX_TIME_LENGTH]; /* Extra stuff not in DB */ int limit; /* limit records to display */ faddr_t rec_addr; @@ -703,9 +704,10 @@ struct MEDIA_DBR { char VolumeName[MAX_NAME_LENGTH]; /* Volume name */ char MediaType[MAX_NAME_LENGTH]; /* Media type */ DBId_t PoolId; /* Pool id */ - time_t FirstWritten; /* Time Volume first written */ + time_t FirstWritten; /* Time Volume first written this usage */ time_t LastWritten; /* Time Volume last written */ time_t LabelDate; /* Date/Time Volume labeled */ + time_t InitialWrite; /* Date/Time Volume first written */ int32_t LabelType; /* Label (Bacula/ANSI/IBM) */ uint32_t VolJobs; /* number of jobs on this medium */ uint32_t VolFiles; /* Number of files */ @@ -726,16 +728,17 @@ struct MEDIA_DBR { uint32_t MaxVolFiles; /* Max files on Volume */ int32_t Recycle; /* recycle yes/no */ int32_t Slot; /* slot in changer */ + int32_t Enabled; /* 0=disabled, 1=enabled, 2=archived */ int32_t InChanger; /* Volume currently in changer */ DBId_t StorageId; /* Storage record Id */ uint32_t EndFile; /* Last file on volume */ uint32_t EndBlock; /* Last block on volume */ + uint32_t RecycleCount; /* Number of times recycled */ char VolStatus[20]; /* Volume status */ DBId_t DeviceId; /* Device where Vol last written */ DBId_t LocationId; /* Where Volume is -- user defined */ DBId_t ScratchPoolId; /* Where to move if scratch */ DBId_t RecyclePoolId; /* Where to move when recycled */ - int32_t Enabled; /* disabled=0, enabled=1, archived=2 */ /* Extra stuff not in DB */ faddr_t rec_addr; /* found record address */ /* Since the database returns times as strings, this is how we pass @@ -744,6 +747,7 @@ struct MEDIA_DBR { char cFirstWritten[MAX_TIME_LENGTH]; /* FirstWritten returned from DB */ char cLastWritten[MAX_TIME_LENGTH]; /* LastWritten returned from DB */ char cLabelDate[MAX_TIME_LENGTH]; /* LabelData returned from DB */ + char cInitialWrite[MAX_TIME_LENGTH]; /* InitialWrite returned from DB */ bool set_first_written; bool set_label_date; }; diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index 1baf407e19..541e2d8863 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -306,7 +306,7 @@ CREATE TABLE Version ( ); -- Initialize Version -INSERT INTO Version (VersionId) VALUES (9); +INSERT INTO Version (VersionId) VALUES (10); END-OF-DATA then diff --git a/bacula/src/cats/make_postgresql_tables.in b/bacula/src/cats/make_postgresql_tables.in index 13d14d4255..37fb52813e 100644 --- a/bacula/src/cats/make_postgresql_tables.in +++ b/bacula/src/cats/make_postgresql_tables.in @@ -156,7 +156,7 @@ CREATE TABLE media endfile integer not null default 0, endblock bigint not null default 0, LocationId integer default 0, - recyclcount integer not null default 0, + recyclecount integer not null default 0, initialwrite timestamp without time zone, scratchpoolid integer default 0, recyclepoolid integer default 0, @@ -336,7 +336,7 @@ INSERT INTO Status (JobStatus,JobStatusLong) VALUES ('p', 'Waiting on higher priority jobs'); -INSERT INTO Version (VersionId) VALUES (9); +INSERT INTO Version (VersionId) VALUES (10); -- Make sure we have appropriate permissions diff --git a/bacula/src/cats/make_sqlite3_tables.in b/bacula/src/cats/make_sqlite3_tables.in index a70a8fcc95..12c635fd55 100644 --- a/bacula/src/cats/make_sqlite3_tables.in +++ b/bacula/src/cats/make_sqlite3_tables.in @@ -325,7 +325,7 @@ INSERT INTO Status (JobStatus,JobStatusLong) VALUES -- Initialize Version -INSERT INTO Version (VersionId) VALUES (9); +INSERT INTO Version (VersionId) VALUES (10); PRAGMA default_synchronous = OFF; diff --git a/bacula/src/cats/make_sqlite_tables.in b/bacula/src/cats/make_sqlite_tables.in index a70a8fcc95..12c635fd55 100644 --- a/bacula/src/cats/make_sqlite_tables.in +++ b/bacula/src/cats/make_sqlite_tables.in @@ -325,7 +325,7 @@ INSERT INTO Status (JobStatus,JobStatusLong) VALUES -- Initialize Version -INSERT INTO Version (VersionId) VALUES (9); +INSERT INTO Version (VersionId) VALUES (10); PRAGMA default_synchronous = OFF; diff --git a/bacula/src/cats/sql_find.c b/bacula/src/cats/sql_find.c index 92f6a2bd22..e11a0e0c5f 100644 --- a/bacula/src/cats/sql_find.c +++ b/bacula/src/cats/sql_find.c @@ -277,7 +277,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr "FirstWritten,LastWritten,VolStatus,InChanger,VolParts," "LabelType " "FROM Media WHERE PoolId=%s AND MediaType='%s' AND VolStatus IN ('Full'," - "'Recycle','Purged','Used','Append') " + "'Recycle','Purged','Used','Append') AND Enabled=1 " "ORDER BY LastWritten LIMIT 1", edit_int64(mr->PoolId, ed1), mr->MediaType); item = 1; @@ -301,12 +301,14 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot," "FirstWritten,LastWritten,VolStatus,InChanger,VolParts," "LabelType " - "FROM Media WHERE PoolId=%s AND MediaType='%s' AND VolStatus='%s' " + "FROM Media WHERE PoolId=%s AND MediaType='%s' AND Enabled=1 " + "AND VolStatus='%s' " "%s " "%s LIMIT %d", edit_int64(mr->PoolId, ed1), mr->MediaType, mr->VolStatus, changer, order, item); } + Dmsg1(100, "fnextvol=%s\n", mdb->cmd); if (!QUERY_DB(jcr, mdb, mdb->cmd)) { db_unlock(mdb); return 0; @@ -361,6 +363,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr mr->InChanger = str_to_int64(row[20]); mr->VolParts = str_to_int64(row[21]); mr->LabelType = str_to_int64(row[22]); + mr->Enabled = 1; /* ensured via query */ sql_free_result(mdb); db_unlock(mdb); diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index 567a18cd13..4068dfbaec 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -274,7 +274,7 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) } else { Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime," "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus," -"Type,Level,ClientId,Name " +"Type,Level,ClientId,Name,PriorJobId,RealEndTime " "FROM Job WHERE JobId=%s", edit_int64(jr->JobId, ed1)); } @@ -304,6 +304,8 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) jr->JobLevel = (int)*row[11]; jr->ClientId = str_to_uint64(row[12]!=NULL?row[12]:(char *)""); bstrncpy(jr->Name, row[13]!=NULL?row[13]:"", sizeof(jr->Name)); + jr->PriorJobId = str_to_uint64(row[14]!=NULL?row[14]:(char *)""); + bstrncpy(jr->cRealEndTime, row[15]!=NULL?row[15]:"", sizeof(jr->cRealEndTime)); sql_free_result(mdb); db_unlock(mdb); @@ -860,7 +862,9 @@ bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs," "MaxVolFiles,Recycle,Slot,FirstWritten,LastWritten,InChanger," - "EndFile,EndBlock,VolParts,LabelType,LabelDate,StorageId " + "EndFile,EndBlock,VolParts,LabelType,LabelDate,StorageId," + "Enabled,LocationId,RecycleCount,InitialWrite," + "ScratchPoolId,RecyclePoolId " "FROM Media WHERE MediaId=%s", edit_int64(mr->MediaId, ed1)); } else { /* find by name */ @@ -868,7 +872,9 @@ bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs," "MaxVolFiles,Recycle,Slot,FirstWritten,LastWritten,InChanger," - "EndFile,EndBlock,VolParts,LabelType,LabelDate,StorageId " + "EndFile,EndBlock,VolParts,LabelType,LabelDate,StorageId," + "Enabled,LocationId,RecycleCount,InitialWrite," + "ScratchPoolId,RecyclePoolId " "FROM Media WHERE VolumeName='%s'", mr->VolumeName); } @@ -917,6 +923,14 @@ bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) bstrncpy(mr->cLabelDate, row[27]!=NULL?row[27]:"", sizeof(mr->cLabelDate)); mr->LabelDate = (time_t)str_to_utime(mr->cLabelDate); mr->StorageId = str_to_int64(row[28]); + mr->Enabled = str_to_int64(row[29]); + mr->LocationId = str_to_int64(row[30]); + mr->RecycleCount = str_to_int64(row[31]); + bstrncpy(mr->cInitialWrite, row[32]!=NULL?row[32]:"", sizeof(mr->cInitialWrite)); + mr->InitialWrite = (time_t)str_to_utime(mr->cInitialWrite); + mr->ScratchPoolId = str_to_int64(row[33]); + mr->RecyclePoolId = str_to_int64(row[34]); + ok = true; } } else { diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index f61e751e30..ff71728cc3 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -148,27 +148,29 @@ db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," - "VolCapacityBytes,VolStatus,Recycle,VolRetention," + "VolCapacityBytes,VolStatus,Enabled,Recycle,VolRetention," "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," - "EndFile,EndBlock,VolParts,LabelType,StorageId" + "EndFile,EndBlock,VolParts,LabelType,StorageId,DeviceId," + "LocationId,RecycleCount,InitialWrite,ScratchPoolId,RecyclePoolId" " FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); } else { Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," - "VolCapacityBytes,VolStatus,Recycle,VolRetention," + "VolCapacityBytes,VolStatus,Enabled,Recycle,VolRetention," "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," - "EndFile,EndBlock,VolParts,LabelType,StorageId" + "EndFile,EndBlock,VolParts,LabelType,StorageId,DeviceId," + "LocationId,RecycleCount,InitialWrite,ScratchPoolId,RecyclePoolId" " FROM Media WHERE Media.PoolId=%s ORDER BY MediaId", edit_int64(mdbr->PoolId, ed1)); } } else { if (mdbr->VolumeName[0] != 0) { - Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus,Enabled," "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); } else { - Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus,Enabled," "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " "FROM Media WHERE Media.PoolId=%s ORDER BY MediaId", edit_int64(mdbr->PoolId, ed1)); diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index c7cd9c80ed..736d94fb31 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -302,8 +302,9 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) time_t ttime; struct tm tm; int stat; - char ed1[50], ed2[50], ed3[50], ed4[50]; - char ed5[50], ed6[50], ed7[50], ed8[50]; + char ed1[50], ed2[50], ed3[50], ed4[50]; + char ed5[50], ed6[50], ed7[50], ed8[50]; + char ed9[50], ed10[50], ed11[50]; Dmsg1(100, "update_media: FirstWritten=%d\n", mr->FirstWritten); @@ -346,7 +347,8 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) "VolWrites=%u,MaxVolBytes=%s,VolStatus='%s'," "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s,VolParts=%d," "LabelType=%d,StorageId=%s,PoolId=%s,VolRetention=%s,VolUseDuration=%s," - "MaxVolJobs=%d,MaxVolFiles=%d" + "MaxVolJobs=%d,MaxVolFiles=%d,Enabled=%d,LocationId=%s," + "ScratchPoolId=%s,RecyclePoolId=%s,RecycleCount=%d" " WHERE VolumeName='%s'", mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1), mr->VolMounts, mr->VolErrors, mr->VolWrites, @@ -361,6 +363,10 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) edit_uint64(mr->VolRetention, ed7), edit_uint64(mr->VolUseDuration, ed8), mr->MaxVolJobs, mr->MaxVolFiles, + mr->Enabled, edit_uint64(mr->LocationId, ed9), + edit_uint64(mr->ScratchPoolId, ed10), + edit_uint64(mr->RecyclePoolId, ed11), + mr->RecycleCount, mr->VolumeName); Dmsg1(400, "%s\n", mdb->cmd); diff --git a/bacula/src/cats/update_mysql_tables.in b/bacula/src/cats/update_mysql_tables.in index a892e392d0..534eac7859 100755 --- a/bacula/src/cats/update_mysql_tables.in +++ b/bacula/src/cats/update_mysql_tables.in @@ -36,7 +36,7 @@ CREATE TABLE Location ( DELETE FROM Version; -INSERT INTO Version (VersionId) VALUES (9); +INSERT INTO Version (VersionId) VALUES (10); END-OF-DATA then diff --git a/bacula/src/cats/update_postgresql_tables.in b/bacula/src/cats/update_postgresql_tables.in index b99f1fa056..88d4ed00d4 100755 --- a/bacula/src/cats/update_postgresql_tables.in +++ b/bacula/src/cats/update_postgresql_tables.in @@ -35,8 +35,6 @@ UPDATE job SET PriorJobId=0; ALTER TABLE jobmedia DROP COLUMN Stripe; - - CREATE TABLE Location ( LocationId SERIAL NOT NULL, Location TEXT NOT NULL, @@ -45,7 +43,8 @@ CREATE TABLE Location ( ); -INSERT INTO version (versionId) VALUES (9); +DELETE FROM version; +INSERT INTO version (versionId) VALUES (10); vacuum; diff --git a/bacula/src/cats/update_sqlite3_tables.in b/bacula/src/cats/update_sqlite3_tables.in index 802a6b5f49..d0871e5b3a 100755 --- a/bacula/src/cats/update_sqlite3_tables.in +++ b/bacula/src/cats/update_sqlite3_tables.in @@ -222,7 +222,7 @@ CREATE TABLE Location ( DELETE FROM Version; -INSERT INTO Version (VersionId) VALUES (9); +INSERT INTO Version (VersionId) VALUES (10); COMMIT; diff --git a/bacula/src/cats/update_sqlite_tables.in b/bacula/src/cats/update_sqlite_tables.in index 802a6b5f49..d0871e5b3a 100755 --- a/bacula/src/cats/update_sqlite_tables.in +++ b/bacula/src/cats/update_sqlite_tables.in @@ -222,7 +222,7 @@ CREATE TABLE Location ( DELETE FROM Version; -INSERT INTO Version (VersionId) VALUES (9); +INSERT INTO Version (VersionId) VALUES (10); COMMIT; diff --git a/bacula/src/console/console_conf.c b/bacula/src/console/console_conf.c index 10dae2d305..8112adfac3 100644 --- a/bacula/src/console/console_conf.c +++ b/bacula/src/console/console_conf.c @@ -82,7 +82,7 @@ static RES_ITEM cons_items[] = { {"tlscacertificatedir", store_dir, ITEM(res_cons.tls_ca_certdir), 0, 0, 0}, {"tlscertificate", store_dir, ITEM(res_cons.tls_certfile), 0, 0, 0}, {"tlskey", store_dir, ITEM(res_cons.tls_keyfile), 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; @@ -99,7 +99,7 @@ static RES_ITEM dir_items[] = { {"tlscacertificatedir", store_dir, ITEM(res_dir.tls_ca_certdir), 0, 0, 0}, {"tlscertificate", store_dir, ITEM(res_dir.tls_certfile), 0, 0, 0}, {"tlskey", store_dir, ITEM(res_dir.tls_keyfile), 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; /* diff --git a/bacula/src/dird/autoprune.c b/bacula/src/dird/autoprune.c index e0214080d9..0995b74ab6 100644 --- a/bacula/src/dird/autoprune.c +++ b/bacula/src/dird/autoprune.c @@ -117,6 +117,10 @@ int prune_volumes(JCR *jcr) if (jcr->jr.PoolId != mr.PoolId) { continue; } + /* Don't prune archived volumes */ + if (mr.Enabled == 2) { + continue; + } /* Prune only Volumes with status "Full", or "Used" */ if (strcmp(mr.VolStatus, "Full") == 0 || strcmp(mr.VolStatus, "Used") == 0) { diff --git a/bacula/src/dird/bacula-dir.conf.in b/bacula/src/dird/bacula-dir.conf.in index 6b9283ea7b..a6211b4ca9 100644 --- a/bacula/src/dird/bacula-dir.conf.in +++ b/bacula/src/dird/bacula-dir.conf.in @@ -273,7 +273,6 @@ Pool { Recycle = yes # Bacula can automatically recycle Volumes AutoPrune = yes # Prune expired volumes Volume Retention = 365 days # one year - Accept Any Volume = yes # write on any volume in the pool } # diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 06ed35937b..02514e8d49 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -221,6 +221,9 @@ void catalog_request(JCR *jcr, BSOCK *bs) if (label || mr.LabelDate == 0) { mr.LabelDate = jcr->start_time; mr.set_label_date = true; + if (mr.InitialWrite == 0) { + mr.InitialWrite = jcr->start_time; + } Dmsg2(400, "label=%d labeldate=%d\n", label, mr.LabelDate); } else { /* diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 77f59a8853..8bd16ae9eb 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -332,7 +332,6 @@ static RES_ITEM pool_items[] = { {"maximumvolumejobs", store_pint, ITEM(res_pool.MaxVolJobs), 0, 0, 0}, {"maximumvolumefiles", store_pint, ITEM(res_pool.MaxVolFiles), 0, 0, 0}, {"maximumvolumebytes", store_size, ITEM(res_pool.MaxVolBytes), 0, 0, 0}, - {"acceptanyvolume", store_bool, ITEM(res_pool.accept_any_volume), 0, ITEM_DEFAULT, true}, {"catalogfiles", store_bool, ITEM(res_pool.catalog_files), 0, ITEM_DEFAULT, true}, {"volumeretention", store_time, ITEM(res_pool.VolRetention), 0, ITEM_DEFAULT, 60*60*24*365}, {"volumeuseduration", store_time, ITEM(res_pool.VolUseDuration), 0, 0, 0}, @@ -799,9 +798,9 @@ next_run: case R_POOL: sendit(sock, _("Pool: name=%s PoolType=%s\n"), res->res_pool.hdr.name, res->res_pool.pool_type); - sendit(sock, _(" use_cat=%d use_once=%d acpt_any=%d cat_files=%d\n"), + sendit(sock, _(" use_cat=%d use_once=%d cat_files=%d\n"), res->res_pool.use_catalog, res->res_pool.use_volume_once, - res->res_pool.accept_any_volume, res->res_pool.catalog_files); + res->res_pool.catalog_files); sendit(sock, _(" max_vols=%d auto_prune=%d VolRetention=%s\n"), res->res_pool.max_volumes, res->res_pool.AutoPrune, edit_utime(res->res_pool.VolRetention, ed1, sizeof(ed1))); diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 0108c6a997..23ff69d42d 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -429,7 +429,6 @@ public: bool use_catalog; /* maintain catalog for media */ bool catalog_files; /* maintain file entries in catalog */ bool use_volume_once; /* write on volume only once */ - bool accept_any_volume; /* accept any volume */ bool purge_oldest_volume; /* purge oldest volume */ bool recycle_oldest_volume; /* attempt to recycle oldest volume */ bool recycle_current_volume; /* attempt recycle of current volume */ diff --git a/bacula/src/dird/newvol.c b/bacula/src/dird/newvol.c index 354c5ddec2..6a542caa4d 100644 --- a/bacula/src/dird/newvol.c +++ b/bacula/src/dird/newvol.c @@ -83,6 +83,7 @@ bool newVolume(JCR *jcr, MEDIA_DBR *mr) goto bail_out; } pr.NumVols++; + mr->Enabled = 1; if (db_create_media_record(jcr, jcr->db, mr) && db_update_pool_record(jcr, jcr->db, &pr)) { db_unlock(jcr->db); diff --git a/bacula/src/dird/next_vol.c b/bacula/src/dird/next_vol.c index 4b09c70ff4..129a8cbde0 100644 --- a/bacula/src/dird/next_vol.c +++ b/bacula/src/dird/next_vol.c @@ -62,14 +62,15 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, bool create) * 1. Look for volume with "Append" status. */ ok = db_find_next_volume(jcr, jcr->db, index, InChanger, mr); - Dmsg2(100, "catreq after find_next_vol ok=%d FW=%d\n", ok, mr->FirstWritten); + Dmsg4(100, "after find_next_vol index=%d ok=%d InChanger=%d Vstat=%s\n", + index, ok, InChanger, mr->VolStatus); if (!ok) { /* * 2. Try finding a recycled volume */ ok = find_recycled_volume(jcr, InChanger, mr); - Dmsg2(100, "find_recycled_volume %d FW=%d\n", ok, mr->FirstWritten); + Dmsg2(100, "find_recycled_volume ok=%d FW=%d\n", ok, mr->FirstWritten); if (!ok) { /* * 3. Try recycling any purged volume diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 212abb247a..a687bb4065 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -219,7 +219,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row); /* ua_prune.c */ int prune_files(UAContext *ua, CLIENT *client); int prune_jobs(UAContext *ua, CLIENT *client, int JobType); -int prune_volume(UAContext *ua, MEDIA_DBR *mr); +bool prune_volume(UAContext *ua, MEDIA_DBR *mr); /* ua_purge.c */ bool mark_media_purged(UAContext *ua, MEDIA_DBR *mr); diff --git a/bacula/src/dird/recycle.c b/bacula/src/dird/recycle.c index b8d0fc9d56..74b2a30d1e 100644 --- a/bacula/src/dird/recycle.c +++ b/bacula/src/dird/recycle.c @@ -70,7 +70,7 @@ bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) const char *select = "SELECT MediaId,LastWritten FROM Media " "WHERE PoolId=%s AND Recycle=1 AND VolStatus='Purged' " - "AND MediaType='%s' %s" + "AND Enabled=1 AND MediaType='%s' %s" "ORDER BY LastWritten ASC,MediaId LIMIT 1"; Dmsg0(100, "Enter recycle_oldest_purged_volume\n"); diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 29feea937e..9b19f765c7 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -186,6 +186,7 @@ void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr) mr->MaxVolFiles = pr->MaxVolFiles; mr->MaxVolBytes = pr->MaxVolBytes; mr->LabelType = pr->LabelType; + mr->Enabled = 1; } @@ -316,6 +317,7 @@ getVolName: mr.Slot = Slot++; mr.InChanger = InChanger; mr.StorageId = store->StorageId; + mr.Enabled = 1; Dmsg1(200, "Create Volume %s\n", mr.VolumeName); if (!db_create_media_record(ua->jcr, ua->db, &mr)) { bsendmsg(ua, "%s", db_strerror(ua->db)); @@ -483,7 +485,6 @@ void set_pooldbr_from_poolres(POOL_DBR *pr, POOL *pool, e_pool_op op) pr->LabelType = pool->LabelType; pr->UseOnce = pool->use_volume_once; pr->UseCatalog = pool->use_catalog; - pr->AcceptAnyVolume = pool->accept_any_volume; pr->Recycle = pool->Recycle; pr->VolRetention = pool->VolRetention; pr->VolUseDuration = pool->VolUseDuration; diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index 5ddfd9e561..613d17c7ed 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -342,7 +342,6 @@ static int defaultscmd(UAContext *ua, const char *cmd) bsendmsg(ua, "pool_type=%s", pool->pool_type); bsendmsg(ua, "label_format=%s", pool->label_format?pool->label_format:""); bsendmsg(ua, "use_volume_once=%d", pool->use_volume_once); - bsendmsg(ua, "accept_any_volume=%d", pool->accept_any_volume); bsendmsg(ua, "purge_oldest_volume=%d", pool->purge_oldest_volume); bsendmsg(ua, "recycle_oldest_volume=%d", pool->recycle_oldest_volume); bsendmsg(ua, "recycle_current_volume=%d", pool->recycle_current_volume); diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index 9e2b7f46b5..1452489736 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -682,6 +682,7 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, mr->VolBytes = 1; /* flag indicating Volume labeled */ mr->InChanger = 1; mr->StorageId = ua->jcr->store->StorageId; + mr->Enabled = 1; if (db_create_media_record(ua->jcr, ua->db, mr)) { bsendmsg(ua, _("Catalog record for Volume \"%s\", Slot %d successfully created.\n"), mr->VolumeName, mr->Slot); diff --git a/bacula/src/dird/ua_prune.c b/bacula/src/dird/ua_prune.c index e074407e64..e6d65dd512 100644 --- a/bacula/src/dird/ua_prune.c +++ b/bacula/src/dird/ua_prune.c @@ -470,16 +470,21 @@ bail_out: /* * Prune a given Volume */ -int prune_volume(UAContext *ua, MEDIA_DBR *mr) +bool prune_volume(UAContext *ua, MEDIA_DBR *mr) { POOLMEM *query = get_pool_memory(PM_MESSAGE); struct s_count_ctx cnt; struct s_file_del_ctx del; - int i, stat = 0; + int i; + bool ok = false; JOB_DBR jr; utime_t now, period; char ed1[50]; + if (mr->Enabled == 2) { + return false; /* Cannot prune archived volumes */ + } + db_lock(ua->db); memset(&jr, 0, sizeof(jr)); memset(&del, 0, sizeof(del)); @@ -501,7 +506,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) if (strcmp(mr->VolStatus, "Append") == 0 && verbose) { bsendmsg(ua, _("There are no Jobs associated with Volume \"%s\". Prune not needed.\n"), mr->VolumeName); - stat = 1; + ok = true; goto bail_out; } /* If volume not already purged, do so */ @@ -509,7 +514,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) bsendmsg(ua, _("There are no Jobs associated with Volume \"%s\". Marking it purged.\n"), mr->VolumeName); } - stat = mark_media_purged(ua, mr); + ok = mark_media_purged(ua, mr); goto bail_out; } @@ -583,11 +588,11 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) } if (cnt.count == 0) { Dmsg0(200, "Volume is purged.\n"); - stat = mark_media_purged(ua, mr); + ok = mark_media_purged(ua, mr); } bail_out: db_unlock(ua->db); free_pool_memory(query); - return stat; + return ok; } diff --git a/bacula/src/filed/filed_conf.c b/bacula/src/filed/filed_conf.c index a58a8fef66..e20709827d 100644 --- a/bacula/src/filed/filed_conf.c +++ b/bacula/src/filed/filed_conf.c @@ -100,7 +100,7 @@ static RES_ITEM cli_items[] = { {"tlscacertificatedir", store_dir, ITEM(res_client.tls_ca_certdir), 0, 0, 0}, {"tlscertificate", store_dir, ITEM(res_client.tls_certfile), 0, 0, 0}, {"tlskey", store_dir, ITEM(res_client.tls_keyfile), 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; /* Directors that can use our services */ @@ -119,7 +119,7 @@ static RES_ITEM dir_items[] = { {"tlskey", store_dir, ITEM(res_dir.tls_keyfile), 0, 0, 0}, {"tlsdhfile", store_dir, ITEM(res_dir.tls_dhfile), 0, 0, 0}, {"tlsallowedcn", store_alist_str, ITEM(res_dir.tls_allowed_cns), 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; /* Message resource */ diff --git a/bacula/src/gnome2-console/console_conf.c b/bacula/src/gnome2-console/console_conf.c index fa9561ff65..090189ad98 100644 --- a/bacula/src/gnome2-console/console_conf.c +++ b/bacula/src/gnome2-console/console_conf.c @@ -75,7 +75,7 @@ static RES_ITEM dir_items[] = { {"tlscacertificatedir", store_dir, ITEM(dir_res.tls_ca_certdir), 0, 0, 0}, {"tlscertificate", store_dir, ITEM(dir_res.tls_certfile), 0, 0, 0}, {"tlskey", store_dir, ITEM(dir_res.tls_keyfile), 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; static RES_ITEM con_items[] = { @@ -88,7 +88,7 @@ static RES_ITEM con_items[] = { {"tlscacertificatedir", store_dir, ITEM(con_res.tls_ca_certdir), 0, 0, 0}, {"tlscertificate", store_dir, ITEM(con_res.tls_certfile), 0, 0, 0}, {"tlskey", store_dir, ITEM(con_res.tls_keyfile), 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; static RES_ITEM con_font_items[] = { @@ -96,7 +96,7 @@ static RES_ITEM con_font_items[] = { {"description", store_str, ITEM(con_font.hdr.desc), 0, 0, 0}, {"font", store_str, ITEM(con_font.fontface), 0, 0, 0}, {"requiressl", store_bit, ITEM(con_font.require_ssl), 1, ITEM_DEFAULT, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index 5f4775fddb..7ccfa0f9b3 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -367,7 +367,8 @@ void _v(char *file, int line, pthread_mutex_t *m) { int errstat; - if ((errstat=pthread_mutex_tryunlock(m)) == 0) { + /* Note, this trylock *should* fail if the mutex is locked */ + if ((errstat=pthread_mutex_trylock(m)) == 0) { berrno be; e_msg(file, line, M_ERROR, 0, _("Mutex unlock not locked. ERR=%s\n"), be.strerror(errstat)); diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index 6d3db5e30e..51b7dd76b7 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -70,7 +70,7 @@ static RES_ITEM store_items[] = { {"tlskey", store_dir, ITEM(res_store.tls_keyfile), 0, 0, 0}, {"tlsdhfile", store_dir, ITEM(res_store.tls_dhfile), 0, 0, 0}, {"tlsallowedcn", store_alist_str, ITEM(res_store.tls_allowed_cns), 0, 0, 0}, - {NULL, NULL, 0, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; @@ -89,7 +89,7 @@ static RES_ITEM dir_items[] = { {"tlskey", store_dir, ITEM(res_dir.tls_keyfile), 0, 0, 0}, {"tlsdhfile", store_dir, ITEM(res_dir.tls_dhfile), 0, 0, 0}, {"tlsallowedcn", store_alist_str, ITEM(res_dir.tls_allowed_cns), 0, 0, 0}, - {NULL, NULL, 0, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; /* Device definition */ @@ -146,7 +146,7 @@ static RES_ITEM dev_items[] = { {"writepartcommand", store_strname,ITEM(res_dev.write_part_command), 0, 0, 0}, {"freespacecommand", store_strname,ITEM(res_dev.free_space_command), 0, 0, 0}, {"labeltype", store_label, ITEM(res_dev.label_type), 0, 0, 0}, - {NULL, NULL, 0, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; /* Autochanger definition */ @@ -156,7 +156,7 @@ static RES_ITEM changer_items[] = { {"device", store_alist_res, ITEM(res_changer.device), R_DEVICE, ITEM_REQUIRED, 0}, {"changerdevice", store_strname, ITEM(res_changer.changer_name), 0, ITEM_REQUIRED, 0}, {"changercommand", store_strname, ITEM(res_changer.changer_command), 0, ITEM_REQUIRED, 0}, - {NULL, NULL, 0, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; diff --git a/bacula/src/wx-console/console_conf.c b/bacula/src/wx-console/console_conf.c index b6c05f7151..fad7061772 100644 --- a/bacula/src/wx-console/console_conf.c +++ b/bacula/src/wx-console/console_conf.c @@ -20,7 +20,7 @@ * Kern Sibbald, January MM, September MM */ /* - Copyright (C) 2000-2005 Kern Sibbald + Copyright (C) 2000-2006 Kern Sibbald This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -87,7 +87,7 @@ static RES_ITEM cons_items[] = { {"tlscacertificatedir", store_dir, ITEM(res_cons.tls_ca_certdir), 0, 0, 0}, {"tlscertificate", store_dir, ITEM(res_cons.tls_certfile), 0, 0, 0}, {"tlskey", store_dir, ITEM(res_cons.tls_keyfile), 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; @@ -104,7 +104,7 @@ static RES_ITEM dir_items[] = { {"tlscacertificatedir", store_dir, ITEM(res_dir.tls_ca_certdir), 0, 0, 0}, {"tlscertificate", store_dir, ITEM(res_dir.tls_certfile), 0, 0, 0}, {"tlskey", store_dir, ITEM(res_dir.tls_keyfile), 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; /*