isboot: help me understand what CAM is doing
John Nielsen <[email protected]> Thu, 15 May 2025 10:29:43 -0600
| Newsgroups | gmane.os.freebsd.devel.scsi |
|---|---|
| Message-ID | <[email protected]> |
Hi all- I=E2=80=99m working on a cosmetic bug in isboot-kmod. There is a global = string called isboot_boot_device which is printed for informational = purposes and also available via the net.isboot.device sysctl. The string = is populated in this function: = https://github.com/jnielsendotnet/isboot/blob/master/src/iscsi.c#L1870. I don=E2=80=99t know when this changed but historically the string = comparison on = https://github.com/jnielsendotnet/isboot/blob/master/src/iscsi.c#L1904 = would be called once with =E2=80=9Cpass=E2=80=9D and once with =E2=80=9Cda= =E2=80=9D and the global isboot_boot_device would be correctly populated = with e.g. =E2=80=9Cda0=E2=80=9D. That sometimes happens in the current code as well, but on my test = machine (running 14-STABLE) it is ONLY when I have enabled debug output = (by setting bootverbose or net.isboot.debug to 1 or higher). Otherwise, = the string comparison is called only once with =E2=80=9Cprobe=E2=80=9D = rather than =E2=80=9Cpass=E2=80=9D or =E2=80=9Cda=E2=80=9D. Everything = still works in this case; the disk is found (at da0 or whatever) and = mounted, but the isboot_boot_device is never populated (or populated = with the wrong name like =E2=80=9Cprobe0=E2=80=9D if I mess with what = the string comparison is looking for. There is no functional change other than debug messages when debug = output is enabled, so I=E2=80=99m guessing this is a race condition. But = since I am still a rank amateur when it comes to kernel programming I = don=E2=80=99t know where else to look. So my questions are twofold: 1) What is going on here? When does the =E2=80=9Cprobe=E2=80=9D name = show up in ccb.cgdl.periph_name and why doesn=E2=80=99t the loop ever = see =E2=80=9Cda=E2=80=9D or =E2=80=9Cpass=E2=80=9D when it does? = Corollary: does isboot_cam_set_devices() operate in a safe/sane way for = modern CAM?=20 2) What would be a safer or more reliable way to determine the correct = device name so it can be written to the isboot_boot_device global = variable? Thanks! JN