cht電腦資訊Linux
adm Find login register

NILFS: 讓 SSDs 尖叫的檔案系統

coolcd
joined: 2008-01-21
posted: 2596
promoted: 348
bookmarked: 95
1subject: NILFS: 讓 SSDs 尖叫的檔案系統Promote 2 Bookmark 02009-06-04quote  

這是在 Linux Magazine 看到的一篇文章的標題,還真聳動啊~

原文網址在此 

http://www.linux-mag.com/cache/7345/1.html

NILFS2 (New Implementation of a Log-Structured File System Version 2) 是一種很有前途的 log-structured file system,它可以對整個檔案系統做連續性的 snapshots (在 NILFS 中稱為 checkpoints) 並進行版本管理, 這意思是說,你可以回復刪掉的檔案,可以救回不小心修改到的檔案,但不必像傳統做 snapshots 那樣,付出效能的代價。除此之外,有證據顯示,NILFS 在 SSD 上效能極佳!

log-structured filesystem 跟樹狀檔案系統不同的是:它不會把資料或資料與 journal 寫到 b-tree 或 h-tree, 它會把所有資料與 metadata 依序寫入一個 continuous stream,這個 stream 就稱為 log (actually it is a circular log)。因為是依序寫入的,所以 seek time 會很短,改善了寫入速度。

這種結構使得 log-structured filesystem 很容易做它的資料與matadata 的 snapshots,crash recovering 也比一般樹狀檔案系統要快,而且回復的速度與檔案系統大小無關(如果做過 fsck 就知道,愈大的檔案系統,在回復時也愈久)。

但這種結構也不是沒有壞處,它麻煩的地方在於,它必需有很強的 garbage collection 的能力。如果佔用的空間因刪除某些檔案而釋出,它就必需在 log 的尾巴重新 reclaim free space,否則,檔案系統很快就會滿了。

目前,the Nippon Telephone 與 Telegraph (NTT) CyberSpace Laboratories 已為 Linux 開發了 NILFS (因為是檔案系統的第二版,所以有時會稱為 NILFS2),已在 kernel 的 2.6.30 版納入。

NILFS 其中一個大賣點就是它可以自動、連續地儲存目前檔案系統的狀態,而不會打斷 service,而且不同的 checkpoints 可以跟主要的檔案系統一起 mount 起來,以下是一些其他的好處:

  • The file size and inode numbers are stored as 64-bit fields
  • File sizes of up to 8 EiB (Exbibyte - approximately an Exabyte)
  • Block sizes that are smaller than a page size (i.e. 1KB-2KB). This can potentially make NILFS much faster for small files than other file systems.
  • File and inode blocks use a B-tree (the use of B-trees in a log-structured file system stems from the implementation which use something called segments)
  • NILFS uses 32-bit checksums (CRC32) on data and metadata for integrity assurance
  • Correctly ordered data and meta-data writes
  • Redundant superblock
  • Read-ahead for meta data files as well as data files (helps read performance)
  • Continuous check pointing which can be used for snapshots. These can be used for backups or they can even be used for recovering files.

2008 年 Samsung 的 Dongjun Shin 做了一個 presentation,他測了 NILFS, Btrfs, Ext2, Ext3, Ext4, ReiserFS, 與 XFS 在 SSD 上的效能,結果顯示,NILFS 的效能超越了其他檔案系統。對小檔而言,NILFS 比最接近的 btrfs 快了約 25-38%;對大檔而言,NILFS 比最接近的 reiserfs 與/或 ext4 快了約 15-25%。

但,天下沒有白吃的牛餐,在 NIFLS 的 mailing list 中有人回報,把它用於 root file system 時,產生了大量的 traffic,再加上 NILFS 可能會有較多寫入動作,這可能會縮短 SSD 的使用壽命!NILFS 的開發者很清楚這個問題,他們正在研究更好的 garbage collection 的演算法。

另外,Linux kernel 的 mailing list 上有人對 使用時間對效能是否有影響 感到好奇,開發者說他沒有這種感覺,但目前並沒有資料佐正,所以一切都還需要再測試。

 

edited: 2
eliu

joined: 2007-08-09
posted: 11468
promoted: 617
bookmarked: 187
新竹, 台灣
2subject: Promote 0 Bookmark 02009-09-01quote  

NILFS & BTRFS 標榜有 

  • flash 支援:避免寫在同一個地方太多次-> 這個 flash controller 本來就會做的事,通常稱為 wear leveling。好像不需要在file system 做?
  • ECC:硬碟好像應該都有 ECC,會自動替換 bad block。所以 file system 來做這個好像也是多餘?

上一次看 benchmark NILFS performance 看起來不怎麼好。特別是multitask, multithread 的情形。

edited: 2
eliu

joined: 2007-08-09
posted: 11468
promoted: 617
bookmarked: 187
新竹, 台灣
3subject: TRIMPromote 0 Bookmark 02010-08-02quote  

目前 SSD 主要是用 wear leveling 的方式,就是讓寫入的次數平均分配到 flash block 上,避免某些 flash block 寫入次數過高,造成損壞。

為了平均寫入,某些 block 必須copy 到其他地方。其實檔案刪除後,某些 block 是不需要 copy 的,可以直接寫入。

為了讓 flash controller 可以知道哪些 block 是沒有資料的,有些 SSD 開始支援 ATA TRIM 的 command,檔案系統 filesystem 可以通知 SSD 硬碟哪些 block 現在沒有放資料了。

ATA TRIM 的支援在 EXT4 也有了。

edited: 1
eliu

joined: 2007-08-09
posted: 11468
promoted: 617
bookmarked: 187
新竹, 台灣
4subject: Promote 0 Bookmark 02013-07-31quote  

聽說 Android 4.3 才開始支援 TRIM,遜斃了。

cht電腦資訊Linux
adm Find login register
views:15892