__scsi_devic...up_by_target(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __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 a u64, 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:


ngl, the takeaway is: hold that host_lock, access nothing without it, and if you're not in irq context, go use scsi_device_lookup_by_target instead. 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