Patent ID: 8176236

Claim:
A memory controller for controlling access to one or more flash memories, in which data erasing is performed in physical blocks, comprising: a logical block management unit which forms plural logical blocks each composed of plural logical sectors to each of which a logical address for a host system is assigned; a free block management unit which manages free physical blocks each of which is a physical block not storing effective data; an assignment unit which assigns a logical block to a free physical block; an order management unit which manages assignment order for physical blocks each storing effective data so that a position of a physical block in the assignment order becomes higher according as assignment of a logical block to the physical block is performed more recently; a data writing unit which, in response to a request issued by the host system, identifies a logical block including a logical sector corresponding to a logical address pertaining to the request and stores data corresponding to the logical address in a physical block corresponding to the logical block identified; an identification unit which, when the assignment unit assigns a logical block to a free physical block, identifies a previous physical block which is a physical block storing effective data and corresponding to the same logical block as the free physical block; a determination unit which, when the identification unit identifies the previous physical block, makes a determination whether or not a position of the previous physical block identified is higher than a predetermined position in the assignment order; and a data transfer unit which, when the determination is negative, performs data transfer for transferring all effective data stored in the previous physical block identified to the free physical block corresponding to the same logical block as the identified previous physical block; wherein, after completing the data transfer, the identified previous physical block becomes a free physical block and is managed by the free block management unit.