2023-10-16 02:09:33

by Wenchao Hao

[permalink] [raw]
Subject: [PATCH v2 2/2] scsi: Add comment of target_destroy in scsi_host_template

Add comment to tell callback function target_destroy of
scsi_host_template is called in atomic context.

Signed-off-by: Wenchao Hao <[email protected]>
---
include/scsi/scsi_host.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 49f768d0ff37..2e8d77441064 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -245,6 +245,9 @@ struct scsi_host_template {
* midlayer calls this point so that the driver may deallocate
* and terminate any references to the target.
*
+ * Note: this callback in called with spin_lock shost->host_lock held,
+ * so donot call functions might cause schedule
+ *
* Status: OPTIONAL
*/
void (* target_destroy)(struct scsi_target *);
--
2.32.0


2023-10-17 21:04:36

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] scsi: Add comment of target_destroy in scsi_host_template

On 10/15/23 19:08, Wenchao Hao wrote:
> Add comment to tell callback function target_destroy of
> scsi_host_template is called in atomic context.
>
> Signed-off-by: Wenchao Hao <[email protected]>
> ---
> include/scsi/scsi_host.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 49f768d0ff37..2e8d77441064 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -245,6 +245,9 @@ struct scsi_host_template {
> * midlayer calls this point so that the driver may deallocate
> * and terminate any references to the target.
> *
> + * Note: this callback in called with spin_lock shost->host_lock held,
> + * so donot call functions might cause schedule
> + *
> * Status: OPTIONAL
> */
> void (* target_destroy)(struct scsi_target *);

The above comment can be made shorter and spelling and grammar can be
improved. How about the following: "This callback is called with the
host lock held and hence must not sleep."?

Thanks,

Bart.

2023-10-18 02:24:49

by Wenchao Hao

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] scsi: Add comment of target_destroy in scsi_host_template

On 2023/10/18 5:04, Bart Van Assche wrote:
> On 10/15/23 19:08, Wenchao Hao wrote:
>> Add comment to tell callback function target_destroy of
>> scsi_host_template is called in atomic context.
>>
>> Signed-off-by: Wenchao Hao <[email protected]>
>> ---
>>   include/scsi/scsi_host.h | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
>> index 49f768d0ff37..2e8d77441064 100644
>> --- a/include/scsi/scsi_host.h
>> +++ b/include/scsi/scsi_host.h
>> @@ -245,6 +245,9 @@ struct scsi_host_template {
>>        * midlayer calls this point so that the driver may deallocate
>>        * and terminate any references to the target.
>>        *
>> +     * Note: this callback in called with spin_lock shost->host_lock held,
>> +     * so donot call functions might cause schedule
>> +     *
>>        * Status: OPTIONAL
>>        */
>>       void (* target_destroy)(struct scsi_target *);
>
> The above comment can be made shorter and spelling and grammar can be improved. How about the following: "This callback is called with the host lock held and hence must not sleep."?
>

Looks better, I would update.

Thanks.

> Thanks,
>
> Bart.
>