Lines Matching refs:mr

39 void set_storageid_in_mr(STORE *store, MEDIA_DBR *mr)  in set_storageid_in_mr()  argument
43 mr->sid_group = edit_int64(mr->StorageId, mr->sid); in set_storageid_in_mr()
48 mr->StorageId = store->StorageId; in set_storageid_in_mr()
52 mr->StorageId = store->StorageId; in set_storageid_in_mr()
61 mr->sid_group = store->ac_group; in set_storageid_in_mr()
64 mr->sid_group = edit_int64(mr->StorageId, mr->sid); in set_storageid_in_mr()
68 static void add_volume_to_exclude_list(JCR *jcr, int index, MEDIA_DBR *mr) in add_volume_to_exclude_list() argument
77 pm_strcat(jcr->next_vol_list, edit_int64(mr->MediaId, ed1)); in add_volume_to_exclude_list()
80 mr->exclude_list = NULL; in add_volume_to_exclude_list()
83 static void set_volume_to_exclude_list(JCR *jcr, int index, MEDIA_DBR *mr) in set_volume_to_exclude_list() argument
88 mr->exclude_list = jcr->next_vol_list; in set_volume_to_exclude_list()
101 int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, in find_next_volume_for_append() argument
109 bstrncpy(mr->MediaType, store->media_type, sizeof(mr->MediaType)); in find_next_volume_for_append()
111 (uint32_t)jcr->JobId, (int)mr->PoolId, mr->MediaType, index, in find_next_volume_for_append()
120 set_volume_to_exclude_list(jcr, index, mr); in find_next_volume_for_append()
128 bstrncpy(mr->VolStatus, "Append", sizeof(mr->VolStatus)); /* want only appendable volumes */ in find_next_volume_for_append()
132 set_storageid_in_mr(store, mr); /* put StorageId in new record */ in find_next_volume_for_append()
133 ok = db_find_next_volume(jcr, jcr->db, index, InChanger, mr); in find_next_volume_for_append()
140 ok, index, InChanger, mr->VolStatus); in find_next_volume_for_append()
144 ok = find_recycled_volume(jcr, InChanger, mr, store); in find_next_volume_for_append()
145 set_storageid_in_mr(store, mr); /* put StorageId in new record */ in find_next_volume_for_append()
146 Dmsg2(dbglvl, "find_recycled_volume ok=%d FW=%d\n", ok, mr->FirstWritten); in find_next_volume_for_append()
151 ok = recycle_oldest_purged_volume(jcr, InChanger, mr, store); in find_next_volume_for_append()
152 set_storageid_in_mr(store, mr); /* put StorageId in new record */ in find_next_volume_for_append()
159 prune_volumes(jcr, InChanger, mr, store); in find_next_volume_for_append()
161 ok = recycle_oldest_purged_volume(jcr, InChanger, mr, store); in find_next_volume_for_append()
162 set_storageid_in_mr(store, mr); /* put StorageId in new record */ in find_next_volume_for_append()
165 ok, index, InChanger, mr->VolStatus); in find_next_volume_for_append()
169 ok = get_scratch_volume(jcr, InChanger, mr, store); in find_next_volume_for_append()
170 set_storageid_in_mr(store, mr); /* put StorageId in new record */ in find_next_volume_for_append()
172 ok, index, InChanger, mr->VolStatus); in find_next_volume_for_append()
190 ok = newVolume(jcr, mr, store, errmsg); in find_next_volume_for_append()
200 set_storageid_in_mr(store, mr); /* update storage id */ in find_next_volume_for_append()
201 ok = db_find_next_volume(jcr, jcr->db, -1, InChanger, mr); in find_next_volume_for_append()
202 set_storageid_in_mr(store, mr); /* update storageid */ in find_next_volume_for_append()
212 Jmsg(jcr, M_INFO, 0, _("Purging oldest volume \"%s\"\n"), mr->VolumeName); in find_next_volume_for_append()
213 ok = purge_jobs_from_volume(ua, mr); in find_next_volume_for_append()
218 Jmsg(jcr, M_INFO, 0, _("Pruning oldest volume \"%s\"\n"), mr->VolumeName); in find_next_volume_for_append()
219 ok = prune_volume(ua, mr); in find_next_volume_for_append()
223 ok = recycle_volume(jcr, mr); in find_next_volume_for_append()
229 Dmsg2(dbglvl, "VolJobs=%d FirstWritten=%d\n", mr->VolJobs, mr->FirstWritten); in find_next_volume_for_append()
232 if (has_volume_expired(jcr, mr)) { in find_next_volume_for_append()
249 add_volume_to_exclude_list(jcr, index, mr);; in find_next_volume_for_append()
258 bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr) in has_volume_expired() argument
267 if (strcmp(mr->VolStatus, "Append") == 0 && mr->VolJobs > 0) { in has_volume_expired()
269 if ((mr->MaxVolBytes > 0 && mr->VolBytes >= mr->MaxVolBytes)) { in has_volume_expired()
272 edit_uint64_with_commas(mr->MaxVolBytes, ed1), mr->VolumeName); in has_volume_expired()
273 bstrncpy(mr->VolStatus, "Full", sizeof(mr->VolStatus)); in has_volume_expired()
277 } else if (mr->VolBytes > 0 && jcr->pool->use_volume_once) { in has_volume_expired()
279 "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); in has_volume_expired()
280 bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); in has_volume_expired()
284 } else if (mr->MaxVolJobs > 0 && mr->MaxVolJobs <= mr->VolJobs) { in has_volume_expired()
287 edit_uint64_with_commas(mr->MaxVolJobs, ed1), mr->VolumeName); in has_volume_expired()
288 Dmsg3(dbglvl, "MaxVolJobs=%d JobId=%d Vol=%s\n", mr->MaxVolJobs, in has_volume_expired()
289 (uint32_t)jcr->JobId, mr->VolumeName); in has_volume_expired()
290 bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); in has_volume_expired()
294 } else if (mr->MaxVolFiles > 0 && mr->MaxVolFiles <= mr->VolFiles) { in has_volume_expired()
297 edit_uint64_with_commas(mr->MaxVolFiles, ed1), mr->VolumeName); in has_volume_expired()
298 bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); in has_volume_expired()
302 } else if (mr->VolUseDuration > 0) { in has_volume_expired()
305 if (mr->VolUseDuration <= (now - mr->FirstWritten)) { in has_volume_expired()
308 edit_uint64_with_commas(mr->VolUseDuration, ed1), mr->VolumeName); in has_volume_expired()
309 bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); in has_volume_expired()
322 edit_uint64_with_suffix(pr.MaxPoolBytes, ed1), mr->VolumeName); in has_volume_expired()
323 bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); in has_volume_expired()
330 Dmsg1(dbglvl, "Vol=%s has expired update media record\n", mr->VolumeName); in has_volume_expired()
331 set_storageid_in_mr(NULL, mr); in has_volume_expired()
332 if (!db_update_media_record(jcr, jcr->db, mr)) { in has_volume_expired()
334 mr->VolumeName, db_strerror(jcr->db)); in has_volume_expired()
337 Dmsg2(dbglvl, "Vol=%s expired=%d\n", mr->VolumeName, expired); in has_volume_expired()
347 void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **reason) in check_if_volume_valid_or_recyclable() argument
354 if (has_volume_expired(jcr, mr)) { in check_if_volume_valid_or_recyclable()
356 if (!mr->Recycle) { /* cannot recycle */ in check_if_volume_valid_or_recyclable()
365 if (strcmp(mr->VolStatus, "Append") == 0 || in check_if_volume_valid_or_recyclable()
366 strcmp(mr->VolStatus, "Recycle") == 0) { in check_if_volume_valid_or_recyclable()
374 if (strcmp(mr->VolStatus, "Purged") == 0) { in check_if_volume_valid_or_recyclable()
375 if (recycle_volume(jcr, mr)) { in check_if_volume_valid_or_recyclable()
376 Jmsg(jcr, M_INFO, 0, _("Recycled current volume \"%s\"\n"), mr->VolumeName); in check_if_volume_valid_or_recyclable()
395 if (!mr->Recycle) { in check_if_volume_valid_or_recyclable()
403 if (mr->LastWritten > 0 in check_if_volume_valid_or_recyclable()
404 && mr->VolRetention > 0 in check_if_volume_valid_or_recyclable()
405 && (mr->LastWritten + mr->VolRetention - 60) < (utime_t)time(NULL) in check_if_volume_valid_or_recyclable()
407 && (strcmp(mr->VolStatus, "Full") == 0 || in check_if_volume_valid_or_recyclable()
408 strcmp(mr->VolStatus, "Used") == 0)) { in check_if_volume_valid_or_recyclable()
416 ok = prune_volume(ua, mr); in check_if_volume_valid_or_recyclable()
421 if (recycle_volume(jcr, mr)) { in check_if_volume_valid_or_recyclable()
422 Jmsg(jcr, M_INFO, 0, _("Recycled current volume \"%s\"\n"), mr->VolumeName); in check_if_volume_valid_or_recyclable()
438 bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr, in get_scratch_volume() argument
457 spr.PoolId = mr->ScratchPoolId; in get_scratch_volume()
461 bstrncpy(smr.MediaType, mr->MediaType, sizeof(smr.MediaType)); in get_scratch_volume()
512 mr->copy(&smr); in get_scratch_volume()
513 set_storageid_in_mr(store, mr); in get_scratch_volume()
516 set_pool_dbr_defaults_in_media_dbr(mr, &pr); in get_scratch_volume()
523 bstrncpy(mr->VolStatus, smr.VolStatus, sizeof(smr.VolStatus)); in get_scratch_volume()
524 mr->RecyclePoolId = smr.RecyclePoolId; in get_scratch_volume()
526 if (!db_update_media_record(jcr, jcr->db, mr)) { in get_scratch_volume()
533 mr->VolumeName, spr.Name, in get_scratch_volume()