FreeBSD Bugzilla – Attachment 163665 Details for
Bug 204901
GEOM doesn't see new disk capacity after VMDK resize without a reboot
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch that adds camcontrol reprobe device command
cam-reprobe-v3.diff (text/plain), 7.28 KB, created by
mgrooms
on 2015-11-29 20:50:47 UTC
(
hide
)
Description:
patch that adds camcontrol reprobe device command
Filename:
MIME Type:
Creator:
mgrooms
Created:
2015-11-29 20:50:47 UTC
Size:
7.28 KB
patch
obsolete
>Index: sbin/camcontrol/camcontrol.8 >=================================================================== >--- sbin/camcontrol/camcontrol.8 (revision 291390) >+++ sbin/camcontrol/camcontrol.8 (working copy) >@@ -104,6 +104,9 @@ > .Ic reset > .Aq all | bus Ns Op :target:lun > .Nm >+.Ic reprobe >+.Aq bus:target:lun >+.Nm > .Ic defects > .Op device id > .Op generic args >@@ -548,6 +551,9 @@ > connecting to that device. > Note that this can have a destructive impact > on the system. >+.It Ic reprobe >+Tell the kernel to re-probe the given bus:target:lun >+(XPT_REPROBE_DEV) by issuing an async event to peripheral device. > .It Ic defects > Send the > .Tn SCSI >Index: sbin/camcontrol/camcontrol.c >=================================================================== >--- sbin/camcontrol/camcontrol.c (revision 291390) >+++ sbin/camcontrol/camcontrol.c (working copy) >@@ -100,7 +100,8 @@ > CAM_CMD_APM = 0x00000021, > CAM_CMD_AAM = 0x00000022, > CAM_CMD_ATTRIB = 0x00000023, >- CAM_CMD_OPCODES = 0x00000024 >+ CAM_CMD_OPCODES = 0x00000024, >+ CAM_CMD_REPROBE = 0x00000025 > } cam_cmdmask; > > typedef enum { >@@ -193,6 +194,7 @@ > #endif /* MINIMALISTIC */ > {"rescan", CAM_CMD_RESCAN, CAM_ARG_NONE, NULL}, > {"reset", CAM_CMD_RESET, CAM_ARG_NONE, NULL}, >+ {"reprobe", CAM_CMD_REPROBE, CAM_ARG_NONE, NULL}, > #ifndef MINIMALISTIC > {"cmd", CAM_CMD_SCSI_CMD, CAM_ARG_NONE, scsicmd_opts}, > {"command", CAM_CMD_SCSI_CMD, CAM_ARG_NONE, scsicmd_opts}, >@@ -273,6 +275,7 @@ > static int rescan_or_reset_bus(path_id_t bus, int rescan); > static int scanlun_or_reset_dev(path_id_t bus, target_id_t target, > lun_id_t lun, int scan); >+static int reprobe_dev(path_id_t bus, target_id_t target, lun_id_t lun); > #ifndef MINIMALISTIC > static int readdefects(struct cam_device *device, int argc, char **argv, > char *combinedopt, int retry_count, int timeout); >@@ -3127,6 +3130,34 @@ > } > > static int >+doreprobe(int argc, char **argv) >+{ >+ static const char must[] = >+ "you must specify a bus:target:lun to reprobe"; >+ int rv; >+ path_id_t bus = CAM_BUS_WILDCARD; >+ target_id_t target = CAM_TARGET_WILDCARD; >+ lun_id_t lun = CAM_LUN_WILDCARD; >+ char *tstr; >+ >+ if (argc < 3) { >+ warnx(must); >+ return(1); >+ } >+ >+ tstr = argv[optind]; >+ while (isspace(*tstr) && (*tstr != '\0')) >+ tstr++; >+ rv = parse_btl(argv[optind], &bus, &target, &lun, &arglist); >+ if (rv != 3) { >+ warnx(must); >+ return(1); >+ } >+ >+ return(reprobe_dev(bus, target, lun)); >+} >+ >+static int > rescan_or_reset_bus(path_id_t bus, int rescan) > { > union ccb ccb, matchccb; >@@ -3382,6 +3413,56 @@ > } > } > >+static int >+reprobe_dev(path_id_t bus, target_id_t target, lun_id_t lun) >+{ >+ union ccb ccb; >+ int fd; >+ >+ if (bus == CAM_BUS_WILDCARD) { >+ warnx("invalid bus number %d", bus); >+ return(1); >+ } >+ >+ if (target == CAM_TARGET_WILDCARD) { >+ warnx("invalid target number %d", target); >+ return(1); >+ } >+ >+ if (lun == CAM_LUN_WILDCARD) { >+ warnx("invalid lun number %jx", (uintmax_t)lun); >+ return(1); >+ } >+ >+ fd = -1; >+ >+ bzero(&ccb, sizeof(union ccb)); >+ >+ if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) { >+ warnx("error opening transport layer device %s\n", >+ XPT_DEVICE); >+ warn("%s", XPT_DEVICE); >+ return(1); >+ } >+ >+ ccb.ccb_h.func_code = XPT_REPROBE_DEV; >+ ccb.ccb_h.path_id = bus; >+ ccb.ccb_h.target_id = target; >+ ccb.ccb_h.target_lun = lun; >+ >+ if (ioctl(fd, CAMIOCOMMAND, &ccb) < 0) { >+ warn("CAMIOCOMMAND ioctl failed"); >+ close(fd); >+ return(1); >+ } >+ close(fd); >+ >+ fprintf(stdout, "Re-probe of %d:%d:%jx was successful\n", >+ bus, target, (uintmax_t)lun); >+ >+ return(0); >+} >+ > #ifndef MINIMALISTIC > > static struct scsi_nv defect_list_type_map[] = { >@@ -8685,6 +8766,7 @@ > #endif /* MINIMALISTIC */ > " camcontrol rescan <all | bus[:target:lun]>\n" > " camcontrol reset <all | bus[:target:lun]>\n" >+" camcontrol reprobe <bus:target:lun>\n" > #ifndef MINIMALISTIC > " camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n" > " [-q][-s][-S offset][-X]\n" >@@ -9053,6 +9135,7 @@ > */ > if ((cmdlist == CAM_CMD_RESCAN) > || (cmdlist == CAM_CMD_RESET) >+ || (cmdlist == CAM_CMD_REPROBE) > || (cmdlist == CAM_CMD_DEVTREE) > || (cmdlist == CAM_CMD_USAGE) > || (cmdlist == CAM_CMD_DEBUG)) >@@ -9204,6 +9287,9 @@ > case CAM_CMD_RESET: > error = dorescan_or_reset(argc, argv, 0); > break; >+ case CAM_CMD_REPROBE: >+ error = doreprobe(argc, argv); >+ break; > #ifndef MINIMALISTIC > case CAM_CMD_READ_DEFECTS: > error = readdefects(cam_dev, argc, argv, combinedopt, >Index: sys/cam/cam_ccb.h >=================================================================== >--- sys/cam/cam_ccb.h (revision 291390) >+++ sys/cam/cam_ccb.h (working copy) >@@ -193,6 +193,11 @@ > * Set SIM specific knob values. > */ > >+ XPT_REPROBE_DEV = 0x1a, >+ /* >+ * Re-probe the sepcified SCSI device. >+ */ >+ > XPT_SMP_IO = 0x1b | XPT_FC_DEV_QUEUED, > /* Serial Management Protocol */ > >@@ -767,6 +772,7 @@ > * Definitions for the asynchronous callback CCB fields. > */ > typedef enum { >+ AC_UNIT_REPROBE = 0x8000,/* Device reprobe user request */ > AC_UNIT_ATTENTION = 0x4000,/* Device reported UNIT ATTENTION */ > AC_ADVINFO_CHANGED = 0x2000,/* Advance info might have changes */ > AC_CONTRACT = 0x1000,/* A contractual callback */ >Index: sys/cam/cam_xpt.c >=================================================================== >--- sys/cam/cam_xpt.c (revision 291390) >+++ sys/cam/cam_xpt.c (working copy) >@@ -433,6 +433,13 @@ > return (EINVAL); > } > break; >+ case XPT_REPROBE_DEV: >+ if (inccb->ccb_h.target_id == CAM_TARGET_WILDCARD || >+ inccb->ccb_h.target_lun == CAM_LUN_WILDCARD) { >+ xpt_release_bus(bus); >+ return (EINVAL); >+ } >+ break; > default: > break; > } >@@ -472,6 +479,29 @@ > xpt_free_ccb(ccb); > break; > >+ case XPT_REPROBE_DEV: { >+ struct cam_path path; >+ >+ /* >+ * Compile a path using the bus, target, and lun the >+ * user passed in. >+ */ >+ if (xpt_compile_path(&path, NULL, >+ inccb->ccb_h.path_id, >+ inccb->ccb_h.target_id, >+ inccb->ccb_h.target_lun) != >+ CAM_REQ_CMP){ >+ error = EINVAL; >+ break; >+ } >+ >+ /* >+ * Notify interested parties >+ */ >+ xpt_async(AC_UNIT_REPROBE, &path, NULL); >+ break; >+ >+ } > case XPT_DEBUG: { > union ccb ccb; > >Index: sys/cam/scsi/scsi_da.c >=================================================================== >--- sys/cam/scsi/scsi_da.c (revision 291390) >+++ sys/cam/scsi/scsi_da.c (working copy) >@@ -1702,6 +1702,17 @@ > } > break; > } >+ case AC_UNIT_REPROBE: >+ { >+ softc = (struct da_softc *)periph->softc; >+ >+ xpt_print(periph->path, >+ "Re-probe requested\n"); >+ softc->flags &= ~DA_FLAG_PROBED; >+ dareprobe(periph); >+ >+ break; >+ } > case AC_UNIT_ATTENTION: > { > union ccb *ccb; >@@ -2240,7 +2251,7 @@ > * would be to not attach the device on failure. > */ > xpt_register_async(AC_SENT_BDR | AC_BUS_RESET | AC_LOST_DEVICE | >- AC_ADVINFO_CHANGED | AC_SCSI_AEN | AC_UNIT_ATTENTION, >+ AC_ADVINFO_CHANGED | AC_SCSI_AEN | AC_UNIT_ATTENTION | AC_UNIT_REPROBE, > daasync, periph, periph->path); > > /* >@@ -3244,12 +3255,11 @@ > if (have_sense) > scsi_sense_print( > &done_ccb->csio); >- else { >+ else > xpt_print(periph->path, > "got CAM status %#x\n", > done_ccb->ccb_h.status); >- } >- >+ > xpt_print(periph->path, "fatal error, " > "failed to attach to device\n"); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 204901
: 163665