[PATCH v6 0/7] 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 three 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() although the last patch attempts to continue from
awkward situations rather than crashing the calling thread (and possibly
the kernel). Some conditional checks are saved by reducing the number of
redundant tests (e.g. multiple checks that the 'result' variable is
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.19/scsi-queue branch.
"Reviewed-by:" tags from v5 have been copied to v6.

ChangeLog since v5
  - rebased on MKP's 4.19/scsi-queue branch
  - churn due to other changes:
      a) __scsi_error_from_host_byte() being renamed
         scsi_result_to_blk_status()
      b) my "scsi_lib: sanitize++ in progress" patch
ChangeLog since v4
  - introduce bool do_print to simplify conditionals in the case of
    a recovered error sense key in 2/7 rather than 3/7
ChangeLog since v3
  - make use of bools sense_valid and sense_current consistent in 3/7
    and 4/7

Douglas Gilbert (7):
  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_reprep helper added
  scsi_io_completion hints on fastpatch
  scsi_io_completion convert BUGs to WARNs

 drivers/scsi/scsi_lib.c | 378 +++++++++++++++++++++++-----------------
 1 file changed, 214 insertions(+), 164 deletions(-)

-- 
2.17.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