File Interpret-DID_NEXUS_FAILURE-as-reservation-conflict.patch of Package sg3_utils.1394

From 33b06761c91ede70fff0dcc724d0f27305587806 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Fri, 29 May 2015 12:18:37 +0200
Subject: [PATCH] Interpret DID_NEXUS_FAILURE as 'reservation conflict'

As reservation conflict doesn't necessarily show up as a scsi
cdb error, it might also end up as a 'DID_NEXUS_FAILURE'
in the scsi command result host_byte.

References: bsc#903332

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 include/sg_lib.h    |    1 +
 lib/sg_cmds_basic.c |    8 ++------
 lib/sg_io_linux.c   |    2 ++
 3 files changed, 5 insertions(+), 6 deletions(-)

--- a/include/sg_lib.h
+++ b/include/sg_lib.h
@@ -254,6 +254,7 @@ void sg_print_scsi_status(int scsi_statu
                                 /*       [sk,asc,ascq: 0x0,*,*] */
 #define SG_LIB_CAT_RECOVERED 21 /* Successful command after recovered err */
                                 /*       [sk,asc,ascq: 0x1,*,*] */
+#define SG_LIB_CAT_RES_CONFLICT SAM_STAT_RESERVATION_CONFLICT
 #define SG_LIB_CAT_MALFORMED 97 /* Response to SCSI command malformed */
 #define SG_LIB_CAT_SENSE 98     /* Something else is in the sense buffer */
 #define SG_LIB_CAT_OTHER 99     /* Some other error/warning has occurred */
--- a/lib/sg_cmds_basic.c
+++ b/lib/sg_cmds_basic.c
@@ -200,12 +200,8 @@ sg_cmds_process_resp(struct sg_pt_base *
             get_scsi_pt_transport_err_str(ptvp, sizeof(b), b);
             fprintf(sg_warnings_strm, "%s: transport: %s\n", leadin, b);
         }
-        if ((SAM_STAT_CHECK_CONDITION == get_scsi_pt_status_response(ptvp))
-            && (slen > 0))
-            return sg_cmds_process_helper(leadin, mx_di_len, resid, sbp,
-                                          slen, noisy, verbose, o_sense_cat);
-        else
-            return -1;
+        return sg_cmds_process_helper(leadin, mx_di_len, resid, sbp,
+                                      slen, noisy, verbose, o_sense_cat);
     case SCSI_PT_RESULT_OS_ERR:
         if (verbose || noisy) {
             get_scsi_pt_os_err_str(ptvp, sizeof(b), b);
--- a/lib/sg_io_linux.c
+++ b/lib/sg_io_linux.c
@@ -229,6 +229,8 @@ sg_err_category_new(int scsi_status, int
             (SG_LIB_DID_BUS_BUSY == host_status) ||
             (SG_LIB_DID_TIME_OUT == host_status))
             return SG_LIB_CAT_TIMEOUT;
+        if (SG_LIB_DID_NEXUS_FAILURE == host_status)
+            return SG_LIB_CAT_RES_CONFLICT;
     }
     if (SG_LIB_DRIVER_TIMEOUT == masked_driver_status)
         return SG_LIB_CAT_TIMEOUT;
openSUSE Build Service is sponsored by