Data read/write method, controller, and storage device
Example data read/write methods and apparatus are described. One example method includes determining, by a controller, a maximum quantity L of data channels used by the controller in a same time period to perform write operations of data on the M storage units based on a current threshold of the storage device, current consumption of performing write operations of data by M storage units, and current consumption of performing write operations on the M storage units by the controller by using a single data channel, where M is a positive integer less than or equal to Q. The controller performs write operations of data on the M storage units by using a maximum of L data channels in the same time period.
1 . A method, applied to a storage device, wherein the storage device comprises a controller and Q storage units, the controller is connected to the Q storage units by using N data channels, N is a positive integer greater than or equal to 2, Q is a positive integer greater than or equal to N, and the method comprises:
determining, by the controller, a maximum quantity L of data channels used by the controller in a same time period to perform write operations of data on M storage units based on the following:
a current threshold of the storage device,
current consumption of performing write operations of data by the M storage units of the Q storage units in the same time period, and
current consumption of performing write operations of data on the M storage units by the controller by using a single data channel in the N data channels,
wherein L is a positive integer less than N, and Mis a positive integer less than or equal to Q; and
performing, by the controller, write operations of data on the M storage units by using a maximum of L data channels in the same time period.
2 . The method according to claim 1 , wherein
a rate at which the controller performs write operations of data on the M storage units is less than a rate at which the controller performs read operations of data on the M storage units.
3 . The method according to claim 1 , wherein a storage unit of the Q storage units comprises a buffer and a storage array; and
a rate at which the controller performs a write operation of data on the buffer is greater than a rate at which the buffer performs a write operation of data on the storage array.
4 . The method according to claim 1 , wherein the method further comprises:
in a time period in which current consumption of the storage device is less than the current threshold, performing, by the controller, write operations of data on P storage units by using a maximum of L data channels, wherein P is a positive integer greater than M and less than or equal to Q.
5 . The method according to claim 1 , wherein the current threshold of the storage device is maximum current consumption that corresponds to a power supply and that the storage device can withstand.
6 . The method according to claim 1 , further comprising:
obtaining current consumption timetables of the M storage units, wherein a current consumption timetable of a storage unit of the M storage units indicates current consumption at different moments in a process in which a buffer in the storage unit performs a write operation of data on a storage array in the storage unit.
7 . The method according to claim 6 , further comprising:
obtaining, by the controller based on a current consumption timetable of each storage unit of the M storage units, current consumption generated when a buffer in the storage unit performs a write operation of data on a storage array in the storage unit at different moments in a predetermined time period.
8 . A controller, used in a storage device, wherein the storage device comprises the controller and Q storage units, the controller is connected to the Q storage units by using N data channels, N is a positive integer greater than or equal to 2, Q is a positive integer greater than or equal to N, and the controller comprises:
a control circuit, configured to:
determine a maximum quantity L of data channels used in a same time period to perform write operations of data on M storage units based on the following:
a current threshold of the storage device,
current consumption of performing write operations of data by the M storage units of the Q storage units in the same time period, and
current consumption of performing write operations of data on the M storage units by using a single data channel in the N data channels,
wherein L is a positive integer less than N, and M is a positive integer less than or equal to Q; and
perform write operations of data on the M storage units by using a maximum of L data channels in the same time period.
9 . The controller according to claim 8 , wherein
a rate at which the control circuit performs write operations of data on the M storage units is less than a rate at which the control circuit performs read operations of data on the M storage units.
10 . The controller according to claim 8 , wherein a storage unit of the Q storage units comprises a buffer and a storage array; and
a rate at which the control circuit performs a write operation of data on the buffer is greater than a rate at which the buffer performs a write operation of data on the storage array.
11 . The controller according to claim 8 , wherein
the control circuit is further configured to: in a time period in which current consumption of the storage device is less than the current threshold, perform, by the control circuit, write operations of data on P storage units by using a maximum of L data channels, wherein P is a positive integer greater than M and less than or equal to Q.
12 . The controller according to claim 8 , wherein the current threshold of the storage device is maximum current consumption that corresponds to a power supply and that the storage device can withstand.
13 . The controller according to claim 8 , wherein the controller is further configured to:
obtain current consumption timetables of the M storage units, wherein a current consumption timetable of a storage unit of the M storage units indicates current consumption at different moments in a process in which a buffer in the storage unit performs a write operation of data on a storage array in the storage unit.
14 . The controller according to claim 13 , wherein the controller is further configured to:
obtain, based on a current consumption timetable of each storage unit of the M storage units, current consumption generated when a buffer in the storage unit performs a write operation of data on a storage array in the storage unit at different moments in a predetermined time period.
15 . A storage device, comprising a controller and Q storage units, wherein;
the controller is connected to the Q storage units by using N data channels, N is a positive integer greater than or equal to 2, and Q is a positive integer greater than or equal to N;
the controller is configured to:
determine a maximum quantity L of data channels used in a same time period to perform write operations of data on M storage units based on the following:
a current threshold of the storage device,
current consumption of performing write operations of data by the M storage units of the Q storage units in the same time period, and
current consumption of performing write operations of data on the M storage units by using a single data channel in the N data channels,
wherein L is a positive integer less than N, and M is a positive integer less than or equal to Q; and
perform write operations of data on the M storage units by using a maximum of L data channels in the same time period.
16 . The storage device according to claim 15 , wherein
a rate at which the controller performs write operations of data on the M storage units is less than a rate at which the controller performs read operations of data on the M storage units.
17 . The storage device according to claim 15 , wherein a storage unit of the Q storage units comprises a buffer and a storage array; and
a rate at which the controller performs a write operation of data on the buffer is greater than a rate at which the buffer performs a write operation of data on the storage array.
18 . The storage device according to claim 15 , wherein
the controller is further configured to: in a time period in which current consumption of the storage device is less than the current threshold, perform write operations of data on P storage units by using a maximum of L data channels, wherein P is a positive integer greater than M and less than or equal to Q.
19 . The storage device according to claim 15 , wherein the controller is further configured to:
obtain current consumption timetables of the M storage units, wherein a current consumption timetable of a storage unit of the M storage units indicates current consumption at different moments in a process in which a buffer in the storage unit performs a write operation of data on a storage array in the storage unit.
20 . The storage device according to claim 19 , wherein the controller is further configured to:
obtain, based on a current consumption timetable of each storage unit of the M storage units, current consumption generated when a buffer in the storage unit performs a write operation of data on a storage array in the storage unit at different moments in a predetermined time period.