X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fprotos.h;h=ef8ebc09f819a864c12f1e251805d2c4d91bdb6a;hb=1bf3065ec3bd9c1d65a14ee98b6e42bf7077ba16;hp=3f9913711c193376d27a342343a1c72cadc9e473;hpb=3ce722c46f0b3c6d4a32318b48ad5b986a07968f;p=bacula%2Fbacula diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index 3f9913711c..ef8ebc09f8 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -1,14 +1,14 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 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. This program is Free Software; you can redistribute it and/or modify it under the terms of version two of the GNU General Public - License as published by the Free Software Foundation plus additions - that are listed in the file LICENSE. + License as published by the Free Software Foundation and included + in the file LICENSE. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -38,7 +38,8 @@ uint32_t new_VolSessionId(); DCR *acquire_device_for_append(DCR *dcr); bool acquire_device_for_read(DCR *dcr); bool release_device(DCR *dcr); -DCR *new_dcr(JCR *jcr, DEVICE *dev); +bool clean_device(DCR *dcr); +DCR *new_dcr(JCR *jcr, DCR *dcr, DEVICE *dev); void free_dcr(DCR *dcr); void detach_dcr_from_dev(DCR *dcr); @@ -49,9 +50,9 @@ enum get_vol_info_rw { }; bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw); bool dir_find_next_appendable_volume(DCR *dcr); -bool dir_update_volume_info(DCR *dcr, bool label); +bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten); bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr); -bool dir_ask_sysop_to_mount_volume(DCR *dcr); +bool dir_ask_sysop_to_mount_volume(DCR *dcr, int mode); bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec); bool dir_send_job_status(JCR *jcr); bool dir_create_jobmedia_record(DCR *dcr); @@ -67,6 +68,7 @@ bool init_autochangers(); int autoload_device(DCR *dcr, int writing, BSOCK *dir); bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd); bool unload_autochanger(DCR *dcr, int loaded); +bool unload_dev(DCR *dcr, DEVICE *dev); char *edit_device_codes(DCR *dcr, char *omsg, const char *imsg, const char *cmd); int get_autochanger_loaded_slot(DCR *dcr); @@ -126,16 +128,10 @@ void dvd_remove_empty_part(DCR *dcr); bool open_device(DCR *dcr); bool first_open_device(DCR *dcr); bool fixup_device_block_write_error(DCR *dcr); -void _lock_device(const char *file, int line, DEVICE *dev); -void _unlock_device(const char *file, int line, DEVICE *dev); -void _block_device(const char *file, int line, DEVICE *dev, int state); -void _unblock_device(const char *file, int line, DEVICE *dev); -void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state); -void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold); +void set_start_vol_position(DCR *dcr); void set_new_volume_parameters(DCR *dcr); void set_new_file_parameters(DCR *dcr); bool is_device_unmounted(DEVICE *dev); -uint32_t get_jobid_from_tid(); /* From dircmd.c */ void *handle_connection_request(void *arg); @@ -171,6 +167,15 @@ void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose); bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec); bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec); +/* From locks.c */ +void _lock_device(const char *file, int line, DEVICE *dev); +void _unlock_device(const char *file, int line, DEVICE *dev); +void _block_device(const char *file, int line, DEVICE *dev, int state); +void _unblock_device(const char *file, int line, DEVICE *dev); +void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state); +void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold); + + /* From match_bsr.c */ int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sesrec); @@ -180,9 +185,7 @@ BSR *find_next_bsr(BSR *root_bsr, DEVICE *dev); bool is_this_bsr_done(BSR *bsr, DEV_RECORD *rec); /* From mount.c */ -bool mount_next_write_volume(DCR *dcr, bool release); bool mount_next_read_volume(DCR *dcr); -void mark_volume_in_error(DCR *dcr); /* From parse_bsr.c */ BSR *parse_bsr(JCR *jcr, char *lf); @@ -213,7 +216,8 @@ void init_reservations_lock(); void term_reservations_lock(); void _lock_reservations(); void _unlock_reservations(); -void release_volume(DCR *dcr); +void _lock_volumes(); +void _unlock_volumes(); VOLRES *reserve_volume(DCR *dcr, const char *VolumeName); VOLRES *find_volume(const char *VolumeName); bool free_volume(DEVICE *dev); @@ -226,27 +230,49 @@ bool is_volume_in_use(DCR *dcr); void send_drive_reserve_messages(JCR *jcr, void sendit(const char *msg, int len, void *sarg), void *arg); bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx); int search_res_for_device(RCTX &rctx); -void release_msgs(JCR *jcr); +void release_reserve_messages(JCR *jcr); extern int reservations_lock_count; +extern int vol_list_lock_count; #ifdef SD_DEBUG_LOCK + #define lock_reservations() \ do { Dmsg4(sd_dbglvl, "lock_reservations at %s:%d precnt=%d JobId=%u\n", \ __FILE__, __LINE__, \ - reservations_lock_count, get_jobid_from_tid()); \ + reservations_lock_count, get_jobid_from_tid(pthread_self())); \ _lock_reservations(); \ Dmsg1(sd_dbglvl, "lock_reservations: got lock JobId=%u\n", \ - get_jobid_from_tid()); \ + get_jobid_from_tid(pthread_self())); \ } while (0) #define unlock_reservations() \ do { Dmsg4(sd_dbglvl, "unlock_reservations at %s:%d precnt=%d JobId=%u\n", \ __FILE__, __LINE__, \ - reservations_lock_count, get_jobid_from_tid()); \ + reservations_lock_count, get_jobid_from_tid(pthread_self())); \ _unlock_reservations(); } while (0) + +#define lock_volumes() \ + do { Dmsg4(sd_dbglvl, "lock_volumes at %s:%d precnt=%d JobId=%u\n", \ + __FILE__, __LINE__, \ + vol_list_lock_count, get_jobid_from_tid(pthread_self())); \ + _lock_volumes(); \ + Dmsg1(sd_dbglvl, "lock_volumes: got lock JobId=%u\n", \ + get_jobid_from_tid(pthread_self())); \ + } while (0) + +#define unlock_volumes() \ + do { Dmsg4(sd_dbglvl, "unlock_volumes at %s:%d precnt=%d JobId=%u\n", \ + __FILE__, __LINE__, \ + vol_list_lock_count, get_jobid_from_tid(pthread_self())); \ + _unlock_volumes(); } while (0) + #else + #define lock_reservations() _lock_reservations() #define unlock_reservations() _unlock_reservations() +#define lock_volumes() _lock_volumes() +#define unlock_volumes() _unlock_volumes() + #endif