Method and non-transitory computer-readable storage medium and apparatus for handling garbage collection process
The invention introduces a method for handling a garbage collection (GC) process, performed by a processing unit of a flash controller, to include: detecting that a portable storage device is inserted into a host equipment; obtaining a maximum transmission bandwidth of a host interface (I/F); determining that a transmission bandwidth of a flash I/F is higher than the maximum transmission bandwidth of the host I/F; and in response to a determination that the transmission bandwidth of the flash I/F is higher than the maximum transmission bandwidth of the host I/F, inserting operations of the GC process during an execution of a host command.
1 . A method for handling a garbage collection (GC) process, performed by a processing unit of a flash controller, wherein a portable storage device is equipped with the flash controller and a flash module, the method comprising:
detecting that the portable storage device is inserted into a host equipment;
obtaining a maximum transmission bandwidth of a host interface (I/F), wherein the flash controller comprises the host I/F, and the host I/F is coupled to the host equipment;
determining that a transmission bandwidth of a flash I/F is higher than the maximum transmission bandwidth of the host I/F, wherein the flash controller comprises the flash I/F, and the flash I/F is coupled to the flash module; and
in response to a determination that the transmission bandwidth of the flash I/F is higher than the maximum transmission bandwidth of the host I/F, inserting operations of the GC process during an execution of a host command, wherein the GC process collects valid user data from a plurality of source blocks in the flash module through the flash I/F, and programs the valid user data into a destination block in the flash module through the flash I/F.
2 . The method of claim 1 , wherein the transmission bandwidth of the flash I/F is higher than N times the maximum transmission bandwidth of the host I/F, N is equal to or greater than 2.
3 . The method of claim 1 , wherein the maximum transmission bandwidth of the host I/F is obtained in a link test of an initialization procedure.
4 . The method of claim 3 , comprising:
performing a series of polling signal interactions with the host equipment through the host I/F in a polling state to determine the maximum transmission bandwidth of the host I/F.
5 . The method of claim 3 , comprising:
reading the transmission bandwidth of the flash I/F from a designated physical address of the flash module through the flash I/F.
6 . The method of claim 1 , comprising:
re-segmenting space of a random access memory (RAM) that originally stores first user data and first auxiliary management data corresponding to the host command, wherein the space of the RAM is divided into a first region and a second region, the first region is used to store the first user data and the first auxiliary management data corresponding to the host command, and the second region is used to store second user data and second auxiliary management data corresponding to the GC process.
7 . The method of claim 1 , comprising:
periodically determining whether the host command is ready;
executing the host command when the host command is ready; and
performing one batch of the GC process when the host command is not ready.
8 . A non-transitory computer-readable storage medium having stored therein program code that, when loaded and executed by a processing unit of a flash controller, causes the processing unit to:
detect that a portable storage device is inserted into a host equipment, wherein the portable storage device is equipped with the flash controller and a flash module;
obtain a maximum transmission bandwidth of a host interface (I/F), wherein the flash controller comprises the host I/F, and the host I/F is coupled to the host equipment;
determine that a transmission bandwidth of a flash I/F is higher than the maximum transmission bandwidth of the host I/F, wherein the flash controller comprises the flash I/F, and the flash I/F is coupled to the flash module; and
in response to a determination that the transmission bandwidth of the flash I/F is higher than the maximum transmission bandwidth of the host I/F, insert operations of a garbage collection (GC) process during an execution of a host command, wherein the GC process collects valid user data from a plurality of source blocks in the flash module through the flash I/F, and programs the valid user data into a destination block in the flash module through the flash I/F.
9 . The non-transitory computer-readable storage medium of claim 8 , wherein the transmission bandwidth of the flash I/F is higher than N times the maximum transmission bandwidth of the host I/F, N is equal to or greater than 2.
10 . The non-transitory computer-readable storage medium of claim 8 , wherein the maximum transmission bandwidth of the host I/F is obtained in a link test of an initialization procedure.
11 . The non-transitory computer-readable storage medium of claim 10 , wherein the program code that, when loaded and executed by the processing unit of the flash controller, causes the processing unit to:
perform a series of polling signal interactions with the host equipment through the host I/F in a polling state to determine the maximum transmission bandwidth of the host I/F.
12 . The non-transitory computer-readable storage medium of claim 10 , wherein the program code that, when loaded and executed by the processing unit of the flash controller, causes the processing unit to:
read the transmission bandwidth of the flash I/F from a designated physical address of the flash module through the flash I/F.
13 . The non-transitory computer-readable storage medium of claim 8 , wherein the program code that, when loaded and executed by the processing unit of the flash controller, causes the processing unit to:
re-segment space of a random access memory (RAM) that originally stores first user data and first auxiliary management data corresponding to the host command, wherein the space of the RAM is divided into a first region and a second region, the first region is used to store the first user data and the first auxiliary management data corresponding to the host command, and the second region is used to store second user data and second auxiliary management data corresponding to the GC process.
14 . An apparatus for handling a garbage collection (GC) process, comprising:
a host interface (I/F);
a flash I/F, coupled to a flash module; and
a processing unit, coupled to the host I/F and the flash I/F, arranged operably to: detect that the apparatus is inserted into a host equipment through the host I/F; obtain a maximum transmission bandwidth of the host interface; determine that a transmission bandwidth of the flash I/F is higher than the maximum transmission bandwidth of the host I/F; and in response to a determination that the transmission bandwidth of the flash I/F is higher than the maximum transmission bandwidth of the host I/F, insert operations of the GC process during an execution of a host command,
wherein the GC process collects valid user data from a plurality of source blocks in the flash module through the flash I/F, and programs the valid user data into a destination block in the flash module through the flash I/F.
15 . The apparatus of claim 14 , wherein the transmission bandwidth of the flash I/F is higher than N times the maximum transmission bandwidth of the host I/F, N is equal to or greater than 2.
16 . The apparatus of claim 14 , wherein the maximum transmission bandwidth of the host I/F is obtained in a link test of an initialization procedure.
17 . The apparatus of claim 16 , wherein the processing unit is arranged operably to: perform a series of polling signal interactions with the host equipment through the host I/F in a polling state to determine the maximum transmission bandwidth of the host I/F.
18 . The apparatus of claim 16 , wherein the processing unit is arranged operably to: read the transmission bandwidth of the flash I/F from a designated physical address of the flash module through the flash I/F.
19 . The apparatus of claim 14 , comprising:
a random access memory (RAM), coupled to the processing unit,
wherein the processing unit is arranged operably to: re-segment space of a random access memory (RAM) that originally stores first user data and first auxiliary management data corresponding to the host command,
wherein the space of the RAM is divided into a first region and a second region, the first region is used to store the first user data and the first auxiliary management data corresponding to the host command, and the second region is used to store second user data and second auxiliary management data corresponding to the GC process.
20 . The apparatus of claim 14 , wherein the processing unit is arranged operably to: periodically determine whether the host command is ready; execute the host command when the host command is ready; and perform one batch of the GC process when the host command is not ready.