Patent ID: 7409527

Claim:
A data storing method for storing data into a storage apparatus, the storage apparatus having a plurality of memory blocks, each memory block comprising a first terminal and a second terminal; the data storing method comprising: receiving a data set; selecting a first writing direction or a second writing direction to be a preferred writing direction, the first writing direction being opposite to the second writing direction, wherein when the first writing direction is selected to be the preferred writing direction, the first terminal is a starting point corresponding to the first writing direction, and when the second writing direction is selected to be the preferred writing direction, the second terminal is a staffing point corresponding to the second writing direction; writing the data set into one or more memory blocks according to the selected writing direction; computing a remaining space of each of the memory blocks; selecting a memory block from the plurality of memory blocks, wherein the remaining space of the selected memory block is greater than the size of the data set; and computing a fragmentation level of each of the memory blocks to select a target-defragment memory block and to perform a defragmentation operation on the target-defragment memory block.