__scsi_devic...up_by_target(9)
π
__scsi_device_lookup_by_target β the UNLOCKED one, bestie
okay so real talk, this is a Kernel API Manual page and it's genuinely one of those "handle with care" girlies. lowkey iconic, highkey dangerous. let's get into it β¨
β¨ NAME β¨
__scsi_device_lookup_by_target β find a device given the target (UNLOCKED) π«Ά
like, yes, that's the whole vibe. it finds a device. for a target. and the UNLOCKED is in all caps for a reason, bestie π
π¦ SYNOPSIS π¦
struct scsi_device * __scsi_device_lookup_by_target (struct scsi_target
*starget , u64 lun );
no cap, that's the exact signature. don't touch a character of it π
πΈ ARGUMENTS πΈ
stargetβ the SCSI target pointer. your target. your main character. π―lunβ the SCSI Logical Unit Number, which is au64, because numbers deserve to be big sometimes π
π DESCRIPTION π
so what it does: it looks up the scsi_device with the specified lun for a given starget. cute, simple, slay. β¨
BUT. and this is the big but, the listen to me but π β the returned scsi_device does not have an additional reference. like, none. zero. she's not holding anything for you. so you must hold the host's host_lock over this call and over any access to the returned scsi_device. every single access. not "most of them". any. π₯
also, a scsi_device that's in state SDEV_DEL just gets skipped. she's deleted, she's not coming to the party, we move on π
π NOTE π
the only reason why drivers should use this is because they need to access the device list in irq context. that's it. that's the one reason. the singular reason. π
otherwise? otherwise you really want to use scsi_device_lookup_by_target instead. like genuinely, bestie, take the locked version. she's right there. she's safer. go get her π
π SEE ALSO π
kernel file ./drivers/scsi/scsi.c, plus the whole friend group:
scsi_finish_command(9)scsi_change_queue_depth(9)scsi_track_queue_full(9)scsi_vpd_inquiry(9)scsi_get_vpd_page(9)scsi_get_vpd_buf(9)scsi_attach_vpd(9)scsi_report_opcode(9)scsi_cdl_check(9)scsi_cdl_enable(9)scsi_device_get(9)scsi_device_put(9)starget_for_each_device(9)__starget_for_each_device(9)scsi_device_lookup_by_target(9)__scsi_device_lookup(9)scsi_device_lookup(9)
ngl, the takeaway is: hold thathost_lock, access nothing without it, and if you're not in irq context, go usescsi_device_lookup_by_targetinstead. periodt. π
okay bye, this page came from ./drivers/scsi, dated October 2026, and it lives in the __scsi_devic...up_by_target(9) era forever π§π stay locked, bestie πΈ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms