diff options
author | Ingo Molnar <mingo@kernel.org> | 2019-06-17 06:06:34 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2019-06-17 06:06:34 -0400 |
commit | 410df0c5748f6c5a53847d2acb163dc7cd8b6c51 (patch) | |
tree | 0c0f547f90a73ec6d30851f93720e0eb24f353eb /drivers/vhost/scsi.c | |
parent | fff9b6c7d26943a8eb32b58364b7ec6b9369746a (diff) | |
parent | 9e0babf2c06c73cda2c0cd37a1653d823adb40ec (diff) |
Merge tag 'v5.2-rc5' into locking/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/vhost/scsi.c')
-rw-r--r-- | drivers/vhost/scsi.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index c090d177bd75..a9caf1bc3c3e 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c | |||
@@ -57,6 +57,12 @@ | |||
57 | #define VHOST_SCSI_PREALLOC_UPAGES 2048 | 57 | #define VHOST_SCSI_PREALLOC_UPAGES 2048 |
58 | #define VHOST_SCSI_PREALLOC_PROT_SGLS 2048 | 58 | #define VHOST_SCSI_PREALLOC_PROT_SGLS 2048 |
59 | 59 | ||
60 | /* Max number of requests before requeueing the job. | ||
61 | * Using this limit prevents one virtqueue from starving others with | ||
62 | * request. | ||
63 | */ | ||
64 | #define VHOST_SCSI_WEIGHT 256 | ||
65 | |||
60 | struct vhost_scsi_inflight { | 66 | struct vhost_scsi_inflight { |
61 | /* Wait for the flush operation to finish */ | 67 | /* Wait for the flush operation to finish */ |
62 | struct completion comp; | 68 | struct completion comp; |
@@ -912,7 +918,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) | |||
912 | struct iov_iter in_iter, prot_iter, data_iter; | 918 | struct iov_iter in_iter, prot_iter, data_iter; |
913 | u64 tag; | 919 | u64 tag; |
914 | u32 exp_data_len, data_direction; | 920 | u32 exp_data_len, data_direction; |
915 | int ret, prot_bytes; | 921 | int ret, prot_bytes, c = 0; |
916 | u16 lun; | 922 | u16 lun; |
917 | u8 task_attr; | 923 | u8 task_attr; |
918 | bool t10_pi = vhost_has_feature(vq, VIRTIO_SCSI_F_T10_PI); | 924 | bool t10_pi = vhost_has_feature(vq, VIRTIO_SCSI_F_T10_PI); |
@@ -932,7 +938,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) | |||
932 | 938 | ||
933 | vhost_disable_notify(&vs->dev, vq); | 939 | vhost_disable_notify(&vs->dev, vq); |
934 | 940 | ||
935 | for (;;) { | 941 | do { |
936 | ret = vhost_scsi_get_desc(vs, vq, &vc); | 942 | ret = vhost_scsi_get_desc(vs, vq, &vc); |
937 | if (ret) | 943 | if (ret) |
938 | goto err; | 944 | goto err; |
@@ -1112,7 +1118,7 @@ err: | |||
1112 | break; | 1118 | break; |
1113 | else if (ret == -EIO) | 1119 | else if (ret == -EIO) |
1114 | vhost_scsi_send_bad_target(vs, vq, vc.head, vc.out); | 1120 | vhost_scsi_send_bad_target(vs, vq, vc.head, vc.out); |
1115 | } | 1121 | } while (likely(!vhost_exceeds_weight(vq, ++c, 0))); |
1116 | out: | 1122 | out: |
1117 | mutex_unlock(&vq->mutex); | 1123 | mutex_unlock(&vq->mutex); |
1118 | } | 1124 | } |
@@ -1171,7 +1177,7 @@ vhost_scsi_ctl_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) | |||
1171 | } v_req; | 1177 | } v_req; |
1172 | struct vhost_scsi_ctx vc; | 1178 | struct vhost_scsi_ctx vc; |
1173 | size_t typ_size; | 1179 | size_t typ_size; |
1174 | int ret; | 1180 | int ret, c = 0; |
1175 | 1181 | ||
1176 | mutex_lock(&vq->mutex); | 1182 | mutex_lock(&vq->mutex); |
1177 | /* | 1183 | /* |
@@ -1185,7 +1191,7 @@ vhost_scsi_ctl_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) | |||
1185 | 1191 | ||
1186 | vhost_disable_notify(&vs->dev, vq); | 1192 | vhost_disable_notify(&vs->dev, vq); |
1187 | 1193 | ||
1188 | for (;;) { | 1194 | do { |
1189 | ret = vhost_scsi_get_desc(vs, vq, &vc); | 1195 | ret = vhost_scsi_get_desc(vs, vq, &vc); |
1190 | if (ret) | 1196 | if (ret) |
1191 | goto err; | 1197 | goto err; |
@@ -1264,7 +1270,7 @@ err: | |||
1264 | break; | 1270 | break; |
1265 | else if (ret == -EIO) | 1271 | else if (ret == -EIO) |
1266 | vhost_scsi_send_bad_target(vs, vq, vc.head, vc.out); | 1272 | vhost_scsi_send_bad_target(vs, vq, vc.head, vc.out); |
1267 | } | 1273 | } while (likely(!vhost_exceeds_weight(vq, ++c, 0))); |
1268 | out: | 1274 | out: |
1269 | mutex_unlock(&vq->mutex); | 1275 | mutex_unlock(&vq->mutex); |
1270 | } | 1276 | } |
@@ -1621,7 +1627,8 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) | |||
1621 | vqs[i] = &vs->vqs[i].vq; | 1627 | vqs[i] = &vs->vqs[i].vq; |
1622 | vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick; | 1628 | vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick; |
1623 | } | 1629 | } |
1624 | vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ, UIO_MAXIOV); | 1630 | vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ, UIO_MAXIOV, |
1631 | VHOST_SCSI_WEIGHT, 0); | ||
1625 | 1632 | ||
1626 | vhost_scsi_init_inflight(vs, NULL); | 1633 | vhost_scsi_init_inflight(vs, NULL); |
1627 | 1634 | ||