unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (HP-UX-11.11)
Page:
Section:
Apropos / Subsearch:
optional field



 scsi_disk(7)							scsi_disk(7)




 NAME
      scsi_disk - SCSI direct access device driver (sdisk)

 DESCRIPTION
      This section describes the interface for access of SCSI disk, CD-ROM,
      and optical disk devices through the character special device driver.

      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 DIOC_DESCRIBE, DIOC_CAPACITY, and
      SIOC_CAPACITY ioctls (see disk(7) and scsi(7); SIOC_CAPACITY is not
      supported on disc3).  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 open() call to such
      a device succeeds, but subsequent read() and write() 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 #define statement.	See the EXAMPLES
      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 SIOC_GET_IR ioctl
      can be used to determine if immediate-reporting functionality is
      currently being used by the device.  The value 1 indicates immediate
      reporting is enabled.  The value zero indicates immediate reporting is
      disabled.	 The SIOC_SET_IR ioctl can be used to enable or disable
      immediate reporting.  A zero value disables immediate reporting.	The
      value 1 enables immediate reporting.

      The SIOC_SYNC_CACHE 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



 Hewlett-Packard Company	    - 1 -   HP-UX Release 11i: November 2000






 scsi_disk(7)							scsi_disk(7)




      accessibility problems, media removal is prevented for the entire
      duration a removable media disk device is open.  Because media removal
      is not supported, the SIOC_MEDIUM_CHANGED ioctl is not supported.

      The header file <&lt&lt&lt;sys/scsi.h>&gt&gt&gt; 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 SIOC_FORMAT ioctl reformats the entire media surface.	 Exclusive
      access to the device, obtained through use of the DIOC_EXCLUSIVE ioctl
      (see disk(7)), is required prior to reformatting to ensure that other
      applications are not affected.  The fmt_optn 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 interleaving.  The
      value zero specifies that an appropriate default interleave should be
      used.

 EXAMPLES
      The following sample code shows how to use ioctls that affect
      scsi_disk.

	   #include <stdio.h>
	   #include <fcntl.h>
	   #include <sys/errno.h>
	   #include <sys/diskio.h>
	   #include <sys/scsi.h>
	   Describe (dfd)
	     int dfd;
	   {
	     int ret;
	     disk_describe_type descr_type;
	     if ((ret = ioctl (dfd, DIOC_DESCRIBE, &descr_type)) != 0) {
	       exit(1);
	     }
	     printf ("\nSuccessful ioctl DIOC_DESCRIBE \n");
	     printf ("	model number: %s\n", descr_type.model_num);
	     printf ("	interface:    %d  <20=scsi>\n", descr_type.intf_type);
	   }
	   Exclusive (dfd)
	     int dfd;
	   {
	     int ret, flag=1;
	     if ((ret = ioctl (dfd, DIOC_EXCLUSIVE, &flag)) != 0) {
	       exit(1);



 Hewlett-Packard Company	    - 2 -   HP-UX Release 11i: November 2000






 scsi_disk(7)							scsi_disk(7)




	     }
	   }
	   Enable_WOE (dfd)
	     int dfd;
	   {
	     int ret, flag=1;
	     if ((ret = ioctl (dfd, SIOC_WRITE_WOE, &flag)) != 0) {
	       exit(1);
	     }
	     printf ("\nSuccessful ioctl SIOC_WRITE_WOE \n");
	   }
	   main (argc, argv)
	     int argc;
	     char ** argv;
	   { int ret, fd; if (argc != 2) {
	       printf ("Usage: %s <disk3_device> \n", argv[0]);
	       exit(1);
	     }
	     if ((fd = open (argv[1], O_RDWR)) < 0) {
	       exit (1);
	     }
	     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 DIOC_DESCRIBE, DIOC_CAPACITY, or
      SIOC_CAPACITY ioctl to determine the appropriate 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 SIOC_VERIFY_WRITES ioctl controls the write mode.  Normally
      written data is assumed to be correctly stored on the media.  Verify-
      writes mode causes verification of written data to ensure that data
      has been correctly written.  Verification can substantially reduce
      write performance and is not generally needed.  The SIOC_VERIFY_WRITES



 Hewlett-Packard Company	    - 3 -   HP-UX Release 11i: November 2000






 scsi_disk(7)							scsi_disk(7)




      ioctl can be used to enable or disable write verification.  A zero
      value disables write verification.  The value 1 enables write
      verification.  Although write verification is primarily intended for
      optical media, some systems may support write verification on normal
      disk devices.

      The SIOC_VERIFY 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 start_lba and block_cnt fields.
      Although verification is intended primarily for optical media, some
      systems may support verify operations on normal disk devices.

      The SIOC_WRITE_WOE 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 dramatically increases write performance by
      skipping the first (erase media area) pass.  To ensure that the
      correct data results, it is essential that write-without-erase
      operations be performed only on media that is known to be blank
      (previously erased or never used).  The SIOC_WRITE_WOE ioctl can be
      used to enable or disable write-without-erase.  A zero value disables
      write-without-erase.  The value 1 enables write-without-erase.

      The SIOC_ERASE ioctl allows media areas to be explicitly erased.	The
      media area to be erased is specified via the start_lba and block_cnt
      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 SIOC_VERIFY_BLANK 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 start_lba and block_cnt
      fields.

      The following optical disk device specific information is included
      from <&lt&lt&lt;sys/scsi.h>&gt&gt&gt;:

	   #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;



 Hewlett-Packard Company	    - 4 -   HP-UX Release 11i: November 2000






 scsi_disk(7)							scsi_disk(7)




	   };

	   /* structure for SIOC_VERIFY_BLANK and SIOC_VERIFY ioctls */
	   struct scsi_verify {
		   unsigned int	   start_lba;
		   unsigned short  block_cnt;
	   };

 FILES
      /usr/include/sys/scsi.h

 SEE ALSO
      mediainit(1), mknod(1M), ioctl(2), disk(7), scsi(7).









































 Hewlett-Packard Company	    - 5 -   HP-UX Release 11i: November 2000