Docstoc

A Driver-Layer Caching Mechanism for Removable Storage Devices

Document Sample
A Driver-Layer Caching Mechanism for Removable Storage Devices Powered By Docstoc
					                                      1




A Driver-Layer Caching Mechanism
for Removable Storage Devices

 Yuan-Hao Chang, Ping-Yi Hsu, Yung-
      Feng Lu, and Tei-Wei Kuo
                                  2


Outline
• Introduction
• A Driver-Layer Caching Policy
• A Cohesive Caching Mechanism
• Performance Evaluation
• Conclusion
                                                                             3


Motivation
- Accessing of An Removable Storage Device-
Archive: Linux-2.6.17 source
Number of files                    19,535
                                                  FAT is the default file
Number of directories               1,200
Average file size                  11 KB
                                                  system for removable
Archive size                   215,666 KB            storage devices
Write the files to a removable storage device
File system                         NTFS          FAT
Number of write requests           24,513     179,670
Time taken (min:sec)                   4:33      54:21         FAT file
Read the files from a removable storage device
                                                               systems
File system                     NTFS            FAT           introduce
Number of read requests            14,568       23,528     excessive write
Time taken (min:sec)                   2:53       3:19     requests! why ?
                                                                            4


    Trace Analysis of Windows FAT (1/2)
      •Trace                                  •Layout of FAT filesystem
      Operation
                LBA Sectors                   LBA 0
       (R/W)
          W       477   1       FAT #1
          W      1466   1       FAT #2
          W    210576   4   Directory Entry
File #1   W    210664   9   Content of File
          W    210576   4
          W    210576   4
                            Directory Entry
          W    210576   4
          W    210576   4
          W       477   1       FAT #1
          W      1466   1       FAT #2
          W    210576   4                      FAT file system did it for
File #2   W
          W
               210576
               210576
                        4
                        4
                            Directory Entry
                                                 data consistency.
          W    210676   1   Content of File
          W    210576   4
                            Directory Entry
          W    210576   4
                                                                                          5


  Trace Analysis of Windows FAT (2/2)                                                >>
              100 blocks / row
LBA 83,600                                                           LBA 83,699
              500                       51

                                                                        Directory
             455                                                       Entry Blocks

                         435
                                    This cluster has
                                     been written
                                       500 times
                                                                        Written Counts
                                                             450         0
                                                                         1~64
                                                                         64~192
                                                                         192~255
                                 450 Time Taken: 54:14                   >255
LBA 91,500
                                      # of write requests: 179,670
                                                               1 block= 1sector = 512 bytes
                                                                                  6


Introduction
- The Characteristics of Flash Memories (1/2)
                                  Example:
• Write Once                      Page Level Mapping

• Bulk Erase                                  A                   A
                                                     Write B      B
• Out-Place Update
                           1 Block
                       (64~128 pages)
                                              1 Page (512B~4KB)
                                  Garbage                              Update A
               Copy valid pages   Collection
                to another free                                         Out-Place
                                                    After
       A             block              A’’                       A’     Update
                                                  sometime
                                        B’                        B
                                        A’                        A
                    Erase               A
                 and reclaim
                  the block
                                                                            7


Introduction
- The Characteristics of Flash Memories (2/2)
• Long Program / Erase time
• Limited Erase Cycles                                          SLC Cell
                                                               H
                   Single-Level Cell     Multi-Level Cell           1
Type
                     NAND Flash           NAND Flash
                                                                    0
Vendor                       Samsung Electronics               L
                                                                   1-bit
Product               K9NCG08U5M             K9GAG08U0M
Capacity                    64 G-bits              16 G-bits
Page Size            4 KB +128 Byte        4KB + 128 Bytes
                                                               MLCx2 Cell
Read Time              25 us (1 page)        60 us (1 page)
                                                               H
                                                                   11
Program Time         200 us (1 page)        800 us (1 page)        10
Block Erase Time   1.5 ms (64 pages)    1.5 ms (128 pages)         01
                                                                   00
Endurance             100,000 cycles          10,000 cycles    L
                                                                   2-bit
                                  8


Outline
• Introduction
• A Driver-Layer Caching Policy
• A Cohesive Caching Mechanism
• Performance Evaluation
• Conclusion
                                                                                9


 System Architecture                                             Card Readers
                                    Applications


                               Operating System API
                                File System Drivers
                                     Disk Drivers
                   Host



                                    Device Drivers
                                    Filter Drivers
                                     Bus Drivers
USB Flash Drives
                                                                 Flash Memory
                                           Host
                             Device                  Device
                   Device




                            Controller              Controller       Cards
                             Storage
                                           Device




                              Media                  Storage
                                                      Media

                              (a)                    (b)
                                                                                        10


Overview                                  USB Mass Storage
                                            Device Driver
                        When ?              I/O               I/O
                                          Request           Response

                        Notifications           Dispatch Unit
                             Read and Write       Other
                               IoPackets        IoPackets


                                                                       Trace   Debug
Filter                 File System       Cache
         Filesystem




                                                             Debug
          Identifier




Driver                    Layout                                               Viewer
                                                              Unit


                       Partition Table        FIFO Queue
                       & Boot Sectors
                                               Transport Unit
                                            I/O               I/O
                                          Request           Response


                                               USB Bus Driver
                                                                                                           11


  The “Allow/Prevent Medium Removal” Operation
  Code in the USB Bulk-Only Transport
                                                                            <CBW> Prevent Medium Removal
                                                                            <CSW> Success


FAT File System                            Disk                                 USB Bus
                       Disk Driver                       USB Mass Storage   …
                                                           Device Driver    …         An IoPacket
                                 …                  …
                                    1st FAT         W      477   1          <CBW> Write10 LBA=1446 LEN=1
     …
                                    2nd FAT         W     1466   1          <DATA>
     hrtimer.c                                      W   210576   4
                                Directory Entry                             <CSW> Success
     intermodule.c               File Content       W   210664   9
     itimer.c                                       W   210576   4          …
     kallsyms.c                                     W   210576   4
                                Directory Entry                             …
     …                                              W   210576   4                Send a notification
                                                    W   210576   4          …
                                 …                  …
                                                                            <CBW> Allow Medium Removal
                                                                            <CSW> Success
      USB Mass Storage Class, Bulk-Only Transport Protocol
      CBW: Command Block Wrapper
      CSW: Command Status Wrapper
                                                                                   12


  Trace Analysis – Caching                                                  << >>
             100 blocks / row   1 block= 1sector = 512 bytes
LBA 83,600                                                     LBA 83,699




                                                                  There are
                                                                  still lots of
                                                                    gaps !

                                                                  Written Counts
                                                                   0 (gaps)
                                                                   1~64
                                                                   64~192
                                                                   192~255
                                 Time Taken: 4:44
                                 # of write requests: 22,488       >255
LBA 91,500
                                                                   13


The Characteristics of NAND Flash
memories
• Block Level Mapping             Write to a replacement Block


       A                  A
       B     Update B     B’                B
       C                  C



     Or … a lazy way    Recycle   Copy all pages to another free block


       A                  A’                A
       B     Update B     B’                B
       C                  C’                C
                                  14


Outline
• Introduction
• A Driver-Layer Caching Policy
• A Cohesive Caching Mechanism
• Performance Evaluation
• Conclusion
                                                                  15


A Cohesive Caching Mechanism
• A driver-layer Caching Policy
  – Merge data buffers with access addresses that satisfy the
    following conditions:
    - Adjacent in non-cluster-area
    - Implicit adjacent (with gaps) in cluster area
  – Use an LRU-Interval tree as its indexing structure
    - To efficiently search the cache for adjacent data buffers
                                                         16


The Cohesive Cache Data Structure
- An LRU-Interval Tree
• It consists of a modified interval tree with an LRU list
  – To efficiently search cached data buffers
• Each node contains an interval as its key
  – It corresponds to the disk accessing addresses
• No overlapped intervals of nodes in the tree
  – It is for data consistency
• A nearly balanced tree
                                                            17


An LRU-Interval Tree
- The Structure of a Node
                        To the
                      parent node



                          Size
                       [Low, High]
  To the IoPacket
                                         To the next node
                                          in the LRU list


                To the left   To the right
                child node    child node
                                                         18


