Patent ID: 8645613
Filing Date: 2014-02-04
Classification: G06F

Abstract:
1. A data writing method, for writing data from a host system into a flash memory chip, wherein the flash memory chip comprises a plurality of physical blocks, the data writing method comprising: receiving, by a flash memory controller, a write command and the data from the host system; grouping a part of the physical blocks into a data area, a spare area and a special area; allocating a plurality of logical blocks for mapping to the physical blocks of the data area, wherein each of the logical blocks is mapped to at least one of the physical blocks of the data area, the write command indicates to store the data into a first logical block among the logical blocks, and the first logical block maps a first physical block among the physical blocks of the data area; grouping the logical blocks into a plurality of logical block groups, wherein at least two of the logical blocks are associated to one of the logical block groups, and the first logical block belongs to a first logical block group among the logical block groups; selecting the physical blocks of the special area as a plurality of buffer physical blocks respectively for the logical block groups, wherein the buffer physical blocks only store the data which size is smaller than a predetermined value and a first buffer physical block among the buffer physical blocks is assigned for the first logical block group; determining whether a size of the data from the host system is smaller than the predetermined value; if the size of the data from the host system is not smaller than the predetermined value, selecting a second physical block from the spare area as a substitute physical block for substituting the first physical block and writing the data into the substitute physical block; if the size of the data from the host system is smaller than the predetermined value, determining whether the first buffer physical block is full by using the flash memory controller; if the first buffer physical block is not full, writing the data from the host system into the first buffer physical block; and if the first buffer physical block is full, selecting a physical block from the spare area as a first spare buffer physical block for the first logical block group and writing the data from the host system into the first spare buffer physical block by using the flash memory controller.