Пример #1
0
/*
 * Search for a Volume name in the read Volume list.
 *
 * Returns: VOLRES entry on success
 *          NULL if the Volume is not in the list
 */
static VOLRES *find_read_volume(const char *VolumeName)
{
   VOLRES vol, *fvol;

   if (read_vol_list->empty()) {
      Dmsg0(dbglvl, "find_read_vol: read_vol_list empty.\n");
      return NULL;
   }

   /*
    * Do not lock reservations here
    */
   lock_read_volumes();

   memset(&vol, 0, sizeof(vol));
   vol.vol_name = bstrdup(VolumeName);

   /*
    * Note, we do want a simple compare_by_volumename on volume name only here
    */
   fvol = (VOLRES *)read_vol_list->binary_search(&vol, compare_by_volumename);
   free(vol.vol_name);

   Dmsg2(dbglvl, "find_read_vol=%s found=%d\n", VolumeName, fvol!=NULL);
   unlock_read_volumes();

   return fvol;
}
Пример #2
0
/*
 * Check if volume name is on read volume list.
 */
bool is_on_read_volume_list(JCR *jcr, const char *VolumeName)
{
   VOLRES vol, *fvol;

   lock_read_volumes();
   vol.vol_name = bstrdup(VolumeName);
   fvol = (VOLRES *)read_vol_list->binary_search(&vol, compare_by_volumename);
   free(vol.vol_name);
   unlock_read_volumes();

   return fvol != NULL;
}
Пример #3
0
/*
 * Add a volume to the read list.
 * Note, we use VOLRES because it simplifies the code
 *   even though, the only part of VOLRES that we need is
 *   the volume name.  The same volume may be in the list
 *   multiple times, but each one is distinguished by the
 *   JobId.  We use JobId, VolumeName as the key.
 * We can get called multiple times for the same volume because
 *   when parsing the bsr, the volume name appears multiple times.
 */
void add_read_volume(JCR *jcr, const char *VolumeName)
{
   VOLRES *nvol, *vol;

   lock_read_volumes();
   nvol = new_vol_item(NULL, VolumeName);
   nvol->set_jobid(jcr->JobId);
   vol = (VOLRES *)read_vol_list->binary_insert(nvol, read_compare);
   if (vol != nvol) {
      free_vol_item(nvol);
      Dmsg2(dbglvl, "read_vol=%s JobId=%d already in list.\n", VolumeName, jcr->JobId);
   } else {
      Dmsg2(dbglvl, "add read_vol=%s JobId=%d\n", VolumeName, jcr->JobId);
   }
   unlock_read_volumes();
}
Пример #4
0
/*
 * Remove a given volume name from the read list.
 */
void remove_read_volume(JCR *jcr, const char *VolumeName)
{
   VOLRES vol, *fvol;
   lock_read_volumes();
   vol.vol_name = bstrdup(VolumeName);
   vol.set_jobid(jcr->JobId);
   fvol = (VOLRES *)read_vol_list->binary_search(&vol, read_compare);
   free(vol.vol_name);
   if (fvol) {
      Dmsg3(dbglvl, "remove_read_vol=%s JobId=%d found=%d\n", VolumeName, jcr->JobId, fvol!=NULL);
   }
   if (fvol) {
      read_vol_list->remove(fvol);
      free_vol_item(fvol);
   }
   unlock_read_volumes();
// pthread_cond_broadcast(&wait_next_vol);
}