Patent ID: 8209465

Claim:
A data writing method of writing data which is write-commanded from a host into a NAND flash memory, the method comprising: saving the data sent from the host once into a cache memory before written to the NAND flash memory, wherein the cache memory includes an aggregate of physical segments whose size is the product of one page sector size of the NAND flash memory and the m-th power of 2 (m is 0 or a positive integer), and causing a CPU of the host to record and manage, in a unit of a sector, the status of data being written to each physical segment, and the CPU executes a process, comprising steps of: 1) recording, in a virtual segment from its number “0”, the writing status of data which initially are write-commanded from the host after turning a system ON and written to the physical segment of the cache memory; and a) recording upper LBA and group LBA of the written data into a tag memory by correlating a physical segment number with the virtual segment number; b) recording, in the tag memory, that the written data to the physical segment is “valid”, by the physical segment number correlating with the virtual segment number; and c) setting an LRU No. to the virtual segment and recording the setting status in the tag memory; 2) when a data write command is issued in succession from the host, searching the tag memory; and a) when there is an existing virtual segment having the same upper LBA as that of the write-commanded data, a-1) overwriting the write-commanded data to the physical segment being correlated with that existing virtual segment; and a-2) setting the LRU No. “0” to the existing virtual and adding the number one (1) to the LRU No. being set to the virtual segment(s), if any, whose LRU No. is smaller than the previous LRU No. of the existing virtual segment and recording the updated LRU No(s). into the tag memory; b) when there is no virtual segment having the same upper LBA as that of the write-commanded data and there is an empty virtual segment, b-1) executing data writing to the empty physical segment; and b-2) when there is no virtual segment having the same group LBA, setting the LRU No. “0” to a virtual segment of the physical segment to which the new data are written, and adding the number one (1) to the LRU No. of the other whole existing virtual segment(s), if any, and recording the updated LRU No(s). in the tag memory; b-3) when there is a virtual segment having the same group LBA, setting the LRU No. to the virtual segment in which the new data-writing-status is recorded, to the value of the existing virtual segment having the same group LBA, afterwards changing both of the LRU Nos. to “0”, and adding the number one (1) to the LRU No. being set to virtual segment(s) whose LRU No. is smaller than the previous LRU No. of the existing virtual segment and recording the updated LRU No(s). in the tag memory; and executing the abovementioned steps until when data writing to the physical segment reaches a predetermined threshold value address.