]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/acquire.c
- Remove \a and -e from error echos in most Makefiles.
[bacula/bacula] / bacula / src / stored / acquire.c
index 71c9811a3a374b99f9cb59a75b5184940b2c5b0a..303fe650a83184e97770209ad38830463b5e3371 100644 (file)
@@ -28,6 +28,8 @@
 #include "bacula.h"                   /* pull in global headers */
 #include "stored.h"                   /* pull in Storage Deamon headers */
 
+static int can_reserve_drive(DCR *dcr);
+
 /*
  * Create a new Device Control Record and attach
  *   it to the device (if this is a real job).
@@ -53,11 +55,42 @@ DCR *new_dcr(JCR *jcr, DEVICE *dev)
    dcr->max_spool_size = dev->device->max_spool_size;
    /* Attach this dcr only if dev is initialized */
    if (dev->fd != 0 && jcr && jcr->JobType != JT_SYSTEM) {
-      dev->attached_dcrs->append(dcr);
+      dev->attached_dcrs->append(dcr); /* attach dcr to device */
+//    jcr->dcrs->append(dcr);        /* put dcr in list for Job */
    }
    return dcr;
 }
 
+/*
+ * Search the dcrs list for the given dcr. If it is found,
+ *  as it should be, then remove it. Also zap the jcr pointer
+ *  to the dcr if it is the same one.
+ */
+#ifdef needed
+static void remove_dcr_from_dcrs(DCR *dcr)
+{
+   JCR *jcr = dcr->jcr;
+   if (jcr->dcrs) {
+      int i = 0;
+      DCR *ldcr;
+      int num = jcr->dcrs->size();
+      for (i=0; i < num; i++) {
+        ldcr = (DCR *)jcr->dcrs->get(i);
+        if (ldcr == dcr) {
+           jcr->dcrs->remove(i);
+           if (jcr->dcr == dcr) {
+              jcr->dcr = NULL;
+           }
+        }
+      }
+   }
+}
+#endif
+
+/*
+ * Free up all aspects of the given dcr -- i.e. dechain it,
+ *  release allocated memory, zap pointers, ...
+ */
 void free_dcr(DCR *dcr)
 {
    JCR *jcr = dcr->jcr;
@@ -80,7 +113,8 @@ void free_dcr(DCR *dcr)
 
    /* Detach this dcr only if the dev is initialized */
    if (dev->fd != 0 && jcr && jcr->JobType != JT_SYSTEM) {
-      dcr->dev->attached_dcrs->remove(dcr);
+      dev->attached_dcrs->remove(dcr); /* detach dcr from device */
+//    remove_dcr_from_dcrs(dcr);      /* remove dcr from jcr list */
    }
    if (dcr->block) {
       free_block(dcr->block);
@@ -94,6 +128,7 @@ void free_dcr(DCR *dcr)
    free(dcr);
 }
 
+
 /*
  * We "reserve" the drive by setting the ST_READ bit. No one else
  *  should touch the drive until that is cleared.
@@ -101,38 +136,40 @@ void free_dcr(DCR *dcr)
  *  starting the job. If the device is not available, the DIR
  *  can wait (to be implemented 1/05).
  */
-bool reserve_device_for_read(JCR *jcr, DEVICE *dev)
+bool reserve_device_for_read(DCR *dcr)
 {
-   DCR *dcr = jcr->dcr;
-   bool ok = false;
+   DEVICE *dev = dcr->dev;
+   JCR *jcr = dcr->jcr;
+   bool first;
 
    ASSERT(dcr);
-   if (device_is_unmounted(dev)) {
-      Jmsg(jcr, M_WARNING, 0, _("device %s is BLOCKED due to user unmount.\n"),
-        dev_name(dev));
-      return false;
-   }
-   lock_device(dev);
-   block_device(dev, BST_DOING_ACQUIRE);
-   unlock_device(dev);
 
-   if (dev->is_busy()) {
-      Jmsg2(jcr, M_FATAL, 0, _("Device %s is busy. Job %d canceled.\n"),
-           dev_name(dev), jcr->JobId);
-      goto get_out;
+   dev->block(BST_DOING_ACQUIRE);
+
+   Mmsg(jcr->errmsg, _("Device %s is BLOCKED due to user unmount.\n"),
+       dev->print_name());
+   for (first=true; device_is_unmounted(dev); first=false) {
+      dev->unblock();
+      if (!wait_for_device(dcr, jcr->errmsg, first))  {
+        return false;
+      }
+     dev->block(BST_DOING_ACQUIRE);
    }
-   if (!dcr) {
-      dcr = new_dcr(jcr, dev);
+
+   Mmsg2(jcr->errmsg, _("Device %s is busy. Job %d canceled.\n"),
+        dev->print_name(), jcr->JobId);
+   for (first=true; dev->is_busy(); first=false) {
+      dev->unblock();
+      if (!wait_for_device(dcr, jcr->errmsg, first)) {
+        return false;
+      }
+      dev->block(BST_DOING_ACQUIRE);
    }
+
    dev->clear_append();
    dev->set_read();
-   ok = true;
-
-get_out:
-   P(dev->mutex);
-   unblock_device(dev);
-   V(dev->mutex);
-   return ok;
+   dev->unblock();
+   return true;
 }
 
 
@@ -145,27 +182,19 @@ get_out:
  *  Returns: NULL if failed for any reason
  *          dcr  if successful
  */
-DCR *acquire_device_for_read(JCR *jcr, DEVICE *dev)
+DCR *acquire_device_for_read(DCR *dcr)
 {
+   DEVICE *dev = dcr->dev;
+   JCR *jcr = dcr->jcr;
    bool vol_ok = false;
    bool tape_previously_mounted;
    bool tape_initially_mounted;
    VOL_LIST *vol;
    bool try_autochanger = true;
    int i;
-   DCR *dcr = jcr->dcr;
    int vol_label_status;
    
-   lock_device(dev);
-   block_device(dev, BST_DOING_ACQUIRE);
-   unlock_device(dev);
-
-   init_dev_wait_timers(dev);
-
-   tape_previously_mounted = dev->can_read() ||
-                            dev->can_append() ||
-                            dev->is_labeled();
-   tape_initially_mounted = tape_previously_mounted;
+   dev->block(BST_DOING_ACQUIRE);
 
    if (dev->num_writers > 0) {
       Jmsg2(jcr, M_FATAL, 0, _("Num_writers=%d not zero. Job %d canceled.\n"), 
@@ -183,8 +212,19 @@ DCR *acquire_device_for_read(JCR *jcr, DEVICE *dev)
    for (i=1; i<jcr->CurVolume; i++) {
       vol = vol->next;
    }
+   if (!vol) {
+      goto get_out;                  /* should not happen */   
+   }
    bstrncpy(dcr->VolumeName, vol->VolumeName, sizeof(dcr->VolumeName));
 
+   init_device_wait_timers(dcr);
+
+   tape_previously_mounted = dev->can_read() ||
+                            dev->can_append() ||
+                            dev->is_labeled();
+   tape_initially_mounted = tape_previously_mounted;
+
+
    /* Volume info is always needed because of VolParts */
    Dmsg0(200, "dir_get_volume_info\n");
    if (!dir_get_volume_info(dcr, GET_VOL_INFO_FOR_READ)) {
@@ -194,7 +234,7 @@ DCR *acquire_device_for_read(JCR *jcr, DEVICE *dev)
    dev->num_parts = dcr->VolCatInfo.VolCatParts;
    
    for (i=0; i<5; i++) {
-      dev->clear_label();               /* force reread of label */
+      dev->clear_labeled();             /* force reread of label */
       if (job_canceled(jcr)) {
          Mmsg1(dev->errmsg, _("Job %d canceled.\n"), jcr->JobId);
         goto get_out;                /* error return */
@@ -208,6 +248,8 @@ DCR *acquire_device_for_read(JCR *jcr, DEVICE *dev)
          Dmsg1(120, "bstored: open vol=%s\n", dcr->VolumeName);
         if (open_dev(dev, dcr->VolumeName, OPEN_READ_ONLY) < 0) {
            if (dev->dev_errno == EIO) {   /* no tape loaded */
+              Jmsg3(jcr, M_WARNING, 0, _("Open device %s Volume \"%s\" failed: ERR=%s\n"),
+                   dev->print_name(), dcr->VolumeName, strerror_dev(dev));
               goto default_path;
            }
            
@@ -218,11 +260,11 @@ DCR *acquire_device_for_read(JCR *jcr, DEVICE *dev)
               break;
            }
            
-            Jmsg(jcr, M_FATAL, 0, _("Open device %s volume %s failed, ERR=%s\n"),
-               dev_name(dev), dcr->VolumeName, strerror_dev(dev));
+            Jmsg3(jcr, M_FATAL, 0, _("Open device %s Volume \"%s\" failed: ERR=%s\n"),
+               dev->print_name(), dcr->VolumeName, strerror_dev(dev));
            goto get_out;
         }
-         Dmsg1(129, "open_dev %s OK\n", dev_name(dev));
+         Dmsg1(129, "open_dev %s OK\n", dev->print_name());
       }
       
       if (dev->is_dvd()) {
@@ -231,10 +273,6 @@ DCR *acquire_device_for_read(JCR *jcr, DEVICE *dev)
         vol_label_status = read_dev_volume_label(dcr);
       }
       
-      /****FIXME***** do not reread label if ioctl() says we are
-       *  correctly possitioned.  Possibly have way user can turn
-       *  this optimization (to be implemented) off.
-       */
       Dmsg0(200, "calling read-vol-label\n");
       switch (vol_label_status) {
       case VOL_OK:
@@ -258,7 +296,7 @@ DCR *acquire_device_for_read(JCR *jcr, DEVICE *dev)
         }
         /* Fall through */
       default:
-         Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
+         Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg);
 default_path:
         tape_previously_mounted = true;
         
@@ -276,7 +314,7 @@ default_path:
            stat = autoload_device(dcr, 0, NULL);
            if (stat > 0) {
               try_autochanger = false;
-              continue;
+              continue;              /* try reading volume mounted */
            }
         }
         
@@ -291,8 +329,8 @@ default_path:
       break;
    } /* end for loop */
    if (!vol_ok) {
-      Jmsg1(jcr, M_FATAL, 0, _("Too many errors trying to mount device \"%s\".\n"),
-           dev_name(dev));
+      Jmsg1(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"),
+           dev->print_name());
       goto get_out;
    }
 
@@ -301,12 +339,10 @@ default_path:
    set_jcr_job_status(jcr, JS_Running);
    dir_send_job_status(jcr);
    Jmsg(jcr, M_INFO, 0, _("Ready to read from volume \"%s\" on device %s.\n"),
-      dcr->VolumeName, dev_name(dev));
+      dcr->VolumeName, dev->print_name());
 
 get_out:
-   P(dev->mutex);
-   unblock_device(dev);
-   V(dev->mutex);
+   dev->unblock();
    if (!vol_ok) {
       free_dcr(dcr);
       dcr = NULL;
@@ -322,78 +358,124 @@ get_out:
  *  the DIR to reserve multiple devices before *really* 
  *  starting the job. It also permits the SD to refuse 
  *  certain devices (not up, ...).
+ *
+ * Note, in reserving a device, if the device is for the
+ *  same pool and the same pool type, then it is acceptable.
+ *  The Media Type has already been checked. If we are
+ *  the first tor reserve the device, we put the pool
+ *  name and pool type in the device record.
  */
-bool reserve_device_for_append(JCR *jcr, DEVICE *dev)
+bool reserve_device_for_append(DCR *dcr)
 {
-   DCR *dcr = jcr->dcr;
-   bool recycle;
+   JCR *jcr = dcr->jcr;
+   DEVICE *dev = dcr->dev;
    bool ok = false;
+   bool first;
 
    ASSERT(dcr);
+   dev->block(BST_DOING_ACQUIRE);
+
+   Mmsg2(jcr->errmsg, _("Device %s is busy reading. Job %d canceled.\n"),
+        dev->print_name(), jcr->JobId);
+   for (first=true; dev->can_read(); first=false) {
+      dev->unblock();
+      if (!wait_for_device(dcr, jcr->errmsg, first)) {
+        return false;
+      }
+      dev->block(BST_DOING_ACQUIRE);
+   }
 
-   lock_device(dev);
-   block_device(dev, BST_DOING_ACQUIRE);
-   unlock_device(dev);
-   if (device_is_unmounted(dev)) {
-      Jmsg(jcr, M_WARNING, 0, _("device %s is BLOCKED due to user unmount.\n"),
-        dev_name(dev));
-      goto get_out;
+
+   Mmsg(jcr->errmsg, _("Device %s is BLOCKED due to user unmount.\n"),
+       dev->print_name());
+   for (first=true; device_is_unmounted(dev); first=false) {
+      dev->unblock();
+      if (!wait_for_device(dcr, jcr->errmsg, first))  {
+        return false;
+      }
+     dev->block(BST_DOING_ACQUIRE);
    }
+
    Dmsg1(190, "reserve_append device is %s\n", dev_is_tape(dev)?"tape":"disk");
-   if (dev->can_append() || dev->num_writers > 0 || dev->reserved_device) {
-      Dmsg0(190, "device already in append.\n");
-      /*
-       * Device already in append mode or reserved for write
-       *
-       * Check if we have the right Volume mounted
-       *   OK if current volume info OK
-       *   OK if next volume matches current volume
-       */
-      bstrncpy(dcr->VolumeName, dev->VolHdr.VolName, sizeof(dcr->VolumeName));
-      if (!dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE) &&
-         !(dir_find_next_appendable_volume(dcr) &&
-           strcmp(dev->VolHdr.VolName, dcr->VolumeName) == 0)) { /* wrong tape mounted */
-         Dmsg0(190, "Wrong tape mounted.\n");
-        if (dev->num_writers != 0 || dev->reserved_device) {
-            Jmsg(jcr, M_FATAL, 0, _("Device %s is busy writing on another Volume.\n"), dev_name(dev));
-           goto get_out;
-        }
-      } else {
-        /*
-         * At this point, the correct tape is already mounted, so
-         *   we do not need to do mount_next_write_volume(), unless
-         *   we need to recycle the tape.
-         */
-          recycle = strcmp(dcr->VolCatInfo.VolCatStatus, "Recycle") == 0;
-          Dmsg1(190, "Correct tape mounted. recycle=%d\n", recycle);
-         if (recycle && dev->num_writers != 0) {
-             Jmsg(jcr, M_FATAL, 0, _("Cannot recycle volume \"%s\""
-                  " because it is in use by another job.\n"));
-            goto get_out;
-         }
-         if (dev->num_writers == 0) {
-            memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
-         }
-       }
-   } else {
-      if (dev->can_read()) {
-         Jmsg(jcr, M_FATAL, 0, _("Device %s is busy reading.\n"), dev_name(dev));
-        goto get_out;
+
+   for ( ;; ) {
+      switch (can_reserve_drive(dcr)) {
+      case 0:
+        /* ****FIXME**** Make wait */
+        goto bail_out;
+      case -1:
+        goto bail_out;               /* error */
+      default:
+        break;                       /* OK, reserve drive */
       }
-      ASSERT(dev->num_writers == 0);
+      break;
    }
 
+
    dev->reserved_device++;
    dcr->reserved_device = true;
    ok = true;
 
-get_out:
-   P(dev->mutex);
-   unblock_device(dev);
-   V(dev->mutex);
+bail_out:
+   dev->unblock();
    return ok;
 }
 
+/*
+ * Returns: 1 if drive can be reserved
+ *         0 if we should wait
+ *        -1 on error
+ */
+static int can_reserve_drive(DCR *dcr) 
+{
+   DEVICE *dev = dcr->dev;
+   JCR *jcr = dcr->jcr;
+   /*
+    * First handle the case that the drive is not yet in append mode
+    */
+   if (!dev->can_append() && dev->num_writers == 0) {
+      /* Now check if there are any reservations on the drive */
+      if (dev->reserved_device) {          
+        /* Yes, now check if we want the same Pool and pool type */
+        if (strcmp(dev->pool_name, dcr->pool_name) == 0 &&
+            strcmp(dev->pool_type, dcr->pool_type) == 0) {
+           /* OK, compatible device */
+        } else {
+           /* Drive not suitable for us */
+            Jmsg(jcr, M_WARNING, 0, _("Device %s is busy writing on another Volume.\n"), dev->print_name());
+           return 0;                 /* wait */
+        }
+      } else {
+        /* Device is available but not yet reserved, reserve it for us */
+        bstrncpy(dev->pool_name, dcr->pool_name, sizeof(dev->pool_name));
+        bstrncpy(dev->pool_type, dcr->pool_type, sizeof(dev->pool_type));
+        dev->PoolId = dcr->PoolId;
+      }
+      return 1;                      /* reserve drive */
+   }
+
+   /*
+    * Now check if the device is in append mode 
+    */
+   if (dev->can_append() || dev->num_writers > 0) {
+      Dmsg0(190, "device already in append.\n");
+      /* Yes, now check if we want the same Pool and pool type */
+      if (strcmp(dev->pool_name, dcr->pool_name) == 0 &&
+         strcmp(dev->pool_type, dcr->pool_type) == 0) {
+        /* OK, compatible device */
+      } else {
+        /* Drive not suitable for us */
+         Jmsg(jcr, M_WARNING, 0, _("Device %s is busy writing on another Volume.\n"), dev->print_name());
+        return 0;                    /* wait */
+      }
+   } else {
+      Pmsg0(000, "Logic error!!!! Should not get here.\n");
+      Jmsg0(jcr, M_FATAL, 0, _("Logic error!!!! Should not get here.\n"));
+      return -1;                     /* error, should not get here */
+   }
+   return 1;                         /* reserve drive */
+}
+
 /*
  * Acquire device for writing. We permit multiple writers.
  *  If this is the first one, we read the label.
@@ -403,25 +485,30 @@ get_out:
  *   Note, normally reserve_device_for_append() is called
  *   before this routine.
  */
-DCR *acquire_device_for_append(JCR *jcr, DEVICE *dev)
+DCR *acquire_device_for_append(DCR *dcr)
 {
    bool release = false;
    bool recycle = false;
    bool do_mount = false;
-   DCR *dcr = jcr->dcr;
+   DEVICE *dev = dcr->dev;
+   JCR *jcr = dcr->jcr;
 
-   if (!dcr) {
-      dcr = new_dcr(jcr, dev);
-   }
-   lock_device(dev);
-   block_device(dev, BST_DOING_ACQUIRE);
-   unlock_device(dev);
+   dev->block(BST_DOING_ACQUIRE);
    Dmsg1(190, "acquire_append device is %s\n", dev_is_tape(dev)?"tape":"disk");
 
    if (dcr->reserved_device) {
       dev->reserved_device--;
       dcr->reserved_device = false;
    }
+
+   /*
+    * With the reservation system, this should not happen
+    */
+   if (dev->can_read()) {
+      Jmsg(jcr, M_FATAL, 0, _("Device %s is busy reading.\n"), dev->print_name());
+      goto get_out;
+   }
+
    if (dev->can_append()) {
       Dmsg0(190, "device already in append.\n");
       /*
@@ -439,7 +526,7 @@ DCR *acquire_device_for_append(JCR *jcr, DEVICE *dev)
            strcmp(dev->VolHdr.VolName, dcr->VolumeName) == 0)) { /* wrong tape mounted */
          Dmsg0(190, "Wrong tape mounted.\n");
         if (dev->num_writers != 0 || dev->reserved_device) {
-            Jmsg(jcr, M_FATAL, 0, _("Device %s is busy writing on another Volume.\n"), dev_name(dev));
+            Jmsg(jcr, M_FATAL, 0, _("Device %s is busy writing on another Volume.\n"), dev->print_name());
            goto get_out;
         }
         /* Wrong tape mounted, release it, then fall through to get correct one */
@@ -466,10 +553,6 @@ DCR *acquire_device_for_append(JCR *jcr, DEVICE *dev)
    } else {
       /* Not already in append mode, so mount the device */
       Dmsg0(190, "Not in append mode, try mount.\n");
-      if (dev->can_read()) {
-         Jmsg(jcr, M_FATAL, 0, _("Device %s is busy reading.\n"), dev_name(dev));
-        goto get_out;
-      }
       ASSERT(dev->num_writers == 0);
       do_mount = true;
    }
@@ -480,8 +563,8 @@ DCR *acquire_device_for_append(JCR *jcr, DEVICE *dev)
       if (!mounted) {
         if (!job_canceled(jcr)) {
             /* Reduce "noise" -- don't print if job canceled */
-            Jmsg(jcr, M_FATAL, 0, _("Could not ready device \"%s\" for append.\n"),
-              dev_name(dev));
+            Jmsg(jcr, M_FATAL, 0, _("Could not ready device %s for append.\n"),
+              dev->print_name());
         }
         goto get_out;
       }
@@ -501,9 +584,7 @@ get_out:
    free_dcr(dcr);
    dcr = NULL;
 ok_out:
-   P(dev->mutex);
-   unblock_device(dev);
-   V(dev->mutex);
+   dev->unblock();
    return dcr;
 }
 
@@ -512,10 +593,12 @@ ok_out:
  *  the device remains open.
  *
  */
-bool release_device(JCR *jcr)
+bool release_device(DCR *dcr)
 {
-   DCR *dcr = jcr->dcr;
+   bool ok = true;
+   JCR *jcr = dcr->jcr;
    DEVICE *dev = dcr->dev;
+
    lock_device(dev);
    Dmsg1(100, "release_device device is %s\n", dev_is_tape(dev)?"tape":"disk");
 
@@ -527,11 +610,7 @@ bool release_device(JCR *jcr)
 
    if (dev->can_read()) {
       dev->clear_read();             /* clear read bit */
-      /* Close if file or !CAP_ALWAYSOPEN */
-      if (!dev->is_tape() || !dev_cap(dev, CAP_ALWAYSOPEN)) {
-        offline_or_rewind_dev(dev);
-        close_dev(dev);
-      }
+
       /******FIXME**** send read volume usage statistics to director */
 
    } else if (dev->num_writers > 0) {
@@ -542,27 +621,33 @@ bool release_device(JCR *jcr)
         if (!dir_create_jobmedia_record(dcr)) {
             Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
               dcr->VolCatInfo.VolCatName, jcr->Job);
+           ok = false;
         }
         /* If no more writers, write an EOF */
         if (!dev->num_writers && dev_can_write(dev)) {
            weof_dev(dev, 1);
+           write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolName);
         }
         dev->VolCatInfo.VolCatFiles = dev->file;   /* set number of files */
         dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs */
         /* Note! do volume update before close, which zaps VolCatInfo */
          Dmsg0(100, "dir_update_vol_info. Release0\n");
         dir_update_volume_info(dcr, false); /* send Volume info to Director */
+         Dmsg0(100, "==== write ansi eof label \n");
       }
 
-      /* If no writers, close if file or !CAP_ALWAYS_OPEN */
-      if (dev->num_writers == 0 && (!dev->is_tape() || !dev_cap(dev, CAP_ALWAYSOPEN))) {
-        offline_or_rewind_dev(dev);
-        close_dev(dev);
-      }
    } else {
-      Jmsg2(jcr, M_FATAL, 0, _("BAD ERROR: release_device %s, Volume \"%s\" not in use.\n"),
-           dev_name(dev), NPRT(dcr->VolumeName));
-      Jmsg2(jcr, M_ERROR, 0, _("num_writers=%d state=%x\n"), dev->num_writers, dev->state);
+      /*               
+       * If we reach here, it is most likely because the
+       *   has failed, since the device is not in read mode and
+       *   there are no writers.
+       */
+   }
+
+   /* If no writers, close if file or !CAP_ALWAYS_OPEN */
+   if (dev->num_writers == 0 && (!dev->is_tape() || !dev_cap(dev, CAP_ALWAYSOPEN))) {
+      offline_or_rewind_dev(dev);
+      close_dev(dev);
    }
 
    /* Fire off Alert command and include any output */
@@ -592,7 +677,8 @@ bool release_device(JCR *jcr)
       free_pool_memory(alert);
    }
    unlock_device(dev);
-   free_dcr(jcr->dcr);
+   free_dcr(dcr);
    jcr->dcr = NULL;
-   return true;
+   pthread_cond_broadcast(&wait_device_release);
+   return ok;
 }