BSD 3-Clause "New" or "Revised" License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

LinearTapeFileSystem/ltfs 技术分析

项目背景与痛点

磁带储存系统凭借其高存储密度和长久保存能力,一直是数据备份和归档的首选。然而,在处理海量数据时,传统的磁带存储方式面临性能和管理上的瓶颈。为解决这些问题,LinearTapeFileSystem (LTFS) 作为线性磁带文件系统的标准化格式,提供了一个开放且易于使用的存储接口。LinearTapeFileSystem/ltfs 项目正是这一开放格式的参考实现,它实现了 LTFS 格式的标准化,使得独立的磁带驱动器能够像硬盘一样高效操作。

核心技术揭秘

ltfs 项目的实现结合了文件系统、磁带驱动控制和数据流管理的复杂挑战。整体架构围绕核心文件系统接口设计,背后使用了多种技术来优化性能与可靠性。

graph TD A[用户请求] --> B[文件系统 API] B --> C[LTFS 文件系统] C --> D{"数据类型识别"} D -->|"文件"| E[磁带文件操作] D -->|"元数据"| F[元数据操作] E --> G[写入磁带] F --> H[元数据更新] G --> I[磁带驱动器控制] H --> I[磁带驱动器控制]

从上图可以看到,项目的实现策略在于将文件系统操作直接封装为对磁带设备的访问。核心文件系统 API 接收用户的请求,根据所需操作类型(文件或元数据),分别调用具体的处理逻辑。这样的分层设计不仅保证了代码的可维护性,也使得系统能够灵活应对多种磁带格式和操作需求。

功能亮点与差异

ltfs 突出的亮点在于其对 Linux 平台的原生支持和 API 的通用性。作为LTFS格式的参考实现,它遵循了标准化协议,确保跨平台的兼容性,这使得用户能够在不同环境下无缝进行数据迁移和处理。此外,项目提供了一套详尽的命令行工具,大大简化了系统的使用难度,这也是其从竞品中脱颖而出的关键因素。

应用场景与落地建议

在生产环境下部署ltfs时,应着重考虑数据一致性和备份频率。由于磁带媒体的物理特性和容量,系统需要定期执行完整的备份操作,以维护数据的完整性和可用性。与此同时,为了保证数据的稳定性和访问性能,合理规划磁带驱动的使用策略,减少频繁的磁带加载和卸载操作。这对于保证系统的高可靠性和响应速度至关重要。

综合评价

整体而言,ltfs 是一个具备高度实用性且设计严谨的项目。它遵循了 LTFS 标准,为磁带驱动器提供了易于集成的文件系统接口。不过,项目文档的不足之处在于对特定场景和性能优化技巧的说明有限,这需要用户自行勘探。若希望在高负载环境中使用,建议用户深入了解文件系统实现细节,并针对具体需求进行适当的扩展和优化。

综上,LinearTapeFileSystem/ltfs 凭借其符合标准的实现和丰富的功能,为高性能磁带存储领域的用户提供了强大的工具。通过细致的管理和策略部署,它能够显著提升大规模数据存储的效率与可靠性。

关于

GitHub 原始描述(英文)

Reference implementation of the LTFS format Spec for stand alone tape drive

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
612
价值分
250
活跃状态
活跃

语言占比

C
C++
Dockerfile
M4
Makefile
Perl
Python
Shell

README

GH Action status BSD License

Linear Tape File System (LTFS)

Linear Tape File System (LTFS) is a filesystem to mount a LTFS formatted tape in a tape drive. Once LTFS mounts a LTFS formatted tape as filesystem, user can access to the tape via filesystem API.

Objective of this project is being the reference implementation of the LTFS format Specifications in SNIA.

