iustin / mt-st

Magnetic tape control tools for Linux SCSI tapes
Other
41 stars 12 forks source link

Backport Linux Kernel WEOFI ioctls #30

Closed dabiged closed 1 year ago

dabiged commented 1 year ago

Fixes #29 .

iustin commented 1 year ago

So this patch as it is is good, but it's not clear to me whether mt/stinit can already program the tape using these features (I suspect not).

I'm referring to @kmakisara comment here: https://yhbt.net/lore/all/4F4DCE31.1000001@kolumbus.fi/ - I think the following might be needed:

For example, I'm looking at this:

https://github.com/iustin/mt-st/blob/eadc992f2a8c55c55326dd0f64cc791b90e9d506/mt.c#L238-L259

And I think the new mode needs to be added.

So this is possibly only half the fix? Just trying to understand the scope of the work.

dabiged commented 1 year ago

I have used the WEOFI ioctl in a python program to write around 900k small files to a 3592-E07 tape. The estimated time to completion without the EOFI was around 4 weeks. With WEOFI it was around 20 hours. The feature worked out of the box with the generic kernel using the standard stinit code.

This PR was to sync the contents of the mtio.h file between the ~2012 kernel and mt.

Adding a weofi option to mt might be a good idea as mt is the defacto tape control standard in linux and this immediate eof feature is practically unknown even amongst tape gurus I know.

iustin commented 1 year ago

I see, thanks. Just for my understanding - for the Python code, you had to issue the EOFI yourself, right? The idea for adding support in stinit would be to allow defining a node that does that automatically.

Thanks, I'll file a separate issue for implementing these extra features, and will merge this.

dabiged commented 1 year ago

@iustin Sorry for the late reply.

The python code looked like this (it is proprietary so I am just writing pseudocode): ` with open('/dev/nst1','wb') as tape:

for filetowrite in filelist:

    with open(filetowrite, 'rb') as inputfile:

        done=False

        while not done:

            a = inputfile.read(blocksize)

            if len(a) > 0:

                tape.write(a)

            else:

                 done=True

        write_eof()  

`

If the last line is a normal EOF write it needs to flush all buffers to the tape. This method takes around 2-3 seconds per file. If the last line is a EOFI, it just places a write_EOF command in the queue to be written. This method tapes around 0.2 seconds per file.

I had to write ~ 700,000 1 MB files per tape. This change reduced our runtime from 3.5 weeks per tape, to about 2 days. The issue was it is basically isn't documented anywhere and I heard about it from a greybeard I used to work with.