Skip to content

RFC fix for the race issue between scsi timer and in-flight scmd

Liu Ping Fan linux-scsi 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest9 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9block: make timeout_list protectd by REQ_ATOM_COMPLETE bitblock/blk-timeout.c+3 -20 replies
2/9scsi: ensure request is dequeue when finishing scmdblock/blk.h drivers/scsi/scsi_error.c drivers/scsi/scsi_lib.c +2 more+22 -20 replies
3/9scsi: introduce new internal flag SUCCESS_REMOVEdrivers/scsi/scsi_error.c include/scsi/scsi.h+8 -10 replies
4/9blk: change the prototype of blk_complete_request()block/blk-softirq.c include/linux/blkdev.h+11 -40 replies
4/9blk: change the prototype of blk_complete_request()block/blk-softirq.c include/linux/blkdev.h+11 -40 replies
6/9blk: split the reclaim of req from blk_finish_request()block/blk-core.c include/linux/blkdev.h+39 -190 replies
7/9scsi: adopt ref on scsi_cmnd to avoid a race on requestdrivers/scsi/scsi.c drivers/scsi/scsi_error.c drivers/scsi/scsi_lib.c +2 more+72 -260 replies
8/9scsi: virtscsi: work around to abort a scmddrivers/scsi/virtio_scsi.c+59 -20 replies
9/9scsi: ibmvscsi: return SUCCESS_REMOVE when finding a abort cmddrivers/scsi/ibmvscsi/ibmvscsi.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC 0/9] fix for the race issue between scsi timer and in-flight scmd

When running io stress test on large latency scsi-disk, e.g guest with virtscsi on a nfs image. It can trigger the BUG_ON(test_bit(REQ_ATOM_COMPLETE, &req->atomic_flags)); in blk_start_request().
Since there is a race between latency "finishing" scmd and the re-allocated scmd. I.e a request is still referred by a scmd, but we had turn it back to
slab.

This series introduces the ref on scmd to exclude this issue, and the following is ref rules.

inc ref rules is like the following:
When setup a scmd, inited as 1. When add a timer inc 1.

dec ref rules is like the following:
-for the normal ref
scsi_done() will drop the ref when fail to acquire REQ_ATOM_COMPLETE immediately or drop the ref by scsi_end_request()
or drop by return SUCCESS_REMOVE
-for a timer ref
when deleting timer, if !list_empty(timeout_list), then there is a timer ref, and drop it.

patch1-2: fix the current potential bug
patch3~6: prepare for the mechanism for the ref

patch7:   the ref rules core
patch8-9:  e.g and test-issue for the new mechanism. Since lack of many virtscsi background,

patch8 may be poor and need to be improved :)

Note: all the patches are based on rhel7, whose kernel version is linux-3.10.
I will rebase them onto the latest commit if my method is practical.

Liu Ping Fan (9):
block: make timeout_list protectd by REQ_ATOM_COMPLETE bit
scsi: ensure request is dequeue when finishing scmd
scsi: introduce new internal flag SUCCESS_REMOVE
blk: change the prototype of blk_complete_request()
blk: change funcs' prototype to expose the ref of timer
blk: split the reclaim of req from blk_finish_request()
scsi: adopt ref on scsi_cmnd to avoid a race on request
scsi: virtscsi: work around to abort a scmd
scsi: ibmvscsi: return SUCCESS_REMOVE when finding a abort cmd

 block/blk-core.c                 | 67 ++++++++++++++++++++++++++++++-----
 block/blk-softirq.c              | 13 +++++--
 block/blk-timeout.c              | 15 +++++---
 block/blk.h                      |  3 +-
 drivers/scsi/ibmvscsi/ibmvscsi.c |  2 +-
 drivers/scsi/scsi.c              | 33 ++++++++++++-----
 drivers/scsi/scsi_error.c        | 10 +++++-
 drivers/scsi/scsi_lib.c          | 76 +++++++++++++++++++++++++++++++---------
 drivers/scsi/scsi_priv.h         |  4 +++
 drivers/scsi/virtio_scsi.c       | 61 ++++++++++++++++++++++++++++++--
 include/linux/blkdev.h           |  9 +++--
 include/scsi/scsi.h              |  1 +
 include/scsi/scsi_cmnd.h         |  1 +
 13 files changed, 246 insertions(+), 49 deletions(-)
Signature · 1 line
1.8.1.4