At this time, the target of this project to meet is the LTFS format specifications 2.4. (https://www.snia.org/sites/default/files/technical_work/LTFS/LTFS_Format_2.4.0_TechPosition.pdf).

LTFS Format Specifications

LTFS Format Specification is specified data placement, shape of index and names of extended attributes for LTFS. This specification is defined in SNIA first and then it is forwarded to ISO as ISO/IEC 20919 from version 2.2.

The table below show status of the LTFS format Specification

Version Status of SNIA Status of ISO
2.2 Published Published as 20919:2016
2.3.1 Published -
2.4 Published -

How to use the LTFS (Quick start)

This section is for person who already have a machine the LTFS is installed.

Instruction how to use the LTFS is on Wiki. Please take a look!

Getting Started from GitHub project

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Linux

    • automake 1.13.4 or later
    • autoconf 2.69 or later
    • libtool 2.4.2 or later
    • fuse 2.6.0 or later
    • uuid 1.36 or later (Linux)
    • libxml-2.0 2.6.16 or later
    • net-snmp 5.3 or later
    • icu4c 4.8 or later
  • OSX (macOS)

    Following packages on homebrew

    • automake
    • autoconf
    • libtool
    • osxfuse (brew cask install osxfuse)
    • ossp-uuid
    • libxml2
    • icu4c
    • gnu-sed
  • FreeBSD:

    • FreeBSD 10.2 or 11.0 or later (for sa(4) driver changes)
    • automake
    • autoconf
    • libtool
    • fusefs-libs
    • net-snmp
    • e2fsprogs-libuuid
    • libxml2
    • icu
  • NetBSD:

    • NetBSD 7.0 or higher (for FUSE support)
    • automake
    • autoconf
    • libtool
    • libfuse
    • net-snmp
    • libuuid
    • libxml2
    • icu

Supported Tape Drives

Vendor Drive Type Minimum F/W Level
IBM LTO5 B170
IBM LTO6 None
IBM LTO7 None
IBM LTO8 HB81
IBM LTO9 None
IBM TS1140 3694
IBM TS1150 None
IBM TS1155 None
IBM TS1160 None
HP LTO5 T.B.D.
HP LTO6 T.B.D.
HP LTO7 T.B.D.
HP LTO8 T.B.D.
HP LTO9 T.B.D.
Quantum LTO5 (Only Half Height) T.B.D.
Quantum LTO6 (Only Half Height) T.B.D.
Quantum LTO7 (Only Half Height) T.B.D.
Quantum LTO8 (Only Half Height) T.B.D.
Quantum LTO9 (Only Half Height) T.B.D.

Installing

LTFS Format Specification is specified data placement, shape of index and names of extended attributes for LTFS. This specification is defined in SNIA first and then it is forwarded to ISO as ISO/IEC 20919 from version 2.2.

The table below show status of the LTFS format Specification

Version Status of SNIA Status of ISO
2.2 Published Published as 20919:2016
2.3.1 Published -
2.4 Published -
2.5.1 Published Published as 20919:2021

How to use the LTFS (Quick start)

This section is for a person who already has a machine with the LTFS installed. Instructions on how to use the LTFS is also available on Wiki.

Step1: List tape drives

# ltfs -o device_list

The output is as follows. You have 3 drives in this example and you can use “Device Name” field, like /dev/sg43 in this case, as the argument of ltfs command to mount the tape drive.

50c4 LTFS14000I LTFS starting, LTFS version 2.4.0.0 (10022), log level 2.
50c4 LTFS14058I LTFS Format Specification version 2.4.0.
50c4 LTFS14104I Launched by "/home/piste/ltfsoss/bin/ltfs -o device_list".
50c4 LTFS14105I This binary is built for Linux (x86_64).
50c4 LTFS14106I GCC version is 4.8.5 20150623 (Red Hat 4.8.5-11).
50c4 LTFS17087I Kernel version: Linux version 3.10.0-514.10.2.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Mon Feb 20 02:37:52 EST 2017 i386.
50c4 LTFS17089I Distribution: NAME="Red Hat Enterprise Linux Server".
50c4 LTFS17089I Distribution: Red Hat Enterprise Linux Server release 7.3 (Maipo).
50c4 LTFS17089I Distribution: Red Hat Enterprise Linux Server release 7.3 (Maipo).
50c4 LTFS17085I Plugin: Loading "sg" tape backend.
Tape Device list:.
Device Name = /dev/sg43, Vender ID = IBM    , Product ID = ULTRIUM-TD5    , Serial Number = 9A700L0077, Product Name = [ULTRIUM-TD5] .
Device Name = /dev/sg38, Vender ID = IBM    , Product ID = ULT3580-TD6    , Serial Number = 00013B0119, Product Name = [ULT3580-TD6] .
Device Name = /dev/sg37, Vender ID = IBM    , Product ID = ULT3580-TD7    , Serial Number = 00078D00C2, Product Name = [ULT3580-TD7] .

Step2: Format a tape

As described in the LTFS format specifications, LTFS uses the partition feature of the tape drive. This means you can’t use a tape just after you purchase a tape. You need format the tape before using it on LTFS.

To format a tape, you can use mkltfs command like

# mkltfs -d 9A700L0077

In this case, mkltfs tries to format a tape in the tape drive 9A700L0077. You can use the device name /dev/sg43 instead.

Step3: Mount a tape through a tape drive

After you prepared a formatted tape, you can mount it through a tape drive like

# ltfs -o devname=9A700L0077 /ltfs

In this command, the ltfs command will try to mount the tape in the tape drive 9A700L0077 to /ltfs directory. Of course, you can use a device name /dev/sg43 instead.

If the mount process is successfully done, you can access to the LTFS tape through /ltfs directory.

You must not touch any st devices while ltfs is mounting a tape.

Step4: Unmount the tape drive

You can use following command when you want to unmount the tape. The ltfs command try to write the current meta-data to the tape and close the tape cleanly.

# umount /ltfs

One thing you need to pay attention to here is, that the unmount command continues to work in the background after it returns. It just initiates a trigger to notify the the ltfs command of the unmount request. Actual unmount is completed when the ltfs command is finished.

The ltfs_ordered_copy utility

The ltfs_ordered_copy is a program to copy files from source to destination with LTFS order optimization.

It is written in python and it can work with both python2 and python3 (Python 2.7 or later is strongly recommended). You need to install the pyxattr module for both python2 and python3.

Building the LTFS from this GitHub project

These instructions will get a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites for build

Please refer this page.

Build and install on Linux

./autogen.sh
./configure
make
make install

./configure --help shows various options for build and install.

In some systems, you might need sudo ldconfig -v after make install to load the shared libraries correctly.

Parameter settings of the sg driver

LTFS uses the sg driver by default. You can improve reliability to change parameters of the sg driver below.

def_reserved_size=1048576

In RHEL7, you can put following file as /etc/modprobe.d/sg.conf.

options sg def_reserved_size=1048576

You can check current configuration of sg driver to see the file /proc/scsi/sg/debug like

$ cat /proc/scsi/sg/debug
max_active_device=44  def_reserved_size=32768
 >>> device=sg25 1:0:10:0   em=0 sg_tablesize=1024 excl=0 open_cnt=1
   FD(1): timeout=60000ms bufflen=524288 (res)sgat=16 low_dma=0
   cmd_q=1 f_packid=0 k_orphan=0 closed=0
     No requests active
 >>> device=sg26 1:0:10:1   em=0 sg_tablesize=1024 excl=0 open_cnt=1
   FD(1): timeout=60000ms bufflen=524288 (res)sgat=16 low_dma=0
   cmd_q=1 f_packid=0 k_orphan=0 closed=0
     No requests active
Performance improvement of the sg device

You can improve performance to change parameters of the sg driver below. But this option may cause I/O error reported as #144 in some HBAs.

allow_dio=1

In RHEL7, you can put following file as /etc/modprobe.d/sg.conf.

options sg allow_dio=1

At this time, we know following HBA’s works correctly.

  • QLogic 8Gb FC HBAs

And following HBA’s doesn’t work correctly.

  • ATTO ExpressSAS H680
  • Emulex FC HBAs (Some drivers work but some drivers dont work, see this section)
Note for the lpfc driver (Emulex Fibre HBAs)

In the lpfc driver (for Emulex Fibre HBAs), the table size of the scatter-gather is 64 by default. This configuration may cause I/O errors intermittently when allow_dio=1 is set and scatter-gather table cannot be reserved. To avoid this error, you need to change the parameter lpfc_sg_seg_cnt to 256 or greater like below.

options lpfc lpfc_sg_seg_cnt=256

In some versions of the lpfc driver (for Emulex Fibre HBAs), the table size of the scatter-gather cannot be changed correctly. You can check the value is changed or not in sg_tablesize value in /proc/scsi/sg/debug. If you don’t have a correct value (256 or greater) in sg_tablesize, removing allow_dio=1 configuration of the sg driver is strongly recommended.

Note for buggy HBAs

LTFS doesn’t support the HBAs which doesn’t handle the transfer length of SCSI data by default. The reason is because the safety of the data but LTFS provides a option to relax this limitation.

You can use such kind of HBAs if you run the configure script with --enable-buggy-ifs option and build.

List of the HBA --enable-buggy-ifs is needed is below.

HBA list require --enable-buggy-ifs

IBM lin_tape driver support

You need to add --enable-lintape as an argument of ./configure script if you want to build the backend for lin_tape. You also need to add DEFAULT_TAPE=lin_tape if you set the lin_tape backend as default backend.

Buildable distributions
Dist Arch Status
RHEL 8 x86_64 OK - Not checked automatically
RHEL 8 ppc64le OK - Not checked automatically
CentOS 8 (Rocky Linux) x86_64 GH Action status
CentOS 8 (Rocky Linux) ppc64le OK - Not checked automatically
Fedora 28 x86_64 GH Action status
Ubuntu 16.04 LTS x86_64 GH Action status
Ubuntu 16.04 LTS ppc64le OK - Not checked automatically
Ubuntu 18.04 LTS x86_64 GH Action status
Ubuntu 18.04 LTS ppc64le OK - Not checked automatically
Ubuntu 20.04 LTS (Need icu-config) x86_64 GH Action status
Debian 9 x86_64 GH Action status
Debian 10 (Need icu-config) x86_64 GH Action status
ArchLinux 2018.08.01 x86_64 OK - Not checked automatically
ArchLinux 2018.12.31 (rolling) x86_64 OK - Not checked automatically

Currently, automatic build checking is working on GitHub Actions and Travis CI.

For Ubuntu20.04 and Debian10, dummy icu-config is needed in the build machine. See Issue #153.

Build and install on OSX (macOS)

Recent Homedrew system setup

Before build on macOS, you need to configure the environment like below.

export ICU_PATH="/usr/local/opt/icu4c/bin"
export LIBXML2_PATH="/usr/local/opt/libxml2/bin"
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig"
export PATH="$PATH:$ICU_PATH:$LIBXML2_PATH"
Old Homedrew system setup

Before build on OSX (macOS), some include path adjustment is required.

brew link --force icu4c
brew link --force libxml2
Building LTFS

On OSX (macOS), snmp cannot be supported, you need to disable it on configure script. And may be, you need to specify LDFLAGS while running configure script to link some required frameworks, CoreFundation and IOKit.

./autogen.sh
LDFLAGS="-framework CoreFoundation -framework IOKit" ./configure --disable-snmp
make
make install

./configure --help shows various options for build and install.

Buildable systems
OS Xcode Package system Status
macOS 10.14.6 11.3 Homebrew Probably OK

Build and install on FreeBSD

Note that on FreeBSD, the usual 3rd party man directory is /usr/local/man. Configure defaults to using /usr/local/share/man. So, override it on the command line to avoid having man pages put in the wrong place.

./autogen.sh
./configure --prefix=/usr/local --mandir=/usr/local/man
make
make install
Buildable versions
Version Arch Status
11 x86_64 OK

Build and install on NetBSD

./autogen.sh
./configure
make
make install
Buildable versions
Version Arch Status
8.1 amd64 OK
8.0 i386 OK
7.2 amd64 OK

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

License

This project is licensed under the BSD License - see the LICENSE file for details

评论

暂无评论