From: <ri...@us...> - 2007-02-19 11:51:46
|
Revision: 4205 http://bacula.svn.sourceforge.net/bacula/?rev=4205&view=rev Author: ricozz Date: 2007-02-19 03:51:46 -0800 (Mon, 19 Feb 2007) Log Message: ----------- ebl add RecyclePool to Pool. Media will take Pool.RecyclePool when moving from Scratch to a Pool or when user will do update volume=xxx frompool To use it, add RecyclePool = aPool to your Pool resource Pool { Name = Default RecyclePool = Scratch ... } Modified Paths: -------------- trunk/bacula/src/cats/cats.h trunk/bacula/src/cats/sql_create.c trunk/bacula/src/cats/sql_get.c trunk/bacula/src/cats/sql_update.c trunk/bacula/src/dird/dird_conf.c trunk/bacula/src/dird/dird_conf.h trunk/bacula/src/dird/protos.h trunk/bacula/src/dird/ua_cmds.c trunk/bacula/src/dird/ua_update.c Modified: trunk/bacula/src/cats/cats.h =================================================================== --- trunk/bacula/src/cats/cats.h 2007-02-18 20:12:11 UTC (rev 4204) +++ trunk/bacula/src/cats/cats.h 2007-02-19 11:51:46 UTC (rev 4205) @@ -734,6 +734,7 @@ uint32_t MaxVolJobs; /* Max Jobs on Volume */ uint32_t MaxVolFiles; /* Max files on Volume */ uint64_t MaxVolBytes; /* Max bytes on Volume */ + DBId_t RecyclePoolId; /* RecyclePool destination when media is purged */ char PoolType[MAX_NAME_LENGTH]; char LabelFormat[MAX_NAME_LENGTH]; /* Extra stuff not in DB */ Modified: trunk/bacula/src/cats/sql_create.c =================================================================== --- trunk/bacula/src/cats/sql_create.c 2007-02-18 20:12:11 UTC (rev 4204) +++ trunk/bacula/src/cats/sql_create.c 2007-02-19 11:51:46 UTC (rev 4205) @@ -170,7 +170,7 @@ db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) { bool stat; - char ed1[30], ed2[30], ed3[50]; + char ed1[30], ed2[30], ed3[50], ed4[50]; Dmsg0(200, "In create pool\n"); db_lock(mdb); @@ -192,8 +192,8 @@ Mmsg(mdb->cmd, "INSERT INTO Pool (Name,NumVols,MaxVols,UseOnce,UseCatalog," "AcceptAnyVolume,AutoPrune,Recycle,VolRetention,VolUseDuration," -"MaxVolJobs,MaxVolFiles,MaxVolBytes,PoolType,LabelType,LabelFormat) " -"VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s',%d,'%s')", +"MaxVolJobs,MaxVolFiles,MaxVolBytes,PoolType,LabelType,LabelFormat,RecyclePoolId) " +"VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s',%d,'%s',%s)", pr->Name, pr->NumVols, pr->MaxVols, pr->UseOnce, pr->UseCatalog, @@ -203,7 +203,8 @@ edit_uint64(pr->VolUseDuration, ed2), pr->MaxVolJobs, pr->MaxVolFiles, edit_uint64(pr->MaxVolBytes, ed3), - pr->PoolType, pr->LabelType, pr->LabelFormat); + pr->PoolType, pr->LabelType, pr->LabelFormat, + edit_int64(pr->RecyclePoolId,ed4)); Dmsg1(200, "Create Pool: %s\n", mdb->cmd); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { Mmsg2(&mdb->errmsg, _("Create db Pool record %s failed: ERR=%s\n"), Modified: trunk/bacula/src/cats/sql_get.c =================================================================== --- trunk/bacula/src/cats/sql_get.c 2007-02-18 20:12:11 UTC (rev 4204) +++ trunk/bacula/src/cats/sql_get.c 2007-02-19 11:51:46 UTC (rev 4205) @@ -574,13 +574,13 @@ Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume," "AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," -"MaxVolBytes,PoolType,LabelType,LabelFormat FROM Pool WHERE Pool.PoolId=%s", +"MaxVolBytes,PoolType,LabelType,LabelFormat,RecyclePoolId FROM Pool WHERE Pool.PoolId=%s", edit_int64(pdbr->PoolId, ed1)); } else { /* find by name */ Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume," "AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," -"MaxVolBytes,PoolType,LabelType,LabelFormat FROM Pool WHERE Pool.Name='%s'", +"MaxVolBytes,PoolType,LabelType,LabelFormat,RecyclePoolId FROM Pool WHERE Pool.Name='%s'", pdbr->Name); } @@ -613,6 +613,7 @@ bstrncpy(pdbr->PoolType, row[14]!=NULL?row[14]:"", sizeof(pdbr->PoolType)); pdbr->LabelType = str_to_int64(row[15]); bstrncpy(pdbr->LabelFormat, row[16]!=NULL?row[16]:"", sizeof(pdbr->LabelFormat)); + pdbr->RecyclePoolId = str_to_int64(row[17]); ok = true; } } Modified: trunk/bacula/src/cats/sql_update.c =================================================================== --- trunk/bacula/src/cats/sql_update.c 2007-02-18 20:12:11 UTC (rev 4204) +++ trunk/bacula/src/cats/sql_update.c 2007-02-19 11:51:46 UTC (rev 4205) @@ -255,7 +255,7 @@ db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) { int stat; - char ed1[50], ed2[50], ed3[50], ed4[50]; + char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50]; db_lock(mdb); Mmsg(mdb->cmd, "SELECT count(*) from Media WHERE PoolId=%s", @@ -267,14 +267,14 @@ "UPDATE Pool SET NumVols=%u,MaxVols=%u,UseOnce=%d,UseCatalog=%d," "AcceptAnyVolume=%d,VolRetention='%s',VolUseDuration='%s'," "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s,Recycle=%d," -"AutoPrune=%d,LabelType=%d,LabelFormat='%s' WHERE PoolId=%s", +"AutoPrune=%d,LabelType=%d,LabelFormat='%s',RecyclePoolId=%s WHERE PoolId=%s", pr->NumVols, pr->MaxVols, pr->UseOnce, pr->UseCatalog, pr->AcceptAnyVolume, edit_uint64(pr->VolRetention, ed1), edit_uint64(pr->VolUseDuration, ed2), pr->MaxVolJobs, pr->MaxVolFiles, edit_uint64(pr->MaxVolBytes, ed3), pr->Recycle, pr->AutoPrune, pr->LabelType, - pr->LabelFormat, + pr->LabelFormat, edit_int64(pr->RecyclePoolId,ed5), ed4); stat = UPDATE_DB(jcr, mdb, mdb->cmd); Modified: trunk/bacula/src/dird/dird_conf.c =================================================================== --- trunk/bacula/src/dird/dird_conf.c 2007-02-18 20:12:11 UTC (rev 4204) +++ trunk/bacula/src/dird/dird_conf.c 2007-02-19 11:51:46 UTC (rev 4205) @@ -361,7 +361,7 @@ {"storage", store_alist_res, ITEM(res_pool.storage), R_STORAGE, 0, 0}, {"autoprune", store_bool, ITEM(res_pool.AutoPrune), 0, ITEM_DEFAULT, true}, {"recycle", store_bool, ITEM(res_pool.Recycle), 0, ITEM_DEFAULT, true}, -// {"recyclepool", store_res, ITEM(res_pool.RecyclePool), R_POOL, 0, 0}, + {"recyclepool", store_res, ITEM(res_pool.RecyclePool), R_POOL, 0, 0}, {NULL, NULL, {0}, 0, 0, 0} }; @@ -854,8 +854,11 @@ edit_uint64(res->res_pool.MigrationHighBytes, ed2), edit_uint64(res->res_pool.MigrationLowBytes, ed3)); if (res->res_pool.NextPool) { - sendit(sock, _(" NextPool=%s\n"), res->res_pool.NextPool->hdr.name); + sendit(sock, _(" NextPool=%s\n"), res->res_pool.NextPool->name()); } + if (res->res_pool.RecyclePool) { + sendit(sock, _(" RecyclePool=%s\n"), res->res_pool.RecyclePool->name()); + } if (res->res_pool.storage) { STORE *store; foreach_alist(store, res->res_pool.storage) { @@ -1245,6 +1248,7 @@ } /* Explicitly copy resource pointers from this pass (res_all) */ res->res_pool.NextPool = res_all.res_pool.NextPool; + res->res_pool.RecyclePool = res_all.res_pool.RecyclePool; res->res_pool.storage = res_all.res_pool.storage; break; case R_CONSOLE: Modified: trunk/bacula/src/dird/dird_conf.h =================================================================== --- trunk/bacula/src/dird/dird_conf.h 2007-02-18 20:12:11 UTC (rev 4204) +++ trunk/bacula/src/dird/dird_conf.h 2007-02-19 11:51:46 UTC (rev 4205) @@ -523,7 +523,7 @@ bool recycle_current_volume; /* attempt recycle of current volume */ bool AutoPrune; /* default for pool auto prune */ bool Recycle; /* default for media recycle yes/no */ - + POOL *RecyclePool; /* RecyclePool destination when media is purged */ /* Methods */ char *name() const; }; Modified: trunk/bacula/src/dird/protos.h =================================================================== --- trunk/bacula/src/dird/protos.h 2007-02-18 20:12:11 UTC (rev 4204) +++ trunk/bacula/src/dird/protos.h 2007-02-19 11:51:46 UTC (rev 4205) @@ -180,6 +180,7 @@ }; int create_pool(JCR *jcr, B_DB *db, POOL *pool, e_pool_op op); void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr); +bool set_pooldbr_recyclepoolid(JCR *jcr, B_DB *db, POOL_DBR *pr, POOL *pool); void set_pooldbr_from_poolres(POOL_DBR *pr, POOL *pool, e_pool_op op); /* ua_input.c */ Modified: trunk/bacula/src/dird/ua_cmds.c =================================================================== --- trunk/bacula/src/dird/ua_cmds.c 2007-02-18 20:12:11 UTC (rev 4204) +++ trunk/bacula/src/dird/ua_cmds.c 2007-02-19 11:51:46 UTC (rev 4205) @@ -194,6 +194,7 @@ mr->Recycle = pr->Recycle; mr->VolRetention = pr->VolRetention; mr->VolUseDuration = pr->VolUseDuration; + mr->RecyclePoolId = pr->RecyclePoolId; mr->MaxVolJobs = pr->MaxVolJobs; mr->MaxVolFiles = pr->MaxVolFiles; mr->MaxVolBytes = pr->MaxVolBytes; @@ -493,7 +494,11 @@ * Pool DB base record from a Pool Resource. We handle * the setting of MaxVols and NumVols slightly differently * depending on if we are creating the Pool or we are - * simply bringing it into agreement with the resource (updage). + * simply bringing it into agreement with the resource (update). + * + * Caution : RecyclePoolId isn't setup in this function. + * You can use set_pooldbr_recyclepoolid(); + * */ void set_pooldbr_from_poolres(POOL_DBR *pr, POOL *pool, e_pool_op op) { @@ -527,7 +532,29 @@ } } +bool set_pooldbr_recyclepoolid(JCR *jcr, B_DB *db, POOL_DBR *pr, POOL *pool) +{ + POOL_DBR rpool; + bool ret = true; + if (pool->RecyclePool) { + memset(&rpool, 0, sizeof(POOL_DBR)); + + bstrncpy(rpool.Name, pool->RecyclePool->name(), sizeof(rpool.Name)); + if (db_get_pool_record(jcr, db, &rpool)) { + pr->RecyclePoolId = rpool.PoolId; + } else { + Jmsg(jcr, M_WARNING, 0, + _("Can't set %s RecyclePool to %s, %s is not in database, try to update it with 'update pool=%s'\n"),pool->name(),rpool.Name, rpool.Name,pool->name()); + + ret = false; + } + } else { /* no RecyclePool used, set it to 0 */ + pr->RecyclePoolId = 0; + } + return ret; +} + /* * Create a pool record from a given Pool resource * Also called from backup.c @@ -554,6 +581,7 @@ } set_pooldbr_from_poolres(&pr, pool, op); + set_pooldbr_recyclepoolid(jcr, db, &pr, pool); if (!db_create_pool_record(jcr, db, &pr)) { return -1; /* error */ Modified: trunk/bacula/src/dird/ua_update.c =================================================================== --- trunk/bacula/src/dird/ua_update.c 2007-02-18 20:12:11 UTC (rev 4204) +++ trunk/bacula/src/dird/ua_update.c 2007-02-19 11:51:46 UTC (rev 4205) @@ -744,6 +744,7 @@ } set_pooldbr_from_poolres(&pr, pool, POOL_OP_UPDATE); /* update */ + set_pooldbr_recyclepoolid(ua->jcr, ua->db, &pr, pool); id = db_update_pool_record(ua->jcr, ua->db, &pr); if (id <= 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |