Skip to content

A hard-coded timeout in cython-sgio #149

@jackeichen

Description

@jackeichen

I noticed that cython-sgio has a hard-coded timeout of 1800000 milliseconds (30 minutes). It means that all commands in python-scsi can only use this fixed timeout value, which makes the library quite inflexible for different use cases.

I understand that 1800000 milliseconds probably works well for most modern SCSI devices in normal situations, but there are definitely cases where we need to be able to set this timeout ourselves, like:

  1. The protocol test to validate command timeout behavior;
  2. Buggy devices where some commands never return, leaving us stuck waiting 30 minutes for a timeout.

sg3_utils has 3 default timeout values for different commands(https://github.com/doug-gilbert/sg3_utils/blob/main/lib/sg_cmds_basic.c#L51-L53), while some commands support to set the timeout in input parameters, like “unmap”:

 # sg_unmap  -h
Usage: sg_unmap [--all=ST,RN[,LA]] [--anchor] [--dry-run] [--force]
                [--grpnum=GN] [--help] [--in=FILE] [--lba=LBA,LBA...]
                [--num=NUM,NUM...] [--timeout=TO] [--verbose] [--version]
                DEVICE
  where:
    --all=ST,RN[,LA]|-A ST,RN[,LA]    start unmaps at LBA ST, RN blocks
                         per unmap until the end of disk, or until
                         and including LBA LA (last)
    --anchor|-a          set anchor field in cdb
    --dry-run|-d         prepare but skip UNMAP call(s)
    --force|-f           don't ask for confirmation before zapping media
    --grpnum=GN|-g GN    GN is group number field (def: 0)
    --help|-h            print out usage message
    --in=FILE|-I FILE    read LBA, NUM pairs from FILE (if FILE is '-'
                         then stdin is read)
    --lba=LBA,LBA...|-l LBA,LBA...    LBA is the logical block address
                                      to start NUM unmaps
    --num=NUM,NUM...|-n NUM,NUM...    NUM is number of logical blocks to
                                      unmap starting at corresponding LBA
    --timeout=TO|-t TO    command timeout (unit: seconds) (def: 60)
    --verbose|-v         increase verbosity
    --version|-V         print version string and exit  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions