Accessing full ECKD tracks
In raw-track access mode, the DASD device driver accesses full ECKD tracks, including record zero and the count and key data fields.
Before you begin
- This section applies to ECKD type DASD only.
- The DASD must be offline when you change the access mode.
- The DIAG access method must not be enabled for the device.
About this task
With this mode, Linux® can access an ECKD device regardless of the track layout. In particular, the device does not need to be formatted for Linux.
For example, with raw-track access mode Linux can create a backup copy of any ECKD device. Full-track access can also enable a special program that runs on Linux to access and process data on an ECKD device that is not formatted for Linux.
By default, the DASD device driver accesses only the data fields of ECKD devices. In default access mode, you can work with partitions, file systems, and files in the file systems on the DASD.
- In memory, each track is represented by 64 KB of data, even if the track occupies less physical disk space. Therefore, a disk in raw-track access mode appears bigger than in default mode.
- Programs must write and should read data in multiples of complete 64 KB tracks. The minimum is a
single track. The maximum is eight tracks by default but can be extended to up to 16 tracks.
The maximum number of tracks depends on the maximum number of sectors as specified in the
max_sectors_kb
sysfs attribute of the DASD. This attribute is located in the block device branch of sysfs at /sys/block/dasd<x>/queue/max_sectors_kb. In the path, dasd<x> is the device name assigned by the DASD device driver.To extend the maximum beyond eight tracks, set the
max_sectors_kb
to the maximum amount of data to be processed in a single read or write operation. For example, to extend the maximum to reading or writing 16 tracks at a time, setmax_sectors_kb
to1024
(16 x 64). - Programs must write only valid ECKD tracks of 64 KB.
- Programs must use direct I/O to prevent the Linux block
layer from splitting tracks into fragments. Open the block device with option O_DIRECT or work with
programs that use direct I/O.
For example, the options
iflag=direct
andoflag=direct
cause dd to use direct I/O. When using dd, also specify the block size with thebs=
option. The block size determines the number of tracks that are processed in a single I/O operation. The block size must be a multiple of 64 KB and can be up to 1024 KB. Specifying a larger block size often results in better performance. If you receive disk image data from a pipe, also use the optioniflag=fullblock
to ensure that full blocks are written to the DASD device.Tools cannot directly work with partitions, file systems, or files within a file system. For example, fdasd and dasdfmt cannot be used.
Procedure
# echo <switch> > /sys/bus/ccw/devices/<device_bus_id>/raw_track_access
where: - <switch>
- is 1 to activate raw data access and 0 to deactivate raw data access.
- <device_bus_id>
- identifies the DASD.
Example
The following example creates a backup of a DASD 0.0.7009 on a DASD 0.0.70a1.
The initial commands ensure that both devices are offline and that the DIAG access method is not enabled for either of them. The subsequent commands activate the raw-track access mode for the two devices and set them both online. The lsdasd command that follows shows the mapping between device bus-IDs and device names.
The dd command for the copy operation specifies direct I/O for both the input and output device and the block size of 1024 KB. After the copy operation is completed, both devices are set offline. The access mode for the original device is then set back to the default and the device is set back online.
# cat /sys/bus/ccw/devices/0.0.7009/online
1
# chccwdev -d 0.0.7009
# cat /sys/bus/ccw/devices/0.0.7009/use_diag
0
# cat /sys/bus/ccw/devices/0.0.70a1/online
0
# cat /sys/bus/ccw/devices/0.0.70a1/use_diag
0
# echo 1 > /sys/bus/ccw/devices/0.0.7009/raw_track_access
# echo 1 > /sys/bus/ccw/devices/0.0.70a1/raw_track_access
# chccwdev -e 0.0.7009,0.0.70a1
# lsdasd 0.0.7009 0.0.70a1
Bus-ID Status Name Device Type BlkSz Size Blocks
==============================================================================
0.0.7009 active dasdf 94:20 ECKD 4096 7043MB 1803060
0.0.70a1 active dasdj 94:36 ECKD 4096 7043MB 1803060
# echo 1024 > /sys/block/dasdf/queue/max_sectors_kb
# echo 1024 > /sys/block/dasdj/queue/max_sectors_kb
# dd if=/dev/dasdf of=/dev/dasdj bs=1024k iflag=direct oflag=direct
# chccwdev -d 0.0.7009,0.0.70a1
# echo 0 > /sys/bus/ccw/devices/0.0.7009/raw_track_access
# chccwdev -e 0.0.7009