An LRU-Interval Tree
- An Example
                                         Insert A[0,4]
               Head   A     5     Tail
                          [0,4]




    Head   A   Tail
                                                                   19


An LRU-Interval Tree
- An Example

                                                  Insert A[0,4]
               Head   A     8                     Insert B[8,10]
                          [0,4]


                                    3
                             B             Tail
                                  [8,10]




    Head   A          B   Tail
                                                                             20


An LRU-Interval Tree
- An Example

                                                           Insert A[0,4]
                         B      12                         Insert B[8,10]
                              [8,10]
                                                           Insert C[12,15]

               Head
                        5                 4
                 A               C                  Tail
                      [0,4]            [12,15]




    Head   A            B              C     Tail
                                                                                 21


An LRU-Interval Tree
- An Example

                                                               Insert A[0,4]
                         B      24                             Insert B[8,10]
                              [8,10]
                                                               Insert C[12,15]
                                                               Insert D[20,31]
               Head
                        5                16
                A                D               Tail
                      [0,4]            [20,31]



                               4
                          C [12,15]



    Head   A            B              C          D     Tail
                                                                              22


An LRU-Interval Tree
- An Example

                                                            Insert A[0,4]
                         B      30
                                                            Insert B[8,10]
                              [8,10]
                                                            Insert C[12,15]
                                                            Insert D[20,31]
               Head
                                                            Insert E[32,37]
                        5                22
                A                D
                      [0,4]            [20,31]



                               4                6
                          C [12,15]        E [32,37] Tail



    Head   A            B              C          D         E    Tail
                                                                            23


An LRU-Interval Tree
- An Example

                                                          Insert A[0,4]
                         C   25
                                                          Insert B[8,10]
                           [12,15]
                                                          Insert C[12,15]
                                                          Insert D[20,31]
              Head
                                                          Insert E[32,37]
                       3               18
               B
                     [8,10]
                               D
                                     [20,31]
                                                          LRU
       5
 A
     [0,4]
                                              6
                                         E [32,37] Tail
Victim Node


              Head      B            C          D         E    Tail
                                                                24


An LRU-Interval Tree
- An Example
                      Tail
                                                  Insert A[0,4]
                      C   28
                                                  Insert B[8,10]
                        [12,18]
                                                  Insert C[12,15]
                                                  Insert D[20,31]
           Head
                                                  Insert E[32,37]
                    3               18
            B
                  [8,10]
                             D
                                  [20,31]
                                                  LRU
                                                  Update C[12,18]


                                           6
                                      E [32,37]



           Head      B            D          E     C   Tail
                                                                 25


The Caching Procedure
                    Accept a Write Request

 No overlapped
intervals allowed   Trimming and Merging
    in the tree

                                             Reducing number
                     Padding and Merging     of write requests

Maintaining the
 cache size
                             LRU


                            Finish
                                                                                                        26


Trimming and Merging
            Step 1                                        Step 2                           Step 3
Searching of                          Trimming of the overlapped                   Merging of
overlapped intervals                  parts of data buffer                         adjacent intervals
Overlap condition 1      Overlap condition 2                   Overlap condition 3      Overlap condition 4
         Ni                      Ni                                           Ni                 Ni

                                           RightChunk LeftChunk



        No                               No                                                      No
                                                                   No



       New Ni                     New Ni                             New Ni                  New Ni


             Data buffer of Ni             Data buffer of No            Trimming          Merging
                                                                                   27


Padding and Merging                                                    Step 1
                                                         Searching of implicitly
              NL                  Ni            NR
                                                         adjacent intervals
            [0, 4]              [8, 10]       [12, 13]


                                                                      Step 2
                                   Padding               Padding of blank
                                                         data buffers

                                                                      Step 3
                New Ni                                   Merging of adjacent
                [0, 13]            Merging
                                                         intervals



1 Cluster = 4 Sectors     Used sectors       Unused sectors     Padding sectors
                                                                                    28


Padding and Merging
-An Example

                                                                  Insert F [0,4]
       3                     G     10                             Insert G[12,13]
I                                [12,13]
     [8,10]                                                       Insert H[20,22]
                                                                  Insert I [8,10]
