Patent ID: 8626987

Claim:
A method of defragmenting a flash memory operated under the control of a host, the flash memory being arranged in a plurality of blocks including a free block and a plurality of fragmented blocks respectively storing at least one fragment, the method comprising: identifying a plurality of fragments stored in the plurality of fragmented blocks according to corresponding logical addresses; converting the logical addresses to corresponding physical addresses using a flash translation layer (FTL); using the physical addresses, reading a subset of fragments in the plurality of fragments from at least one of the plurality of fragmented blocks; grouping the subset of fragments in a defragmentation region having a size defined by a flash management unit in response to a defragmentation command by the host; writing the grouped subset of fragments to the free block, wherein the reading and the grouping of the subset of fragments are performed regardless of an arrangement order of the plurality of fragments as stored in the flash memory; and setting the defragmentation region according to a defragmentation size, a defragmentation start sector and a number of sectors provided by the host.