diff mbox series

[1/1] vhost: scsi: notify TCM about the maximum sg entries supported per command.

Message ID 1590166317-953-1-git-send-email-sudhakar.panneerselvam@oracle.com (mailing list archive)
State Accepted
Commit 5ae6a6a915033bfee79e76e0c374d4f927909edc
Headers show
Series [1/1] vhost: scsi: notify TCM about the maximum sg entries supported per command. | expand

Commit Message

Sudhakar Panneerselvam May 22, 2020, 4:51 p.m. UTC
vhost-scsi pre-allocates the maximum sg entries per command and if a
command requires more than VHOST_SCSI_PREALLOC_SGLS entries, then that
command is failed by it. This patch lets vhost communicate the max sg limit
when it registers vhost_scsi_ops with TCM. With this change, TCM would
report the max sg entries through "Block Limits" VPD page which will be
typically queried by the SCSI initiator during device discovery. By knowing
this limit, the initiator could ensure the maximum transfer length is less
than or equal to what is reported by vhost-scsi.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Sudhakar Panneerselvam <sudhakar.panneerselvam@oracle.com>
---
 drivers/vhost/scsi.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Mike Christie May 23, 2020, 7:05 p.m. UTC | #1
On 5/22/20 11:51 AM, Sudhakar Panneerselvam wrote:
> vhost-scsi pre-allocates the maximum sg entries per command and if a
> command requires more than VHOST_SCSI_PREALLOC_SGLS entries, then that
> command is failed by it. This patch lets vhost communicate the max sg limit
> when it registers vhost_scsi_ops with TCM. With this change, TCM would
> report the max sg entries through "Block Limits" VPD page which will be
> typically queried by the SCSI initiator during device discovery. By knowing
> this limit, the initiator could ensure the maximum transfer length is less
> than or equal to what is reported by vhost-scsi.
> 
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Signed-off-by: Sudhakar Panneerselvam <sudhakar.panneerselvam@oracle.com>
> ---
>  drivers/vhost/scsi.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index c39952243fd3..8b104f76f324 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -2280,6 +2280,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
>  static const struct target_core_fabric_ops vhost_scsi_ops = {
>  	.module				= THIS_MODULE,
>  	.fabric_name			= "vhost",
> +	.max_data_sg_nents		= VHOST_SCSI_PREALLOC_SGLS,
>  	.tpg_get_wwn			= vhost_scsi_get_fabric_wwn,
>  	.tpg_get_tag			= vhost_scsi_get_tpgt,
>  	.tpg_check_demo_mode		= vhost_scsi_check_true,
> 

Looks ok to me.

Reviewed-by: Mike Christie <mchristi@redhat.com>
Martin K. Petersen May 27, 2020, 2:13 a.m. UTC | #2
On Fri, 22 May 2020 16:51:57 +0000, Sudhakar Panneerselvam wrote:

> vhost-scsi pre-allocates the maximum sg entries per command and if a
> command requires more than VHOST_SCSI_PREALLOC_SGLS entries, then that
> command is failed by it. This patch lets vhost communicate the max sg limit
> when it registers vhost_scsi_ops with TCM. With this change, TCM would
> report the max sg entries through "Block Limits" VPD page which will be
> typically queried by the SCSI initiator during device discovery. By knowing
> this limit, the initiator could ensure the maximum transfer length is less
> than or equal to what is reported by vhost-scsi.

Applied to 5.8/scsi-queue, thanks!

[1/1] scsi: vhost: Notify TCM about the maximum sg entries supported per command
      https://git.kernel.org/mkp/scsi/c/5ae6a6a91503
diff mbox series

Patch

diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index c39952243fd3..8b104f76f324 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -2280,6 +2280,7 @@  static void vhost_scsi_drop_tport(struct se_wwn *wwn)
 static const struct target_core_fabric_ops vhost_scsi_ops = {
 	.module				= THIS_MODULE,
 	.fabric_name			= "vhost",
+	.max_data_sg_nents		= VHOST_SCSI_PREALLOC_SGLS,
 	.tpg_get_wwn			= vhost_scsi_get_fabric_wwn,
 	.tpg_get_tag			= vhost_scsi_get_tpgt,
 	.tpg_check_demo_mode		= vhost_scsi_check_true,