Writing to an SSD? Part 2

We discussed the method of writing data to an SSD in How does an SSD write? Part 1. We explored writing data in pages within blocks.  Whole blocks must be erased at a time, therefore data needs to be shuffled around in order to free up whole blocks of data.  This means that the cells storing the data has to be written to more often the what is ideally required (NAND Flash Cells only have a limited number of times that they can be written to (or have voltage applied to them)).  Data that fill partial blocks have to be moved around before the rest of the block can be erased.

Over Provisioning on an SSD allows the drive to be more efficient by ensuring that there is an unusable area of storage allocated on the SSD to shuffle data – it’s unusable to the user, and used internally by the SSD’s controller.


Spare SSD Space

The latest SATA III SSDs come in sizes that are short (60GB instead of 64GB, 120GB instead of 128GB and 240GB instead of 256GB) in traditional disk drive sizes.  This is due to the over provisioning storage allocated to allow efficient garbage collection processing.

The consequence of this over provisioned area gives an increase in overall write IOPS as well as better reliability due to the fact that this area can also be used to replace bad memory blocks.

Bad Blocks!  This may send alarm bells – but the facts are that between 2 and 10% of blocks may be prone to error or be unusable when the device is new.  During the drive’s lifetime, good blocks can also become corrupted by charge leakage.  Due to the fact that MLC (Multi Layer Cell) devices have 4 states per cell – there is a chance that slight disturbances in the cell’s structure become unreliable, and reading accurate voltage levels fails.  This is less likely in Single Layer (SLC) drives as the cells either store a voltage or not, so the tolerance for failure is higher. 

This does not mean that the MLC drive is unreliable.  The controller maps any dead or unusable cells in a dead pool.  SSD design accepts that cells die and the software within the controller compensates for it.

SSD designers have to calculate the average number of bad blocks that the SSD will encounter over it’s lifetime and ensure that there are enough spare blocks to cover this number.  If the bad blocks number exceeds the number of spare blocks set aside – the SSD fails.

Some Enterprise based Solid State Disks also have a built in RAID configuration, where the data is striped across numbers of NAND Flash chips.  In the event of a bad block occurring, data is not lost, instead recovered from an alternative chip.

Some SSD models also have an InDrive UPS function which guarantees no data loss during any unexpected power dips, spikes or failures.

SSD Anatomy

A Solid State Disk comprises of a circuit board with a series of chips mounted on it.


Basic SSD Anatomy

The above image shows a series of NAND Flash chips – the actual number of them is determined by design, and depends on the GB size of the SSD.  In the example there are 8x NAND Flash chips – so let’s assume it’s a 128GB disk, where each chip is  16GB in size or 120GB available where 1GB per chip is assigned as SPARE.  In actual fact the chips could be stacked so there may be two or four dies per NAND FLASH IC (e.g. 16x 8GB stacked in pairs).

Some SSD have an additional Cache or Buffer of DRAM.  This stores the directory of block placement and wear levelling DATA.  Other’s store this information differently.  For this article we’ll try and keep this simple.

The controller can have between 4 and 10 channels, where data flows to and from the NAND storage area, Cache is used as a buffer to shuffle data around.


SSD Anatomy with channels

Each NAND Flash IC has a read/write speed up to about 40 MB/s, therefore if the controller read and writes to more than one NAND Flash Chip at a time, then the SSD can achieve high read and write speeds.  A traditional spinning disk has only a single head which moves back and forth as the disk spins to read and write the data.

An SSD controller places data across different NAND Flash IC so that it can achieve fast read and write performance.  In Part 1 of this article we showed the data written sequentially across adjacent blocks, in actual fact data is written in blocks – but the blocks can be spread across the different Chips to give more bandwidth to the controller. Without this functionality the controller would get bogged down reading or writing to a single chip through a single channel.

Some Solid State Disks have a Battery/Capacitor which allows the disk to complete the writing to a disk should power fail or a spike is detected, allowing too reliably complete the outstanding transaction and prevent data loss.

The Downsides

Ok – so we have explored very roughly how an SSD works.  We’ve looked at the fact that the drive read and writes in 4KB pages, stored in blocks of 64 pages or 256KB in size.  Actually the latest SSDs are using 128 paged block sizes of 512KB.  Data is written in pages of 4KB but only deleted in blocks of 256KB (or later 512KB).  This cuts down on the number of writes (which has a finite number).

What happens when I overwrite or update a file?  It actually just marks the pages storing the old file as available, writes the new version to another location, if there is space – if not the SSD has to clean itself up before writing the updated file – the original version of the file gets wiped when the SSD cleans itself up.  This process is virtually the same for a spinning disk, except for overwriting, where the HDD does actually overwrite the data.

Here’s one downside of Solid State Disk technology – due to the above scenario, they will get slower as they get used.  The data has to be shuffled around before erasing, then writing occurs.  Anand Lal Shimpi has a great blog about this at http://www.anandtech.com/show/2738/8

SSD TRIM

Modern Operating Systems (see table below), have a function called TRIM built into the OS.  This function forces the SSD to clean blocks before the the data is finally written to a page.  This does cause an additional overhead, but keeps the SSD in a clean state as it goes along.

Operating System
Supported since
Notes
Windows 7
Final release – October 2009
Windows Server 2008 R2
Final release – October 2009
Linux 2.6.33
Feb-10
Not all filesystems make use of TRIM. Ext4 and Btrfs are known to support it
OpenSolaris
Jul-10
FreeBSD 8.1
Jul-10
Only for low-level device erase (zeroing all LBAs).
FreeBSD 8.2
29-Jan-11
Full support in UFS, no support in ZFS.
Mac OS X Snow Leopard v10.6.6 (Build 10J3210)
24 February 2011 (With 3rd party)*
*TRIM can be unofficially enabled on Mac OS X Snow Leopard by modifying extensions. Since February 2011 MacBook Pro models that ship with Intel SSDs are supported by Apple and feature TRIM support. Reinstalling the OS disables TRIM by default. It can be re-enabled by 3rd party software. By modifying extensions TRIM feature can be patched to support third-party SSDs and installed on other Macs. Version 10.6.8, build 10K540, released 23 June 2011, enabled TRIM support for solid state hard drives shipped in Apple-produced configurations.
Mac OS X Lion v10.7 (Build 11A444d)
24 February 2011

Testing for TRIM

Windows 7
You can  check whether or not TRIM is enabled by accessing the Command Prompt (running as Administrator);

CD to C:\Windows\system32 and enter: > fsutil behavior query disabledeletenotify

The result will be one of the following:-

DisableDeleteNotify = 1 (Windows TRIM commands are disabled)

DisableDeleteNotify = 0 (Windows TRIM commands are enabled)

AHCI – Advanced Host Controller Interface
Most Motherboards on PCs have 2x disk modes, RAID or PCI-IDE mode. SSD’s work best when the motherboard is in AHCI mode. This is found in the BIOS settings of the system and is enabled using the RAID option – Although It may not mention AHCI, it will usually be in operation when RAID is enabled. Although TRIM does not work on RAID volumes, you can use RAID with most SSD drives in a PC, although this will give faster read and write performance – it is questionable whether a user will notice any improvement over a standard SSD unless there are extreme applications shuffling a lot of data about. 

It is best to enable AHCI before installing the SSD and Operating System, however for Windows 7 – this can be done retrospectively – check out how at http://support.microsoft.com/kb/922976

We welcome discussion on this subject – get in touch if you need more info.

Post a Comment

Your email is never shared. Required fields are marked *

*
*