Ni                Head
                           5                  3
                   F                 H               Tail
                         [0,4]             [20,22]

                   NL                                Ni ← I [8,10]
                                                     NL← Interval Search (4,7)




     Head     F          G            H       Tail
                                                                                 29


Padding and Merging
-An Example
                     Head
                                                               Insert F [0,4]
       11                G      5                              Insert G[12,13]
I                            [12,13]
     [0,10]                                                    Insert H[20,22]
                                                               Insert I [8,10]
Ni
                                          3
                                 H               Tail
                                       [20,22]

                                                 Ni ← I [8,10]
                                                 NL← Interval Search (4,7)
                                                 Ni ← Padding and Merging (NL, Ni)



              Head   G            H       Tail
                                                                                  30


Padding and Merging
-An Example
                      Head
                                                                Insert F [0,4]
       11                 G      5                              Insert G[12,13]
I                             [12,13]
     [0,10]                                                     Insert H[20,22]
                     NR                                         Insert I [8,10]
Ni
                                           3
                                  H               Tail
                                        [20,22]

                                                  Ni ← I [8,10]
                                                  NL← Interval Search (4,7)
                                                  Ni ← Padding and Merging (NL, Ni)
                                                  NR← Interval Search (11,14)


              Head   G             H       Tail
                                                                        31


Padding and Merging
-An Example
              Head             Tail
                                                      Insert F [0,4]
       14       H       3                             Insert G[12,13]
I                    [20,22]
     [0,13]                                           Insert H[20,22]
                                                      Insert I [8,10]
Ni



                                        Ni ← I [8,10]
                                        NL← Interval Search (4,7)
                                        Ni ← Padding and Merging (NL, Ni)
                                        NR← Interval Search (11,14)
                                        Ni← Padding and Merging (NR, Ni)

               Head       H      Tail
                                                                               32


Padding and Merging
-An Example

                                                             Insert F [0,4]
                       H      17                             Insert G[12,13]
                                       Head
                            [20,22]
                                                             Insert H[20,22]
                                                             Insert I [8,10]
               I     14
                   [0,13]
                            Tail
                                               Ni ← I [8,10]
                                               NL← Interval Search (4,7)
                                               Ni ← Padding and Merging (NL, Ni)
                                               NR← Interval Search (11,14)
                                               Ni← Padding and Merging (NR, Ni)
                                               Insert (Ni)
        Head       H               I    Tail
                                                               33


An LRU-Interval Tree
- Operations
• Interval Searching: O(lgN)
• Inserting/Removing of a Node O(lgN)
  – Simultaneously insert/remove the node both from the list
    and the tree.
• Updating of a Node O(lgN)
  – Move the node to the tail of the LRU list
  – The structure on the tree is unchanged
• Selection of a Victim Node O(1)
  – Return the front node of the LRU list
                                                                                   34


  Trace Analysis – Cohesive Caching                                         <<
             100 blocks / row   1 block= 1sector = 512 bytes
LBA 83,600                                                     LBA 83,699




                                                                  Written Counts
                                                                   0
                                                                   1~64
                                                                   64~192
                                                                   192~255
                                 Time Taken: 3:40
                                 # of write requests: 4,879        >255
LBA 91,500
                                  35


Outline
• Motivation and Introduction
• A Driver-Layer Caching Policy
• Cohesive Caching Mechanism
• Performance Evaluation
• Conclusion
                                                                      36


Environment Settings
• Experiment Designs
  – The proposed method was Implemented as a system driver module
  – The experiments were carried out by real data transmissions and
    storage benchmarks
• Operating System/Hardware
  – Windows Vista/Intel Core2 6400 2.13GHz, 3GB RAM, 160GB HD
• Removable Device
  – SanDiskTM Cruzer CrossfireTM 2.0 GB USB Flash Drive
• Test Items
  – Representative and realistic cases
  – Cache size
  – Benchmarks
                                        37


Transmission Dialogs on Windows Vista

Cohesive Caching    Without Caching
                                                                 38


Performance Metrics
• Representative and Realistic Cases
  – The Number of Write Requests
  – Transmission Time
  – The Amount of Data Transferred to The Device
