On Thu of July 4 2013, Mariusz Mazur wrote:

> Part two does ibm-specific error detection, so it's
> non-mergable. I'll send it later, maybe it'll be useful to some people.)

Attached. To actually use it, one needs to apply both patches and add the 
following to sd's config:

  Use MTIOCGET = No
  IOError at EOM = Yes
  IBM lintape = Yes



--mmazur
--- bacula-5.2.13.orig/src/stored/IBM_tape.h	1970-01-01 01:00:00.000000000 +0100
+++ bacula-5.2.13/src/stored/IBM_tape.h	2013-07-04 13:14:08.275153642 +0200
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ *   IBM_tape.h
+ *
+ *   (C) Copyright International Business Machines  Corp., 2001-2012
+ *   This file is part of the IBM Linux Enhanced SCSI Tape and
+ *   Medium Changer Device Driver
+ *
+ *   This library is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Lesser General Public License version 2.1
+ *   as published by the Free Software Foundation.
+ *
+ *   This library is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ *   the GNU Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public License
+ *   along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ******************************************************************************/
+
+#ifndef IBM_TAPE_H
+#define IBM_TAPE_H
+
+/*******************************************************************************
+* IOCTL Structures                                                             *
+*******************************************************************************/
+#ifndef unchar
+#define unchar unsigned char
+#endif
+
+#ifndef boolean
+#define boolean unchar
+#endif
+
+#ifndef BYTE
+#define BYTE unchar
+#endif
+
+#define SIOC_REQSENSE                 _IOR ('C',0x02,struct request_sense)
+
+struct request_sense {
+	uint valid : 1,                 /* information field is valid         */
+		err_code : 7;           /* error code                         */
+	unchar segnum;                  /* segment number                     */
+	uint fm : 1,                    /* file mark detected                 */
+		eom : 1,                /* end of medium                      */
+		ili : 1,                /* incorrect length indicator         */
+		resvd1 : 1,             /* reserved                           */
+		key : 4;                /* sense key                          */
+	int info;                       /* information bytes                  */
+	unchar addlen;                  /* additional sense length            */
+	uint cmdinfo;                   /* command specific information       */
+	unchar asc;                     /* additional sense code              */
+	unchar ascq;                    /* additional sense code qualifier    */
+	unchar fru;                     /* field replaceable unit code        */
+	uint sksv : 1,                  /* sense key specific valid           */
+		cd : 1,                 /* control/data                       */
+		resvd2 : 2,             /* reserved                           */
+		bpv : 1,                /* bit pointer valid                  */
+		sim : 3;                /* system information message         */
+	unchar field[2];                /* field pointer                      */
+	unchar vendor[109];             /* vendor specific (padded to 127)    */
+};
+
+#endif
--- bacula-5.2.13.orig/src/stored/dev.h	2013-02-19 20:21:35.000000000 +0100
+++ bacula-5.2.13/src/stored/dev.h	2013-07-04 17:59:53.838595174 +0200
@@ -135,6 +135,7 @@
 #define CAP_CHECKLABELS    (1<<22)    /* Check for ANSI/IBM labels */
 #define CAP_BLOCKCHECKSUM  (1<<23)    /* Create/test block checksum */
 #define CAP_IOERRATEOM     (1<<24)    /* IOError at EOM */
+#define CAP_IBMLINTAPE     (1<<25)    /* Assume it's lin_tape driver */
 
 /* Test state */
 #define dev_state(dev, st_state) ((dev)->state & (st_state))
--- bacula-5.2.13.orig/src/stored/stored_conf.c	2013-02-19 20:21:35.000000000 +0100
+++ bacula-5.2.13/src/stored/stored_conf.c	2013-07-04 18:00:39.110114148 +0200
@@ -124,6 +124,7 @@
    {"backwardspacefile",     store_bit,  ITEM(res_dev.cap_bits), CAP_BSF,  ITEM_DEFAULT, 1},
    {"bsfateom",              store_bit,  ITEM(res_dev.cap_bits), CAP_BSFATEOM, ITEM_DEFAULT, 0},
    {"ioerrorateom",          store_bit,  ITEM(res_dev.cap_bits), CAP_IOERRATEOM, ITEM_DEFAULT, 0},
+   {"ibmlintape",            store_bit,  ITEM(res_dev.cap_bits), CAP_IBMLINTAPE, ITEM_DEFAULT, 0},
    {"twoeof",                store_bit,  ITEM(res_dev.cap_bits), CAP_TWOEOF, ITEM_DEFAULT, 0},
    {"forwardspacerecord",    store_bit,  ITEM(res_dev.cap_bits), CAP_FSR,  ITEM_DEFAULT, 1},
    {"forwardspacefile",      store_bit,  ITEM(res_dev.cap_bits), CAP_FSF,  ITEM_DEFAULT, 1},
--- bacula-5.2.13.orig/src/stored/dev.c	2013-07-04 17:55:45.738750861 +0200
+++ bacula-5.2.13/src/stored/dev.c	2013-07-04 17:58:47.559835394 +0200
@@ -80,6 +80,7 @@
 
 #include "bacula.h"
 #include "stored.h"
+#include "IBM_tape.h"
 
 #ifndef O_NONBLOCK 
 #define O_NONBLOCK 0
@@ -1204,8 +1205,26 @@
              *  at EOM instead of EOF
              */
             } else if (has_cap(CAP_IOERRATEOM) && at_eof() && errno == EIO) {
-               Dmsg0(100, "Got EIO on read, assuming that's due to EOD\n");
-               stat = 0;
+               if (has_cap(CAP_IBMLINTAPE)) {
+                  struct request_sense sense_data;
+                  int rc;
+                  Dmsg0(100, "Got EIO on read, checking lin_tape sense data\n");
+                  memset(&sense_data, 0, sizeof(struct request_sense));
+                  rc = ioctl(m_fd, SIOC_REQSENSE, &sense_data);
+                  if (rc == 0 && sense_data.key == 0x08 && sense_data.asc == 0x00 && sense_data.ascq == 0x05) {
+                     Dmsg0(100, "Sense data confirms it's EOD\n");
+                     stat = 0;
+                  } else {
+                     Dmsg0(100, "Not at EOD, might be a real error. Check sense trace from lin_taped logs.\n");
+                     set_eot();
+                     clrerror(-1);
+                     Mmsg1(errmsg, _("read error on %s. ERR=Input/Output error.\n"), print_name());
+                     break;
+                  }
+               } else {
+                  Dmsg0(100, "Got EIO on read, assuming that's due to EOD\n");
+                  stat = 0;
+               }
             } else {
                berrno be;
                set_eot();
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to