磁帶新觀念

petertc
9 min readJul 6, 2018

--

Modern magnetic tape semantics

https://www.youtube.com/watch?v=6mw1Gpe6dWw

止痛有新觀念,磁帶也有。剛開始研究磁帶技術的時候是從一些經典的磁帶管理經驗談開始,例如 John R Jackson的 summary of the behavior of tapes on UNIX systems,及Dr. John W.C. Van Bogart寫的Magnetic Tape Storage and Handling。這些經驗大部份是基於1980年代的磁帶技術, e.g., DLT(Digital Linear Tape), DDS (Digital Data Storage)。四十年後的現在,這些經驗很多依然適用,但對現代磁帶(例如LTO-8 Ultrium規格)來說,something different。用這篇文章整理一下我在學習歷程中改變的觀念。

現代磁帶機可避免擦鞋(Shoe Shining) 效應

擦鞋效應是指讀寫磁帶時會發生的一種現象,這種現象造成磁帶效能低落及減損壽命。Wikipedia對shoe shining有以下敘述:

shoe-shining occurs during read/write if the data transfer rate falls below the minimum threshold at which the tape drive heads were designed to transfer data to or from a continuously running tape.

而現在的tape drive通常會利用buffer機制可變速率寫入避免此問題,例如廠商的手冊可能會有類似下列的敘述:

The drive will match the throughput of any host up to the maximum supported transfer rate using the Data Rate Matching (DRM) functionality. There is no performance penalty for hosts that are slower than the maximum supported transfer rate. This capability is accomplished using buffer management for transfer rates of 0 MB/s up to the minimum tape streaming transfer rate, and the Adaptive Tape Speed (ATS) technology from the minimum to maximum tape streaming transfer rate.

LTFS

磁帶循序讀寫的特性,侷限其適用的workload。面對儲存市場的競爭,磁帶廠商推出了LTFS,試圖擴展磁帶的應用範疇。LTFS是讓磁帶自帶index,使磁帶能模擬成一個file system mount point,像是能random access一樣來操作。可以看這個demo影片:

HPE Store open demo

進一步介紹可以參考wikipedia及各種廠商業配。

LTFS畢竟還是受限其底層磁帶特性,這邊整理一下我看到的使用限制:

  • append only,刪除的空間無法釋出。
  • 若要確保durability,會有寫index造成的seek time overhead,因為他必須分別在index partition和data partition寫入新的index。
  • 若是用接tape library,支援度較差。IBM看起來支援度較佳,HP則在今年放棄support了。這也可以看出LTFS已經不是各家磁帶廠商的兵家必爭之地。目前感覺IBM推的比較積極,除了基本的LTFS實做,還有嘗試基於此技術的HSMopenstack swift整合。
  • 通用性與開源社群支援疑慮。雖然LTFS是開放標準,但各家廠商放出來的LTFS軟體都只說建議用在自家的磁帶機,而且也沒有足夠開源社群支持。要用的話,現階段看起來只有撒幣綁定IBM的solution好像比較可靠。

LTO磁帶沒有setmark

斯斯有兩種磁帶的separator mark也有兩種。查到古早的standard (ECMA-139 / ECMA-150 / ECMA-170 for DDS-1, ECMA-198 for
DDS-2, ECMA-236 for DDS-3, and ECMA-288 for DDS-4) 說:

“In this ECMA Standard, there are two types of Separator Marks
which are referred to as Separator 1 and Separator 2.
Some other standards, e.g. those which define an interface
between a tape drive and a host computer, use the terms “file mark”
and “set mark” to denote Separator Marks.
It is recommended that Separator 1 be equated to file mark
and Separator 2 be equated to set mark.

而filemark又可分為short, normal, long三種…總之LTO只支援 “正常” 的filemark就對了!

LTO磁帶不用retension

直接引言說明:

Retensioning is not needed on single hub media, such as DLT and LTO. Dual hub media requires retensioning after it has been dropped as the tape path because it can be skewed between the two hubs. Since DLT and LTO media have a single hub, the tape is wound through a path within the drive onto an internal hub. This eliminates the problem with skewing.

懶的看文字的話,看圖更清楚。這種的要retension:

https://goo.gl/images/tSGJsM

這種的不用:

https://goo.gl/images/3iHqDb

LTO磁帶有Media Auxiliary Memory

傳統上磁帶的一些metadata是記載在磁帶一開頭的地方或是非儲存資料的軌道邊緣區域,因此要取得這些資訊,就要把磁帶載入磁帶機就緒後,才可以讀出。Media Auxiliary Memory / cartridge memory是在磁帶卡夾另外加上一塊小小16KB 記憶體。

https://goo.gl/images/UScKnT

這塊記憶體可以紀錄前面提到的metadata,因為讀寫這塊資訊不用載入磁帶或是轉動磁帶,使得一些磁帶控制操作, e.g., load/unload, locate等效率提昇。對user來說,也有機會利用這個空間寫入一些user defined metadata。

高階成熟的商用備份軟體

所以現在一般sysadmin根本不用管以上的技術細節,直接掏錢買整套solution就對了!

知道這些要幹嘛?

現在大家通常將磁帶應用於如備份等特定用途,因此廠商或系統管理員都直接套用備份軟體,比較少現代LTO磁帶的資訊及底層操作經驗可供參考。但若是要把磁帶用於其他的儲存應用,像是CERN把磁帶用在科研儲存或是前面提到的將磁帶用在openstack,就不能依賴現成的商業軟體,而需要深入瞭解這些細節了。

另外若想要對設備有更多掌控,跳過備份軟體,直接操作磁帶機,也需要對要操作的磁帶機規格有較多的瞭解。舉例來說,要在linux用mt指令,透過st driver控制磁帶機時,就需要有這些基礎知識,才能較完整的理解指令的用法。例如mt的man page會寫到:

wset

(SCSI tapes) Write count setmarks at current position (only SCSI tape).

他只寫only SCSI tape,那我現在的磁帶機到底適不適用呢?

seek

(SCSI tapes) Seek to the count block on the tape. This operation is available on some Tandberg and Wangtek streamers and some SCSI-2 tape drives. The block address should be obtained from a tell call earlier.

這個指令也需要知道自己的磁帶機屬於哪個類別,才能正確使用。

setpartition

(SCSI tapes) Switch to the partition determined by count. The default data partition of the tape is numbered zero. Switching partition is available only if enabled for the device, the device supports multiple partitions, and the tape is formatted with multiple partitions.

單看mt man page沒有列出支援哪些種類的磁帶,所以就要有先備知識,知道LTO是有partition支援的!

compression

(SCSI tapes) The compression within the drive can be switched on or off using the MTCOMPRESSION ioctl. Note that this method is not supported by all drives implementing compression. For instance, the Exabyte 8 mm drives use density codes to select compression.

之前也是搞不懂怎麼用壓縮功能,花了一些時間搞懂,還特別寫一篇文章紀錄這件事。

--

--