ibm-s390-linux / s390-tools

Tools for use with the s390 Linux kernel and device drivers
MIT License
63 stars 61 forks source link

zdsfs fails when a volume contains `FDRABR.Vxxxxxx` dataset #161

Open VitekVlcek-Broadcom opened 11 months ago

VitekVlcek-Broadcom commented 11 months ago

zdsfs fails when mounting zos volume that contains FDRABR.Vxxxxxx dataset

I executed

chccwdev -a raw_track_access=1 -e 0.0.7000
zdsfs /dev/dasdj /mnt

it fails with

error when extracting data sets from dasd /dev/dasdj: Protocol error
rc 71: extract data sets: creating dataset failed for /dev/dasdj
rc 71: create data sets: data set sequence number out of bounds failed for FDRABR.VAARS02

When mounting a volume without FDRABR.Vxxxxxx dataset mount finishes successfully

I made a dump of VTOC entry for FDRABR.VAARS02

0000  C6C4D9C1 C2D94BE5 C3C1E2E2 F0F24040  40404040 40404040 40404040 40404040  *FDRABR.VAARS02..................*
0020  40404040 40404040 40404040 F11C0208  000172A1 0A72007E 63016D00 4A00C9C2  *............1......~...=.._.¢.IB*
0040  D4D6E2E5 E2F24040 40404000 00008000  00000000 00010050 32000072 8C808000  *MOSVS2.................&........*
0060  00000000 00E5A200 0F000000 00000000  00000000 00000000 00000000 00000000  *.....Vs.........................*
0080  00000000 00000000 00000000                                                *............                    *

My investigation: DSCB structure reveals 1) DS1FMTID (offset 0x2C) has a value 0xF1 ie DSCB Format-1 1) DS1VOLSQ (offset 0x33) contains 0xA10A=41226 ie outside of range 0..MAXVOLUMESPERDS (0..59)

Because the value in DS1VOLSQ is out of range, the code fails here https://github.com/ibm-s390-linux/s390-tools/blob/master/libzds/libzds.c#L1937. I could mount the volume when I set dspindex=0 instead of failing ie

    if (dspindex < 0 || dspindex >= MAXVOLUMESPERDS) {
        // free(dsp);
        // return errorlog_add_message(
        //  &dasd->log, NULL, EPROTO,
        printf(
            "create data sets: data set sequence number "
            "out of bounds failed for %s\n",
            ds->name);
        dspindex=0;
    }

I was puzzled by the fact that DS1DSSN (offset 0x2D) contains strange values further reading revealed that FDRABR.VAARS02 is likely an artifact of FDR/ABR (Automatic Backup and Restore)

I consider my proposal rather a hack than a solution. What do you think?

stefan-haberland commented 11 months ago

Hi,

thanks for analyzing this issue.

MAXVOLUMESPERDS defines the maximum numbers of volumes in a multi volume dataset. The number of 41226 looks way to high for a MV dataset.

I have to take a closer look at the documentation if there is a corner case defined how this value might be interpreted differently.