From ade966037f181b6d53b09bc413d77d41cdd2d7a2 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 7 Apr 2010 11:18:53 +0200 Subject: [PATCH] Add lock position info to volume manager --- bacula/src/stored/protos.h | 12 ++++++------ bacula/src/stored/reserve.c | 4 ++-- bacula/src/stored/vol_mgr.c | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index 8aa28538e5..26ffd476de 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -214,9 +214,9 @@ bool read_records(DCR *dcr, /* From reserve.c */ void init_reservations_lock(); void term_reservations_lock(); -void _lock_reservations(); +void _lock_reservations(const char *file="**Unknown**", int line=0); void _unlock_reservations(); -void _lock_volumes(); +void _lock_volumes(const char *file="**Unknown**", int line=0); void _unlock_volumes(); void unreserve_device(DCR *dcr); void send_drive_reserve_messages(JCR *jcr, void sendit(const char *msg, int len, void *sarg), void *arg); @@ -232,7 +232,7 @@ extern int reservations_lock_count; do { Dmsg3(sd_dbglvl, "lock_reservations at %s:%d precnt=%d\n", \ __FILE__, __LINE__, \ reservations_lock_count); \ - _lock_reservations(); \ + _lock_reservations(__FILE__, __LINE__); \ Dmsg0(sd_dbglvl, "lock_reservations: got lock\n"); \ } while (0) #define unlock_reservations() \ @@ -245,7 +245,7 @@ extern int reservations_lock_count; do { Dmsg3(sd_dbglvl, "lock_volumes at %s:%d precnt=%d\n", \ __FILE__, __LINE__, \ vol_list_lock_count); \ - _lock_volumes(); \ + _lock_volumes(__FILE__, __LINE__); \ Dmsg0(sd_dbglvl, "lock_volumes: got lock\n"); \ } while (0) @@ -257,9 +257,9 @@ extern int reservations_lock_count; #else -#define lock_reservations() _lock_reservations() +#define lock_reservations() _lock_reservations(__FILE__, __LINE__) #define unlock_reservations() _unlock_reservations() -#define lock_volumes() _lock_volumes() +#define lock_volumes() _lock_volumes(__FILE__, __LINE__) #define unlock_volumes() _unlock_volumes() #endif diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 8119f84af7..40e0f2f275 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -101,11 +101,11 @@ void term_reservations_lock() int reservations_lock_count = 0; /* This applies to a drive and to Volumes */ -void _lock_reservations() +void _lock_reservations(const char *file, int line) { int errstat; reservations_lock_count++; - if ((errstat=rwl_writelock(&reservation_lock)) != 0) { + if ((errstat=rwl_writelock_p(&reservation_lock, file, line)) != 0) { berrno be; Emsg2(M_ABORT, 0, "rwl_writelock failure. stat=%d: ERR=%s\n", errstat, be.bstrerror(errstat)); diff --git a/bacula/src/stored/vol_mgr.c b/bacula/src/stored/vol_mgr.c index 5bc9ba840d..5edd8aa807 100644 --- a/bacula/src/stored/vol_mgr.c +++ b/bacula/src/stored/vol_mgr.c @@ -105,11 +105,11 @@ void term_vol_list_lock() /* * This allows a given thread to recursively call to lock_volumes() */ -void _lock_volumes() +void _lock_volumes(const char *file, int line) { int errstat; vol_list_lock_count++; - if ((errstat=rwl_writelock(&vol_list_lock)) != 0) { + if ((errstat=rwl_writelock_p(&vol_list_lock, file, line)) != 0) { berrno be; Emsg2(M_ABORT, 0, "rwl_writelock failure. stat=%d: ERR=%s\n", errstat, be.bstrerror(errstat)); @@ -127,14 +127,14 @@ void _unlock_volumes() } } -void lock_read_volumes() +void lock_read_volumes(const char *file="**Unknown", int line=0) { - P(read_vol_lock); + bthread_mutex_lock_p(&read_vol_lock, file, line); } void unlock_read_volumes() { - V(read_vol_lock); + bthread_mutex_unlock(&read_vol_lock); } /* -- 2.39.5