[PATCH v2 0/2] scsi_io_completion cleanup and fix CONDITION MET handling

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

 



This patch started as an attempt to fix the erroneous handling of
CONDITION MET, a relatively rare special case. A solution meant adding
another special case to the already complicated scsi_io_completion()
function. To better understand that function the author found it
useful to refactor the function into one relatively short function
that the fast path passes through and two helper functions. These
helper functions do the bulk of the error and special case handling.

The SCSI PRE-FETCH (10 or 16) command is present both on hard disks
and some SSDs. It is useful when the address of the next block(s) to
be read is known but it is not following the LBA of the current READ
(so read-ahead won't help). It returns two "good" SCSI Status values.
If the requested blocks have fitted (or will most likely fit (when
the IMMED bit is set)) into the disk's cache, it returns CONDITION
MET. If it didn't (or will not) fit then it returns GOOD status.

Future work: if the sd driver was to use the PRE-FETCH command,
decide whether it and/or the block layer needs to know about the
two different "good" statuses. If so a mechanism would be needed
to do that.

ChangeLog for v2:
  - after checkpatch.pl warning about BUG statements and confirmed
    by a reviewer, convert 3 BUG calls in scsi_io_completion()
    into WARN calls

ChangeLog for v1:
  - split scsi_io_completion() into one short function that the
    fast path uses, and two helper functions
  - add conditional hints on the fast path
  - rename some variables to make the code a little clearer
  - add scsi_io_completion_nz_result() helper for the initial
    handling of the non-zero cmd->result case
  - add scsi_io_completion_action() helper for the 'action'
    processing of errors and special cases
  - expand inline function scsi_status_is_good() to check for
    CONDITION MET
  - add a corner case in scsi_io_completion_nz_result() for
    CONDITION MET (and similar "good" SCSI statuses)
  - structure code so extra checks are only on the error
    path (i.e. when cmd->result is non-zero)

This patch is against mkp's 4.17/scsi-queue branch. It also
 applies to lk 4.15.x where it was tested on a SAS SSD.


Douglas Gilbert (2):
  scsi_io_completion cleanup and fix CONDITION MET handling
  scsi_io_completion-change2warn

 drivers/scsi/scsi_lib.c | 304 +++++++++++++++++++++++++++++-------------------
 include/scsi/scsi.h     |   2 +
 2 files changed, 188 insertions(+), 118 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