[PATCH v2 0/6] scsi_io_completion cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



While working of this "[PATCH v4] Make SCSI Status CONDITION MET
equivalent to GOOD" the author had trouble finding how to add another
corner case check in the scsi_io_completion() function (scsi_lib.c).
That function is executed at the completion of every SCSI command but
only 20 or so of its hundred of lines of code are executed for the vast
majority of invocations (i.e. the fastpath).

This patch refactors scsi_io_completion() by taking the bulk of its
error processing code into two static helper functions, leaving only
the 20 or so code lines that constitute the fastpath. In this process
comments were added and tweaked, plus variables renamed. The last two
patches in this set are optional: adding conditional hints along the
fastpath and converting 3 BUG() calls in scsi_io_completion() to WARNs
as requested by a reviewer.

There is no attempt in this patchset to change the logic of the original
scsi_io_completion(). Some conditional checks are saved by reducing the
number of redundant tests (e.g. on the 'result' variable being non-zero). 
Also De Morgan's laws are applied to some complex conditions to simplify
them from the reader's perspective. The fact remains, this is a very
complex function.

This patch is against Martin Petersen's 4.17/scsi-queue branch.

Note to reviewers: a patchset that refactors code, in this case one very
long function into one short function and two longish helpers, does not
"own" the logic in the original function. The main thing to review is
whether the refactoring is worthwhile and whether the logic remains the
same after the refactoring. 

Douglas Gilbert (6):
  scsi_io_completion comment on end_request return
  scsi_io_completion rename variables
  scsi_io_completion_nz_result function added
  scsi_io_completion_action helper added
  scsi_io_completion hints on fastpatch
  scsi_io_completion convert BUGs to WARNs

 drivers/scsi/scsi_lib.c | 376 ++++++++++++++++++++++++++++--------------------
 1 file changed, 219 insertions(+), 157 deletions(-)

-- 
2.14.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux