Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

scsi_disk(7) [hpux man page]

scsi_disk(7)						 Miscellaneous Information Manual					      scsi_disk(7)

NAME
scsi_disk - SCSI direct access device drivers (esdisk/sdisk) DESCRIPTION
This section describes the interface for access of SCSI disk, CD-ROM, and optical disk devices through the character special device driver. is the default driver for direct access devices starting at HP-UX 11i Version 3. is the default driver used on HP-UX 11i Version 2 and earlier releases. It is maintained for backward compatibility. SCSI direct access devices store a sequence of data blocks. Each direct access device has a specific device size consisting of a number of data blocks and a logical block size. All data blocks have the same logical block size. Since I/O operations must have a size that is an integral number of blocks, one logical block size is the smallest possible I/O quantity. The device block size can be determined through use of the and ioctls (see disk(7) and scsi(7); is not supported on A direct access device that is not ready for use, whether due to no media installed or another reason, is interpreted to mean the device has zero size. An call to such a device succeeds, but subsequent and calls fail. The ioctl(2) manpage explains how the operations and arguments are used. Note, the arg used is commonly the address of the parameter cited in the particular ioctl statement. See the section for sample code. To improve performance, many SCSI disk devices have caches, which can be used for both read and write operations. Read cache use, called "read ahead", causes the disk drive to read data in anticipation of read requests. Read ahead is only apparent to users in the increased performance that it produces. Write cache use is called "immediate reporting". Immediate reporting increases I/O performance by reporting a completed write status before the data being written is actually committed to media. If the subsequent physical write operation does not complete successfully, data may be lost. Physical write failures due to media defects are largely eliminated by use of automatic sparing in disk drives. Power failure between immediate reporting and media commit can result in cached data being lost. However, the period of time between these events is typically relatively small, making such losses unlikely. The ioctl can be used to determine if immediate-reporting functionality is currently being used by the device. The value indicates immedi- ate reporting is enabled. The value zero indicates immediate reporting is disabled. The ioctl can be used to enable or disable immediate reporting. A zero value disables immediate reporting. The value enables immediate reporting. The ioctl can be used to force data cached in the device to media. Most SCSI removable media disk devices support "prevent" and "allow" media-removal commands. To avoid data corruption and data accessibil- ity problems, media removal is prevented for the entire duration a removable media disk device is open. Because media removal is not sup- ported, the ioctl is not supported. The header file has useful information for direct access device control, including the following: /* ioctl support for SCSI disk devices */ #define SIOC_GET_IR _IOR('S', 14, int) #define SIOC_SET_IR _IOW('S', 15, int) #define SIOC_SYNC_CACHE -IOW('S', 70, int) The ioctl reformats the entire media surface. Exclusive access to the device, obtained through use of the ioctl (see disk(7)), is required prior to reformatting to ensure that other applications are not affected. The field can be used to select the desired media geometry. Only one media geometry is supported on most devices. The value zero should be used for these devices. The value zero can also be used to select the default geometry on devices that support multiple media geometries. The interleave field can be used to specify sector inter- leaving. The value zero specifies that an appropriate default interleave should be used. EXAMPLES
The following sample code shows how to use ioctls that affect #include <stdio.h> #include <fcntl.h> #include <sys/errno.h> #include <sys/diskio.h> #include <sys/scsi.h> Describe_ext(dfd) int dfd; { int ret; disk_describe_type_ext_t disk_descr; uint64_t capacity; if ((ret = ioctl (dfd, DIOC_DESCRIBE_EXT, &descr_type)) != 0) { exit(1); } printf(" Successful ioctl DIOC_DESCRIBE_EXT "); printf(" model number: %s ", disk_descr.model_num); printf(" interface: %d <20=scsi> ", disk_descr.intf_type); capacity = (disk_descr.maxsva_high << 32) + disk_descr.low_lba; printf(" Capacity: %llu (blocks) ", capacity); printf(" block size: %u (bytes) ", disk_descr.lgblksz); printf(" Device type: %u (0=disk, 5=CD, 7=OM) ", disk_descr.dev_type); printf(" Write Protected: %s ", disk_descr.flags & WRITE_PROTECT_FLAG ? "yes" : "No"); } Describe (dfd) int dfd; { int ret; disk_describe_type descr_type; if ((ret = ioctl (dfd, DIOC_DESCRIBE, &descr_type)) != 0) { exit(1); } printf (" Successful ioctl DIOC_DESCRIBE "); printf (" model number: %s ", descr_type.model_num); printf (" interface: %d <20=scsi> ", descr_type.intf_type); } Exclusive (dfd) int dfd; { int ret, flag=1; if ((ret = ioctl (dfd, DIOC_EXCLUSIVE, &flag)) != 0) { exit(1); } } Enable_WOE (dfd) int dfd; { int ret, flag=1; if ((ret = ioctl (dfd, SIOC_WRITE_WOE, &flag)) != 0) { exit(1); } printf (" Successful ioctl SIOC_WRITE_WOE "); } main (argc, argv) int argc; char ** argv; { int ret, fd; if (argc != 2) { printf ("Usage: %s <disk_device> ", argv[0]); exit(1); } if ((fd = open (argv[1], O_RDWR)) < 0) { exit(1); } Describe_ext(fd); Describe (fd); Exclusive (fd); Enable_WOE (fd); } WARNINGS
Historically, disk devices have had small (typically 512 byte) block sizes; however, many newer disk devices (such as optical disks and disk arrays) have relatively large block sizes. Applications using direct raw disk access should use the or ioctl to determine the appro- priate minimum I/O size. Media removal and insertion while a disk device is open is unsupported and unpredictable. Do not attempt to circumvent prevention of media removal. Device capacity changes resulting from such intervention may not be recognized. Often larger I/O operation sizes are expected to be more efficient. However, SCSI disk I/O operations that are large relative to the device's cache can result in insufficient cache space for the device to maintain full-media-speed data transfer rates. This can result in decreased I/O performance relative to smaller I/O sizes. DEPENDENCIES
Optical Disk Devices The ioctl controls the write mode. Normally written data is assumed to be correctly stored on the media. Verify-writes mode causes veri- fication of written data to ensure that data has been correctly written. Verification can substantially reduce write performance and is not generally needed. The ioctl can be used to enable or disable write verification. A zero value disables write verification. The value enables write verifi- cation. Although write verification is primarily intended for optical media, some systems may support write verification on normal disk devices. The ioctl verifies that a media area contains valid data (that is, data that has been correctly written). Verified media will not cause I/O errors when reading is attempted. The media area to be verified is specified via the and fields. Although verification is intended primarily for optical media, some systems may support verify operations on normal disk devices. The ioctl controls the write mode used for magneto-optical disk devices. Normally magneto-optical write operations require two physical head passes. The first pass erases the media area to be written. The second pass actually writes the data. Write-without-erase mode dra- matically increases write performance by skipping the first (erase media area) pass. To ensure that the correct data results, it is essen- tial that write-without-erase operations be performed only on media that is known to be blank (previously erased or never used). The ioctl can be used to enable or disable write-without-erase. A zero value disables write-without-erase. The value enables write-without-erase. The ioctl allows media areas to be explicitly erased. The media area to be erased is specified via the and fields. Media areas erased in this manner can be written using write-without-erase mode. Note that an erased media area is different from a media area written with some data values (e.g. zeros). An erased media area should not be read. Attempting to read an erased media area generally results in an I/O error. The ioctl verifies that a media area has been erased and is suitable for being written using write-without-erase mode. The media area to be verified is specified via the and fields. The following optical disk device specific information is included from #define SIOC_WRITE_WOE _IOW('S', 17, int) #define SIOC_VERIFY_WRITES _IOW('S', 18, int) #define SIOC_ERASE _IOW('S', 19, struct scsi_erase) #define SIOC_VERIFY_BLANK _IOW('S', 20, struct scsi_verify) #define SIOC_VERIFY _IOW('S', 21, struct scsi_verify) /* structure for SIOC_ERASE ioctl */ struct scsi_erase { unsigned int start_lba; unsigned short block_cnt; }; /* structure for SIOC_VERIFY_BLANK and SIOC_VERIFY ioctls */ struct scsi_verify { unsigned int start_lba; unsigned short block_cnt; }; FILES
SEE ALSO
mediainit(1), mknod(1M), ioctl(2), disk(7), scsi(7). scsi_disk(7)
Man Page