Disclosure of Invention
In view of the above problems, the present invention aims to provide a method for managing a solid state disk and a solid state disk, so as to solve the problems existing in the prior art.
According to an aspect of the present invention, there is provided a method for managing a solid state disk, the solid state disk including a controller and a flash memory, the flash memory including a plurality of DIE, wherein the controller performs the following operations for each of the DIE:
dividing the plurality of DIEs into a plurality of virtual DIEs;
establishing a plurality of RAID stripe groups by taking a plurality of virtual DIEs as references;
establishing a mapping relation between a logical address and a physical address of data to be stored according to the length of the RAID stripe group;
and storing the data in the flash memory according to the mapping relation and accessing the flash memory.
Optionally, the step of dividing the plurality of did into a plurality of virtual did comprises:
Splitting each DIE into at least two identical virtual DIEs.
Optionally, the step of dividing the plurality of did into a plurality of virtual did comprises:
Combining each at least two of said DIEs into one of said virtual DIEs.
Optionally, each DIE includes a plurality of physical blocks, and the virtual DIE is divided by using a physical block as a unit, and the number of the physical blocks included in each virtual DIE is the same.
Optionally, each physical block includes a plurality of rows of physical pages, and the plurality of rows of physical pages are named by different page numbers respectively; the step of establishing a plurality of RAID stripe groups based on the plurality of virtual DIEs comprises the following steps:
Numbering a plurality of physical blocks in each virtual DIE;
merging physical pages with the same page number in the physical blocks with the same number in each virtual DIE into the same RAID stripe group;
and establishing a plurality of RAID stripe groups according to the sequence of the numbers and the sequence of the page numbers.
Optionally, the storage space corresponding to the DIE is the physical address, and the storage space corresponding to the virtual DIE is the logical address.
Optionally, the step of storing data in a flash memory and accessing the flash memory according to the mapping relationship comprises:
According to the mapping relation, the data to be stored are stored in the physical address according to a storage mode of a RAID stripe group;
And when the flash memory is accessed, converting the physical address into the logical address according to the mapping relation.
According to another aspect of the present invention, there is provided a solid state disk including:
A controller connected to the host for receiving write data from outside; and
A flash memory connected to the controller for receiving the write data, the flash memory including a plurality of did,
The controller is used for dividing each DIE into a plurality of virtual DIEs and establishing a plurality of RAID stripe groups by taking each virtual DIE as a reference.
Optionally, each DIE includes a plurality of physical blocks, and the virtual DIE is divided by using a physical block as a unit, and the number of the physical blocks included in each virtual DIE is the same.
Optionally, each of said did includes at least two identical said virtual did, or, at least two said did are combined into one said virtual did.
According to the management method of the solid state disk and the solid state disk, each DIE in the flash memory is divided into a plurality of virtual DIEs, and the RAID stripe group is established based on the plurality of the virtual DIEs, so that the length of the RAID stripe group is increased (or reduced), the occupied space of check data in the RAID stripe group is correspondingly reduced (or improved), the requirement on RAID space is reduced (or improved), the data protection capability and the management capability are improved, and the read-write efficiency and the quality of the solid state disk are improved.
Detailed Description
The invention will be described in more detail below with reference to the accompanying drawings. Like elements are denoted by like reference numerals throughout the various figures. For clarity, the various features of the drawings are not drawn to scale. Furthermore, some well-known portions may not be shown.
The present invention is described below based on examples, but the present invention is not limited to only these examples. In the following detailed description of the present invention, certain specific details are set forth in detail. The present invention will be fully understood by those skilled in the art without the details described herein. Well-known methods, procedures, flows, components and circuits have not been described in detail so as not to obscure the nature of the invention.
Unless the context clearly requires otherwise, throughout the description and the claims, the words "comprise", "comprising", and the like are to be construed in an inclusive sense as opposed to an exclusive or exhaustive sense; that is, it is the meaning of "including but not limited to". In the description of the present invention, it should be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. Furthermore, in the description of the present invention, unless otherwise indicated, the meaning of "a plurality" is two or more.
The following describes in further detail the embodiments of the present invention with reference to the drawings and examples.
Fig. 1 shows a schematic block diagram of a solid state disk according to an embodiment of the present invention, and fig. 2 shows a schematic block diagram of a flash memory according to an embodiment of the present invention.
As shown in fig. 1, the solid state disk is a storage hard disk manufactured by using a solid state electronic storage chip, and the solid state disk 100 of the present embodiment includes: the controller 110 and the flash memory 120, the controller 110 is responsible for data management on the flash memory 120, and the host 200 and the flash memory 120 are connected as data transfer, and write data is received from the outside. Solid state disk 100 may further include DRAM130 as a second cache unit for assisting controller 110 in data processing.
Further, the controller 110 includes: an interface unit 111, a flash memory controller 112, a cache controller 113, a central processing unit 114 and a first cache unit 115. The interface unit 111 connects the external host 200 and the central processor 114 to realize data transmission, for example, write data of the host 200 is transmitted to the controller 110, and common interface units 111 include SATA, PCIe, and the like; the central processing unit 114 is, for example, a CPU, and is configured to control operations of various components in the solid state disk 100, for example, connect with the first cache unit 115, control storage and release of write data in the first cache unit 115, and store the write data in the first cache unit 115, where the first cache unit 115 is an SRAM; the flash memory controller 112 is connected with the central processing unit 114 and the flash memory 120, and writes write data into the flash memory 120 according to the control of the central processing unit 114; the cache controller 113 is connected to the central processor 114 and the second cache unit 130, and the second cache unit 130 is a DRAM. In this embodiment, the controller 110 controls the flash memory controller 112 through the central processing unit 114 therein, so as to control the flash memory 120.
The flash memory 120 is connected to the controller 110, and receives write data from the controller 110. The flash memory 120 includes a plurality of did 121 (Logical Unit, a minimum Unit in the flash memory 120 that can independently execute a command and report a command execution status, and a plurality of did are included in one flash memory 120), and the solid-state disk 100 of this embodiment divides each did 121 in the flash memory 120 into a plurality of Virtual did 1211 (Virtual did), and establishes a plurality of RAID stripe groups based on each Virtual did 1211.
As shown in fig. 2, each flash memory 120 includes a plurality of did 121, which are the smallest physical units within the flash memory 120 that can concurrently perform operations. Each DIE also comprises a plurality of planes (operation faces), each Plane comprises a plurality of blocks (physical blocks), each Block comprises a plurality of pages (physical pages), wherein the blocks are minimum units of erasing operation, and the pages are minimum units of reading and writing operation. The RAID stripe groups may be organized in units of physical pages within flash memory 120.
In this embodiment, taking a flash memory 120 containing 4 DIE121 (DIE 0, DIE1, DIE2, and DIE 3) as an example, each DIE121 includes at least two Virtual DIE1211, and each DIE121 in fig. 2 includes two Virtual DIE1211 (Virtual DIE), then the 4 DIE121 can be split into 8 Virtual DIE1211. A schematic of the structure inside each DIE121 is shown in the right side of fig. 2. Taking DIE1 as an example, each DIE121 contains a plurality of physical blocks, each identified by a Block number (named DIE 1Block 0, DIE 1Block1 … DIE 1Block M, DIE 1Block m+1 … … Block T, respectively, T being, for example, 255). The DIE121 may be divided into a plurality of virtual DIE1211 according to the number of physical blocks, and specifically, the plurality of virtual DIE1211 in each DIE121 includes the same number of physical blocks. Thus, each virtual did 1211 also includes a plurality of physical blocks, each re-identified with a block number according to the same rules. DIE1 split into two Virtual DIEs 1211 for Virtual DIE1 and Virtual DIE 5, with Virtual DIE1 comprising N+1 physical blocks (Virtual DIE 1Block 0-Virtual DIE 1Block N), virtual DIE 5 page comprising N+1 physical blocks (Virtual DIE 5Block 0-Virtual DIE 5Block N), the total number of physical blocks for two Virtual DIEs 1211 being equal to the number of all physical blocks in DIE 1.
In addition, the structure inside each physical block is also the same, specifically, each physical block includes a plurality of rows of physical pages, shown by row numbers (Page 0, page 1 … … Page X), each row representing one Page. Taking the example that a DIE includes two planes (Plane 0 and Plane 1), then two physical Page pages are contained in one row of a Block. Taking a portion of the physical pages on each virtual DIE1211 may form a RAID stripe group. Specifically, the physical page rows with the same row number in the physical blocks with the same block number in all the virtual did 1211 are taken as one RAID stripe group, so that a plurality of stripe groups are obtained, and the controller 110 receives write data and writes the write data into each stripe group one by one.
FIG. 3 is a schematic diagram of a RAID stripe group in a conventional solid state disk.
As shown in fig. 3, one flash memory includes 4 DIE121, and in conjunction with fig. 2 and 3, the flash memory includes DIE0, DIE1, DIE2, and DIE3. Multiple physical pages with the same line number (Page 0) in the same numbered physical blocks (Block N) in each DIE are combined into a RAID stripe group. The portion shown in the dashed box in fig. 3 is a Stripe group, denoted by Stripe 0. Typically, a stripe contains one or more physical pages, and several stripes together form a RAID stripe group, the number of stripes contained in the stripe group, i.e., the length of the RAID stripe group. Depending on the RAID policy, if any of the stripes making up the RAID stripe group fail, the data of the failed stripe may be recovered by the other stripes. The common RAID5 strategy has one stripe for storing check data, the other stripes for storing write data, wherein the check data is a result obtained by performing exclusive OR operation on each write data in the same stripe group, if the write data of one stripe is lost, the lost write data can be obtained by performing operation on the write data of other stripes, so that the write data is recovered.
For a solid state disk with only 4 DIE, the following ways of composing a RAID stripe group may be used according to the difference that the stripe contains physical pages: strategy one: 1 plane of 1 DIE is a stripe, each row of physical page has data protection, 1 DIE has 2 stripes, RAID stripe has 4 DIEs, 8 stripes, 7 stripes store write data, 8 th stripe store check data; strategy II: 2 planes of 1 DIE are one stripe, each row of physical page has data protection, 1 DIE has 1 stripe, RAID stripe has 4 DIEs, 4 stripes, 3 stripes store write data, and 4 th stripe store check data; strategy III: 1 plane of 1 DIE is a stripe, a plurality of rows of physical pages (e.g. 4 rows, page 0-Page 3) has one data protection, 1 DIE has 8 stripes, RAID stripe has 4 DIEs, 32 stripes, 31 of which store write data, and 32 of which store check data; strategy IV: 2 planes of 1 DIE are one stripe, a plurality of rows of physical pages (e.g., 4 rows, page 0-Page 3) have one data protection, 1 DIE has 4 stripes, RAID stripe has 4 DIEs, 16 stripes, 15 stripes storing write data, and 16 th stripe storing parity data. When the RAID of the third policy or the fourth policy is used to protect data, if there are multiple consecutive rows of physical pages (for example, page 1 and Page2 are simultaneously) in the same DIE, at least two stripes in one stripe group have data errors and cannot be corrected by RAID, so that the solid state disk generally uses such a storage mode less. When the first strategy and the second strategy are used, although each row can recover data in the corresponding stripe group when the physical page of the continuous row is in error, a larger space for checking the data is required, for example, the solid state disk of the first strategy needs to lose 1/8 of available space for storing the checking data, and the second strategy loses 1/4 of available space. This is a significant space penalty for solid state drives.
The invention improves the traditional solid state disk, so that the space required by RAID can be reduced, and a better data protection function is achieved. Therefore, the invention also provides a management method of the solid state disk, and the method is specifically described with reference to fig. 4-7.
Fig. 4 shows a flowchart of a method for managing a solid state disk according to an embodiment of the present invention.
In the management method of the solid state disk, the solid state disk can increase the number of DIEs by constructing the virtual DIEs, so that the length of the RAID stripe group is increased, and the requirement on RAID space is reduced.
Referring to fig. 2 and 4, the management method for the solid state disk 100 of the present embodiment is executed by the controller 110, and specifically includes the following steps:
In step S101, a plurality of did is divided into a plurality of virtual did. In this step, each DIE121 is divided into a plurality of virtual DIE1211, and the number of virtual operation units 1211 is a multiple of the number of DIE 121. In the present invention, one DIE121 may be divided into a plurality of virtual DIE1211 (the embodiment shown in fig. 4 to 6), and in addition, a plurality of DIE121 may be combined into one virtual DIE1211 (the embodiment shown in fig. 7).
In step S102, a plurality of RAID stripe groups are established based on the plurality of virtual DIEs. In this step, since virtual DIE1211 is actually part of DIE121, it can be regarded as a new DIE121, and virtual DIE1211 is used to replace DIE121 to create a RAID stripe group, and the new RAID stripe group is created based on virtual DIE 1211. Then, since the number of virtual did 1211 is different from did 121, the length of the RAID stripe group was changed. Taking the strategy one mentioned in fig. 3 as an example, if there are 4 did 121, when the virtual did is not partitioned, there are only 8 stripes for one RAID stripe group; and if divided into 8 virtual did, a RAID stripe group has 16 stripes.
In step S103, a mapping relationship between a logical address and a physical address of the data to be stored is established according to the length of the RAID stripe group. In this step, a mapping relationship between the did 121 and the virtual did 1211 needs to be established. Then, after the solid state disk 100 is powered on, a mapping relationship between the virtual DIE and the actual DIE is first constructed, and a relationship between a logical address and a physical address of data to be stored, for example, write data is established. Different virtual levels can be set according to different data management requirements, but the mapping relation constructed after each power-on is the same in the same batch operation of the solid state disk 100. It should be understood that since the flash memory 120 has a read/write unit of a page, and the page size is typically 4KB or 8KB, but write data sent via the host 200 is typically performed according to the sector size of the hard disk (typically 512 bytes), write data received from the host 200 needs to be converted into write data organized in units of pages of the flash memory, but the host 200 also needs to access these write data, so that address mapping data of a logical address (the write data may be accessed by the subsequent host 200 based on the logical address) and a physical address (for specifying the storage location of the actual write data in the flash memory 120) needs to be established. For example, the location actually stored on the did 1211 is the physical address of the data and the location on the virtual did is the logical address.
In step S104, data is stored in and accessed to the flash memory according to the mapping relation. The method comprises the following steps: according to the mapping relation, the data to be stored are stored in the physical address according to the storage mode of the RAID stripe group; when the flash memory 120 is accessed, the physical address is converted into a logical address according to the mapping relationship.
Specifically, in this step, during the operation of the solid state disk 100, various data are managed in the DIE1211 according to the mapping relationship. Before accessing the flash memory 120, the data needs to be converted to a logical address according to the mapping relationship. For example, the controller 110 continuously receives write data transmitted from the host 200. If the mapping relationship has been established during the operation of the solid state disk 100, the controller 110 will manage various data in the DIE1211 according to the mapping relationship after receiving the write data, and write the write data into the real physical address according to the mapping relationship. Further, when the host 200 accesses the memory 120, a logical address of the user data is obtained, and a physical address of the user data is obtained by searching with the logical address as an index.
Further, according to the first strategy mentioned in fig. 3, for each stripe group, write data is written to all physical pages before the last physical page of the stripe group on a physical page-by-physical page basis, and then check data is generated and written to the last physical page of the stripe group.
Therefore, the adjustment of the RAID stripe group length is realized, the RAID stripe group length is changed while the data protection is realized, the required space of RAID is changed, and the data protection capability is improved.
FIG. 5 shows a schematic block diagram of the inside of a flash memory in a solid state disk according to a first embodiment of the present invention; fig. 6 shows a schematic diagram of a RAID stripe group according to a first embodiment of the present invention.
In the first embodiment, as shown in fig. 5, the multiple DIE121 are divided into multiple Virtual DIE1211, and the structure inside each Virtual DIE1211 is referred to in fig. 2, as in fig. 5, the original DIE 0 is divided into the current Virtual DIE 0 and Virtual DIE 4, the DIE1 is divided into the Virtual DIE1 and the Virtual DIE 5, the DIE 2 is divided into the Virtual DIE 2 and the Virtual DIE 6, the DIE 3 is divided into the Virtual DIE 3 and the Virtual DIE 7, and each Virtual DIE1211 can be regarded as one DIE121, so that the number of DIE121 for creating a RAID stripe group is increased. The RAID protection data of the first strategy and the second strategy can be supported by the solid state disk with smaller DIE number, RAID resource overhead is reduced, and the data protection capability of the solid state disk is improved.
The step of establishing a plurality of RAID stripe groups with reference to the plurality of virtual operating units 1211 includes: numbering a plurality of physical blocks in each virtual operation unit 1211; combining physical pages with the same row number in physical blocks with the same block number in each virtual operation unit 1211 into the same RAID stripe group; a plurality of RAID stripe groups are established in the order of block numbers and the order of row numbers. Each RAID stripe group includes a plurality of stripes that occupy the same space, each row of physical pages of each virtual DIE1211 including two physical pages, each stripe including one or two physical pages. One of the stripes is used to store the parity data and the remaining stripes are used to store the write data to be stored. The RAID protection data of the first strategy and the second strategy can be supported by the solid state disk with larger DIE number, the RAID stripe length is reduced, and the data protection capability of the solid state disk is improved.
Referring to fig. 6, the same Block N of all Virtual operation units 1211 is selected, and Plane 0 of Page 0 of Virtual DIE 0 is denoted by (0, 0), plane 1 of Page 0 of Virtual DIE1 is denoted by (1, 1) … …, and then a RAID Stripe group established by the first (Page 0) physical Page of the 8 Virtual DIE1211 is denoted by Stripe 1, and the Stripe group is merged by the physical pages with the same Page number in the same physical Block in each Virtual DIE 1211. Taking policy one as an example, the present stripe group includes 16 stripes, (7, 1) as the check information storage bits, and the rest of the stripes store data, compared with the same flash memory in fig. 3, in the RAID stripe group of the present embodiment, the check information occupation space is reduced to 1/16, which saves half of the space compared with the original 1/8, so that the space requirement on the RAID is reduced. The 8 virtual DIEs 1211 can establish a plurality of RAID stripe groups, the occupied space of the whole check data is reduced by 1/2 compared with the original check data, the occupied space of the write data is improved, and the data can be effectively protected. In addition, if more virtual did 1211 are built (i.e., one did is split into 3 or more virtual did), the space requirements drop even more.
Fig. 7 is a schematic structural diagram showing the inside of a flash memory in a solid state disk according to a second embodiment of the present invention.
In a second embodiment, dividing the plurality of did 121 into a plurality of virtual did 1211 includes: every at least two DIE121 are combined into one virtual DIE1211. As shown in fig. 7, the original 2 did 121 are combined into one virtual did 1211, and taking the example that the original storage granule contains 8 did, 4 virtual did are formed after the combination. Taking policy one as an example, when the RAID stripe group is established, the length of the stripe group is reduced, and the occupied space of verification information is increased. For the solid state disk with large storage space, as each row of physical pages can form RAID stripes, verification data are increased, so that the error rate of the data is reduced, and the data recovery rate is improved.
Therefore, the management method of the solid state disk and the solid state disk provided by the embodiment of the application can be suitable for different scenes, and the management method of the first embodiment can be adopted for the solid state disk with smaller DIE number, so that RAID resource overhead is reduced, the data storage space is enlarged, the solid state disk with smaller capacity can store data as much as possible, and the effect of improving the data protection capability of the solid state disk is achieved. The method can also support the data protection of the solid state disk with larger DIE number, and the management method of the second embodiment reduces RAID stripe length, reduces error rate of data storage, improves verification rate and improves data protection capability of the solid state disk. The management method can be changed at any time according to actual conditions, the management method of the first embodiment is adopted for some solid state disks, and the management method of the second embodiment is adopted for others, so that the protection capability of the solid state disks on key data is improved.
In summary, according to the management method of the solid state disk and the solid state disk provided by the invention, the DIE in the flash memory is divided into the plurality of virtual operation units, and the RAID stripe group is established based on the DIE, so that the length of the RAID stripe group is increased, the occupied space of check data in the RAID stripe group is correspondingly reduced, the requirement on RAID space is reduced, the data protection capability and management capability are improved, and the read-write efficiency and quality of the solid state disk are improved.
Embodiments in accordance with the present invention, as described above, are not intended to be exhaustive or to limit the invention to the precise embodiments disclosed. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the invention and the practical application, to thereby enable others skilled in the art to best utilize the invention and various modifications as are suited to the particular use contemplated. The invention is limited only by the claims and the full scope and equivalents thereof.