• Cache size
  – The Number of Write Requests
• Benchmarks
  – Operations per Minute
    - An operation stands for the completion in copying a file
    - Transfer Speed = File Size x Operations per Minute
                                                        39


Representative and Realistic cases
• Representative Cases
  – Multiple files of the same archive size (Class A)
    - Archive size: 100 MB
  – Multiple empty directories (Class B)
  – Files in multiple nested directories (Class C)
    - 1,000 files, 10KB each, Archive size: 10 MB
• Realistic Cases
  – Linux 2.6.17 source codes
  – Photos
  – MP3
  – Video
                                      40


                                   14.87%
FAT:
Representative Cases
The Number of Write                2.86%
Requests
                               A




                      19.71%       20.58%




                      1.47%        1.28%


 B                             C
                                      41


FAT:
Representative Cases
                                    4.53%
The Transmission Time
                                    3.35%

                                A




                        9.02%       7.37%

                        7.22%       5.16%


 B                              C
                                                                             42

                                File size (KB): 102 51 34 26 20 17 15 12 11 10
FAT:                                                                      43.13%
Representative Cases                                                      37.26%
The Amount of Data
Actually Transferred
                                      A




                       31.34%                                             33.00%

                       31.29%                                             32.01%



 B                                    C
                                                                               43


FAT: Realistic Cases
Archive characteristics
                      Archive       Number of       Number of     Average
Archive
                      Size          directories     files         file size
linux-2.6.17 source   210 MB        1,201           19,536        11 KB
Photo                 205 MB        1               214           985 KB
MP3                   206 MB        5               47            4 MB
Video                 208 MB        1               2             104 MB

Transfer results: comparison on the number of write requests
Archive               No Caching            Caching        Cohesive Caching
linux-2.6.17 source       179,670                 22,488               4,879
Photo                           5,022              3,906               3,431
MP3                             3,841              3,630               3,506
Video                           3,475              3,461               3,365
                                             44


FAT: Benchmarks
                      Removable Storage
                     Benchmark, SiSoftware
     FDBench v1.01
                      Sandra Lite XI.SP1a



                                +37%
                      +1095%
                                                              45


FAT: Ideal Cache Size
Archive: 20,000 Files, file size: 5 KB




                                Overheads introduced
                                by merging operations




                                         Saturated at 64 KB
                                      46

                                   63.86%

NTFS:
Representative Cases
The Number of Write                11.73%

Requests
                               A




                      80.86%
                                   70.87%
                      52.93%

                                   32.02%




 B                             C
                                                                               47


NTFS: Realistic Cases
Archive characteristics
                      Archive       Number of       Number of     Average
Archive
                      Size          directories     files         file size
linux-2.6.17 source   210 MB        1,201           19,536        11 KB
Photo                 205 MB        1               214           985 KB
MP3                   206 MB        5               47            4 MB
Video                 208 MB        1               2             104 MB

Transfer results: comparison on the number of write requests
Archive               No Caching            Caching        Cohesive Caching
linux-2.6.17 source        60,457                 41,105               8,268
Photo                           3,951              3,972               3,776
MP3                             3,489              3,480               3,452
Video                           3,387              3,379               3,374
                                             48


NTFS: Benchmarks
                      Removable Storage
                     Benchmark, SiSoftware
     FDBench v1.01
                      Sandra Lite XI.SP1a


                      +103%    +20%
                                                       49


NTFS: Ideal Cache Size
Archive: 20,000 Files, file size: 5 KB




                                  Saturated at 96 KB
                                  50


Outline
• Motivation and Introduction
• A Driver-Layer Caching Policy
• Cohesive Caching Mechanism
• Performance Evaluation
• Conclusion
                                                  51


Conclusion
• A Cohesive Caching Mechanism
  – The LRU-Interval Tree
  – Procedures in Request Manipulation
• High applicability
  – A System Driver Module
  – Compatibility with NTFS and FAT File System
• Memory Efficiency
  – FAT: 64KB
  – NTFS: 96KB
                                           52


Future Work
• Designs of Hybrid Devices
• Trace Study
• Experimental and Development Platforms
      53




Q&A

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:0
posted:2/17/2012
language:
pages:53