Re: [PATCH v4 3/6] scsi: core: Pass the SCSI host pointer directly

Bart Van Assche <[email protected]> Mon, 3 Aug 2026 09:14:11 -0700
Newsgroups gmane.linux.scsi
Message-ID <[email protected]>
On 8/3/26 6:01 AM, John Garry wrote:
> On 31/07/2026 22:52, Bart Van Assche wrote:
> 
> "Pass the SCSI host pointer directly" - that's too vague a title.

Huh? This patch passes the SCSI host pointer directly to several 
functions instead of deriving the SCSI host pointer from the SCSI target
pointer (dev_to_shost(starget->dev.parent)). Hence, I think the title is
accurate.

>> In the functions scsi_probe_and_add_lun(), scsi_sequential_lun_scan(),
>> scsi_report_lun_scan() and __scsi_scan_target() the SCSI host pointer is
>> derived from the SCSI target pointer. Pass the SCSI host pointer
>> directly. This patch prepares for enabling lock context analysis.
> 
> How?

With this patch, lock context annotations can refer to the SCSI host
pointer directly (__must_hold(&shost->scan_mutex)). Without this patch,
the following lock context annotation would have to be used instead:

__must_hold(&dev_to_shost(starget->dev.parent)->scan_mutex)

Additionally, in code that locks shost->scan_mutex, the following would
have to be added to help the compiler understand that shost ==
dev_to_shost(starget->dev.parent):

__assume_ctx_lock(&dev_to_shost(starget->dev.parent)->scan_mutex);

Christoph Hellwig made it clear during the LSF/MM/BPF summit that he is
doesn't like __assume_ctx_lock() statements being added and also that he
prefers to add arguments to functions if that eliminates the need for
introducing __assume_ctx_lock() statements. Hence this patch.

Thanks,

Bart.