A computer program product for writing data in a tape recording device, the computer program product comprising a computer readable storage medium having program code embodied therewith, the program code readable/executable by a computer to perform a method comprising:
- upon receipt of an append write command, storing the data stored in a buffer in a non-volatile memory starting from an appended data end position;
- sending back a completion notification of the append write command to a higher-level device when data in the buffer is written in the non-volatile memory;
- moving the data temporarily stored in the non-volatile memory and then moving to a tape writing position where the data temporarily stored in the non-volatile memory is to be written to perform append writing on a basis of a predetermined criterion so as to minimize a moving distance by which a tape travels relative to a head, when moving from an end position on the tape of read data for a m-th read command to a reading start position for a subsequent n-th read command, wherein n=m+1;
- and
- when receiving an overwrite command of data in a predetermined position on the tape between mixed commands in a series of commands, updating an overwrite data end position as an appended data end position when the tape position for overwriting the data is encountered earlier than an appended data end position of the tape, and updating the overwrite data end position as an appended data end position in the non-volatile memory when the tape position for overwriting the data is encountered later than the appended data end position of the tape.