scsi: fix the {host,target,device}_blocked counter mess
authorChristoph Hellwig <hch@lst.de>
Thu, 26 Jun 2014 02:14:42 +0000 (20:14 -0600)
committerJens Axboe <axboe@fb.com>
Thu, 2 Apr 2015 18:12:27 +0000 (12:12 -0600)
commita0581bc9459f1b68dd8ae77daee0f358e8a6e042
tree4fc109ffb3459c05884a503b276d6540c35bf1b9
parent7edbc26c12b94b2a70699ace8638bdc36a6b908c
scsi: fix the {host,target,device}_blocked counter mess

Seems like these counters are missing any sort of synchronization for
updates, as a over 10 year old comment from me noted.  Fix this by
using atomic counters, and while we're at it also make sure they are
in the same cacheline as the _busy counters and not needlessly stored
to in every I/O completion.

With the new model the _busy counters can temporarily go negative,
so all the readers are updated to check for > 0 values.  Longer
term every successful I/O completion will reset the counters to zero,
so the temporarily negative values will not cause any harm.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/scsi/scsi.c
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_sysfs.c
include/scsi/scsi_device.h
include/scsi/scsi_host.h