From: Eric Bollengier Date: Wed, 9 Dec 2009 14:29:33 +0000 (+0100) Subject: Add mutex some priority info for SD X-Git-Tag: Release-7.0.0~2480 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=68d72521de685430e982afd432ce920273eebb7d;p=bacula%2Fbacula Add mutex some priority info for SD --- diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 36b03d9236..2535dfc5c5 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -267,6 +267,10 @@ init_dev(JCR *jcr, DEVRES *device) Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(errstat)); Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg); } + /* Ensure that we respect this order in P/V operations */ + bthread_mutex_set_priority(&dev->m_mutex, PRIO_SD_DEV_ACCESS); + bthread_mutex_set_priority(&dev->spool_mutex, PRIO_SD_DEV_SPOOL); + bthread_mutex_set_priority(&dev->acquire_mutex, PRIO_SD_DEV_ACQUIRE); #ifdef xxx if ((errstat = rwl_init(&dev->lock)) != 0) { berrno be; diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index 8a5a6f1344..93baea05f7 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -221,9 +221,9 @@ private: public: DEVICE * volatile swap_dev; /* Swap vol from this device */ dlist *attached_dcrs; /* attached DCR list */ - pthread_mutex_t m_mutex; /* access control */ - pthread_mutex_t spool_mutex; /* mutex for updating spool_size */ - pthread_mutex_t acquire_mutex; /* mutex for acquire code */ + bthread_mutex_t m_mutex; /* access control */ + bthread_mutex_t spool_mutex; /* mutex for updating spool_size */ + bthread_mutex_t acquire_mutex; /* mutex for acquire code */ pthread_cond_t wait; /* thread wait variable */ pthread_cond_t wait_next_vol; /* wait for tape to be mounted */ pthread_t no_wait_id; /* this thread must not wait */ @@ -498,7 +498,7 @@ private: public: dlink dev_link; /* link to attach to dev */ JCR *jcr; /* pointer to JCR */ - pthread_mutex_t m_mutex; /* access control */ + bthread_mutex_t m_mutex; /* access control */ DEVICE * volatile dev; /* pointer to device */ DEVRES *device; /* pointer to device resource */ DEV_BLOCK *block; /* pointer to block */ diff --git a/bacula/src/stored/vol_mgr.c b/bacula/src/stored/vol_mgr.c index 61b2c9fbb7..dff4f21454 100644 --- a/bacula/src/stored/vol_mgr.c +++ b/bacula/src/stored/vol_mgr.c @@ -90,7 +90,7 @@ int vol_list_lock_count = 0; void init_vol_list_lock() { int errstat; - if ((errstat=rwl_init(&vol_list_lock)) != 0) { + if ((errstat=rwl_init(&vol_list_lock, PRIO_SD_VOL_LIST)) != 0) { berrno be; Emsg1(M_ABORT, 0, _("Unable to initialize volume list lock. ERR=%s\n"), be.bstrerror(errstat)); @@ -102,8 +102,6 @@ void term_vol_list_lock() rwl_destroy(&vol_list_lock); } - - /* * This allows a given thread to recursively call to lock_volumes() */