From cd9070c9c512ff7995f9019392e0ae548df3a088 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 23 Jan 2014 12:07:41 +0100 Subject: 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 Reviewed-by: Martin K. Petersen Reviewed-by: Webb Scales Acked-by: Jens Axboe Tested-by: Bart Van Assche Tested-by: Robert Elliott --- include/scsi/scsi_host.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'include/scsi/scsi_host.h') diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 51f7911..5e8ebc1 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -583,6 +583,8 @@ struct Scsi_Host { struct blk_queue_tag *bqt; atomic_t host_busy; /* commands actually active on low-level */ + atomic_t host_blocked; + unsigned int host_failed; /* commands that failed. protected by host_lock */ unsigned int host_eh_scheduled; /* EH scheduled without command */ @@ -682,11 +684,6 @@ struct Scsi_Host { struct workqueue_struct *tmf_work_q; /* - * Host has rejected a command because it was busy. - */ - unsigned int host_blocked; - - /* * Value host_blocked counts down from */ unsigned int max_host_blocked; -- cgit v1.1