Page MenuHomeFreeBSD

D34325.id103011.diff
No OneTemporary

D34325.id103011.diff

Index: sbin/camcontrol/fwdownload.c
===================================================================
--- sbin/camcontrol/fwdownload.c
+++ sbin/camcontrol/fwdownload.c
@@ -57,12 +57,15 @@
#include <err.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <cam/cam.h>
#include <cam/scsi/scsi_all.h>
+#include <cam/scsi/scsi_pass.h>
#include <cam/scsi/scsi_message.h>
#include <camlib.h>
@@ -759,6 +762,38 @@
return (retval);
}
+/*
+ * After the firmware is downloaded, we know the sense data has changed (or is
+ * likely to change since it contains the firmware version). Rescan the lun with
+ * a flag to tell the kernel it's OK. This allows us to continnue using the old
+ * periph/disk in the kernel, which is less disruptive.
+ */
+static int
+fw_rescan_lun(struct cam_device *dev, bool printerrors)
+{
+ union ccb ccb;
+
+ bzero(&ccb, sizeof(union ccb));
+ ccb.ccb_h.func_code = XPT_SCAN_LUN;
+ ccb.ccb_h.path_id = dev->bus_id;
+ ccb.ccb_h.target_id = dev->target_id;
+ ccb.ccb_h.target_lun = dev->target_lun;
+ ccb.ccb_h.timeout = 5000;
+ ccb.crcn.flags = CAM_EXPECT_INQ_CHANGE;
+ /* run this at a low priority */
+ ccb.ccb_h.pinfo.priority = 5;
+
+ if (cam_send_ccb(dev, &ccb) < 0 ||
+ (ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+ warn("Can't send rescan lun");
+ if (printerrors)
+ cam_error_print(dev, &ccb, CAM_ESF_ALL, CAM_EPF_ALL,
+ stderr);
+ return (1);
+ }
+ return (0);
+}
+
/*
* Download firmware stored in buf to cam_dev. If simulation mode
* is enabled, only show what packet sizes would be sent to the
@@ -912,6 +947,9 @@
if (quiet == 0)
progress_complete(&progress, size - img_size);
cam_freeccb(ccb);
+ if (retval == 0 && !sim_mode) {
+ fw_rescan_lun(cam_dev, printerrors);
+ }
return (retval);
}

File Metadata

Mime Type
text/plain
Expires
Thu, Jun 11, 10:09 AM (16 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33875597
Default Alt Text
D34325.id103011.diff (1 KB)

Event Timeline