Commit bf2d6503 authored by Mike Christie's avatar Mike Christie Committed by Michael S. Tsirkin
Browse files

vhost-scsi: Allocate T10 PI structs only when enabled



T10 PI is not a widely used feature. This has us only allocate the
structs for it if the feature has been enabled. For a common small setup
where you have 1 virtqueue and 128 commands per queue, this saves:

8MB = 32 bytes per sg * 2048 entries * 128 commands

per vhost-scsi device.

Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
Message-Id: <20241203191705.19431-3-michael.christie@oracle.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 4c1f3a7d
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -1651,6 +1651,7 @@ static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds)
			goto out;
		}

		if (vhost_has_feature(vq, VIRTIO_SCSI_F_T10_PI)) {
			tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS,
						sizeof(struct scatterlist),
						GFP_KERNEL);
@@ -1659,6 +1660,7 @@ static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds)
				goto out;
			}
		}
	}
	return 0;
out:
	vhost_scsi_destroy_vq_cmds(vq);