linux/drivers/scsi/sd.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *      sd.c Copyright (C) 1992 Drew Eckhardt
 *           Copyright (C) 1993, 1994, 1995, 1999 Eric Youngdale
 *
 *      Linux scsi disk driver
 *              Initial versions: Drew Eckhardt
 *              Subsequent revisions: Eric Youngdale
 *	Modification history:
 *       - Drew Eckhardt <[email protected]> original
 *       - Eric Youngdale <[email protected]> add scatter-gather, multiple 
 *         outstanding request, and other enhancements.
 *         Support loadable low-level scsi drivers.
 *       - Jirka Hanika <[email protected]> support more scsi disks using 
 *         eight major numbers.
 *       - Richard Gooch <[email protected]> support devfs.
 *	 - Torben Mathiasen <[email protected]> Resource allocation fixes in 
 *	   sd_init and cleanups.
 *	 - Alex Davis <[email protected]> Fix problem where partition info
 *	   not being read in sd_open. Fix problem where removable media 
 *	   could be ejected after sd_open.
 *	 - Douglas Gilbert <[email protected]> cleanup for lk 2.5.x
 *	 - Badari Pulavarty <[email protected]>, Matthew Wilcox 
 *	   <[email protected]>, Kurt Garloff <[email protected]>: 
 *	   Support 32k/1M disks.
 *
 *	Logging policy (needs CONFIG_SCSI_LOGGING defined):
 *	 - setting up transfer: SCSI_LOG_HLQUEUE levels 1 and 2
 *	 - end of transfer (bh + scsi_lib): SCSI_LOG_HLCOMPLETE level 1
 *	 - entering sd_ioctl: SCSI_LOG_IOCTL level 1
 *	 - entering other commands: SCSI_LOG_HLQUEUE level 3
 *	Note: when the logging level is set by the user, it must be greater
 *	than the level indicated above to trigger output.	
 */

#include <linux/bio-integrity.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/bio-integrity.h>
#include <linux/hdreg.h>
#include <linux/errno.h>
#include <linux/idr.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/blkpg.h>
#include <linux/blk-pm.h>
#include <linux/delay.h>
#include <linux/rw_hint.h>
#include <linux/major.h>
#include <linux/mutex.h>
#include <linux/string_helpers.h>
#include <linux/slab.h>
#include <linux/sed-opal.h>
#include <linux/pm_runtime.h>
#include <linux/pr.h>
#include <linux/t10-pi.h>
#include <linux/uaccess.h>
#include <asm/unaligned.h>

#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_dbg.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_devinfo.h>
#include <scsi/scsi_driver.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_ioctl.h>
#include <scsi/scsicam.h>
#include <scsi/scsi_common.h>

#include "sd.h"
#include "scsi_priv.h"
#include "scsi_logging.h"

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_BLOCKDEV_MAJOR();
MODULE_ALIAS_SCSI_DEVICE();
MODULE_ALIAS_SCSI_DEVICE();
MODULE_ALIAS_SCSI_DEVICE();
MODULE_ALIAS_SCSI_DEVICE();

#define SD_MINORS

static void sd_config_discard(struct scsi_disk *sdkp, struct queue_limits *lim,
		unsigned int mode);
static void sd_config_write_same(struct scsi_disk *sdkp,
		struct queue_limits *lim);
static int  sd_revalidate_disk(struct gendisk *);
static void sd_unlock_native_capacity(struct gendisk *disk);
static void sd_shutdown(struct device *);
static void scsi_disk_release(struct device *cdev);

static DEFINE_IDA(sd_index_ida);

static mempool_t *sd_page_pool;
static struct lock_class_key sd_bio_compl_lkclass;

static const char *sd_cache_types[] =;

static void sd_set_flush_flag(struct scsi_disk *sdkp,
		struct queue_limits *lim)
{}

static ssize_t
cache_type_store(struct device *dev, struct device_attribute *attr,
		 const char *buf, size_t count)
{}

static ssize_t
manage_start_stop_show(struct device *dev,
		       struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(manage_start_stop);

static ssize_t
manage_system_start_stop_show(struct device *dev,
			      struct device_attribute *attr, char *buf)
{}

static ssize_t
manage_system_start_stop_store(struct device *dev,
			       struct device_attribute *attr,
			       const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(manage_system_start_stop);

static ssize_t
manage_runtime_start_stop_show(struct device *dev,
			       struct device_attribute *attr, char *buf)
{}

static ssize_t
manage_runtime_start_stop_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(manage_runtime_start_stop);

static ssize_t manage_shutdown_show(struct device *dev,
				    struct device_attribute *attr, char *buf)
{}

static ssize_t manage_shutdown_store(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(manage_shutdown);

static ssize_t
allow_restart_show(struct device *dev, struct device_attribute *attr, char *buf)
{}

static ssize_t
allow_restart_store(struct device *dev, struct device_attribute *attr,
		    const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(allow_restart);

static ssize_t
cache_type_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RW(cache_type);

static ssize_t
FUA_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(FUA);

static ssize_t
protection_type_show(struct device *dev, struct device_attribute *attr,
		     char *buf)
{}

static ssize_t
protection_type_store(struct device *dev, struct device_attribute *attr,
		      const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(protection_type);

static ssize_t
protection_mode_show(struct device *dev, struct device_attribute *attr,
		     char *buf)
{}
static DEVICE_ATTR_RO(protection_mode);

static ssize_t
app_tag_own_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(app_tag_own);

static ssize_t
thin_provisioning_show(struct device *dev, struct device_attribute *attr,
		       char *buf)
{}
static DEVICE_ATTR_RO(thin_provisioning);

/* sysfs_match_string() requires dense arrays */
static const char *lbp_mode[] =;

static ssize_t
provisioning_mode_show(struct device *dev, struct device_attribute *attr,
		       char *buf)
{}

static ssize_t
provisioning_mode_store(struct device *dev, struct device_attribute *attr,
			const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(provisioning_mode);

/* sysfs_match_string() requires dense arrays */
static const char *zeroing_mode[] =;

static ssize_t
zeroing_mode_show(struct device *dev, struct device_attribute *attr,
		  char *buf)
{}

static ssize_t
zeroing_mode_store(struct device *dev, struct device_attribute *attr,
		   const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(zeroing_mode);

static ssize_t
max_medium_access_timeouts_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{}

static ssize_t
max_medium_access_timeouts_store(struct device *dev,
				 struct device_attribute *attr, const char *buf,
				 size_t count)
{}
static DEVICE_ATTR_RW(max_medium_access_timeouts);

static ssize_t
max_write_same_blocks_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}

static ssize_t
max_write_same_blocks_store(struct device *dev, struct device_attribute *attr,
			    const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(max_write_same_blocks);

static ssize_t
zoned_cap_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(zoned_cap);

static ssize_t
max_retries_store(struct device *dev, struct device_attribute *attr,
		  const char *buf, size_t count)
{}

static ssize_t
max_retries_show(struct device *dev, struct device_attribute *attr,
		 char *buf)
{}

static DEVICE_ATTR_RW(max_retries);

static struct attribute *sd_disk_attrs[] =;
ATTRIBUTE_GROUPS();

static struct class sd_disk_class =;

/*
 * Don't request a new module, as that could deadlock in multipath
 * environment.
 */
static void sd_default_probe(dev_t devt)
{}

/*
 * Device no to disk mapping:
 * 
 *       major         disc2     disc  p1
 *   |............|.............|....|....| <- dev_t
 *    31        20 19          8 7  4 3  0
 * 
 * Inside a major, we have 16k disks, however mapped non-
 * contiguously. The first 16 disks are for major0, the next
 * ones with major1, ... Disk 256 is for major0 again, disk 272 
 * for major1, ... 
 * As we stay compatible with our numbering scheme, we can reuse 
 * the well-know SCSI majors 8, 65--71, 136--143.
 */
static int sd_major(int major_idx)
{}

#ifdef CONFIG_BLK_SED_OPAL
static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer,
		size_t len, bool send)
{}
#endif /* CONFIG_BLK_SED_OPAL */

/*
 * Look up the DIX operation based on whether the command is read or
 * write and whether dix and dif are enabled.
 */
static unsigned int sd_prot_op(bool write, bool dix, bool dif)
{}

/*
 * Returns a mask of the protection flags that are valid for a given DIX
 * operation.
 */
static unsigned int sd_prot_flag_mask(unsigned int prot_op)
{}

static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd,
					   unsigned int dix, unsigned int dif)
{}

static void sd_disable_discard(struct scsi_disk *sdkp)
{}

static void sd_config_discard(struct scsi_disk *sdkp, struct queue_limits *lim,
		unsigned int mode)
{}

static void *sd_set_special_bvec(struct request *rq, unsigned int data_len)
{}

static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd)
{}

static void sd_config_atomic(struct scsi_disk *sdkp, struct queue_limits *lim)
{}

static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd,
		bool unmap)
{}

static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,
		bool unmap)
{}

static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd)
{}

static void sd_disable_write_same(struct scsi_disk *sdkp)
{}

static void sd_config_write_same(struct scsi_disk *sdkp,
		struct queue_limits *lim)
{}

static blk_status_t sd_setup_flush_cmnd(struct scsi_cmnd *cmd)
{}

/**
 * sd_group_number() - Compute the GROUP NUMBER field
 * @cmd: SCSI command for which to compute the value of the six-bit GROUP NUMBER
 *	field.
 *
 * From SBC-5 r05 (https://www.t10.org/cgi-bin/ac.pl?t=f&f=sbc5r05.pdf):
 * 0: no relative lifetime.
 * 1: shortest relative lifetime.
 * 2: second shortest relative lifetime.
 * 3 - 0x3d: intermediate relative lifetimes.
 * 0x3e: second longest relative lifetime.
 * 0x3f: longest relative lifetime.
 */
static u8 sd_group_number(struct scsi_cmnd *cmd)
{}

static blk_status_t sd_setup_rw32_cmnd(struct scsi_cmnd *cmd, bool write,
				       sector_t lba, unsigned int nr_blocks,
				       unsigned char flags, unsigned int dld)
{}

static blk_status_t sd_setup_rw16_cmnd(struct scsi_cmnd *cmd, bool write,
				       sector_t lba, unsigned int nr_blocks,
				       unsigned char flags, unsigned int dld)
{}

static blk_status_t sd_setup_rw10_cmnd(struct scsi_cmnd *cmd, bool write,
				       sector_t lba, unsigned int nr_blocks,
				       unsigned char flags)
{}

static blk_status_t sd_setup_rw6_cmnd(struct scsi_cmnd *cmd, bool write,
				      sector_t lba, unsigned int nr_blocks,
				      unsigned char flags)
{}

/*
 * Check if a command has a duration limit set. If it does, and the target
 * device supports CDL and the feature is enabled, return the limit
 * descriptor index to use. Return 0 (no limit) otherwise.
 */
static int sd_cdl_dld(struct scsi_disk *sdkp, struct scsi_cmnd *scmd)
{}

static blk_status_t sd_setup_atomic_cmnd(struct scsi_cmnd *cmd,
					sector_t lba, unsigned int nr_blocks,
					bool boundary, unsigned char flags)
{}

static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
{}

static blk_status_t sd_init_command(struct scsi_cmnd *cmd)
{}

static void sd_uninit_command(struct scsi_cmnd *SCpnt)
{}

static bool sd_need_revalidate(struct gendisk *disk, struct scsi_disk *sdkp)
{}

/**
 *	sd_open - open a scsi disk device
 *	@disk: disk to open
 *	@mode: open mode
 *
 *	Returns 0 if successful. Returns a negated errno value in case 
 *	of error.
 *
 *	Note: This can be called from a user context (e.g. fsck(1) )
 *	or from within the kernel (e.g. as a result of a mount(1) ).
 *	In the latter case @inode and @filp carry an abridged amount
 *	of information as noted above.
 *
 *	Locking: called with disk->open_mutex held.
 **/
static int sd_open(struct gendisk *disk, blk_mode_t mode)
{}

/**
 *	sd_release - invoked when the (last) close(2) is called on this
 *	scsi disk.
 *	@disk: disk to release
 *
 *	Returns 0. 
 *
 *	Note: may block (uninterruptible) if error recovery is underway
 *	on this disk.
 *
 *	Locking: called with disk->open_mutex held.
 **/
static void sd_release(struct gendisk *disk)
{}

static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
{}

/**
 *	sd_ioctl - process an ioctl
 *	@bdev: target block device
 *	@mode: open mode
 *	@cmd: ioctl command number
 *	@arg: this is third argument given to ioctl(2) system call.
 *	Often contains a pointer.
 *
 *	Returns 0 if successful (some ioctls return positive numbers on
 *	success as well). Returns a negated errno value in case of error.
 *
 *	Note: most ioctls are forward onto the block subsystem or further
 *	down in the scsi subsystem.
 **/
static int sd_ioctl(struct block_device *bdev, blk_mode_t mode,
		    unsigned int cmd, unsigned long arg)
{}

static void set_media_not_present(struct scsi_disk *sdkp)
{}

static int media_not_present(struct scsi_disk *sdkp,
			     struct scsi_sense_hdr *sshdr)
{}

/**
 *	sd_check_events - check media events
 *	@disk: kernel device descriptor
 *	@clearing: disk events currently being cleared
 *
 *	Returns mask of DISK_EVENT_*.
 *
 *	Note: this function is invoked from the block subsystem.
 **/
static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)
{}

static int sd_sync_cache(struct scsi_disk *sdkp)
{}

static void sd_rescan(struct device *dev)
{}

static int sd_get_unique_id(struct gendisk *disk, u8 id[16],
		enum blk_unique_id type)
{}

static int sd_scsi_to_pr_err(struct scsi_sense_hdr *sshdr, int result)
{}

static int sd_pr_in_command(struct block_device *bdev, u8 sa,
			    unsigned char *data, int data_len)
{}

static int sd_pr_read_keys(struct block_device *bdev, struct pr_keys *keys_info)
{}

static int sd_pr_read_reservation(struct block_device *bdev,
				  struct pr_held_reservation *rsv)
{}

static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key,
			     u64 sa_key, enum scsi_pr_type type, u8 flags)
{}

static int sd_pr_register(struct block_device *bdev, u64 old_key, u64 new_key,
		u32 flags)
{}

static int sd_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type,
		u32 flags)
{}

static int sd_pr_release(struct block_device *bdev, u64 key, enum pr_type type)
{}

static int sd_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key,
		enum pr_type type, bool abort)
{}

static int sd_pr_clear(struct block_device *bdev, u64 key)
{}

static const struct pr_ops sd_pr_ops =;

static void scsi_disk_free_disk(struct gendisk *disk)
{}

static const struct block_device_operations sd_fops =;

/**
 *	sd_eh_reset - reset error handling callback
 *	@scmd:		sd-issued command that has failed
 *
 *	This function is called by the SCSI midlayer before starting
 *	SCSI EH. When counting medium access failures we have to be
 *	careful to register it only only once per device and SCSI EH run;
 *	there might be several timed out commands which will cause the
 *	'max_medium_access_timeouts' counter to trigger after the first
 *	SCSI EH run already and set the device to offline.
 *	So this function resets the internal counter before starting SCSI EH.
 **/
static void sd_eh_reset(struct scsi_cmnd *scmd)
{}

/**
 *	sd_eh_action - error handling callback
 *	@scmd:		sd-issued command that has failed
 *	@eh_disp:	The recovery disposition suggested by the midlayer
 *
 *	This function is called by the SCSI midlayer upon completion of an
 *	error test command (currently TEST UNIT READY). The result of sending
 *	the eh command is passed in eh_disp.  We're looking for devices that
 *	fail medium access commands but are OK with non access commands like
 *	test unit ready (so wrongly see the device as having a successful
 *	recovery)
 **/
static int sd_eh_action(struct scsi_cmnd *scmd, int eh_disp)
{}

static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
{}

/**
 *	sd_done - bottom half handler: called when the lower level
 *	driver has completed (successfully or otherwise) a scsi command.
 *	@SCpnt: mid-level's per command structure.
 *
 *	Note: potentially run from within an ISR. Must not block.
 **/
