Skip to content

The file backend

Atsushi Abe edited this page Feb 27, 2021 · 2 revisions

Overview

The file backend is a tape emulator on disk for LTFS.

LTFS is roughly composed by 4 portions. FUSE-LTFS filesystem operation glue (ltfs_fuse), LTFS filesystem operation (ltfs_fsops), LTFS format spec handling (libltfs) and the tape backends.

Tape backend is responsible for communication between libltfs and (physical) tape drive. It is pluggable and it is loaded by libltfs at runtime. So you can specify tape backend by an option for each commands. Default backend is specified by [INSTALL_PREFIX]/etc/ltfs.conf and you can override it by [INSTALL_PREFIX]/etc/ltfs.conf.local.

The backends handles SCSI command in it normally. Currently, following backends are available for using physical tape drive. (All backends only supports IBM tape drives at this time)

  1. sg (linux)
  2. lin_tape (Linux)
  3. cam (FreeBSD)
  4. iokit (MacOS)

The file backend doesn't depend on OS. It regards files on a directory as a tape data stream. From LTFS point of view, the directory is corresponding to the device file of the physical drive and one file in the directory is corresponding to the record on the tape.

The main purpose of the file backend is debug without a physical tape and develop the logic for abnormal condition. You can create abnormal conditions to modify the contents of the directory by hand and debug that condition, such as EOD missing tape recovery by ltfsck.

Initialization

  1. Create empty directory as a virtual tape (ex: mkdir /tmp/foo)
  2. Format the virtual tape with the file backend (ex: mkltfs -e file -d /tmp/foo)

Some files are created into /tmp/foo after step2.

Mount

  1. Kick ltfs command with the file backend (ex: ltfs -o tape_backend=file -o devname=/tmp/foo /ltfs)

You can use /ltfs as same as "physical drive mounted" ltfs. The difference between physical drive is

  • Written data through the mount point (ex: /ltfs) is written to the directory under the virtual tape directory (ex: /tmp/foo). You need to take care about filesystem capacity of the virtual tape directory
  • By default, the tape capacity is 3GiB and the size of one record is constant, 512KiB, even if it is a filemark

Unmount

As same as normal usage.

Recovery

You can use ltfsck, of cause.

  1. Kick ltfsck command with the file backend (ex: ltfsck -e file -o /tmp/foo)

Tape configuration

You can see a file filedebug_tc_conf.xml in a virtual tape directory. This file describes the characteristics of the tape.

<?xml version="1.0" encoding="UTF-8"?>
<filedebug_cartridge_config>
    <dummy_io>false</dummy_io>
    <emulate_readonly>false</emulate_readonly>
    <capacity_mb>3072</capacity_mb>
    <cart_type>L5</cart_type>
    <density_code>58</density_code>
</filedebug_cartridge_config>
  • dummy_io: Use dummy io or not. No files will be written to the disk on "true". And also garbage will be returned against read operation. This is the function to measure the overhead of FUSE and libltfs
  • emulate_readonly: Emulate write protect notch on "true". LTFS will mount this virtual tape directory as read only volume
  • capacity_mb: Capacity in MiB. One record is constant length, 512KiB, even if it is a filemark or short record
  • cart_type: Cartridge type. Valid types are
    • "L5": LTO5
    • "L6": LTO6
    • "L7": LTO7
    • "L8": LTO8
    • "JB": JB for TS11x0
    • "JX": JX for TS11x0
    • "JC": JC for TS11x0
    • "JK": JK for TS11x0
    • "JY": JY for TS11x0
    • "JD": JD for TS11x0
    • "JL": JL for TS11x0
    • "JZ": JZ for TS11x0
  • density code: Density code of this tape. Defined densities are below (in tape_ops.h) but you can specify any density code.
    • LTO5: 0x58
    • LTO6: 0x5A
    • LTO7: 0x5C
    • LTOM8: 0x5D
    • LTO8: 0x5E
    • J4: 0x54
    • J4E: 0x74
    • J5: 0x55
    • J5E: 0x75
    • J5A: 0x56
    • J5AE: 0x76

File format definitions

There are 3 types in the files in a virtual tape directory.

  1. Record/FM/EOD
  2. Attribute
  3. Configuration file

Files format of Record/FM/EOD

File name is [part]-[pos]-[type]. And the contents are the actual record contents. For example the file 1-5-R has a contents of the record (partition=1, position=5, type=record).

Type shall be one of below.

  • R: Record
  • F: Filemark (size shall be 0)
  • E: EOD (end-of-partition, size shall be 0)

Attribute

Attribute which can be accessed by SCSI READ_ATTRIBUTE(0x8C)/WRITE_ATTRIBUTE(0x8D) commands. File name is attr_[part]_[page]. Page number is presented by hexadecimal without 0x.