Low write amplification in solid state drive
View Patent ↗Methods, systems, and computer programs are presented for storing data in a solid state drive (SSD). One method includes an operation for detecting a plurality of streams writing to the SSD, each stream writing in sectors, a page including a plurality of sectors and a block including a plurality of pages. A write operation includes writing at least one complete page, and an erase operation includes erasing at least one complete block. The method further includes operations for allocating a write buffer for each stream in RAM memory, and for storing each received sector of a stream in the corresponding write buffer. When a write buffer stores enough sectors to fill a page, content of the write buffer is written to a page in flash memory such that the page is filled. Further, the write buffer is freed after writing the content of the write buffer to the flash memory.
1. A method for storing data in a solid state drive (SSD), the method comprising:
detecting a plurality of streams writing to the SSD, wherein each stream of the plurality of streams writes data to the SSD in sectors, wherein a page includes a plurality of sectors, wherein a block includes a plurality of pages and has a block size, wherein a write operation to the SSD includes writing at least one page, wherein an erase operation in the SSD includes erasing at least one block;
allocating a respective write buffer for each of the plurality of streams in a random access memory (RAM), wherein a tag is defined for each of the plurality of streams, and wherein the tag for a stream is equal to a logical block address of a sector within the stream divided by the block size;
storing, for each stream of the plurality of streams, each received sector of the stream in the allocated write buffer of the stream;
in response to a write buffer storing sufficient sectors to fill a page, writing content of the write buffer to fill a page in the SSD;
freeing the write buffer after writing the content of the write buffer to the SSD;
configuring a waiting buffer in the RAM, the waiting buffer including entries of received sectors that are not associated with any of the detected plurality of streams;
detecting two sectors in the waiting buffer having a same tag;
creating a new stream for the detected two sectors; and
moving the detected two sectors from the waiting buffer to the write buffer of the created new stream.
2. The method as recited in claim 1 , further including:
defining a buffer allocation table in the RAM, each entry in the buffer allocation table being associated with a respective write buffer, wherein each entry in the buffer allocation table includes the tag defined for a stream, a last offset in the write buffer, a buffer ID of the write buffer, an open block ID, and an address in the SSD.
3. The method as recited in claim 2 , wherein writing content of the write buffer to fill the page further includes:
finding a free page in the block identified by the open block ID; and
writing the page to the free page.
4. The method as recited in claim 1 , further including:
defining an open blocks table in the RAM to store information regarding blocks having free pages.
5. The method as recited in claim 4 , further including:
in response to a block mapped in the open blocks table being filled, taking the filled block off the open blocks table and creating a new entry in the open blocks table for a block with at least one empty page.
6. The method as recited in claim 1 , wherein each write buffer has a size equal to a size of a page of the SSD.
7. The method as recited in claim 1 , wherein the write unit is equal to a size of a page and an erase unit is equal to a size of a block.
8. A system comprising:
a memory storing a computer program having program instructions; and
a processor to execute the computer program to:
detect a plurality of streams writing to a solid state drive (SSD), wherein each stream of the plurality of streams writes data to the SSD in sectors, wherein a page includes a plurality of sectors, wherein a block includes a plurality of pages and has a block size, wherein a write operation to the SSD includes writing at least one page, wherein an erase operation in the SSD includes erasing at least one block; and
allocate a respective write buffer for each of the plurality of streams in a random access memory (RAM), wherein a tag is defined for each of the plurality of streams, and wherein the tag for a stream is equal to a logical block address of a sector within the stream divided by the block size;
store, for each stream of the plurality of streams, each received sector of the stream in the allocated write buffer of the stream; and
in response to a write buffer storing sufficient sectors to fill a page, write content of the write buffer to fill a page in the SSD;
free the write buffer after writing the content of the write buffer to the SSD;
configure a waiting buffer in the RAM, the waiting buffer including entries of received sectors that are not associated with any of the detected plurality of streams;
detect two sectors in the waiting buffer having a same tag;
creating a new stream for the detected two sectors; and
move the detected two sectors from the waiting buffer to the write buffer of the created new stream.
9. The system as recited in claim 8 , wherein the processor is to execute the computer program to define a buffer allocation table in the RAM memory, each entry in the buffer allocation table being associated with a respective write buffer, wherein each entry in the buffer allocation table includes the tag defined for a stream of the plurality of streams, a last offset in the write buffer, a buffer ID of the write buffer, an open block ID, and an address in the SSD.
10. The system as recited in claim 9 , wherein to write the content of the write buffer to fill the page, the processor is to execute the computer program to find a free page in the block identified by the open block ID, and write the page to the free page.
11. The system as recited in claim 9 , wherein the processor is to execute the computer program to define an open blocks table in the RAM to store information regarding blocks having free pages, and in response to a block mapped in the open blocks table being filled, take the filled block off the open blocks table and to create a new entry in the open blocks table for a block with at least one empty page.
12. The system as recited in claim 8 , wherein the processor is to execute the computer program to configure a waiting buffer in the RAM, the waiting buffer including entries of received sectors that are not associated with any of the detected plurality of streams.
13. A non-transitory computer-readable storage medium storing machine readable instructions that when executed by a processor cause a processor to:
detect a plurality of streams writing to a solid state drive (SSD), wherein each stream of the plurality of streams writes data to the SSD in sectors, wherein a page includes a plurality of sectors, wherein a block includes a plurality of pages and has a block size, wherein a write operation to the SSD includes writing at least one complete page, wherein an erase operation in the SSD includes erasing at least one complete block;
allocate a respective write buffer for each stream of the plurality of streams in a random access memory (RAM), wherein a tag is defined for each of the plurality of streams, and wherein the tag for a stream is equal to a logical block address of a sector within the stream divided by the block size;
store, for each stream of the plurality of streams, each received sector of the stream in the allocated write buffer of the stream;
in response to a write buffer storing sufficient sectors to fill a page, write content of the write buffer to a page in flash memory such that the page is filled;
free the write buffer after writing the content of the write buffer to the SSD;
configure a waiting buffer in the RAM, the waiting buffer including entries of received sectors that are not associated with any of the detected plurality of streams;
detect two sectors in the waiting buffer having a same tag;
create a new stream for the detected two sectors; and
move the detected two sectors from the waiting buffer to the write buffer of the created new stream.
14. The storage medium as recited in claim 13 , wherein the instructions are further to cause the processor to:
define a buffer allocation table in the RAM, each entry in the buffer allocation table being associated with a respective write buffer, wherein each entry in the buffer allocation table includes the tag defined for a stream of the plurality of streams, a last offset in the write buffer, a buffer ID of the write buffer, an open block ID, and an address in the SSD.
15. The storage medium as recited in claim 14 , wherein, to write the page, the instructions are further to cause the processor to:
find a free page in the block identified by the open block ID; and
write the page to the free page.
16. The storage medium as recited in claim 13 , wherein the instructions are further to cause the processor to:
define an open blocks table in the RAM to store information regarding blocks having free pages.
17. The storage medium as recited in claim 16 , wherein the instructions are further to cause the processor to:
in response to a block mapped in the open blocks table being filled, the processor is to take the filled block off the open blocks table and create a new entry in the open blocks table for a block with at least one empty page.