git: 8f5c107656c4 - stable/13 - camcontrol fwdownload minor improvements
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 09 Mar 2022 20:52:58 UTC
The branch stable/13 has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=8f5c107656c4aca6fac52f3e5a510a8a9cc67c89
commit 8f5c107656c4aca6fac52f3e5a510a8a9cc67c89
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-02-22 21:25:32 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-03-09 20:52:23 +0000
camcontrol fwdownload minor improvements
Minor improvements to the fwdownload code suggested by chs@:
o Print the path_id/target we're rescanning so it's not invisible
o No need for XPT_GDEVLIST, all the info is filled in. Remove sending it
as well as a comment related to it from a mistaken observation. libcam
always fills these in properly, so use those for the ccb path/target.
o Don't leak /dev/xpt fd in success cases.
o Rename fw_rescan_lun to fw_rescan_target and pass sim_mode to
only print path_id and target_id info.
Reviewed by: chs@
Fixes: 9835900cb95bcd068774934961fb1419719d595b
Sponsored by: Netflix
MFC After: 1 week
Differential Revision: https://reviews.freebsd.org/D34348
(cherry picked from commit 78fbaa1fac2677feeb2094048d77587a2ab80d11)
---
sbin/camcontrol/fwdownload.c | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
diff --git a/sbin/camcontrol/fwdownload.c b/sbin/camcontrol/fwdownload.c
index 56ccaaac1e59..038c4a836878 100644
--- a/sbin/camcontrol/fwdownload.c
+++ b/sbin/camcontrol/fwdownload.c
@@ -776,12 +776,15 @@ bailout:
* download.
*/
static int
-fw_rescan_lun(struct cam_device *dev, bool printerrors)
+fw_rescan_target(struct cam_device *dev, bool printerrors, bool sim_mode)
{
union ccb ccb;
int fd;
- target_id_t target;
- uint32_t bus;
+
+ printf("Rescanning target %d:%d:* to pick up new fw revision / parameters.\n",
+ dev->path_id, dev->target_id);
+ if (sim_mode)
+ return (0);
/* Can only send XPT_SCAN_TGT via /dev/xpt, not pass device in *dev */
if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) {
@@ -791,24 +794,11 @@ fw_rescan_lun(struct cam_device *dev, bool printerrors)
return (1);
}
- /* Fill in the bus and target IDs as they don't seem to be in *dev */
- bzero(&ccb, sizeof(union ccb));
- ccb.ccb_h.func_code = XPT_GDEVLIST;
- strlcpy(ccb.cgdl.periph_name, dev->device_name, sizeof(ccb.cgdl.periph_name));
- ccb.cgdl.unit_number = dev->dev_unit_num;
- if (cam_send_ccb(dev, &ccb) < 0) {
- warn("send_ccb GDEVLIST failed\n");
- close(fd);
- return (1);
- }
- bus = ccb.ccb_h.path_id;
- target = ccb.ccb_h.target_id;
-
/* Rescan the target */
bzero(&ccb, sizeof(union ccb));
ccb.ccb_h.func_code = XPT_SCAN_TGT;
- ccb.ccb_h.path_id = bus;
- ccb.ccb_h.target_id = target;
+ ccb.ccb_h.path_id = dev->path_id;
+ ccb.ccb_h.target_id = dev->target_id;
ccb.ccb_h.target_lun = CAM_LUN_WILDCARD;
ccb.crcn.flags = CAM_EXPECT_INQ_CHANGE;
ccb.ccb_h.pinfo.priority = 5; /* run this at a low priority */
@@ -823,8 +813,10 @@ fw_rescan_lun(struct cam_device *dev, bool printerrors)
if (printerrors)
cam_error_print(dev, &ccb, CAM_ESF_ALL, CAM_EPF_ALL,
stderr);
+ close(fd);
return (1);
}
+ close(fd);
return (0);
}
@@ -983,8 +975,8 @@ bailout:
if (quiet == 0)
progress_complete(&progress, size - img_size);
cam_freeccb(ccb);
- if (retval == 0 && !sim_mode) {
- fw_rescan_lun(cam_dev, printerrors);
+ if (retval == 0) {
+ fw_rescan_target(cam_dev, printerrors, sim_mode);
}
return (retval);
}