• Christoph Hellwig's avatar
    [SCSI] untangle scsi_prep_fn · 3b003157
    Christoph Hellwig authored
    I wanted to add some BUG checks to scsi_prep_fn to make sure no one
    sends us a non-sg command, but this function is a horrible mess.
    
    So I decided to detangle the function and document what the valid
    cases are.  While doing that I found that REQ_TYPE_SPECIAL commands
    aren't used by the SCSI layer anymore and we can get rid of the code
    handling them.
    
    The new structure of scsi_prep_fn is:
    
     (1) check if we're allowed to send this command
     (2) big switch on cmd_type.  For the two valid types call into
         a function to set the command up, else error
     (3) code to handle error cases
    
    Because FS and BLOCK_PC commands are handled entirely separate after
    the patch this introduces a tiny amount of code duplication.  This
    improves readabiulity though and will help to avoid the bidi command
    overhead for FS commands so it's a good thing.
    
    I've tested this on both sata and mptsas.
    Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
    3b003157
scsi_lib.c 56.8 KB