]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Rework certain SD locking based on gdb tracebacks of deadlocks
authorKern Sibbald <kern@sibbald.com>
Thu, 27 Mar 2008 09:57:54 +0000 (09:57 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 27 Mar 2008 09:57:54 +0000 (09:57 +0000)
     sent by Eric. This code now uses only the volume_lock() rather
     than the reservations lock when at EOM and acquiring a new
     volume.
kes  Ensure only one exit point in several subroutines.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6695 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/stored/askdir.c
bacula/src/stored/reserve.c
bacula/src/version.h
bacula/technotes-2.1

index 6d1d2ce823ff6e37e86d6042f1eb0e2118325f3f..c5adcdbe5f53a93e043381c2ecd93a12ccc2acb7 100644 (file)
@@ -252,6 +252,7 @@ bool dir_find_next_appendable_volume(DCR *dcr)
 {
     JCR *jcr = dcr->jcr;
     BSOCK *dir = jcr->dir_bsock;
+    bool rtn;
 
     Dmsg2(200, "dir_find_next_appendable_volume: reserved=%d Vol=%s\n", 
        dcr->reserved_device, dcr->VolumeName);
@@ -261,7 +262,7 @@ bool dir_find_next_appendable_volume(DCR *dcr)
      *   the most available could already be mounted on another
      *   drive, so we continue looking for a not in use Volume.
      */
-    lock_reservations();
+    lock_volumes();
     P(vol_info_mutex);
     dcr->volume_in_use = false;
     for (int vol_index=1;  vol_index < 40; vol_index++) {
@@ -271,8 +272,7 @@ bool dir_find_next_appendable_volume(DCR *dcr)
        unbash_spaces(dcr->media_type);
        unbash_spaces(dcr->pool_name);
        Dmsg1(100, ">dird %s", dir->msg);
-       bool ok = do_get_volume_info(dcr);
-       if (ok) {
+       if (do_get_volume_info(dcr)) {
           if (!is_volume_in_use(dcr)) {
              Dmsg0(400, "dir_find_next_appendable_volume return true\n");
              if (reserve_volume(dcr, dcr->VolumeName) == 0) {
@@ -280,9 +280,8 @@ bool dir_find_next_appendable_volume(DCR *dcr)
                     dcr->dev->print_name());
                 continue;
              }
-             V(vol_info_mutex);
-             unlock_reservations();
-             return true;
+             rtn = true;
+             goto get_out;
           } else {
              Dmsg1(100, "Volume %s is in use.\n", dcr->VolumeName);
              dcr->volume_in_use = true;
@@ -293,11 +292,13 @@ bool dir_find_next_appendable_volume(DCR *dcr)
           dcr->dev->print_name());
        break;
     }
-
+    rtn = false;
     dcr->VolumeName[0] = 0;
+
+get_out:
     V(vol_info_mutex);
-    unlock_reservations();
-    return false;
+    unlock_volumes();
+    return rtn;
 }
 
 
index 33340c1e6edb134675bf35de6182e59bef19bc51..bc102f2d1b4d8431612492ede3de09b834580276 100644 (file)
@@ -410,7 +410,6 @@ get_out:
  */
 void switch_device(DCR *dcr, DEVICE *dev)
 {
-   // lock_reservations();
    DCR save_dcr;
 
    dev->dlock();
@@ -589,28 +588,36 @@ void free_volume_list()
 
 bool is_volume_in_use(DCR *dcr)
 {
-   VOLRES *vol = find_volume(dcr);
+   bool rtn = false;
+   VOLRES *vol;
+
+   lock_volumes();
+   vol = find_volume(dcr);
    if (!vol) {
       Dmsg2(dbglvl, "jid=%u Vol=%s not in use.\n", jid(), dcr->VolumeName);
-      return false;                   /* vol not in list */
+      goto get_out;                   /* vol not in list */
    }
    ASSERT(vol->dev != NULL);
 
    if (dcr->dev == vol->dev) {        /* same device OK */
       Dmsg2(dbglvl, "jid=%u Vol=%s on same dev.\n", jid(), dcr->VolumeName);
-      return false;
+      goto get_out;
    } else {
       Dmsg4(dbglvl, "jid=%u Vol=%s on %s we have %s\n", jid(), dcr->VolumeName,
             vol->dev->print_name(), dcr->dev->print_name());
    }
    if (!vol->dev->is_busy()) {
       Dmsg3(dbglvl, "jid=%u Vol=%s dev=%s not busy.\n", jid(), dcr->VolumeName, vol->dev->print_name());
-      return false;
+      goto get_out;
    } else {
       Dmsg3(dbglvl, "jid=%u Vol=%s dev=%s busy.\n", jid(), dcr->VolumeName, vol->dev->print_name());
    }
    Dmsg3(dbglvl, "jid=%u Vol=%s in use by %s.\n", jid(), dcr->VolumeName, vol->dev->print_name());
-   return true;
+   rtn = true;
+
+get_out:
+   unlock_volumes();
+   return rtn;
 }
 
 
index 9ff870d571b689d3214b29379b391bfbe7b63a42..25ca63c7c42a6e8eb110470303aded3cc42b9939 100644 (file)
@@ -3,9 +3,9 @@
  */
 
 #undef  VERSION
-#define VERSION "2.2.9-b2"
-#define BDATE   "24 March 2008"
-#define LSMDATE "24Mar08"
+#define VERSION "2.2.9-b3"
+#define BDATE   "27 March 2008"
+#define LSMDATE "27Mar08"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2008"       /* year for copyright messages in progs */
index b7dcdbeb155f16599c05de254980f5c8d4e3a29d..328050599f3ab64efcbc226f4faa3403ba5bdfda 100644 (file)
@@ -1,6 +1,14 @@
               Technical notes on version 2.2
 
 General:
+Beta release Version 2.2.9-b3
+27Mar08
+kes  Rework certain SD locking based on gdb tracebacks of deadlocks
+     sent by Eric. This code now uses only the volume_lock() rather
+     than the reservations lock when at EOM and acquiring a new
+     volume. 
+kes  Ensure only one exit point in several subroutines.
+
 22Mar08
 kes  Fix to JobMedia fix.
 kes  Fix bug pointed out by Peter Much that causes the StorageId to