static int sd_done(struct scsi_cmnd *SCpnt)
{}

/*
 * spinup disk - called only in sd_revalidate_disk()
 */
static void
sd_spinup_disk(struct scsi_disk *sdkp)
{}

/*
 * Determine whether disk supports Data Integrity Field.
 */
static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer)
{}

static void sd_config_protection(struct scsi_disk *sdkp,
		struct queue_limits *lim)
{}

static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,
			struct scsi_sense_hdr *sshdr, int sense_valid,
			int the_result)
{}

#define RC16_LEN
#if RC16_LEN > SD_BUF_SIZE
#error RC16_LEN must not be more than SD_BUF_SIZE
#endif

#define READ_CAPACITY_RETRIES_ON_RESET

static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
		struct queue_limits *lim, unsigned char *buffer)
{}

static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
						unsigned char *buffer)
{}

static int sd_try_rc16_first(struct scsi_device *sdp)
{}

/*
 * read disk capacity
 */
static void
sd_read_capacity(struct scsi_disk *sdkp, struct queue_limits *lim,
		unsigned char *buffer)
{}

/*
 * Print disk capacity
 */
static void
sd_print_capacity(struct scsi_disk *sdkp,
		  sector_t old_capacity)
{}

/* called with buffer of length 512 */
static inline int
sd_do_mode_sense(struct scsi_disk *sdkp, int dbd, int modepage,
		 unsigned char *buffer, int len, struct scsi_mode_data *data,
		 struct scsi_sense_hdr *sshdr)
{}

/*
 * read write protect setting, if possible - called only in sd_revalidate_disk()
 * called with buffer of length SD_BUF_SIZE
 */
static void
sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
{}

/*
 * sd_read_cache_type - called only from sd_revalidate_disk()
 * called with buffer of length SD_BUF_SIZE
 */
static void
sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
{}

static bool sd_is_perm_stream(struct scsi_disk *sdkp, unsigned int stream_id)
{}

static void sd_read_io_hints(struct scsi_disk *sdkp, unsigned char *buffer)
{}

/*
 * The ATO bit indicates whether the DIF application tag is available
 * for use by the operating system.
 */
static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
{}

static unsigned int sd_discard_mode(struct scsi_disk *sdkp)
{}

/*
 * Query disk device for preferred I/O sizes.
 */
static void sd_read_block_limits(struct scsi_disk *sdkp,
		struct queue_limits *lim)
{}

/* Parse the Block Limits Extension VPD page (0xb7) */
static void sd_read_block_limits_ext(struct scsi_disk *sdkp)
{}

/* Query block device characteristics */
static void sd_read_block_characteristics(struct scsi_disk *sdkp,
		struct queue_limits *lim)
{}

/**
 * sd_read_block_provisioning - Query provisioning VPD page
 * @sdkp: disk to query
 */
static void sd_read_block_provisioning(struct scsi_disk *sdkp)
{}

static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)
{}

static void sd_read_security(struct scsi_disk *sdkp, unsigned char *buffer)
{}

static inline sector_t sd64_to_sectors(struct scsi_disk *sdkp, u8 *buf)
{}

/**
 * sd_read_cpr - Query concurrent positioning ranges
 * @sdkp:	disk to query
 */
static void sd_read_cpr(struct scsi_disk *sdkp)
{}

static bool sd_validate_min_xfer_size(struct scsi_disk *sdkp)
{}

/*
 * Determine the device's preferred I/O size for reads and writes
 * unless the reported value is unreasonably small, large, not a
 * multiple of the physical block size, or simply garbage.
 */
static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp,
				      unsigned int dev_max)
{}

static void sd_read_block_zero(struct scsi_disk *sdkp)
{}

/**
 *	sd_revalidate_disk - called the first time a new disk is seen,
 *	performs disk spin up, read_capacity, etc.
 *	@disk: struct gendisk we care about
 **/
