/* * sdev state: If you alter this, you also need to alter scsi_sysfs.c * (for the ascii descriptions) and the state model enforcer: * scsi_lib:scsi_device_set_state().
*/ enum scsi_device_state {
SDEV_CREATED = 1, /* device created but not added to sysfs
* Only internal commands allowed (for inq) */
SDEV_RUNNING, /* device properly configured
* All commands allowed */
SDEV_CANCEL, /* beginning to delete device
* Only error handler commands allowed */
SDEV_DEL, /* device deleted
* no commands allowed */
SDEV_QUIESCE, /* Device quiescent. No block commands * will be accepted, only specials (which
* originate in the mid-layer) */
SDEV_OFFLINE, /* Device offlined (by error handling or
* user request */
SDEV_TRANSPORT_OFFLINE, /* Offlined by transport class error handler */
SDEV_BLOCK, /* Device blocked by scsi lld. No * scsi commands from user or midlayer * should be issued to the scsi
* lld. */
SDEV_CREATED_BLOCK, /* same as above but for created devices */
};
/* put union of data structures, for non-simple event types, * here
*/
};
/** * struct scsi_vpd - SCSI Vital Product Data * @rcu: For kfree_rcu(). * @len: Length in bytes of @data. * @data: VPD data as defined in various T10 SCSI standard documents.
*/ struct scsi_vpd { struct rcu_head rcu; int len; unsignedchar data[];
};
/* the next two are protected by the host->host_lock */ struct list_head siblings; /* list of all devices on this host */ struct list_head same_target_siblings; /* just the devices sharing same target id */
struct sbitmap budget_map;
atomic_t device_blocked; /* Device returned QUEUE_FULL. */
atomic_t restarts;
spinlock_t list_lock; struct list_head starved_entry; unsignedshort queue_depth; /* How deep of a queue we want */ unsignedshort max_queue_depth; /* max queue depth */ unsignedshort last_queue_full_depth; /* These two are used by */ unsignedshort last_queue_full_count; /* scsi_track_queue_full() */ unsignedlong last_queue_full_time; /* last queue full time */ unsignedlong queue_ramp_up_period; /* ramp up period in jiffies */ #define SCSI_DEFAULT_RAMP_UP_PERIOD (120 * HZ)
unsignedlong last_queue_ramp_up; /* last queue ramp up time */
unsignedint id, channel;
u64 lun; unsignedint manufacturer; /* Manufacturer of device, for using
* vendor-specific cmd's */ unsigned sector_size; /* size in bytes */
void *hostdata; /* available to low-level driver */ unsignedchar type; char scsi_level; char inq_periph_qual; /* PQ from INQUIRY data */ struct mutex inquiry_mutex; unsignedchar inquiry_len; /* valid bytes in 'inquiry' */ unsignedchar * inquiry; /* INQUIRY response data */ constchar * vendor; /* [back_compat] point into 'inquiry' ... */ constchar * model; /* ... after scan; point to static string */ constchar * rev; /* ... "nullnullnullnull" before scan */
blist_flags_t sdev_bflags; /* black/white flags as also found in * scsi_devinfo.[hc]. For now used only to * pass settings from sdev_init to scsi
* core. */ unsignedint eh_timeout; /* Error handling timeout */
/* * If true, let the high-level device driver (sd) manage the device * power state for system suspend/resume (suspend to RAM and * hibernation) operations.
*/ unsigned manage_system_start_stop:1;
/* * If true, let the high-level device driver (sd) manage the device * power state for runtime device suspand and resume operations.
*/ unsigned manage_runtime_start_stop:1;
/* * If true, let the high-level device driver (sd) manage the device * power state for system shutdown (power off) operations.
*/ unsigned manage_shutdown:1;
/* * If set and if the device is runtime suspended, ask the high-level * device driver (sd) to force a runtime resume of the device.
*/ unsigned force_runtime_start_on_system_start:1;
/* * Set if the device is an ATA device.
*/ unsigned is_ata:1;
unsigned removable:1; unsigned changed:1; /* Data invalid due to media change */ unsigned busy:1; /* Used to prevent races */ unsigned lockable:1; /* Able to prevent media removal */ unsigned locked:1; /* Media removal disabled */ unsigned borken:1; /* Tell the Seagate driver to be
* painfully slow on this device */ unsigned disconnect:1; /* can disconnect */ unsigned soft_reset:1; /* Uses soft reset option */ unsigned sdtr:1; /* Device supports SDTR messages */ unsigned wdtr:1; /* Device supports WDTR messages */ unsigned ppr:1; /* Device supports PPR messages */ unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */ unsigned simple_tags:1; /* simple queue tag messages are enabled */ unsigned was_reset:1; /* There was a bus reset on the bus for
* this device */ unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN
* because we did a bus reset. */ unsigned use_10_for_rw:1; /* first try 10-byte read / write */ unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ unsigned set_dbd_for_ms:1; /* Set "DBD" field in mode sense */ unsigned read_before_ms:1; /* perform a READ before MODE SENSE */ unsigned no_report_opcodes:1; /* no REPORT SUPPORTED OPERATION CODES */ unsigned no_write_same:1; /* no WRITE SAME command */ unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */ unsigned use_16_for_sync:1; /* Use sync (16) over sync (10) */ unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ unsigned skip_vpd_pages:1; /* do not read VPD pages */ unsigned try_vpd_pages:1; /* attempt to read VPD pages */ unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ unsigned no_start_on_add:1; /* do not issue start on add */ unsigned allow_restart:1; /* issue START_UNIT in error handler */ unsigned start_stop_pwr_cond:1; /* Set power cond. in START_STOP_UNIT */ unsigned no_uld_attach:1; /* disable connecting to upper level drivers */ unsigned select_no_atn:1; unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */ unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */ unsigned last_sector_bug:1; /* do not use multisector accesses on
SD_LAST_BUGGY_SECTORS */ unsigned no_read_disc_info:1; /* Avoid READ_DISC_INFO cmds */ unsigned no_read_capacity_16:1; /* Avoid READ_CAPACITY_16 cmds */ unsigned try_rc_10_first:1; /* Try READ_CAPACACITY_10 first */ unsigned security_supported:1; /* Supports Security Protocols */ unsigned is_visible:1; /* is the device visible in sysfs */ unsigned wce_default_on:1; /* Cache is ON by default */ unsigned no_dif:1; /* T10 PI (DIF) should be disabled */ unsigned broken_fua:1; /* Don't set FUA bit */ unsigned lun_in_cdb:1; /* Store LUN bits in CDB[1] */ unsigned unmap_limit_for_ws:1; /* Use the UNMAP limit for WRITE SAME */ unsigned rpm_autosuspend:1; /* Enable runtime autosuspend at device
* creation time */ unsigned ignore_media_change:1; /* Ignore MEDIA CHANGE on resume */ unsigned silence_suspend:1; /* Do not print runtime PM related messages */ unsigned no_vpd_size:1; /* No VPD size reported in header */
/* * like scmd_printk, but the device name is passed in * as a string pointer
*/
__printf(4, 5) void
sdev_prefix_printk(constchar *, conststruct scsi_device *, constchar *, constchar *, ...);
/* * scsi_target: representation of a scsi target, for now, this is only * used for single_lun devices. If no one has active IO to the target, * starget_sdev_user is NULL, else it points to the active sdev.
*/ struct scsi_target { struct scsi_device *starget_sdev_user; struct list_head siblings; struct list_head devices; struct device dev; struct kref reap_ref; /* last put renders target invisible */ unsignedint channel; unsignedint id; /* target id ... replace
* scsi_device.id eventually */ unsignedint create:1; /* signal that it needs to be added */ unsignedint single_lun:1; /* Indicates we should only * allow I/O to one of the luns
* for the device at a time. */ unsignedint pdt_1f_for_no_lun:1; /* PDT = 0x1f
* means no lun present. */ unsignedint no_report_luns:1; /* Don't use
* REPORT LUNS for scanning. */ unsignedint expecting_lun_change:1; /* A device has reported * a 3F/0E UA, other devices on
* the same target will also. */ /* commands actually active on LLD. */
atomic_t target_busy;
atomic_t target_blocked;
/* * LLDs should set this in the sdev_init host template callout. * If set to zero then there is not limit.
*/ unsignedint can_queue; unsignedint max_target_blocked; #define SCSI_DEFAULT_TARGET_BLOCKED 3
char scsi_level; enum scsi_target_state state; void *hostdata; /* available to low-level driver */ unsignedlong starget_data[]; /* for the transport */ /* starget_data must be the last element!!!! */
} __attribute__((aligned(sizeof(unsignedlong))));
/* only exposed to implement shost_for_each_device */ externstruct scsi_device *__scsi_iterate_devices(struct Scsi_Host *, struct scsi_device *);
/** * shost_for_each_device - iterate over all devices of a host * @sdev: the &struct scsi_device to use as a cursor * @shost: the &struct scsi_host to iterate over * * Iterator that returns each device attached to @shost. This loop * takes a reference on each device and releases it at the end. If * you break out of the loop, you must call scsi_device_put(sdev).
*/ #define shost_for_each_device(sdev, shost) \ for ((sdev) = __scsi_iterate_devices((shost), NULL); \
(sdev); \
(sdev) = __scsi_iterate_devices((shost), (sdev)))
/** * __shost_for_each_device - iterate over all devices of a host (UNLOCKED) * @sdev: the &struct scsi_device to use as a cursor * @shost: the &struct scsi_host to iterate over * * Iterator that returns each device attached to @shost. It does _not_ * take a reference on the scsi_device, so the whole loop must be * protected by shost->host_lock. * * Note: The only reason to use this is because you need to access the * device list in interrupt context. Otherwise you really want to use * shost_for_each_device instead.
*/ #define __shost_for_each_device(sdev, shost) \
list_for_each_entry((sdev), &((shost)->__devices), siblings)
/* * scsi_execute_cmd users can set scsi_failure.result to have * scsi_check_passthrough fail/retry a command. scsi_failure.result can be a * specific host byte or message code, or SCMD_FAILURE_RESULT_ANY can be used * to match any host or message code.
*/ #define SCMD_FAILURE_RESULT_ANY 0x7fffffff /* * Set scsi_failure.result to SCMD_FAILURE_STAT_ANY to fail/retry any failure * scsi_status_is_good returns false for.
*/ #define SCMD_FAILURE_STAT_ANY 0xff /* * The following can be set to the scsi_failure sense, asc and ascq fields to * match on any sense, ASC, or ASCQ value.
*/ #define SCMD_FAILURE_SENSE_ANY 0xff #define SCMD_FAILURE_ASC_ANY 0xff #define SCMD_FAILURE_ASCQ_ANY 0xff /* Always retry a matching failure. */ #define SCMD_FAILURE_NO_LIMIT -1
struct scsi_failure { int result;
u8 sense;
u8 asc;
u8 ascq; /* * Number of times scsi_execute_cmd will retry the failure. It does * not count for the total_allowed.
*/
s8 allowed; /* Number of times the failure has been retried. */
s8 retries;
};
struct scsi_failures { /* * If a scsi_failure does not have a retry limit setup this limit will * be used.
*/ int total_allowed; int total_retries; struct scsi_failure *failure_definitions;
};
/* Optional arguments to scsi_execute_cmd */ struct scsi_exec_args { unsignedchar *sense; /* sense buffer */ unsignedint sense_len; /* sense buffer len */ struct scsi_sense_hdr *sshdr; /* decoded sense header */
blk_mq_req_flags_t req_flags; /* BLK_MQ_REQ flags */ int scmd_flags; /* SCMD flags */ int *resid; /* residual length */ struct scsi_failures *failures; /* failures to retry */
};
int scsi_execute_cmd(struct scsi_device *sdev, constunsignedchar *cmd,
blk_opf_t opf, void *buffer, unsignedint bufflen, int timeout, int retries, conststruct scsi_exec_args *args); void scsi_failures_reset_retries(struct scsi_failures *failures);
/** * scsi_device_supports_vpd - test if a device supports VPD pages * @sdev: the &struct scsi_device to test * * If the 'try_vpd_pages' flag is set it takes precedence. * Otherwise we will assume VPD pages are supported if the * SCSI level is at least SPC-3 and 'skip_vpd_pages' is not set.
*/ staticinlineint scsi_device_supports_vpd(struct scsi_device *sdev)
{ /* Attempt VPD inquiry if the device blacklist explicitly calls * for it.
*/ if (sdev->try_vpd_pages) return 1; /* * Although VPD inquiries can go to SCSI-2 type devices, * some USB ones crash on receiving them, and the pages * we currently ask for are mandatory for SPC-2 and beyond
*/ if (sdev->scsi_level >= SCSI_SPC_2 && !sdev->skip_vpd_pages) return 1; return 0;
}
/* Macros to access the UNIT ATTENTION counters */ #define scsi_get_ua_new_media_ctr(sdev) atomic_read(&sdev->ua_new_media_ctr) #define scsi_get_ua_por_ctr(sdev) atomic_read(&sdev->ua_por_ctr)
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.35Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.