THIS ARTICLE IS COPYRIGHTED: HTTP://WWW.CONCEPTSOLUTIONSBC.COM. IF YOU CAN READ THIS TEXT, THE POSTER STOLE MY PROPERTY
Simplified z/OS DASD
First of all, mainframe disks are called Direct Access Storage Devices (DASD). Each DASD has what is called a 'Volume Table of Content' or more often called a VTOC. The VTOC contains information about the volume. It also contains information about a file within the volume.
To help you understand how mainframe DASDs look like, please check the diagram that shows a simplified view of a mainframe DASD.
As an example, a model 3390 DASD has 15 tracks per cylinder. If a step allocates a file as 15 tracks and the step only uses 1 track, the rest of the unused 14 tracks are released at the end of the step. However, if a step allocates 1 cylinder, which is also 15 tracks, and uses only 1 track, the rest of the 14 tracks are not released because the file allocation is in cylinder.
DASD files are allocated based on the SPACE parameter in the JCL. The SPACE parameter specifies the type of allocation (TRK or CYL) and the primary and secondary allocation. z/OS allocates space using the primary allocation once and will allocate space based on the secondary allocation 15 times. So if the SPACE parameter is specified as (TRK,(5,1)),RLSE), z/OS will allocate five tracks first.
As the program writes out to the file, if the 5 tracks are not sufficient, it will allocate an additional one track. When that 1 track is also not sufficient, MVS will continue to allocate 1 track 14 more times if needed. A file is allowed only 16 allocations. If space is still needed after the 16th extent, the step will terminate with an Abnormal End (ABEND) due to insufficient space. (For discussions on JCL and ABENDs, please read my previous article on Job Control Language (JCL).
Data Set Names (DSN)
Mainframe files are called data sets. Names of these data sets are called data set names (DSN). Mainframe dataset names have naming conventions. They can have a maximum of 44 characters. Each DSN can be made up of qualifiers. A qualifier is a set of alphabet and numbers separated by a dot. A qualifier can have a maximum of 8 characters and the first character always has to be an alphabetic character. All mainframe files are in upper case.
This is a valid DSN: SAMPLE.X001.V001. This has three qualifiers (SAMPLE, X001 and V001). Each of these has less than or equal to 8 characters and each start with an alphabetic character.
This is an invalid DSN: SAMPLE.001.V001. This has three qualifiers (SAMPLE, 001 and V001). Each has less than 8 characters. But the second qualifier begins with a number making it invalid.
This is invalid also: SAMPLE001.X001.V001. It has three qualifiers (SAMPLE001, X001 and V001). The first qualifier has more than 8 characters, making it invalid.
File Length (LRECL)
Variable Block and Fixed Block
The access method is responsible for splitting the block into logical records and passing the record to the program. Although a program can handle breaking the blocks into logical records, this task is normally done by the access method. A record length can be fixed or variable.
As the picture shows, in a fixed block file, all logical records have the same length. This means all physical blocks have the same length also. A dataset with a physical record length of 80 can have a block size that is divisible by 80.
For variable block records, the logical length is variable. However, unlike Windows or *NIX records which are terminated with CR/LF characters, z/OS has a way of managing variable length records.
As the picture shows, each variable block has a block length indicator. This is four overhead bytes. The first two bytes contain the length of the entire block. In the picture, the two overhead bytes for the block have the value of: x'0AFE' which when converted is 2814. This means the block has 2814 bytes.
After this is the record length indicator which is another four overhead bytes. The first two bytes of this indicator contains the length of the record. In the picture, the value is x'002B' which has a decimal value of 43. This means that the record has 43 bytes.
The access method uses these overhead bytes to break down the records to be passed to a program.
Partitioned Data Sets (PDS)
z/OS has a file type called partitioned data set (PDS). These data sets are unique because they are made up of two parts, a directory and data space. You can think of this as a file that can hold several sub-files. These sub-files are called members.
The directory contains the name of the members within the PDS. It also contains a pointer that indicates where the subfile resides in the PDS. One thing to note about the PDS is that if a member is deleted, it is only logically deleted. The member entry in the directory is only deleted but the contents are still in the PDS. There will come a time when the PDS will become full. When this happens, the PDS needs to be compressed.
There is a variation of this file called Extended Partitioned Data Set (PDSE). One of the features of the PDSE is that it removes the need for the data set to be compressed. To allocate a PDSE, you need to specify DSNTYPE=LIBRARY in the JCL when you preallocate the data set.
Mainframe DASD file system is different from Windows and *NIX file systems. It has been around for decades and as long as mainframes will be around, they will continue to exist. One of the mistakes of those coming from the PC and *NIX world is to think that mainframe files work the same way. It is more complicated than files they are used to. Hopefully, this short background will help in providing a better understanding of how the mainframe manages files.