Bacula-users

Re: [Bacula-users] bconsole(8) mount / Autochanger Mount Logic in stored/autochanger.c

2008-09-12 11:35:30
Subject: Re: [Bacula-users] bconsole(8) mount / Autochanger Mount Logic in stored/autochanger.c
From: "Brian A. Seklecki" <bseklecki AT collaborativefusion DOT com>
To: bacula-users AT lists.sourceforge DOT net
Date: Fri, 12 Sep 2008 11:35:19 -0400
The problem is at line 274 of stored/autochanger.c:

Per the "autochanger API", inscribed in stone at
dev-manual/Autochanger_Resource1.html, calls to "loaded" commands that
return "zero" (0) imply that the drive is empty.

Where as, in fact, slot zero could very well be the "source" slot of the
tape loaded into the "drive".

Instead, lets make that "-1", or "127", etc etc.... Instead of assuming
that:

- Slot 0 doesn't exist because it doesn't exist on GNU/Linux
- Slot 0 can exist, but non-GNU/Linux changer scripts must:

  - Decrement every incoming value
  - Increment every outgoing value

needlenose:/usr/ports/sysutils/bacula-server% diff
-u 
/usr/obj/usr/ports/sysutils/bacula-server/work/bacula-2.4.2/src/stored/autochanger.c
 /tmp/autochanger.c 
--- 
/usr/obj/usr/ports/sysutils/bacula-server/work/bacula-2.4.2/src/stored/autochanger.c
        2008-07-02 16:49:44.000000000 -0400
+++ /tmp/autochanger.c  2008-09-12 11:27:42.000000000 -0400
@@ -274,11 +274,12 @@
    Dmsg3(100, "run_prog: %s stat=%d result=%s", changer, status,
results.c_str());
    if (status == 0) {
       loaded = str_to_int32(results.c_str());
-      if (loaded > 0) {
+      if (loaded > -1) {
          Jmsg(jcr, M_INFO, 0, _("3302 Autochanger \"loaded? drive %d\",
result is Slot %d.\n"),
               drive, loaded);
          dev->set_slot(loaded);
-      } else {
+      } else  {
+       // -1 = Tape not loaded
+       // Slot 0 is not a special 
+       // Slot 0 is not a beautiful and unique snowflake
+       // Slot 0 is the same decaying organic matter as everything 
+       // else.
          Jmsg(jcr, M_INFO, 0, _("3302 Autochanger \"loaded? drive %d\",
result: nothing loaded.\n"),
               drive);
          dev->clear_slot();   /* unknown */

You get the idea.

~BAS


On Fri, 2008-09-12 at 10:11 -0400, Brian A. Seklecki wrote:
> All:
> 
> In *BSD, sa(4)/mt(4) devices can't be fopen()'d until they have media
> loaded.
> 
> So, when you issue "mount" command in bconsole(8), and the autochanger
> doesn't have a tape loaded, why would it try to access the tape drive
> w/o issuing a load command first?
> 
> I'm looking at the code a bit lost get_autochanger_loaded_slot() is
> called by autoload_device() on line 170 of stored/autochanger.c
> 
>   if (loaded != slot)
> 
>       try_to_unload
> 
> I think in this case, there should be a case for: 
>    if (loaded = 0) -- nothing loaded.
> 
>       - Don't try to unload
>       - Load
> 
> It's like something in unload_autochanger(), for some reason, is trying
> to access the drive.
> 
> * mount
> The defined Storage resources are:
>      1: Bar
>      2: Foo
>      3: TapeChanger
> Select Storage resource (1-3): 3
> Enter autochanger slot: 0
> 3301 Issuing autochanger "loaded? drive 0" command.
> 3302 Autochanger "loaded? drive 0", result: nothing loaded.
> 3901 Unable to open device "Ultrium" (/dev/nsa0): ERR=dev.c:432 Unable
> to open device "Ultrium" (/dev/nsa0): ERR=Device not configured
> 
> 
> Error 3901 only happens in stored/dircmd.c mount_cmd().  I don't see the
> path between autoload_device() and mount_cmd().
> 
> Also, we seem to be missing the step in "mount" where we actually load
> the tape into the drive :)
> 
> Is there maybe another CLI command hidden/undocumented?
> 
> 
-- 
Brian A. Seklecki <bseklecki AT collaborativefusion DOT com>
Collaborative Fusion, Inc.




IMPORTANT: This message contains confidential information and is intended only 
for the individual named. If the reader of this message is not an intended 
recipient (or the individual responsible for the delivery of this message to an 
intended recipient), please be advised that any re-use, dissemination, 
distribution or copying of this message is prohibited. Please notify the sender 
immediately by e-mail if you have received this e-mail by mistake and delete 
this e-mail from your system.



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users