提交 6d06368d 编写于 作者: A Anthony Liguori

Merge remote-tracking branch 'bonzini/scsi-next' into staging

# By Paolo Bonzini (4) and Peter Lieven (2)
# Via Paolo Bonzini
* bonzini/scsi-next:
  scsi-disk: handle io_canceled uniformly and correctly
  scsi-disk: do not complete canceled UNMAP requests
  scsi: do not call scsi_read_data/scsi_write_data for a canceled request
  iscsi: look for pkg-config file too
  iscsi: add iscsi_truncate support
  iscsi: retry read, write, flush and unmap on unit attention check conditions
此差异已折叠。
...@@ -2803,7 +2803,13 @@ if test "$libiscsi" != "no" ; then ...@@ -2803,7 +2803,13 @@ if test "$libiscsi" != "no" ; then
#include <iscsi/iscsi.h> #include <iscsi/iscsi.h>
int main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; } int main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
EOF EOF
if compile_prog "" "-liscsi" ; then if $pkg_config --atleast-version=1.7.0 libiscsi --modversion >/dev/null 2>&1; then
libiscsi="yes"
libiscsi_cflags=$($pkg_config --cflags libiscsi 2>/dev/null)
libiscsi_libs=$($pkg_config --libs libiscsi 2>/dev/null)
CFLAGS="$CFLAGS $libiscsi_cflags"
LIBS="$LIBS $libiscsi_libs"
elif compile_prog "" "-liscsi" ; then
libiscsi="yes" libiscsi="yes"
LIBS="$LIBS -liscsi" LIBS="$LIBS -liscsi"
else else
......
...@@ -1508,6 +1508,10 @@ void scsi_req_unref(SCSIRequest *req) ...@@ -1508,6 +1508,10 @@ void scsi_req_unref(SCSIRequest *req)
will start the next chunk or complete the command. */ will start the next chunk or complete the command. */
void scsi_req_continue(SCSIRequest *req) void scsi_req_continue(SCSIRequest *req)
{ {
if (req->io_canceled) {
trace_scsi_req_continue_canceled(req->dev->id, req->lun, req->tag);
return;
}
trace_scsi_req_continue(req->dev->id, req->lun, req->tag); trace_scsi_req_continue(req->dev->id, req->lun, req->tag);
if (req->cmd.mode == SCSI_XFER_TO_DEV) { if (req->cmd.mode == SCSI_XFER_TO_DEV) {
req->ops->write_data(req); req->ops->write_data(req);
......
...@@ -178,6 +178,9 @@ static void scsi_aio_complete(void *opaque, int ret) ...@@ -178,6 +178,9 @@ static void scsi_aio_complete(void *opaque, int ret)
assert(r->req.aiocb != NULL); assert(r->req.aiocb != NULL);
r->req.aiocb = NULL; r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct); bdrv_acct_done(s->qdev.conf.bs, &r->acct);
if (r->req.io_canceled) {
goto done;
}
if (ret < 0) { if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) { if (scsi_handle_rw_error(r, -ret)) {
...@@ -223,6 +226,10 @@ static void scsi_write_do_fua(SCSIDiskReq *r) ...@@ -223,6 +226,10 @@ static void scsi_write_do_fua(SCSIDiskReq *r)
{ {
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
if (r->req.io_canceled) {
goto done;
}
if (scsi_is_cmd_fua(&r->req.cmd)) { if (scsi_is_cmd_fua(&r->req.cmd)) {
bdrv_acct_start(s->qdev.conf.bs, &r->acct, 0, BDRV_ACCT_FLUSH); bdrv_acct_start(s->qdev.conf.bs, &r->acct, 0, BDRV_ACCT_FLUSH);
r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r); r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r);
...@@ -230,6 +237,8 @@ static void scsi_write_do_fua(SCSIDiskReq *r) ...@@ -230,6 +237,8 @@ static void scsi_write_do_fua(SCSIDiskReq *r)
} }
scsi_req_complete(&r->req, GOOD); scsi_req_complete(&r->req, GOOD);
done:
if (!r->req.io_canceled) { if (!r->req.io_canceled) {
scsi_req_unref(&r->req); scsi_req_unref(&r->req);
} }
...@@ -243,6 +252,9 @@ static void scsi_dma_complete(void *opaque, int ret) ...@@ -243,6 +252,9 @@ static void scsi_dma_complete(void *opaque, int ret)
assert(r->req.aiocb != NULL); assert(r->req.aiocb != NULL);
r->req.aiocb = NULL; r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct); bdrv_acct_done(s->qdev.conf.bs, &r->acct);
if (r->req.io_canceled) {
goto done;
}
if (ret < 0) { if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) { if (scsi_handle_rw_error(r, -ret)) {
...@@ -274,6 +286,9 @@ static void scsi_read_complete(void * opaque, int ret) ...@@ -274,6 +286,9 @@ static void scsi_read_complete(void * opaque, int ret)
assert(r->req.aiocb != NULL); assert(r->req.aiocb != NULL);
r->req.aiocb = NULL; r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct); bdrv_acct_done(s->qdev.conf.bs, &r->acct);
if (r->req.io_canceled) {
goto done;
}
if (ret < 0) { if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) { if (scsi_handle_rw_error(r, -ret)) {
...@@ -305,6 +320,9 @@ static void scsi_do_read(void *opaque, int ret) ...@@ -305,6 +320,9 @@ static void scsi_do_read(void *opaque, int ret)
r->req.aiocb = NULL; r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct); bdrv_acct_done(s->qdev.conf.bs, &r->acct);
} }
if (r->req.io_canceled) {
goto done;
}
if (ret < 0) { if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) { if (scsi_handle_rw_error(r, -ret)) {
...@@ -312,10 +330,6 @@ static void scsi_do_read(void *opaque, int ret) ...@@ -312,10 +330,6 @@ static void scsi_do_read(void *opaque, int ret)
} }
} }
if (r->req.io_canceled) {
return;
}
/* The request is used as the AIO opaque value, so add a ref. */ /* The request is used as the AIO opaque value, so add a ref. */
scsi_req_ref(&r->req); scsi_req_ref(&r->req);
...@@ -423,6 +437,9 @@ static void scsi_write_complete(void * opaque, int ret) ...@@ -423,6 +437,9 @@ static void scsi_write_complete(void * opaque, int ret)
r->req.aiocb = NULL; r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct); bdrv_acct_done(s->qdev.conf.bs, &r->acct);
} }
if (r->req.io_canceled) {
goto done;
}
if (ret < 0) { if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) { if (scsi_handle_rw_error(r, -ret)) {
...@@ -1478,13 +1495,17 @@ static void scsi_unmap_complete(void *opaque, int ret) ...@@ -1478,13 +1495,17 @@ static void scsi_unmap_complete(void *opaque, int ret)
uint32_t nb_sectors; uint32_t nb_sectors;
r->req.aiocb = NULL; r->req.aiocb = NULL;
if (r->req.io_canceled) {
goto done;
}
if (ret < 0) { if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) { if (scsi_handle_rw_error(r, -ret)) {
goto done; goto done;
} }
} }
if (data->count > 0 && !r->req.io_canceled) { if (data->count > 0) {
sector_num = ldq_be_p(&data->inbuf[0]); sector_num = ldq_be_p(&data->inbuf[0]);
nb_sectors = ldl_be_p(&data->inbuf[8]) & 0xffffffffULL; nb_sectors = ldl_be_p(&data->inbuf[8]) & 0xffffffffULL;
if (!check_lba_range(s, sector_num, nb_sectors)) { if (!check_lba_range(s, sector_num, nb_sectors)) {
...@@ -1501,10 +1522,9 @@ static void scsi_unmap_complete(void *opaque, int ret) ...@@ -1501,10 +1522,9 @@ static void scsi_unmap_complete(void *opaque, int ret)
return; return;
} }
scsi_req_complete(&r->req, GOOD);
done: done:
if (data->count == 0) {
scsi_req_complete(&r->req, GOOD);
}
if (!r->req.io_canceled) { if (!r->req.io_canceled) {
scsi_req_unref(&r->req); scsi_req_unref(&r->req);
} }
......
...@@ -460,6 +460,7 @@ scsi_req_data(int target, int lun, int tag, int len) "target %d lun %d tag %d le ...@@ -460,6 +460,7 @@ scsi_req_data(int target, int lun, int tag, int len) "target %d lun %d tag %d le
scsi_req_data_canceled(int target, int lun, int tag, int len) "target %d lun %d tag %d len %d" scsi_req_data_canceled(int target, int lun, int tag, int len) "target %d lun %d tag %d len %d"
scsi_req_dequeue(int target, int lun, int tag) "target %d lun %d tag %d" scsi_req_dequeue(int target, int lun, int tag) "target %d lun %d tag %d"
scsi_req_continue(int target, int lun, int tag) "target %d lun %d tag %d" scsi_req_continue(int target, int lun, int tag) "target %d lun %d tag %d"
scsi_req_continue_canceled(int target, int lun, int tag) "target %d lun %d tag %d"
scsi_req_parsed(int target, int lun, int tag, int cmd, int mode, int xfer) "target %d lun %d tag %d command %d dir %d length %d" scsi_req_parsed(int target, int lun, int tag, int cmd, int mode, int xfer) "target %d lun %d tag %d command %d dir %d length %d"
scsi_req_parsed_lba(int target, int lun, int tag, int cmd, uint64_t lba) "target %d lun %d tag %d command %d lba %"PRIu64 scsi_req_parsed_lba(int target, int lun, int tag, int cmd, uint64_t lba) "target %d lun %d tag %d command %d lba %"PRIu64
scsi_req_parse_bad(int target, int lun, int tag, int cmd) "target %d lun %d tag %d command %d" scsi_req_parse_bad(int target, int lun, int tag, int cmd) "target %d lun %d tag %d command %d"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册