static int sd_revalidate_disk(struct gendisk *disk)
{}

/**
 *	sd_unlock_native_capacity - unlock native capacity
 *	@disk: struct gendisk to set capacity for
 *
 *	Block layer calls this function if it detects that partitions
 *	on @disk reach beyond the end of the device.  If the SCSI host
 *	implements ->unlock_native_capacity() method, it's invoked to
 *	give it a chance to adjust the device capacity.
 *
 *	CONTEXT:
 *	Defined by block layer.  Might sleep.
 */
static void sd_unlock_native_capacity(struct gendisk *disk)
{}

/**
 *	sd_format_disk_name - format disk name
 *	@prefix: name prefix - ie. "sd" for SCSI disks
 *	@index: index of the disk to format name for
 *	@buf: output buffer
 *	@buflen: length of the output buffer
 *
 *	SCSI disk names starts at sda.  The 26th device is sdz and the
 *	27th is sdaa.  The last one for two lettered suffix is sdzz
 *	which is followed by sdaaa.
 *
 *	This is basically 26 base counting with one extra 'nil' entry
 *	at the beginning from the second digit on and can be
 *	determined using similar method as 26 base conversion with the
 *	index shifted -1 after each digit is computed.
 *
 *	CONTEXT:
 *	Don't care.
 *
 *	RETURNS:
 *	0 on success, -errno on failure.
 */
static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
{}

/**
 *	sd_probe - called during driver initialization and whenever a
 *	new scsi device is attached to the system. It is called once
 *	for each scsi device (not just disks) present.
 *	@dev: pointer to device object
 *
 *	Returns 0 if successful (or not interested in this scsi device 
 *	(e.g. scanner)); 1 when there is an error.
 *
 *	Note: this function is invoked from the scsi mid-level.
 *	This function sets up the mapping between a given 
 *	<host,channel,id,lun> (found in sdp) and new device name 
 *	(e.g. /dev/sda). More precisely it is the block device major 
 *	and minor number that is chosen here.
 *
 *	Assume sd_probe is not re-entrant (for time being)
 *	Also think about sd_probe() and sd_remove() running coincidentally.
 **/
static int sd_probe(struct device *dev)
{}

/**
 *	sd_remove - called whenever a scsi disk (previously recognized by
 *	sd_probe) is detached from the system. It is called (potentially
 *	multiple times) during sd module unload.
 *	@dev: pointer to device object
 *
 *	Note: this function is invoked from the scsi mid-level.
 *	This function potentially frees up a device name (e.g. /dev/sdc)
 *	that could be re-used by a subsequent sd_probe().
 *	This function is not called when the built-in sd driver is "exit-ed".
 **/
static int sd_remove(struct device *dev)
{}

static void scsi_disk_release(struct device *dev)
{}

static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
{}

/*
 * Send a SYNCHRONIZE CACHE instruction down to the device through
 * the normal SCSI command structure.  Wait for the command to
 * complete.
 */
static void sd_shutdown(struct device *dev)
{}

static inline bool sd_do_start_stop(struct scsi_device *sdev, bool runtime)
{}

static int sd_suspend_common(struct device *dev, bool runtime)
{}

static int sd_suspend_system(struct device *dev)
{}

static int sd_suspend_runtime(struct device *dev)
{}

static int sd_resume(struct device *dev)
{}

static int sd_resume_common(struct device *dev, bool runtime)
{}

static int sd_resume_system(struct device *dev)
{}

static int sd_resume_runtime(struct device *dev)
{}

static const struct dev_pm_ops sd_pm_ops =;

static struct scsi_driver sd_template =;

/**
 *	init_sd - entry point for this driver (both when built in or when
 *	a module).
 *
 *	Note: this function registers this driver with the scsi mid-level.
 **/
static int __init init_sd(void)
{}

/**
 *	exit_sd - exit point for this driver (when it is a module).
 *
 *	Note: this function unregisters this driver from the scsi mid-level.
 **/
static void __exit exit_sd(void)
{}

module_init();
module_exit(exit_sd);

void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
{}

void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result)
{}