Patent ID: 8041883

Claim:
A method for restoring operation of a storage device based on a flash memory, the storage device emulating a logical memory space, including a plurality of logical blocks each one having a plurality of logical sectors, being mapped on a physical memory space of the flash memory including a plurality of physical blocks each one having a plurality of physical sectors for storing different versions of the logical sectors, wherein the method includes the steps for: detecting a plurality of conflicting physical blocks for a corrupted logical block resulting from a breakdown of the storage device, determining a plurality of validity indexes calculated from the number of last versions of the logical sectors of the corrupted logical block being stored in the conflicting physical blocks, selecting at least one of the conflicting physical blocks according to the validity indexes, associating the at least one selected conflicting physical block with the corrupted logical block, and discarding each one of the non-selected conflicting physical blocks; wherein consecutive versions of the logical sectors of each logical block are stored in succession in the physical sectors of a root physical block and at least one child physical block when the root physical block is full, the step for detecting the conflicting physical blocks including: detecting two conflicting root physical blocks for the corrupted logical block resulting from the breakdown of the storage device during a garbage collection procedure including compacting an old root physical block and at least one child physical block storing the corrupted logical block into a new root physical block storing the last versions only of the logical sectors of the corrupted logical block and discarding the old root physical block and the at least one child physical block, the new root physical block including a new root indicator, and discriminating the old root physical block and the new root physical block according to the new root indicator, wherein the step for determining the validity indexes includes: determining an old validity index calculated from the number of last versions of the logical sectors of the corrupted logical block being stored in the old root physical block and the at least one child physical block, and a new validity index calculated from the number of last versions of the logical sectors of the corrupted logical block being stored in the new root physical block, and wherein the step for selecting at least one of the conflicting physical blocks includes: selecting the new root physical block when the at least one child physical block has been discarded, or otherwise selecting the new root physical block when the new validity index is equal to the old validity index or selecting the old root physical block and the at least one child physical block when the old validity index is higher than the new validity index.