Data storage method and related equipment

By introducing two storage areas with high performance and low performance in flash memory and dynamically managing them according to data types, the performance bottlenecks of existing flash memory when reading and writing data are solved, and more efficient data storage and read performance is achieved.

CN113590501BActive Publication Date: 2025-03-28HUAWEI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010371512.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-30
Publication Date
2025-03-28
Estimated Expiration
2040-04-30

AI Technical Summary

Technical Problem

There are performance bottlenecks when reading and writing data, especially when reading data, existing flash memory has performance bottlenecks that affect overall performance and user experience.

Method used

By introducing two storage areas in the storage device, a first storage area with high storage performance and a second storage area with low storage performance, and data are stored separately in different areas upon writing according to the data type. When data is recycled, it is determined based on the data type whether it continues to reside in a high-performance area or recycles to a low-performance area.

Benefits of technology

Improves the comprehensive reading/writing performance of data, especially for data types with high read performance requirements, which can be read directly from high-performance storage areas, improving user experience and system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113590501B_ABST
    Figure CN113590501B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a data storage method and related equipment, which are applied to a storage device, wherein the storage device is a non-volatile memory, and includes at least a first storage area and a second storage area, and the method includes: receiving a write command for target data, wherein the write command includes a data type identifier of the target data; according to the write command, writing the target data and the data type identifier into the first storage area; if the storage space occupied by the target data needs to be reclaimed, identifying the data type of the target data according to the data type identifier; if it is determined that the target data is of the first type, retaining the target data in the first storage area; if it is determined that the target data is of the second type, moving the target data to the second storage area. The use of the embodiment of the present invention can improve the read and write performance of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of storage technology, and in particular to a data storage method and related equipment. Background Art

[0002] With the continuous development of storage technology, flash memory with NAND Flash as storage medium has gradually become the mainstream storage form. NAND Flash is a non-volatile random access storage medium, the characteristic of which is that the data does not disappear after power failure. At present, according to different storage principles, NAND Flash mainly includes the following types: single-level cell (SLC), multi-level cell (MLC) and triple-level cell (TLC). Among them,

[0003] (1) SLC has only two charge values: 0 and 1, that is, 1 storage unit can store 1 bit of data (1 bit per cell), and has a lifespan of about 100,000 erase and write cycles. This design of SLC improves durability, accuracy, and storage performance, and is characterized by high cost, small capacity, and fast read and write speeds.

[0004] (2) MLC has four charge values: 00, 01, 10, and 11, that is, one storage unit can store 2 bits of data (2 bits per cell), and has a life span of about 10,000 erase and write cycles. MLC has twice the capacity of SLC, but at the cost of reduced service life and reliability. In general, its characteristics are average cost, average capacity, and much slower read and write speed than SLC.

[0005] (3) TLC has eight charge values: 000, 001, 010, 011, 100, 101, 110 and 111, that is, one storage unit can store 3 bits of data (3 bits per cell), and has a lifespan of about 5,000 erase and write cycles. TLC has twice the capacity of SLC, but its cost is also a lower lifespan and lower reliability. In general, its characteristics are low cost, large capacity, and much slower read and write speeds than SLC and MLC. It is usually used in consumer electronic products with relatively low performance and durability requirements.

[0006] Based on the above-mentioned characteristics of SLC with fast storage speed but high cost, and MLC / TLC with low cost but slow storage speed, SLC buffer technology has been introduced in the prior art, especially in the application of mobile terminals. SLC Buffer technology is to add a high-performance SLC write buffer to the flash memory. When data needs to be written, the host side will first write the data to the SLC buffer in the flash memory; when the flash memory is idle, the data will be moved from the SLC buffer to the place where the data is actually stored - the TLC storage area. The core content of this technology is to introduce a combination of SLC and TLC, and use the fast reading and writing characteristics of SLC to improve the performance of TLC-based flash memory, so that users will have an extremely fast experience at the beginning of writing.

[0007] However, in actual user usage scenarios, the flash memory not only writes data but also reads data. In the flash memory using the SLCBuffer technology, when data is read from the TLC storage area, the slow reading speed will still be exposed, which will affect the overall performance of the flash memory and the user experience. Therefore, how to provide a flash memory with low cost and better read and write performance is an urgent problem to be solved. Summary of the invention

[0008] The embodiment of the present invention provides a data storage method and related equipment to improve the reading and writing performance of stored data.

[0009] In a first aspect, an embodiment of the present invention provides a data storage method, which is applied to a storage device, wherein the storage device is a non-volatile memory, and includes at least a first storage area and a second storage area, and the storage performance of the first storage area is better than that of the second storage area; the method may include: receiving a write command for target data, the write command including a data type identifier of the target data; according to the write command, writing the target data and the data type identifier into the first storage area; if the storage space occupied by the target data needs to be reclaimed, identifying the data type of the target data according to the data type identifier; the data type includes a first type and a second data type; if it is determined that the target data is of the first type, retaining the target data in the first storage area; if it is determined that the target data is of the second type, moving the target data to the second storage area; wherein the storage performance requirement of the first type of data is higher than that of the second type of data.

[0010] In the embodiment of the present invention, when writing data to a storage device (e.g., a mobile phone flash memory), all types of data are first uniformly written into a first storage area with better storage performance (e.g., random read / write performance, etc.) to improve the write performance of the initial storage of the target data; because the data type identifier of the data is carried in the data write command, and the corresponding data type identifier is stored while writing the target data, when the storage space occupied by the target data (e.g., the physical block) is to be reclaimed later, it can be determined according to the data type identifier whether the target data continues to reside in the first storage area with better storage performance or is reclaimed to the second storage area with relatively poor storage performance. When the host side needs to read the target data next time, it can be directly read from the storage area where it is located to ensure that different types of data have different storage performance requirements, especially to improve the reading speed of the first type of data. For example, when the storage space for target data is reclaimed, if the target data is the first type of data with higher random read performance requirements, it will continue to reside in the first storage area; if the target data is the second type of data with slightly lower random read performance requirements, it can be recycled to the second storage area; subsequently, when the host side reads the first type of target data from the first storage area, the reading speed of the first type of data can be improved based on the better storage performance provided by the first storage area, thereby meeting its higher random read performance requirements. In summary, the embodiments of the present invention can greatly improve the comprehensive read / write performance of data.

[0011] In one possible implementation, the method further includes: receiving a read command for the target data; if the target data is of the first type, controlling the target data to be read out from the first storage area; if the target data is of the second type, controlling the target data to be read out from the second storage area.

[0012] In the embodiment of the present invention, when the storage space of the target data is recycled, and the target data resides in the first storage area or is recycled to the second storage area, if the host side needs to read the target data from the storage device, if the target data currently resides in the first storage area as the first type of data, then the host side directly reads the target data from the first storage area; if the target data currently is stored in the second storage area as the second type of data, then the host side directly reads the target data from the second storage area. When the target data is the first type of data with higher storage performance requirements, it can be directly read from the first storage area with better storage performance to improve the reading performance of the first type of data.

[0013] In a possible implementation, if it is determined that the target data is of the first type, retaining the target data in the first storage area includes: if it is determined that the target data is of the first type, retaining the target data and the data type identifier in the first storage area.

[0014] In the embodiment of the present invention, after the target data is determined to be of the first type, the target data and its corresponding data type identifier are stored together in the first storage area, and are not moved to the second storage area. That is, the data type identifier is used as one of the attributes of the target data, and is stored and circulated for a long time in the subsequent data reading / writing process, so that when the target data is subsequently moved or stored, the storage area can still be determined according to the stored data type identifier.

[0015] In a possible implementation, the storage device is one or more of a universal flash memory UFS, an embedded multimedia card eMMC, a universal flash storage multi-chip package uMCP memory, and an embedded multimedia card multi-chip package eMCP memory; the first storage area includes one or more of a single-layer unit SLC storage area, a fast and non-Fast NAND memory, a phase change memory PCM, and a 3D stacked phase change memory X3D, and the second storage area includes one or more of a multi-layer unit MLC storage area, a three-layer unit TLC storage area, a four-layer unit QLC storage area, and a five-layer unit PLC storage area.

[0016] In an embodiment of the present invention, the storage device may be various types of flash memory or flash memory chips used in mobile terminals, such as mobile phone flash memory or mobile phone flash memory chips. Among them, the storage device may include one or more of UFS, eMMC, eMCP, and uMCP. Specifically, the first storage area may include one or more of SLC, Fast NAND, PCM, and X3D, and the second storage area may include one or more of MLC, TLC, QLC, and PLC.

[0017] In a possible implementation, the writing the target data and the data type identifier into the first storage area includes: writing the target data and the data type identifier into a first storage block Block in the first storage area; if it is determined that the target data is of the first type, retaining the target data in the first storage area includes: if it is determined that the target data is of the first type, moving the target data and the data type identifier from a first Block in the first storage area to a second Block in the first storage area.

[0018] In an embodiment of the present invention, when reclaiming the storage space occupied by the target data, according to the characteristics of certain storage media, it may be necessary to rewrite the target data into other physical blocks in the first storage area, thereby freeing up the storage space occupied by the target data. For example, in SLC, the storage space is reclaimed in units of physical blocks (i.e., erasure is in units of blocks), so when the storage space occupied by the target data is reclaimed, it is actually a whole recovery of the physical block where the target data is located. Therefore, it is necessary to move all valid data in the physical block where the target data is located. Specifically, the storage space of the entire physical block is reclaimed by moving the first type of target data to another physical block in the first storage area and moving the second type of target data to the second storage area.

[0019] In a possible implementation, the first storage area includes an SLC storage area; the SLC storage area includes a static SLC storage area and a dynamic SLC storage area; the first Block is a Block in the static SLC storage area, and the second Block is a Block in the dynamic SLC storage area; or, the first Block is a Block in the dynamic SLC storage area, and the second Block is a Block in the static SLC storage area, or, both the first Block and the second Block are Blocks in the static SLC storage area; or, both the first Block and the second Block are Blocks in the extended dynamic SLC storage area.

[0020] In the embodiment of the present invention, when the first storage area is an SLC storage area and includes a static SLC storage area and a dynamic SLC storage area, the target data (whether of the first type or the second type) can be initially stored in the static or dynamic SLC storage area. That is, in the embodiment of the present invention, there is no specific limitation on whether the target data is initially stored in the dynamic or static SLC area, and when the target data is subsequently moved, there is no specific limitation on whether it is moved between blocks in the static and static SLC storage areas, or between blocks in the dynamic and dynamic SLC storage areas, or between blocks in the static and dynamic SLC storage areas, as long as the first type of data is moved between blocks in the SLC storage area.

[0021] In a possible implementation, if it is determined that the target data is of the second type, the target data is moved to the second storage area, including: if it is determined that the target data type is of the second type, the target data and the data type identifier are rewritten into the second storage area, and the target data in the first storage area is set to invalid. Optionally, the data type identifier of the second type of target data may also be deleted this time.

[0022] In the embodiment of the present invention, when the target data is the second type of data, when the storage space occupied by the target data is recycled, since the data of this type has a lower storage performance requirement, more space in the first storage area can be reserved for the first type of data with a higher storage performance requirement by recycling it to the second storage area. Specifically, the recycling to the second storage area is to rewrite the target data and the corresponding data type identifier into the second storage area, and set the original target data in the first storage area to be invalid, thereby realizing the movement of the second type of data.

[0023] In a possible implementation, the storage performance includes one or more of random read performance, random write performance, and storage life.

[0024] In the embodiment of the present invention, the random read performance, random write performance or storage life of the first storage area is better than that of the second storage area, and correspondingly, the first type of data has higher requirements for random read performance, random write performance or storage time than the second type of data. That is, data with different performance requirements are stored in storage areas that meet their different performance requirements, thereby improving the overall performance of data storage.

[0025] In a possible implementation, the first type of data includes one or more of file system metadata, a high-frequency access database, and swap area SWAP data.

[0026] In an embodiment of the present invention, the first type of data may be index data in a file system, or a database frequently accessed by users, or SWAP data temporarily replaced from a memory space and which may be subsequently restored at any time. Setting the above data as the first type of data may further improve the operating efficiency and performance of the storage system or the host system where the storage system is located.

[0027] In a second aspect, an embodiment of the present invention provides a data storage method, which is applied to a host. The method may include:

[0028] Determine a data type of target data to be written into a storage device; the data type includes a first type or a second type;

[0029] generating a write command for the target data, the write command comprising a data type identifier of the target data; the data type identifier is used to identify the first type or the second type;

[0030] The write command is sent to the storage device, where the write command is used to instruct the storage device to store the target data and the data type identifier.

[0031] In a possible implementation, the method further includes:

[0032] Determine whether the target data is any one of file system metadata, high-frequency access database, or swap area SWAP data;

[0033] If yes, determining the target data as the first type of data;

[0034] If not, the target data is determined to be the second type of data, and the storage performance requirement of the first type of data is higher than that of the second type of data.

[0035] In a possible implementation, the method further includes:

[0036] Sending a read command for the target data to the storage device;

[0037] If the target data is of the first type, reading the target data and the data type identifier from the first storage area;

[0038] If the target data is of the second type, the target data and the data type identifier are read from the second storage area.

[0039] In a possible implementation, the host further includes an internal memory, and the internal memory is a volatile memory;

[0040] The method further includes: storing the read target data and the data type identifier in the internal memory.

[0041] In a third aspect, an embodiment of the present invention provides a storage device, which is a non-volatile memory, and may include: a storage controller, a solid-state storage array coupled to the storage controller, the solid-state storage array includes at least a first storage area and a second storage area, and the storage performance of the first storage area is better than that of the second storage area; wherein,

[0042] The storage controller is used for:

[0043] receiving a write command for target data, wherein the write command includes a data type identifier of the target data;

[0044] Writing the target data and the data type identifier into the first storage area according to the write command;

[0045] If the storage space occupied by the target data needs to be reclaimed, identifying the data type of the target data according to the data type identifier;

[0046] If it is determined that the target data is of the first type, the target data is retained in the first storage area; if it is determined that the target data is of the second type, the target data is moved to the second storage area; wherein the storage performance requirement of the first type of data is higher than that of the second type of data.

[0047] In a possible implementation, the storage controller is further configured to:

[0048] receiving a read command for the target data;

[0049] If the target data is of the first type, controlling to read the target data from the first storage area;

[0050] If the target data is of the second type, the control reads the target data from the second storage area.

[0051] In a possible implementation, the storage controller is specifically configured to:

[0052] If it is determined that the target data is of the first type, the target data and the data type identifier are retained in the first storage area.

[0053] In a possible implementation, the storage device is one or more of a universal flash memory UFS, an embedded multimedia card eMMC, a universal flash storage multi-chip package uMCP memory, and an embedded multimedia card multi-chip package eMCP memory; the first storage area includes one or more of a single-layer unit SLC storage area, a fast and non-Fast NAND memory, a phase change memory PCM, and a 3D stacked phase change memory X3D, and the second storage area includes one or more of a multi-layer unit MLC storage area, a three-layer unit TLC storage area, a four-layer unit QLC storage area, and a five-layer unit PLC storage area.

[0054] In a possible implementation, the storage controller is specifically configured to:

[0055] Writing the target data and the data type identifier into a first storage block Block in the first storage area;

[0056] If it is determined that the target data is of the first type, the target data and the data type identifier are moved from the first Block in the first storage area to the second Block in the first storage area.

[0057] In a possible implementation, the first storage area includes an SLC storage area; the SLC storage area includes a static SLC storage area and a dynamic SLC storage area;

[0058] The first Block is a Block in the static SLC storage area, and the second Block is a Block in the dynamic SLC storage area; or,

[0059] The first Block is a Block in the dynamic SLC storage area, and the second Block is a Block in the static SLC storage area, or,

[0060] The first Block and the second Block are both Blocks in the static SLC storage area; or,

[0061] The first Block and the second Block are both Blocks in the extended dynamic SLC storage area.

[0062] In a possible implementation, the storage controller is specifically configured to:

[0063] If it is determined that the target data type is the second type, the target data and the data type identifier are rewritten into the second storage area, and the target data in the first storage area is set to be invalid.

[0064] In a possible implementation, the storage performance includes one or more of random read performance, random write performance, and storage life.

[0065] In a possible implementation, the first type of data includes one or more of file system metadata, a high-frequency access database, and swap area SWAP data.

[0066] In a fourth aspect, an embodiment of the present invention provides a host, which may include: a host controller, wherein:

[0067] The host controller is used for:

[0068] Determine a data type of target data to be written into a storage device; the data type includes a first type or a second type;

[0069] generating a write command for the target data, the write command comprising a data type identifier of the target data; the data type identifier is used to identify the first type or the second type;

[0070] The write command is sent to the storage device, where the write command is used to instruct the storage device to store the target data and the data type identifier.

[0071] In a possible implementation, the host controller is further configured to:

[0072] Determine whether the target data is any one of file system metadata, high-frequency access database, or swap area SWAP data;

[0073] If yes, determining the target data as the first type of data;

[0074] If not, the target data is determined to be the second type of data, and the storage performance requirement of the first type of data is higher than that of the second type of data.

[0075] In a possible implementation, the host controller is further configured to:

[0076] Sending a read command for the target data to the storage device;

[0077] If the target data is of the first type, reading the target data and the data type identifier from the first storage area;

[0078] If the target data is of the second type, the target data and the data type identifier are read from the second storage area.

[0079] In a possible implementation, the host further includes an internal memory, and the internal memory is a volatile memory;

[0080] The host controller is further used to store the read target data and the data type identifier in the internal memory.

[0081] In a fifth aspect, an embodiment of the present invention provides an electronic device, which may include: a host and a storage device coupled to the host;

[0082] The host is the host described in any one of the implementations of the fourth aspect above;

[0083] The storage device is the storage device described in any one of the implementations in the third aspect above.

[0084] In a sixth aspect, an embodiment of the present invention provides a data storage method, which is applied to an electronic device, wherein the electronic device includes an internal memory and an external memory, the internal memory includes a normal partition and a SWAP partition, the external memory includes a first storage area and a second storage area, the storage performance of the first storage area is better than that of the second storage area, and the method may include: the electronic device runs N applications, and the running data of the N applications are stored in the internal memory; the N applications include a first application, the first application is an application running in the foreground, and the first application occupies part of the space of the normal partition, and N is a positive integer; in response to a startup operation of the second application, the electronic device determines the remaining space of the normal partition and the remaining space of the swap SWAP partition; if the normal partition If both the remaining space of the SWAP partition and the remaining space of the SWAP partition are insufficient, the data of the SWAP partition is determined as the first type of data, stored in the first storage area, and the SWAP partition is cleared; the running data of M applications among the N applications are compressed, and the compressed running data are stored in the SWAP partition, and the ordinary partition occupied by the M applications is released; wherein the M applications include the first application; the second application is run in the foreground; the second application occupies part or all of the ordinary partition occupied by the released M applications; in response to the startup operation of the first application, the running data of the first application is read from the SWAP partition; the running data of the first application is decompressed, and the first application is run in the foreground.

[0085] In an embodiment of the present invention, when the memory space of the electronic device is insufficient, including the insufficient space of the SWAP partition in the memory, the data of the SWAP partition can be determined as the first type of data in the embodiment of the present invention, and the first type of data is stored in the first storage area in the external memory, so that the space of the SWAP partition in the internal memory can be released, so part of the data of the ordinary partition in the internal memory can be further compressed to the SWAP partition and the space of the ordinary partition can be released again to meet the memory space requirements of more applications. Based on the above, the application that may need to be killed can be kept in the first storage area with a faster storage speed instead of being killed, so as to achieve the effect of expanding the SWAP partition. The survival rate of the background application when the memory space is insufficient is improved, that is, under the condition of the same memory space size, the electronic device provided by the embodiment of the present invention can make more applications retain their runtime data (including their context state) and achieve the purpose of not being checked and killed. When the user needs to call it back from the background, it can return to the state where the application is suspended, which greatly improves the user experience.

[0086] In a possible implementation, before reading the running data of the first application from the SWAP partition, the method also includes: searching for the running data of the first application in the first storage area; and reading the running data of the first application contained in the first storage area into the SWAP partition.

[0087] In the embodiment of the present invention, in some possible situations, for example, when the second application is running in the foreground, the user runs other applications, resulting in insufficient remaining space in the normal partition and the SWAP partition. In this case, it is necessary to execute the process of determining the data of the SWAP partition as the first type of data, storing it in the first storage area, and clearing the SWAP partition again; that is, the compressed running data of the M applications among the above-mentioned N applications will be transferred from the SWAP partition to the first storage area, and the SWAP partition will be cleared. Since the compressed running data of the M applications includes the compressed running data of the first application, if the user needs to restore the first application later, the compressed running data of the first application is searched in the first storage area and reloaded into the SWAP partition, and then restored from the SWAP partition to the normal partition for normal operation.

[0088] In a possible implementation, the method further includes: selecting M applications with high priorities from the N applications to be determined as the M applications, and releasing the space of the common partition occupied by L applications with low priorities from the N applications.

[0089] In the embodiment of the present invention, for some applications that are less frequently used by some users or have a lower priority, they can be checked and killed when the memory space (such as the remaining space in the ordinary partition) is insufficient, and the space occupied by them in the ordinary partition is directly released, that is, they are not allowed to occupy the space of the SWAP partition, and the space of the ordinary partition and the SWAP partition is reserved for applications with higher priority or programs with high user frequency. Among them, the priority of the application can be determined by the electronic device by monitoring the user's frequency of use, or it can be manually set by the user, such as setting the application that he wants to keep alive more to a high priority and setting other ordinary applications to a low priority.

[0090] In one possible implementation, determining the data of the SWAP partition as the first type of data and storing it in the first storage area includes: generating a write command for the data of the SWAP partition, the write command including the first type of data type identifier of the data of the SWAP partition; and storing the data of the SWAP partition and the first type of data type identifier in the first storage area according to the write command.

[0091] In an embodiment of the present invention, after the data of the SWAP partition is determined to be data of the first type, the data type identifier of the data of the SWAP partition is carried in the write command of the data of the SWAP partition, and its corresponding data type identifier is stored while writing the data of the SWAP partition. Therefore, when the storage space occupied by the data of the SWAP partition (such as the physical block where it is located) is to be reclaimed subsequently, it can be determined based on the data type identifier that the data of the SWAP partition can continue to reside in the first storage area with better storage performance, rather than being reclaimed as second type data to the second storage area with relatively poor storage performance.

[0092] In one possible implementation, the method further includes: if the storage space of the first storage area meets the recycling conditions, retaining the first type of data in the first storage area and recycling the second type of data to the second storage area; wherein the storage performance requirement of the first type of data is higher than that of the second type of data.

[0093] In an embodiment of the present invention, various types of data can be uniformly written into a first storage area with better storage performance (such as random read / write performance, etc.) to improve the write performance of the initial storage of various types of data; because the data type identifier of the data is carried in the data write command, and its corresponding data type identifier is stored when the data is written, when the storage space occupied by the data (such as the physical block) is to be reclaimed later, it can be determined based on the data type identifier whether the data continues to reside in the first storage area with better storage performance, or is reclaimed to the second storage area with relatively poor storage performance.

[0094] In a possible implementation, storing the data of the SWAP partition and the data type identifier of the first type in the first storage area includes: storing the data of the SWAP partition and the data type identifier of the first type in a first storage block Block in the first storage area; if the storage space of the first storage area meets the recycling condition, retaining the data of the first type in the first storage area, including: if the storage space of the first storage area meets the recycling condition, moving the data of the SWAP partition and the data type identifier of the first type from the first storage block Block in the first storage area to the second Block in the first storage area.

[0095] In an embodiment of the present invention, when the storage space occupied by the data of the SWAP partition in the first storage area is reclaimed, according to the characteristics of certain storage media, it may be necessary to rewrite the data of the SWAP partition into other physical blocks in the first storage area, thereby freeing up the storage space occupied by the data of the SWAP partition. For example, in SLC, the storage space is recovered in units of physical blocks (i.e., erasure is in units of blocks), so when the storage space occupied by the data of the SWAP partition is recovered, it is actually recovered as a whole for the physical block where the data of the SWAP partition is located. Therefore, all valid data in the physical block where the data of the SWAP partition is located needs to be moved. Specifically, the storage space of the entire physical block is recovered by moving the data of the first type of SWAP partition to another physical block in the first storage area and moving other data of the second type to the second storage area.

[0096] In a seventh aspect, an embodiment of the present invention provides a data storage device, characterized in that it is applied to an electronic device, the electronic device includes an internal memory and an external memory, the internal memory includes a normal partition and a SWAP partition, the external memory includes a first storage area and a second storage area, the storage performance of the first storage area is better than that of the second storage area, and the device includes:

[0097] A first running unit, configured to run N applications, wherein running data of the N applications are stored in the internal memory; the N applications include a first application, the first application is an application running in the foreground, the first application occupies part of the space of the common partition, and N is a positive integer;

[0098] A first response unit, configured to, in response to a start operation of a second application, determine, by the electronic device, a remaining space of the common partition and a remaining space of the swap partition;

[0099] A first storage unit is used for determining the data of the SWAP partition as the first type of data, storing the data in the first storage area, and clearing the SWAP partition if the remaining space of the common partition and the remaining space of the SWAP partition are both insufficient; compressing the running data of M applications among the N applications, storing the compressed running data in the SWAP partition, and releasing the common partition occupied by the M applications; wherein the M applications include the first application;

[0100] A second running unit is used to run the second application in the foreground; the second application occupies part or all of the common partitions occupied by the M applications that are released;

[0101] a second response unit, configured to read the running data of the first application from the SWAP partition in response to a start operation on the first application;

[0102] The third running unit is used to decompress the running data of the first application and run the first application in the foreground.

[0103] In a possible implementation manner, the device further includes:

[0104] a searching unit, configured to search the running data of the first application in the first storage area before reading the running data of the first application from the SWAP partition;

[0105] The running data of the first application program included in the first storage area is read into the SWAP partition.

[0106] In a possible implementation manner, the device further includes:

[0107] The determining unit is used to select M applications with high priorities from the N applications to be determined as the M applications, and release the space of the common partition occupied by L applications with low priorities from the N applications.

[0108] In a possible implementation, the first storage unit is specifically configured to:

[0109] Generate a write command for the data of the SWAP partition, the write command including a data type identifier of a first type of the data of the SWAP partition;

[0110] According to the write command, the data of the SWAP partition and the data type identifier of the first type are stored in the first storage area.

[0111] In a possible implementation manner, the device further includes:

[0112] A second storage unit is used to retain the first type of data in the first storage area and recycle the second type of data to the second storage area if the storage space of the first storage area meets the recycling conditions; wherein the storage performance requirement of the first type of data is higher than that of the second type of data.

[0113] In a possible implementation, the first storage unit is specifically configured to: store the data of the SWAP partition and the data type identifier of the first type in a first storage block Block in the first storage area;

[0114] The second storage unit is specifically used to: if the storage space of the first storage area meets the recycling condition, move the data of the SWAP partition and the data type identifier of the first type from the first storage block Block in the first storage area to the second Block in the first storage area.

[0115] In an eighth aspect, the present application provides a semiconductor chip that may include a storage device involved in any one of the implementation methods in the third aspect above.

[0116] In a ninth aspect, the present application provides a semiconductor chip that may include a host involved in any one of the implementation methods in the fourth aspect above.

[0117] In a tenth aspect, the present application provides a chip system, which includes a storage device involved in any one of the implementations of the third aspect. The chip system may be composed of a chip, or may include a chip and other discrete devices.

[0118] In an eleventh aspect, the present application provides a chip system, which includes a host involved in any one of the implementations of the fourth aspect. The chip system may be composed of a chip, or may include a chip and other discrete devices.

[0119] In a twelfth aspect, the present application provides a chip system, which includes the electronic device involved in any one of the implementations of the sixth aspect. The chip system may be composed of a chip, or may include a chip and other discrete devices.

[0120] In a thirteenth aspect, the present application provides an electronic device comprising a processor and a memory, wherein the memory is used to store program code, and the processor is used to call the program code stored in the memory to execute a storage device involved in any one of the implementation methods in the sixth aspect above.

[0121] In a fourteenth aspect, the present application provides a system-on-chip (SoC) chip, which includes a host involved in any one of the implementations in the fourth aspect, and optionally, further includes an internal memory and an external memory coupled to the host. The SoC chip may be composed of a chip, or may include a chip and other discrete devices.

[0122] In a fifteenth aspect, the present application provides a storage device having the function of implementing any one of the data storage methods in the first aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.

[0123] In a sixteenth aspect, the present application provides a host having a function of implementing any one of the data storage methods in the second aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.

[0124] In a seventeenth aspect, the present application provides a terminal, the terminal comprising a host and a storage device, the host comprising the host involved in any one of the implementations in the fourth aspect, the storage device comprising the storage device involved in any one of the implementations in the third aspect. The terminal may also include a communication interface for the terminal to communicate with other devices or a communication network.

[0125] In an eighteenth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a storage device, the process of the data storage method described in any one of the above-mentioned first aspects is implemented.

[0126] In the nineteenth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a host, the process of the data storage method described in any one of the above-mentioned second aspects is implemented.

[0127] In the twentieth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, which, when executed by an electronic device, implements the process of the data storage method described in any one of the sixth aspects above.

[0128] In the twenty-first aspect, an embodiment of the present invention provides a computer program, which includes instructions. When the computer program is executed by a storage device, the storage device can execute the process of the data storage method described in any one of the above-mentioned first aspects.

[0129] In the twenty-second aspect, an embodiment of the present invention provides a computer program, which includes instructions. When the computer program is executed by a host, the host can execute the process of the data storage method described in any one of the above-mentioned second aspects.

[0130] In the twenty-third aspect, an embodiment of the present invention provides a computer program, which includes instructions. When the computer program is executed by an electronic device, the host can execute the process of the data storage method described in any one of the above-mentioned sixth aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0131] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the background technology, the drawings required for use in the embodiments of the present invention or the background technology will be described below.

[0132] Figure 1A The data flow architecture diagram of the dynamic and static SLC Buffer in the prior art.

[0133] Figure 1B The figure is a schematic diagram of the architecture of the SLC Zone technology in the prior art.

[0134] Figure 2A A schematic diagram of the structure of a host and a storage device provided in an embodiment of the present invention.

[0135] Figure 2B A schematic diagram of the structure of a storage device provided by an embodiment of the present invention.

[0136] Figure 2C Some user interface diagrams for adjusting the cache area and the general area provided in the embodiments of the present invention.

[0137] Figure 2D A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.

[0138] Figure 3A A schematic diagram of an interface for some users to perform quick mode settings provided in an embodiment of the present invention.

[0139] Figure 3B A schematic diagram of the structure of another electronic device provided by an embodiment of the present invention.

[0140] Figure 4A A schematic diagram of a write command format provided by an embodiment of the present invention.

[0141] Figure 4B A schematic diagram of another write command format provided by an embodiment of the present invention.

[0142] Figure 5A-Figure 5CSome schematic diagrams of writing new data into a static SLC storage area of ​​a storage device are provided in embodiments of the present invention.

[0143] Figure 6A-6C Some schematic diagrams of writing new data into a dynamic SLC storage area of ​​a storage device are provided in embodiments of the present invention.

[0144] Figure 7A-7C Some schematic diagrams of rewriting existing data into a dynamic SLC storage area of ​​a storage device are provided in embodiments of the present invention.

[0145] Figure 8A-8C Schematic diagram of data recovery in some garbage recovery processes provided by embodiments of the present invention.

[0146] Fig. 9A A flowchart of a data storage method provided by an embodiment of the present invention.

[0147] Fig. 9B A schematic structural diagram of another electronic device provided by an embodiment of the present invention.

[0148] Figure 9C-9E Schematic diagram of some user interface of applications provided by embodiments of the present invention.

[0149] Fig.10 The present invention provides an overall process of a data storage method. DETAILED DESCRIPTION

[0150] The embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0151] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0152] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0153] The terms "component", "module", "system", etc. used in this specification are used to represent computer-related entities, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program and / or a computer. By way of illustration, both applications running on a computing device and a computing device can be components. One or more components may reside in a process and / or an execution thread, and a component may be located on a computer and / or distributed between two or more computers. In addition, these components may be executed from various computer-readable media having various data structures stored thereon. Components may, for example, communicate through local and / or remote processes according to signals having one or more data packets (e.g., data from two components interacting with another component between a local system, a distributed system and / or a network, such as the Internet interacting with other systems through signals).

[0154] First, some terms in this application are explained to facilitate understanding by those skilled in the art.

[0155] (1) Not AND Flash (NAND Flash) is a non-volatile storage medium, which means that data can be stored even after power failure. Its development goal is to reduce the storage cost per bit and increase storage capacity. Usually, NAND Flash reads and writes in pages and erases in blocks. Due to the storage principle of Flash, writing data to Flash can only change the data (bit) from 1 to 0; while erasing can only change all data (bits) from 0 to 1. Therefore, when modifying data or writing new data, it must be written to the free page that has been erased, otherwise the data will be messed up.

[0156] (2) Solid State Drive (SSD), commonly known as SSD, is a hard disk made of solid-state electronic storage chip array. SSD consists of a control unit and a storage unit (FLASH chip, DRAM chip). Among them, the FLASH chip in the SSD usually uses the above-mentioned NAND Flash chip as its storage unit. The SSD is exactly the same as the ordinary hard disk in terms of interface specifications and definitions, functions and usage methods, and is also completely consistent with the ordinary hard disk in product appearance and size. It is widely used in many fields such as military, automotive, industrial control, video surveillance, network monitoring, network terminals, electricity, medical, aviation, navigation equipment, etc.

[0157] (3) SSD Over-Provision (OP) refers to the capacity that cannot be operated by users. The size is the actual capacity of the SSD minus the user-available capacity. In simple terms, OP can improve the wear-leveling of the SSD, reduce write amplification, improve random write performance, and extend the service life of the SSD.

[0158] (4) Flash Friendly File System (F2FS) is a file storage architecture on the operating system. It is a new open source flash file system designed specifically for NAND-based storage devices. F2FS supports the Linux operating system. It is suitable for NAND-based flash memory devices (such as solid-state drives, eMMC, and SD cards), which means it is more suitable for current mobile devices.

[0159] (5) The so-called META tag is an important HTML tag in the source code of an HTML web page. The META tag is used to describe the properties of an HTML web page document, such as author, date and time, web page description, keywords, page refresh, etc.

[0160] (6) Most Significant Bit (MSB) In a binary number, the MSB is the most weighted bit. Similar to the leftmost bit in a decimal number, the MSB is usually located at the leftmost side of a binary number.

[0161] (7) Least Significant Bit (Linux Standards Base, LSB) is the least significant bit in a binary number. It is similar to the rightmost bit in a decimal number. Usually, the LSB is located at the rightmost side of a binary number.

[0162] (8) Operation Code (OP). An instruction actually includes two types of information, namely, operation code and address code. OP is used to indicate the operation to be performed by the instruction (such as addition, subtraction, multiplication, division, data transfer, etc.). Its length depends on the number of instructions in the instruction system. The address code is used to describe the operation object of the instruction. It either directly gives the operand, or indicates the memory address or register address (i.e., register name) of the operand.

[0163] (9) Double Data Rate DDR = Double Data Rate, Double Data Rate Synchronous Dynamic Random Access Memory = DDRSDRAM, commonly referred to as DDR, where SDRAM is the abbreviation of Synchronous Dynamic Random Access Memory, and DDR SDRAM is the abbreviation of Double Data Rate SDRAM, which means double data rate synchronous dynamic random access memory. DDR memory is developed based on SDRAM memory and still uses the SDRAM production system. Therefore, for memory manufacturers, they only need to slightly improve the equipment for manufacturing ordinary SDRAM to realize the production of DDR memory, which can effectively reduce costs.

[0164] (10) Physical Extent (PE) Each physical volume is divided into basic units called PEs. A PE with a unique number is the smallest unit that can be addressed by the Logical Volume Manager (LVM). The size of a PE is configurable and defaults to 4MB.

[0165] (11) Failure rate refers to the probability that a product that has not failed at a certain time will fail per unit time after that time. It is usually denoted as λ. It is also a function of time t, so it is also denoted as λ(t). It is called the failure rate function, sometimes also called the failure rate function or risk function.

[0166] First, the technical problems to be solved by this application are further analyzed and proposed. In the field of flash memory storage technology, the SLC Buffer storage technology related to this application includes the following two mainstream technologies:

[0167] Technology 1: Dynamic and Static SLC Buffer Technology

[0168] The dynamic and static SLC Buffer technology builds a high-speed and reliable SLC Buffer in front of the low-speed and large-capacity TLC to provide high-speed write buffering for the host. Among them, the SLC Buffer can be further divided into: static SLC Buffer and dynamic SLC Buffer. The space provided by the static SLC Buffer is fixed, and the space provided by the dynamic SLC Buffer can be flexibly changed with the remaining available space. For example, the static SLC Buffer uses the NAND media supply industry practice to fix the reserved space (Over Provision) outside the TLC capacity specification (ie: 128GB, 256GB...) to SLC mode at one time. The dynamic SLC Buffer takes advantage of the fact that the User Data Area (especially large-capacity storage) is not easy to be full, and temporarily converts TLC to SLC to handle the write overflow scenario of the static SLC Buffer.

[0169] See also Figure 1A , Figure 1A The following is a data flow architecture diagram of the dynamic and static SLC Buffer in the prior art. In this architecture:

[0170] 1. The host writes data to the static SLC Buffer first.

[0171] 2. When the static SLC Buffer is full, the host side (Host) data is written to the dynamic SLC Buffer. Therefore, if there is more available storage space, the dynamic SLC Buffer space can be correspondingly larger; if there is less available space, the dynamic SLC Buffer space will be correspondingly smaller.

[0172] 3. The host side (Host) actively initiates data garbage collection operation, or when the host load is idle, the valid data enters the user data storage area (User Data Area) through the garbage collection (GC) operation from the dynamic and static SLC Buffer (including static SLC Buffer and dynamic SLC Buffer), and then resides in the main storage area in the MLC / TLC form.

[0173] The defect of technology 1: dynamic and static SLC Buffer technology. In essence, both dynamic and static SLC Buffer are used as temporary buffers. That is, after garbage collection, all data will be recycled to the user data area, which cannot achieve hot data retention, and cannot achieve cold-to-hot data migration back to SLC Buffer. In short, the read performance of hot data cannot enjoy the high performance of SLC.

[0174] Technology 2: SLC Zone Technology

[0175] SLC Zone technology only provides a number of SLC Blocks to ensure high reliability of metadata for small I / O systems. Most of the data is written directly to TLC based on TLC failure rate control (i.e., the failure rate is guaranteed not to exceed the standard before being directly written to TLC). For example, by taking advantage of the fact that the user data storage area (User Data Area), especially large-capacity storage, is not easy to be full, some TLCs are temporarily converted to SLCs to provide independent fast disks. At this time, for the HOST, it is reflected as 2 User Data Areas. Therefore, the SLC Zone hot data can be retained and the migration of cold-to-hot data can be achieved through HOST management.

[0176] See also Figure 1B , Figure 1B The following is a schematic diagram of the architecture of the SLC Zone technology in the prior art. In this architecture:

[0177] 1. The host can write data directly to User Data Area 1 (SLC Zone) or to User Data Area 2 via the static SLC Buffer. In principle, the data in User Data Area 1 does not enter User Data Area 2, so that hot data resides in User Data Area 1 (i.e., SLC Zone).

[0178] 2. When the static SLC Buffer is full, valid data is transferred from the static SLC Buffer to the TLC User Data Area 2 through garbage collection.

[0179] The defects of Solution 2: SLC Zone technology is essentially not an independent medium that provides a fast access area. User Data Area 1 and User Data Area 2 cannot have independent resources at the back-end media access level (for example, User Data Area 1 and User Data Area 2 share the read-write buffer located on the SRAM in the storage controller, etc.). When cross-reading and writing are performed in real user scenarios, the performance is not as good as expected. And because there are two write channels under this architecture, and the two write channels are actually one channel physically, but two channels logically, this may lead to a decrease in write processing performance, for example, mutual exclusion or occupation of each other. Therefore, when SLC or other fast new media cannot be commercialized in the short term due to technology, cost, and supply, the benefits of SLC Zone technology will continue to fall short of expectations.

[0180] To summarize, the technical problems that the present application actually aims to solve include the following aspects: In view of the limitations of existing storage technologies, a solution for accelerating the reading / writing of storage data is provided, and the solution can be built on mainstream technology trends (i.e., including dynamic and static SLC Buffer technologies), so as to improve the comprehensive reading and writing performance of flash memory at a relatively low cost, especially to improve the reading performance of certain types of data (such as hot data).

[0181] Based on the above, an embodiment of the present invention provides a host and a storage device. Figure 2A , Figure 2A A schematic diagram of the structure of a host and a storage device provided in an embodiment of the present invention, wherein the host 10 can be any computing device that generates data, such as a server, a personal computer, a tablet computer, a mobile phone, a personal digital assistant, a smart wearable device, and other types of devices; the storage device 103 can be any non-volatile memory that provides the host 10 with the function of storing / reading data. In an embodiment of the present invention, the storage device 103 can be built into the host 10, or it can be an independent device from the host 10, or the storage device 103 and the host 10 can be co-located in an electronic device, and this application does not make specific limitations on this. The host 10 or the storage device 103 can specifically be a chip or a chipset or a circuit board equipped with a chip or a chipset, and the chip or chipset or the circuit board equipped with a chip or a chipset can work under the necessary software drive. Specifically,

[0182] The host 10 may include a processor (central processing unit, CPU) 100 and an internal memory 101. Optionally, it may also include a host controller 102. Further, it may also include Figure 2A All physical devices on the application processing side, such as power supplies, other input / output controllers, and interfaces, not shown.

[0183] Processor 100: can run an operating system, a file system (such as a flash file system F2FS) or an application program, etc., to control multiple hardware or software components connected to the processor 100, and can process various data and perform operations. The processor 100 can load instructions or data stored in the storage device 103 into the internal memory 101, and call the instructions or data that need to be calculated to the processor 100 for calculation. After the calculation is completed, the processor 100 temporarily stores the result in the internal memory 101, and stores the instructions or data that need to be stored for a long time in the storage device 103 through the host controller 102. The processor 100 may include one or more processing units (also called processing cores), for example: the processor 100 may include one or more of a central processing unit (CPU), an application processing unit (application processor, AP), a modem processing unit, a graphics processing unit (graphics processing unit, GPU), an image signal processing unit (image signal processor, ISP), a video codec unit, a digital signal processing unit (digital signal processor, DSP), a baseband processing unit and a neural-network processing unit (neural-network processing unit, NPU). Among them, different processing units can be independent devices or integrated in one or more devices. Optionally, a memory can also be set in the processor 100 for storing instructions and data. In some embodiments, the memory in the processor 100 is a cache memory (Cache). The Cache can save instructions or data that the processor 100 has just used or circulated. If the processor 100 needs to use the instruction or data again, it can be called directly from the Cache. Repeated access is avoided, the waiting time of the processor 100 is reduced, and the efficiency of the system is improved. Furthermore, the processor 100 can also be implemented as a system on chip (System on Chip, SoC).

[0184] The internal memory 101 is usually a volatile memory that loses power when the power is off. The content stored on it will be lost when the power is off. It can also be called memory or main memory. The internal memory 101 in this application includes a readable and writable running memory, which is used to temporarily store the calculation data in the processor 100, and to exchange data with the storage device 103 or other external memory. It can be used as a storage medium for temporary data of the operating system or other running programs. For example, the operating system running on the processor 100 transfers the data to be calculated from the internal memory 101 to the processor 100 for calculation, and when the calculation is completed, the processor 100 transmits the result.

[0185] The internal memory 101 may include one or more of dynamic random access memory (DRAM), static random access memory (SRAM), synchronous dynamic random access memory (SDRAM), etc. Among them, DRAM includes double data rate synchronous dynamic random access memory (Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM), referred to as DDR, second generation double data rate synchronous dynamic random access memory (DDR2), third generation double data rate synchronous dynamic random access memory (DDR3), fourth generation low power double data rate synchronous dynamic random access memory (Low Power Double Data Rate 4, LPDDR4) and fifth generation low power double data rate synchronous dynamic random access memory (Low Power Double Data Rate 5, LPDDR5), etc.

[0186] The host controller 102 is used to manage and control the communication between the host 10 and the storage device 103, and provide a standardized interface (such as the universal flash storage UFS standard) for the communication between the host 10 and the storage device 103. Specifically, the host controller 102 can transmit commands (such as write, read, erase, etc. commands) and data to the storage device 103 according to the read / write request issued by the processor 100, and feedback events (such as command completion events, command status events, hardware error events, etc.) to the host 10 according to the results of reading / writing data of the storage device 103. For commands or data issued by the processor 100, the host controller 102 can convert the commands or data into data packets supporting a certain protocol by encapsulation, and the host controller 102 performs the reverse operation for the data received by the host 10. Optionally, a host can support multiple host controllers (HostController) to support communication with storage devices of different protocols. In an embodiment of the present invention, the host controller 102 generates the write command, read command, erase command, etc. involved in this application according to the protocol (e.g., UFS protocol) supported between the host 10 and the storage device 103, and carries the data type identifier of the data in the generated command to indicate the type of data to the storage device 103. Please refer to the subsequent detailed description of the data storage method, which is not described in detail here. Optionally, the function of the host control 102 can also be integrated in the processor 100, that is, the processor 100 completes the above-mentioned function of the host control 102, which is not specifically limited here.

[0187] The storage device 103 includes at least a first storage area 1031 and a second storage area 1032. Further, the storage device 103 may also include a storage controller 1033. In the embodiment of the present invention, the first storage area 1031 and the second storage area 1032 have different storage performances, so as to be used to store data with different performance requirements.

[0188] The storage device 103 is a non-volatile memory, and its stored contents will not be lost after power failure. The storage device 103 (including the first storage area 1031 and the second storage area 1032) can be used for long-term storage of instructions and data involved in the operation of the host 10, such as boot programs, operating systems, applications and data. Since the processor 100 in the host 10 cannot directly read the instructions and data in the storage device 103 or directly write instructions or data to the storage device 103, when the processor 100 executes a read (or load) command, it actually temporarily loads the contents to be read (including instructions and / or data) stored in the storage device 103 into the internal memory 101 through the host controller 102, and then the processor 100 reads it from the internal memory 101; and when executing a write (i.e. storage) command, it actually temporarily writes the data to be stored (including instructions and / or data) into the internal memory 101 by the processor 100, and then stores it from the internal memory 101 to the storage device 103 through the host controller 102. Therefore, the performance of the storage device 103, such as the read rate, write rate, erase rate, erase times, data retention capability, etc., has a great impact on the performance of the host 10, and determines whether the host 10 or the electronic device where the host 10 is located can operate normally, stably, and efficiently. Since in the present application, the storage device 103 includes at least a first storage area 1031 and a second storage area 1032, and the storage performance of the first storage area 1031 is better than that of the second storage area 1032, therefore, the embodiment of the present invention stores data of different types (that is, different performance requirements) in the same or different storage areas at different stages based on the data type of the data to be stored, so as to ensure the read / write performance of the host 10 side when reading / writing data, thereby improving the overall operation efficiency of the host. This will be further explained in the subsequent embodiments and will not be described in detail here.

[0189] The storage device 103 may include one or more of Flash flash memory (e.g., NAND flash memory, NOR flash memory, etc.), universal flash storage (UFS), embedded multimedia card eMMC, universal flash storage multi-chip package uMCP memory, embedded multimedia card multi-chip package eMCP memory, solid-state drive (SSD), etc. In one possible implementation, the storage device 103 includes at least a first storage area 1031 and a second storage area 1032, and the first storage area 1031 includes one or more of a single-layer unit SLC storage area, a fast and non-Fast NAND memory, a phase change memory PCM, and a 3D stacked phase change memory X3D, and the second storage area 1032 includes one or more of a multi-layer unit MLC storage area, a three-layer unit TLC storage area, a four-layer unit QLC storage area, and a five-layer unit PLC storage area. Among them, the storage media of the first storage area 1031 and the second storage area 1032 may be the same or different. Further, the storage device 103 may also include other storage media such as a mechanical hard disk (Hard Disk Drive, HDD), etc.

[0190] Optionally, when the storage media of the first storage area 1031 and the second storage area 1032 are different, for example, the first storage area 1031 is an SLC flash memory, and the second storage area 1032 is an MLC or TLC flash memory. Figure 2B As shown, Figure 2B A schematic diagram of the structure of a storage device provided in an embodiment of the present invention, wherein the first storage area 1031 may include M blocks, each block includes N pages, and each page includes a certain number of cells. All cells in all pages in all blocks in the first storage area 1031 are single-layer cells (SLC), so the first storage area forms an SLC type storage area. Similarly, the second storage area may include L blocks, each block includes N pages (the number here may not be N), and each page includes a certain number of cells, and all cells in all pages in all blocks in the second storage area 1032 are multi-layer cells (MLC) or triple-layer cells (TLC), so the second storage area 1032 forms an MLC / TLC type storage area. That is, the read latency, write latency and / or read-write reliability of the pages in the blocks included in different types of storage areas are different.

[0191] Optional, based on the above Figure 2BWhen the storage medium of the first storage area 1031 and the second storage area 1032 is the same, and when the storage medium is MLC or TLC, part of the MLC or TLC block can be converted to SLC mode. The reason is that the difference between MLC / TLC and SLC is how many bits of data are stored in a cell, MLC stores three bits, MLC stores two bits, and SLC stores one bit. Converting MLC to SLC mode means using only one of the two bits, namely the least significant bit (LSB). Similarly, the principle of converting TLC to SLC mode is the same, only using the least significant bit (LSB) of the three bits. Of course, not using the other one or two bits means that the other half or two-thirds of the capacity is not used. Therefore, after the MLC is converted to SLC mode, the capacity is only half of the original MLC, and after the TLC is converted to SLC mode, the capacity is only one-third of the original TLC. Therefore, in an embodiment of the present invention, in a solid-state storage device 103 based on MLC / TLC NAND Flash, the read and write performance can be improved by switching part of the MLC / TLC block to SLC block. That is, the first storage area 1031 and the second storage area 1032 are essentially MLC / TLC, and the first storage area 1031 is an SLC storage area converted from MLC / TLC, which is mainly used to accelerate the writing speed of newly written data and the reading speed of subsequent partial data (such as the first type of data). In summary, the size between the first storage area 1031 and the second storage area 1032 in the embodiment of the present invention can be changed dynamically. For example, the entire storage device 103 has 512 blocks. When there are 100 blocks in the SLC mode, there are 412 blocks in the MLC / TLC mode; when there are 200 blocks in the SLC mode, there are 312 blocks in the MLC / TLC mode, and so on. In other words, the number of SLC blocks can be set according to different data storage requirements. Further optionally, in the converted SLC block, a part of the SLC blocks can be set as static SLC blocks, and the rest can be set as dynamic SLC blocks. That is, no matter how the number of SLC blocks changes, the number of static SLC blocks remains unchanged (for example, 40), while the number of dynamic SLC blocks can change according to demand. That is, the number of blocks in different storage areas can be determined specifically according to the need for storing data.

[0192] It should be noted that Page is the smallest addressing unit in NAND Flash, that is, the smallest unit of reading / writing. The number of Pages in a Block varies according to the specifications of different manufacturers, and the size of the Page itself is also different. For example, there are 1024 pages in a Block, and the size of each page is (16KB+2208B), of which 16KB is the data area for storing data, and 2208B is the metadata area for storing metadata. For example, 16KB is used to store one or more target data in the application, and 2208B is used to store the data type identifier corresponding to the one or more target data. Among them, the erase performance of SLC and MLC is similar, while the read performance (including read speed), write performance (including write speed) and storage performance (including storage life) of SLC flash memory are better than MLC / TLC flash memory.

[0193] See also Figure 2C , Figure 2C Some user interface diagrams for adjusting the cache area and the common area provided in the embodiment of the present invention, in the user interface 21, the user enters the user interface 22 of the system setting function by clicking the setting button 201, and the user further clicks the option storage management 202 to enter the user interface 23 of the partition management. The user can adjust the current size of the cache area (that is, the first storage area 1031 in this application, such as the SLC storage area) through the "increase" button 203 or the "decrease" button 204. Since the total storage space of the storage device 103 is fixed, the size of the common area (that is, the second storage area 1032 in this application, such as the MLC / TLC storage area) can be indirectly adjusted by adjusting the size of the "cache area". Therefore, the current size of the common area in the storage device 103 can be displayed only through the display box 205, and the user can be prompted through the prompt information 206: "The total storage space is 512G, of which the cache area is converted from the common area, and the size after conversion is half of the original common area." It is understandable that the cache area may include a static cache area (such as a static SLC storage area) and a dynamic cache area (dynamic SLC storage area). Since the static cache area can be considered to have a fixed size (such as 4G), the user actually adjusts the size of the dynamic cache area in the cache area. In specific circumstances, the user can set the size ratio between the cache area and the general area according to their own usage requirements, and the embodiment of the present invention does not specifically limit this.

[0194] The storage controller 1033 is an interface device between the host 10 and the storage device 103. Its main function is to convert the interface, convert the read, write, delete and other commands issued by the host 10 (such as the host controller in the host 10) into signals that can be recognized by the storage device 103, and can also complete the address decoding between the host 10 and the storage device 103 (for example, the mapping between the logical address of the host 10 and the physical address in the storage device 103), data format conversion (such as data bit width), etc. In short, the storage controller 1033 can perform necessary control on the access to the storage device 103 in which it is located according to certain timing rules, including the control of address signals, data signals and various command signals, so that the host 10 can use the storage resources on the storage device 103 according to demand. For example, the storage controller 1033 receives and parses a read command or a write command sent by the host controller 102 in the host 10, and according to the logical address of the data carried in the read command or the write command, parses the logical address of the data into a physical address according to a fixed address mapping relationship, and then searches for the location of the data to be read or written, and finally sends a control signal corresponding to the command to the first storage area 1031 or the second storage area 1032.

[0195] It should be noted that the computer program (referred to as the data storage program, which may include relevant instructions and relevant data, which will not be repeated later) used to implement any data storage method in the present application involves and includes multiple functions, one of which is the determination of the data type of the data to be stored by the host 10 side (including identification, storage management, etc.), and the processing process of indicating the data type of the data to be stored in the write command; the other part is the processing process of the storage device 103 side receiving the data to be stored, performing preliminary storage and subsequent storage space recovery. Among them, the data type identification function can be implemented by the data identification program in the operating system run by the processor 100, the storage management function after the data type identification can be implemented by the file system (such as F2FS) in the operating system run by the processor 100, the function of indicating the data type can be implemented by the control program run by the host controller 102, and the storage data (including initial storage and subsequent space recovery) can be implemented as a control program run by the storage controller 1033. Finally, through the multiple functions contained in the above data storage program, the function of high-performance data storage between the host 10 and the storage device 103 is realized. This will be further explained in the subsequent embodiments, and will not be described in detail here. Among them, the file system refers to the software organization in the operating system that is responsible for managing and storing file information.

[0196] Understandably, Figure 2A or Figure 2BThe structures of the host 10 or the storage device 103 are only some exemplary implementations provided by the embodiments of the present invention. The structures of the host 10 and the storage device 103 in the embodiments of the present invention include but are not limited to the above implementations.

[0197] It can also be understood that the processor 100 and the internal memory 101, the host controller and the storage device 103 can communicate with each other through the system bus, or can communicate through other connection methods, and the embodiment of the present invention does not specifically limit this. The structure illustrated in the embodiment of the present invention does not constitute a specific limitation of the host 10 or the storage device 103. In other embodiments of the present application, the host 10 or the storage device 103 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.

[0198] Further, when the host 10 and the storage device 103 are both part of the electronic device 20 (ie, they are co-located in the same electronic device 20), please refer to Figure 2D , Figure 2D This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. The electronic device 20 or the host 10 in the electronic device 20 may also include the following functional modules:

[0199] The external memory interface 104 can be used to connect an external memory card, for example, a TF (TransFLash) card also known as a T-Flash card, a flash drive, a compact flash (CF), a secure digital card (SD), a micro SD, a mini SD, an xD card, a multimedia card (MMC), a memory stick, etc. The external memory card is operably and / or physically connected to the electronic device 20 through the external memory interface 104 to expand the storage capacity of the electronic device 20. For example, files such as music and videos are stored in the external memory card.

[0200] The SIM card interface 105 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 20 by inserting the SIM card interface 105 or pulling the SIM card out of the SIM card interface 105. The electronic device 20 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 105 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 105 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 105 can also be compatible with different types of SIM cards. The SIM card interface 105 can also be compatible with external memory cards. The electronic device 20 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 20 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 20 and cannot be separated from the electronic device 20.

[0201] The display screen 106 is used to display text, images, videos, etc. The display screen 106 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light emitting diode (QLED), etc. Further, the display screen 260 may include a touch screen, and may receive a touch, gesture, approach or hover input from an electronic pen or a part of the user's body. In some embodiments, the electronic device 20 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0202] The audio system 107 may include a speaker, a receiver, a microphone, an earphone interface, etc. The electronic device 20 may implement audio functions such as calls, music playback, and recording through the audio system 107 and the AP in the processor 100 .

[0203] The camera system 108 may include a camera or multiple cameras (e.g., a front camera and a rear camera, or multiple front cameras and multiple rear cameras), and the camera may also be a group of camera modules. The camera is used to capture static images or videos. The electronic device 20 may implement a shooting function through the camera, the ISP, the video codec, the GPU and the AP in the processor 100, and the display screen 106.

[0204] The sensor system 109 may include a four-in-one (accelerometer, angular velocity meter, gyroscope, compass) motion sensor, a pressure sensor, a temperature sensor, a light sensor, a proximity light sensor, a 3D structured light sensor, etc. Different sensors are used to sense different signals, so that the processor 100 performs operations and processing according to different sensing signals to realize different functions of the electronic device 20. For example, the four-in-one motion sensor can be used to determine the motion posture and orientation information of the electronic device 20; the light sensor is used to sense the ambient light brightness, and the electronic device 20 can adaptively adjust the brightness of the display screen 106 according to the perceived ambient light brightness, or it can also be used for the shooting system 108 to automatically adjust the white balance when taking pictures.

[0205] Communication system, the wireless communication function of the electronic device 20 can be realized by antenna 1, antenna 2, mobile communication module 110, wireless communication module 111, modulation and demodulation processor and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Mobile communication module 110 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to electronic device 20. Wireless communication module 111 can provide solutions for wireless communications including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc. applied to electronic device 20.

[0206] The power management module (PMU) 110 can manage the power of the electronic device 20. The power management module 112 receives input from the battery 113 and / or the charging management module 114, and supplies power to the processor 100, the internal memory 101, the host controller 102, the storage device 103, the display screen 106, the audio system 107, the camera system 108, the sensor system 109, the mobile communication module 110, and the wireless communication module 111. The charging management module 114 can use wired and / or wireless charging methods. Wireless charging methods may include, for example, magnetic resonance methods, magnetic induction methods, electromagnetic methods, etc. The battery 113 may include a rechargeable battery and / or a solar cell, etc.

[0207] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 20. In other embodiments of the present application, the electronic device 20 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0208] Combine the following Figure 2A-2B The structure of the host 10 and the storage device 103 shown, and Figure 2D The structure of the electronic device 20 shown in the figure specifically introduces the data storage method provided by the embodiment of the present invention. In the data storage method provided by the embodiment of the present invention, it involves the host 10 storing data in the storage device 103, and the related process of reading data from the storage device 103. Specifically, when the host 10 needs to write target data to the storage device 103, it is necessary to indicate the data type of the target data to the storage device 103 and carry the data type in the write command, and the storage device 103 first uniformly stores the target data (including the corresponding data type) in the first storage area 1031 with better performance to ensure the fast performance when the data is initially written. Later, due to the limited space of the first storage area 1031 and other reasons, when it is necessary to perform storage space recovery (also called garbage collection in some application scenarios) operation on part or all of the data (including the target data) in the area, it is necessary to further determine the data type of the data to be recovered. If the target data belongs to the first type with higher storage performance requirements, the target data will continue to be retained in the first storage area 1031 with better performance. If the target data belongs to the second type with lower storage performance requirements, the target data will be moved to the second storage area 1032 with relatively weaker performance for storage, so as to ensure the subsequent read performance of the host 10 when reading data from the storage device 103, thereby achieving the purpose of improving the overall operating performance of the host 10.

[0209] The data storage method provided by the present application is specifically described below by two aspects: how the host 10 determines and indicates the type of data to be stored; and how the storage device 103 stores the data to be stored according to the data type.

[0210] (I) How does the host 10 determine and indicate the type of data to be stored?

[0211] In the embodiment of the present invention, the following points will be described about how the host 10 determines and indicates the type of data to be stored: 1. How the host determines the type of data to be stored; 2. How the host specifically indicates the type of data to be stored; 3. How the write command is sent to the storage device 103.

[0212] 1. How does the host determine the data type to be stored?

[0213] When the host 10 is powered on, it needs to read data (including instructions or data) from the storage device 103, that is, the processor 100 first loads the corresponding data from the storage device 103 into the internal memory 101 through the host controller 102, and then the processor 100 in the host 10 can load and run. For example, the read data includes relevant instructions and data of the boot program, operating system, and application program (such as social application, video application, music application), etc.; when the host 10 needs to write the data to be stored in the storage device 103, the processor 100 needs to write the processed results from the temporary internal memory 101 to the storage device 103 for long-term storage. For example, the data to be stored includes system logs, user-edited documents, downloaded videos, music, historical data of commonly used software, etc.

[0214] In an embodiment of the present invention, the data to be stored that the host 10 needs to write to the storage device 103 is divided into at least a first type and a second type, and the storage performance requirement of the first type of data is higher than that of the second type of data. Specifically, the data read / written by the host 10 generally involves system data and user data, wherein the system data generally includes the operating system (such as Linux kernel, Android operating system) run by the host 10, the file system, the system built-in application (such as application market, wallet application, security center, etc.) that comes with the host when it leaves the factory, and the system data related to the operation of the system (such as configuration file data, log file data, cache data, etc.). User data generally includes the application programs downloaded and installed by the user after leaving the factory (such as social applications, video applications, mobile payment applications, game applications, etc.), as well as the data generated during use (such as music, photos, videos, contact information, chat records, browsing records, documents, password data, cache data of each application, etc.).

[0215] In the embodiment of the present invention, the first type of data may include one or more of the following situations:

[0216] (1) Highly accessed databases, i.e., databases that may be frequently read and written, such as photo databases, video databases, document databases, etc. When a user frequently clicks on an album to view pictures, frequently watches videos, or frequently edits and saves documents, etc., through the host 10, the corresponding database stored in the storage device 103 will be frequently accessed (read or written) by the host 10. Therefore, in an embodiment of the present invention, it can be set as the first type of data, so that it can be subsequently stored in the first storage area with better performance, so that this part of the data can achieve faster reading and writing efficiency, thereby ensuring better reading / writing performance, etc., to improve the overall performance of the host 10.

[0217] (2) Data of commonly used applications, for example, relevant data of game applications, social applications, photo applications, and beauty applications that users often use. When a user frequently starts a game application to play games, opens a social application to chat, opens a photo application to take photos, and opens a beauty application to retouch and beautify the photos taken, the relevant data of the corresponding application stored in the storage device 103 will often be frequently accessed (read or written) by the host 10. Therefore, in an embodiment of the present invention, it can be set as the first type of data, so that it can be stored in the first storage area with better performance in the future, so that this part of the data can achieve faster reading and writing efficiency, thereby ensuring that it is provided with better reading / writing performance, so as to improve the overall performance of the host 10.

[0218] The data of the frequently accessed database or commonly used applications can be automatically determined or counted by the operating system on the host 10 according to the frequency of the user's use of the application, or can be set by the user according to his or her own preferences, for example, applications that the user needs to use frequently, or that the user considers important, or that the user hopes to improve the experience. Figure 3A , Figure 3A Schematic diagram of some user interfaces for quick mode settings provided by embodiments of the present invention. In user interface 31, the user clicks setting button 301 to enter user interface 32 of system setting function. The user further clicks option storage management 302 to enter user interface 33 of quick mode management. The user can use switch controls for each application, such as switch controls 303 of gallery, Switch control 304, The switch control 305 for apps, the switch control 306 for music, etc., are used to turn the "fast mode" on or off for each app. The user is reminded through a prompt message 307: "When the fast mode is turned on (ON), the app can be stored in the "fast area" (i.e., the first storage area in this application) for a long time, and enjoy a faster and better experience when starting or running." It is understandable that when the fast function is turned off, the app will be stored in the "normal area" (i.e., the second storage area in this application) for a long time, and the startup or operation speed will be relatively slow. For example, when the gallery and When the "Quick Mode" function is turned on (ON), that is, when the switch controls 303 and 305 are in the ON state, the electronic device 20 will convert the gallery and Application-related data is set to the first type so that the gallery and The application-related data is not only initially stored in the first storage area 1031, but also can continue to reside in the first storage area 1031 after the space is subsequently reclaimed. When it needs to be read from the storage device 103, it can be directly read from the first storage area 1031 to achieve "fast mode"; When the switch controls 304 and 306 of the music are in the OFF state, the data of the application is also initially stored in the first storage area, but after the space recovery operation, it will be recovered to the slightly slower "normal area", that is, the second storage area 1032. In specific circumstances, users can set the applications they want to reside in the fast area according to their own usage habits or needs, and they will not be listed one by one here.

[0219] (3) Metadata of the file system. The data in any file system is divided into data and metadata. Data refers to the actual data in an ordinary file, that is, the actual content of the file; while metadata refers to system data used to describe the characteristics of a file, such as access rights, file owners, and distribution information of file data blocks (such as index nodes inode). When the host 10 needs to operate a file in the file system, it must first obtain its metadata in order to locate the location of the file and obtain the content or related attributes of the file. Since the role of the file system is to determine how to store and retrieve data in local storage. For example, the flash file system (F2FS), F2FS has a "Meta" area that contains a variety of metadata. When the host 10 side needs to perform any read or write operations on the storage device 103, it needs to use the metadata in the file system as an index for subsequent operations. Therefore, in an embodiment of the present invention, the metadata of the file system (i.e., F2FS META) can be set as the first type of data, so that the metadata can be read or written more efficiently by the host 10 by residing in the first storage area 1031 with better performance, and the host 10 can respond faster to all subsequent operations, thereby ensuring better read / write performance and improving the overall performance of the host 10.

[0220] (4) Swap partition data. The Swap partition is also commonly referred to as virtual memory, which is a partition divided from the storage device 103. When the actual memory (i.e., physical memory, corresponding to the internal memory 101 in this application) is insufficient, the operating system will take out a portion of temporarily unused data from the memory and put it in the swap partition Swap, thereby freeing up enough memory space for the currently running program. That is, when the actual memory is insufficient, the Swap partition is used to temporarily replace it as virtual memory. The released memory space may come from some programs that have not been operated for a long time, or applications that have retreated to the background during mobile phone operation. Optionally, in the field of mobile terminals, a swap partition is usually set in the internal memory 101 (also known as ZRAM space), and these released programs are temporarily saved in the Swap partition of the internal memory 101 (for example, with an elastic size of 300MB to 2GB). For example, the data can be compressed by about 3:1 and then saved in the SWAP partition. When this part of the program needs to be run, the saved data can be restored from the Swap partition to the ordinary partition of the memory.

[0221] That is, when the host 10 side has insufficient space in the memory (i.e., the internal memory 101) or the ordinary partition of the memory, it is necessary to temporarily store part of the data currently stored in the internal memory 101 in the Swap partition of the internal memory 101 or the storage device 103 as Swap partition data, and this part of the Swap partition data may be restored to the internal memory 101 at any time. Therefore, in the embodiment of the present invention, this part of the Swap partition data can be set as the first type of data, so that after the first type of data is transferred to the external memory (storage device 103), it can reside in the first storage area with better performance for a long time. When the operating system accesses this part of the data again, the Swap partition data is quickly restored from the first storage area 1031 to the internal memory 101, so that this part of the data can achieve faster read and write efficiency, thereby ensuring better read / write performance, etc., to improve the overall performance of the host 10. It should be noted that the Swap partition data does not refer to certain fixed data, but refers to the data loaded into the Swap partition under any circumstances, that is, the Swap partition data under different circumstances may correspond to different data.

[0222] That is, in the embodiment of the present invention, the first type of data may be data that is more sensitive to read performance or data that is more sensitive to read and write performance, so as to subsequently reduce the read response time of the first type of data to improve user experience.

[0223] In the embodiment of the present invention, the second type of data may include one or more of the following situations:

[0224] (1) Data with large data volume, such as video data and audio data downloaded by users.

[0225] (2) Low-frequency access databases, for example, databases that may be read less frequently, such as document databases, video databases, etc.

[0226] (3) Data on infrequently used applications, such as data on sports applications, forum applications, food delivery applications, etc. that are not frequently used by users.

[0227] Optionally, the second type of data may be all data other than the first type in the data processed by the host 10. Since the second type of data has lower storage performance requirements than the first type of data, it can be initially stored in the first storage area to ensure its initial fast write performance. When the space of the first storage area is reclaimed due to limited space in the first storage area, the second type of data is reclaimed in the second storage area for long-term storage, and the first storage area is left as much as possible for the first type of data with higher storage performance requirements. In a possible implementation, the first type of data may also be hot data (i.e., data with high read and write frequency or data with high activity), and the second type of data may be cold data (i.e., data with low read and write frequency or data with low activity).

[0228] That is, the host 10 can determine whether the data belongs to the first type or the second type based on one or more of the data's write frequency, read frequency, expected read performance, expected write performance, expected data retention duration (for example, how long the data is expected to be stored in the storage system), data type, data attributes, and other characteristics, and then determine the storage areas corresponding to each category of data at different stages.

[0229] See also Figure 3B , Figure 3B A structural schematic diagram of another electronic device provided for an embodiment of the present invention, for example, the first storage area is an SLC storage area (that is, the area includes multiple SLC Blocks), and the second storage area is an MLC / TLC storage area (that is, the area includes multiple MLC / TLC Blocks). Then, when the first type of data and the second type of data are written to the storage device 103 on the host 10 side, they are initially written to the SLC storage area 1031 under the control of the storage controller 1033, and after the subsequent storage space recovery operation, the first type of data continues to reside in the physical block Block in the SLC storage area 1031, and the second type of data is recovered to the physical block Block in the MLC / TLC storage area 1032.

[0230] In one possible implementation, the identification of the first type or the second type of data type can be implemented by a relevant data detection engine (software function module) in the operating system running in the host 10. After the identification is completed, the data type information can be saved and managed by the file system (such as F2FS) in the operating system running in the host 10. When the host 10 subsequently needs to indicate the data type of the data to be stored to the storage device 103, it can be obtained from the data type information saved and managed in the above file system through the host controller 102, and a write command carrying the corresponding data type identifier can be generated.

[0231] It should be noted that whether the data belongs to the first type or the second type can be set differently according to the type of the host 10 or the type of the electronic device 20. For example, when the electronic device is a mobile terminal, the first type of data may include data of commonly used applications, and when the electronic device is a smart wearable device, the first type of data may include frequently accessed databases, etc. In addition, different time periods or different modes of the electronic device 20 may result in different corresponding first type or second type data. That is, the same type of data in different hosts 10 or electronic devices 20, or in different time periods and different modes in the same host 10 or electronic device 20, may have different requirements for storage performance, resulting in different definitions of the first type or second type of data in different hosts 10 or electronic devices 20, which will not be explained one by one here.

[0232] 2. How does the host specifically indicate the type of data to be stored?

[0233] In the data storage method of the embodiment of the invention, after the host 10 determines the type of data, it can store the type information corresponding to the data in the file system. When the data needs to be stored in the storage device 103, the type information of the relevant data stored in the file system (i.e., the data type identifier) ​​is carried in the write command, thereby indicating the first type or the second type corresponding to the data to be stored. Optionally, the data type identifier can be stored in the file system metadata (META), and the metadata of the file system will be refreshed to the external memory (i.e., the storage device 103) for long-term storage, and will also be imported into the internal memory 101 for use when the host is running. That is, it can be understood that the host 10 indicates the type of the data to be stored to the storage device 103 by the host controller 102 by marking the data type label for the data to be stored, so that when the data in the subsequent storage device 103 is reclaimed for storage space, it can be stored again or permanently in the first storage area with better performance by relying on the first type of data type identifier. Optionally, the host 10 side can determine the type of the data at the initial data generation stage, or determine the data type before it is stored in the storage device 103. Finally, the data type of the data is indicated by carrying the data type identifier of the data in a preset position of the write command sent to the storage device 103.

[0234] See also Figure 4A , Figure 4A A schematic diagram of a write command format provided by an embodiment of the present invention. For example, Figure 4A The command format shown is a write command format that complies with the Universal Flash Storage (UFS), and is named Table 11-30-WRITE(10)command. For example, the data type identifier may be carried on the Reserved corresponding to the reserved bit 1, reserved bit 2, or reserved bit 3. Optionally, the data type identifier in this application may also be carried in any reserved bit not occupied by the standard protocol in the above write command or other types of UFS WRITE commands. For example, in addition to the above, the WRITE command may also have Figure 4A In addition to the WRITE(10) shown in the figure, there are also WRITE(6), WRITE(16) and other formats, which are not listed here. Figure 4AAs shown, the write command includes 10 bytes, from Byte0 to Byte9, where each byte has 8 bits (bits) from 0 to 7. The first byte Byte0 of the write command is used to indicate the operation code, that is, the byte is used to indicate operations such as read, write or erase; the second byte Byte1 is a control byte, which is used to limit the state of the operation corresponding to the above operation code, such as write protection; the third to sixth bytes Byte2 to Byte5 are used to indicate the logical block address (LogicalBlock Address), that is, the data of the above logical block address in the memory (internal memory 101) is written into the flash memory (storage device 103) space; the seventh byte Byte6 is used to indicate the group number (Group Number) and the reserved bit (Reserved); the eighth to ninth bytes Byte7 to Byte8 are used to indicate the length of the data to be stored; the tenth byte Byte9 is also a reserved control bit. Before the host 10 writes data (such as target data) to the storage device 103, the host controller 102 can pre-acquire the data type of the target data stored in the file system, and then when it needs to be written to the storage device 103, the logical block address of the target data in the memory of the host 10Host, the transfer length, etc. are indicated in the write command to indicate the address of the target data in the memory, and the data type identifier carried in the reserved bit in the write command indicates whether the target data is the first type or the second type of data. After receiving the write command, the storage device 103 parses the write command through the storage controller 1033 to determine the address and data type of the target data to be written, and stores the target data and the corresponding data type identifier in the first storage area 1031 of the storage device 103. When the storage space is subsequently recovered (such as garbage collection), it can be further determined whether the target data continues to reside in the first storage area or is recovered to the second storage area according to the stored data type identifier, according to the data type of the target data. In a possible implementation, the first type corresponds to hot data, and the corresponding data type is identified as a hot tag, the second type corresponds to cold data, and the corresponding data type is identified as a cold tag, the first storage area corresponds to the SLC storage area (which may include a static SLC storage area and a dynamic SLC storage area), and the second storage area corresponds to the MLC / TLC storage area. In the initial case, both cold data and hot data are stored in the SLC storage area (static SLC storage area or dynamic SLC storage area), and when garbage collection is performed, the hot data continues to reside in the SLC storage area (static SLC storage area or dynamic SLC storage area), and the cold data is recycled to the MLC / TLC storage area.

[0235] See also Figure 4B , Figure 4B A schematic diagram of another write command format provided for an embodiment of the present invention, the write command is a data packet that complies with the Universal Flash Storage (UFS) protocol, called the UFS Protocol Information Unit (UPIU). UPIU is a fixed-format data structure used to transmit commands or requests sent from the application layer, as well as data or status information related to them. It can be understood that UPIU is a carrier for the transmission of commands, data, and status information. That is, the above Figure 4A The corresponding write command can be encapsulated or carried in Figure 4B In the CMD UPIU format packet provided in, for example, WRITE(6) uses (is carried in) Figure 4B The CDB[0] to CDB[5] bytes in the CMD UPIU data packet are used (carried on) the CDB[0] to CDB[9] bytes, and the WRITE(16) is used (carried on) the CDB[0] to

[15] bytes. The UPIU is a data packet with a fixed format, in which the logical unit number of the data can be carried in certain bytes (byte [2] in the figure). When the host side has explicit fast and slow dual partitions presented to the operating system (OS), they can also be identified by LUN numbers. For example, the physical space managed by the file system is divided into LUN3 and LUN4. The data stored in LUN4 is the data expected to be read quickly, and the data stored in LUN3 is the data expected to be read normally. Then the logical partition number can be used as the data type identifier of the first type of data or the second type of data in this application, that is, the data with the logical partition number LUN4 corresponds to the first type, and the data with the logical partition number LUN3 corresponds to the second type. In other words, the data type identifier of the data at this time is the logical partition number of the data, and different logical partition numbers represent data with different storage performance requirements (especially random read or write performance). It can be understood that other bytes in the command are not described in detail here.

[0236] In summary, in the embodiment of the present invention, the data type of the data to be stored can be indicated by a preset bit in the write command, or a logical partition number in the encapsulated write command.

[0237] (II) How does the storage device 103 store data according to the data type?

[0238] In the embodiment of the present invention, the following points will be described about how the storage device 103 stores the data to be stored according to the data type: 1. The storage device receives the write command and parses the write command; 2. According to the parsed write command, the data to be stored and the corresponding data type are stored; 3. When the storage space is recycled, how to recycle or retain the data to be recycled; how the host side Host specifically reads the data in the storage device 103.

[0239] 1. The storage device 103 receives the write command and parses the write command

[0240] After receiving the write command sent by the host 10, the storage device 103 writes the data to be stored (such as target data) and the corresponding data type identifier into the first storage area 1031 in the storage device 103 by parsing the write command. That is, in the data storage method in the embodiment of the present invention, the host 10 tags all data with the first type or the second type, for example, a cold data tag or a hot data tag, and the storage controller 1033 on the storage device 103 parses the write command (including parsing the address and data type in the write command), and stores the data and the data type identifier according to the parsed write command.

[0241] 2. According to the parsed write command, store the data to be stored and the corresponding data type

[0242] When the host 101 writes data to the storage device 103, there are two situations: ① one is to write new (newly added) data; ② the other is to rewrite (or overwrite) existing data. The above different types of data writing methods may cause the storage controller 1033 to process data in different ways. Among them,

[0243] (1) Newly written (newly added) data

[0244] For newly written data, the newly written target data may be written into a completely free physical block (Block), or may be written into a partially free physical block. However, since the newly written data is in pages, it can be written into any free page in one or more blocks. And since it is the initial write, whether it is the first type of data or the second type of data, it is written into a physical block (Block) in the first storage area 1031, so that both can enjoy the fast write performance provided by the first storage area 1031.

[0245] See also Figure 5A-Figure 5C , Figure 5A-Figure 5C Some schematic diagrams of writing new data to a static SLC storage area of ​​a storage device provided by embodiments of the present invention, for example, Figure 5A As shown in , when the first storage area 1031 is an SLC storage area, and further optionally, the SLC storage area includes a static SLC storage area (Static SLC buffer) and a dynamic SLC storage area (Dynamic SLC buffer), wherein the static SLC storage area includes T SLC blocks, the dynamic SLC storage area includes S SLC blocks, and T is a fixed size and S is a variable size. Figure 5B As shown in , the newly written target data can be written to a physical block in the static SLC storage area in the SLC storage area 1031, such as being written to free page1 and page2 in Block1 of the static SLC storage area. In a possible implementation, as Figure 5C As shown, each physical page in each Block includes a data area and a metadata area. At this time, the target data itself and the corresponding data type identifier can be stored in the data area and the metadata area respectively. For example, data 2 is written to the idle physical page Page1, and the corresponding data type identifier is written to the corresponding metadata area (identifier 2); data 3 is written to the idle physical page Page2, and the corresponding data type identifier is written to the corresponding metadata area (identifier 3).

[0246] See also Figure 6A-6C , Figure 6A-6C Some schematic diagrams of writing new data to a dynamic SLC storage area of ​​a storage device provided by an embodiment of the present invention are optional, such as Fig. 6A As shown, the newly written target data can be written to a physical block in the dynamic SLC storage area in the SLC storage area 1031. Figure 6B As shown in , for example, writing to the free page2 and page3 in Block2 in the dynamic SLC storage area. In a possible implementation, as Figure 6C As shown, each physical page in each Block includes a data area and a metadata area. At this time, the target data itself and the corresponding data type identifier can be stored in the data area and the metadata area respectively. For example, data 3 is written to the idle physical page Page2, and the corresponding data type identifier (identifier 3) is written to the corresponding metadata area. Data 4 is written to the idle physical page Page3, and the corresponding data type identifier (identifier 4) is written to the corresponding metadata area.

[0247] Further optionally, the newly written target data can be written to the static SLC storage area first, and only when the static SLC storage area is full or reaches a certain storage capacity, it is written to the dynamic SLC storage area. Among them, the StaticSLC buffer is usually a fixed size, for example, fixed to 2G, and the storage size of the Dynamic SLC buffer can be adjusted according to the size of the second storage area, such as MLC / TLC. That is, the size of the Dynamic SLC buffer can be adjusted accordingly according to the size of the remaining available space in the storage device 103. The larger the remaining space, the larger the dynamic SLC Buffer area can be. For example, it can be converted according to the conversion relationship of MLC / TLC: SLC=3:1.

[0248] (2) Rewrite (or copy) existing data

[0249] See also Figure 7A-7C , Figure 7A-7C Some schematic diagrams of rewriting existing data to the dynamic SLC storage area of ​​the storage device provided in the embodiments of the present invention, in the case of rewriting existing data, according to the storage principle and characteristics of the flash memory (Flash), it is necessary to write the rewritten data to a new physical block (rather than directly modifying the original data page), and then set the corresponding page to be modified in the source data block to invalid, and the other unrewritten data in the source physical block will not be processed temporarily, and will be moved uniformly when the storage space is reclaimed (such as garbage collection) later. Fig. 7A As shown, it is assumed that the data in Block 1 in the static SLC storage area needs to be rewritten, and finally updated in Block S-2 in the dynamic SLC storage area in a different place. Figure 7B As shown, assuming that it is currently necessary to rewrite Page0 and Page2 (data 1 and data 3) of Block1 stored in the static SLC storage area, the content to be rewritten (data 1' and data 3') is newly written to the free pages Page0 and Page1 in the dynamic SLC area (which can be a completely free physical block or a partially free physical block), and the data in Page0 and Page2 in Block1 before the rewrite is set to invalid, while the data that does not need to be rewritten (such as data 2 in Page1 of Block1 and data 4 in Page3, etc.) is still retained in the original Block1 until Block1 is garbage collected, then the valid data in Block1 is moved, and then all invalid data in the source physical block is uniformly erased.

[0250] In one possible implementation, Figure 7CAs shown, each physical page in each Block in the SLC storage area 1031 includes a data area and a metadata area. At this time, the target data to be rewritten and the corresponding data type identifier can be stored in the data area and the metadata area respectively. For example, the updated data 1' and are written to the idle physical page Page0 respectively, and the corresponding data type identifier (identifier 1) is written to the corresponding metadata area at the same time, and the data 3' is written to the idle physical page Page1, and the corresponding data type identifier (identifier 3) is written to the corresponding metadata area at the same time.

[0251] The location where the data type identifier of the data to be stored is stored can be as follows: Figure 6C or Figure 7C The metadata area stored in the physical page where the target data is stored is shown in . Optionally, the data type identifiers of all stored data can also be uniformly stored in one or more physical blocks in the storage device 103, that is, its specific storage location is related to the decision of the file system run by the host, and the embodiment of the present invention does not specifically limit this. As long as the data type identifier of the stored data can be saved, it is convenient to identify the category of the data later, so as to finally realize the function of the storage controller 1033 to perform subsequent residence or recycling according to the type of data. Furthermore, once the data type identifier of the data is determined and stored, it can be circulated in the host 10 and the storage device 103 (host 10→storage device 103→host 10→storage device 103...), that is, after the host 10 side reads out the target data next time, it can read out the data type identifier of the data together, and continue to carry the data type identifier in the write command when it is stored in the storage device 103 next time, finally realizing the preservation and circulation function of the "label".

[0252] 3. When reclaiming storage space, how to recycle or retain the reclaimed data?

[0253] 1) Under what circumstances will the physical block in the first storage area be triggered to reclaim storage space?

[0254] In the present application, whether it is new writing of data or rewriting of data, for the storage device 103, free physical blocks (Blocks) in the first storage area 1031 will be consumed, so that the number of remaining free physical blocks (Blocks) will be reduced. When the number of remaining free physical blocks (Blocks) is less than a certain number, it may cause the data to be unable to continue to be stored in the first storage area 1031. Therefore, storage space recovery or garbage collection (GC) operation can be performed on some physical blocks in the first storage area 1031, thereby releasing more free physical blocks Block for writing new data. The following exemplary provides several conditions for triggering storage space recovery of physical blocks in the first storage area 1031:

[0255] (1) When there is a data read / write operation on the host 10 side, and the number of free physical blocks remaining in the first storage area (such as the SLC storage area) is less than a certain proportion or number, the host 10 side may actively initiate a garbage collection (Garbage Collection) operation.

[0256] (2) When the host 10 detects that there is no current read or write demand (i.e., the load is idle), and the number of remaining free physical blocks in the first storage area (such as the SLC storage area) is less than a certain proportion or number, it actively initiates a request for a garbage collection operation to reclaim part of the storage space in the first storage area 1031.

[0257] (3) Optionally, the host 10 may perform garbage collection only after a data read or write operation is performed, or after the host 10 detects that there is no current read or write demand.

[0258] (4) When the storage controller 1033 inside the storage device 103 detects that the current load of the storage device 103 is relatively idle (ie, no read command or write command is received), it can actively initiate a request for a garbage collection operation to reclaim part of the storage space of the first storage area 1031.

[0259] That is to say, garbage collection can be actively initiated by the host 10 side when certain conditions are met, or it can be actively initiated by the storage device 103 side when certain conditions are met, and the embodiment of the present invention does not make specific limitations on this.

[0260] 2) How to recycle or retain data after triggering storage space reclamation

[0261] In a possible implementation of the storage space recovery process, all valid data in the source physical block to be recovered is moved, and then the entire physical block is erased. After erasing, the physical block becomes a free physical block. In an embodiment of the present invention, when a garbage collection (GC) operation is performed on a portion of a physical block (for example, including one or more target data) in the storage device 103, different operations need to be performed on different types of data according to the type of data. In the present application, the data to be stored includes at least a first type and a second type. Therefore, the following specifically describes how to perform garbage collection on the first type and the second type of data, respectively:

[0262] (1) Storage space recovery for the first type of data

[0263] Since the first type of data has high requirements for storage performance, this type of data continues to reside in the first storage area 1031. However, since there may be other second type of data in the physical block where the first type of data is located that needs to be recovered, and the recovery (i.e., erasure) of a physical block is in blocks, the first type of data needs to be moved to other physical blocks in the first storage area 1031.

[0264] (2) Storage space recovery for the second type of data

[0265] Since the second type of data has low storage performance requirements, it is necessary to recycle (or move) this type of data to the second storage area 1032 with relatively weak storage performance for storage, and free up more physical blocks in the first storage area for use by the first type of data with higher storage performance requirements.

[0266] That is, for the above-mentioned first type of data and second type of data, through the label attached to the data (i.e., the data type identifier), during the storage space recovery (such as garbage collection operation), the data to be recovered (the first type of data and the second type of data) are moved from the same source physical block to different destination physical blocks, so as to realize the garbage collection diversion operation.

[0267] like Figure 8A-8C As shown, Figure 8A-8C Schematic diagram of data recovery in some garbage recovery processes provided by embodiments of the present invention, for example, Fig. 8AAssume that the source physical blocks to be reclaimed include Block 1 in the static SLC storage area. Since Block 1 contains invalid data, data of the first type (e.g., hot data Hot), and data of the second type (e.g., cold data Clod), the corresponding destination physical blocks after the migration are Block S-1 in the dynamic SLC storage area 1031 and Block 5 in the MLC / TLC storage area 1032. Figure 8B As shown, for the first type of data (such as hot data), that is, data 4 in Page3 and data N in PageN-1, they still reside in the SLC storage area 1031, but because the physical block Block1 needs to be recycled (that is, completely erased), the valid data 4 and valid data N need to be moved to other physical blocks in the SLC storage area 1031, for example, to Page0 and Page1 in BlockS-2 in the dynamic SLC area. It can be understood that it can also be moved to other physical blocks in the static SLC area. This is only shown as an example, and does not limit the specific target physical block to be moved, as long as it is any free physical block (partially free or completely free) in the SLC storage area that does not need to be garbage collected. As for the second type of data (such as cold data), that is, data 2 in Page 1, it is necessary to recycle it to the physical block in the MLC / TLC storage area 1032, such as Block 5. After all valid numbers are moved, all data in the source physical block Block 1 can be set to invalid. At this time, all invalid data in the Block (including data that was originally invalid and set to invalid after the move) can be erased. In this way, a free physical block, namely Block 1 in the static SLC area, is released.

[0268] Further optional, such as Figure 8C As shown, each physical page in each Block includes a data area and a metadata area. At this time, the recovered data itself and the corresponding data type identifier can be recovered to the data area and the metadata area respectively. For example, data 4 and data N in the static SLC storage area are moved to physical pages Page0 and Page1 in the dynamic SLC storage area, and the corresponding data type identifiers (identifier 4 and identifier N) are moved to the corresponding metadata area, and data 2 is moved to Page0 of Block5 in the MLC / TLC storage area 1032, and the corresponding data type identifier (identifier 2) is moved to the corresponding metadata area.

[0269] It should be noted that the physical block in which the first type of data is initially stored in the SLC Buffer may be a physical block stored in a static SLC Buffer or a physical block in a dynamic SLC Buffer. The source physical block selected by garbage collection may be a physical block in a static SLC Buffer or a physical block in a dynamic SLC Buffer. That is, in the process of SLC to SLC migration or relocation (Migration (Re-location)), as long as the destination block is an SLC block, it is not necessarily limited to a static or dynamic SLC block. In summary, there is no specific limitation on whether the target data is initially stored in a dynamic or static SLC area, and when the target data is subsequently moved, there is no specific limitation on whether it is moved between blocks in static and static SLC storage areas, or between blocks in dynamic and dynamic SLC storage areas, or between blocks in static and dynamic SLC storage areas, as long as the first type of target data is moved between blocks in the SLC storage area.

[0270] Based on the above description of garbage collection for the first type and the second type of data, for a certain SLC physical block in the SLC storage area, there may be the following recycling situations:

[0271] (1) The SLC physical block contains only the first type of data

[0272] Since there is only valid first-type data (for example, hot data) in the physical block, and the first-type data needs to continue to reside in the first storage area, at this time, all the hot data in the physical block may not be recycled, that is, no processing is performed; optionally, all the hot data on the physical block may be uniformly moved to another physical block in the first storage area, such as from a physical block in the static SLC storage area to a physical block in the dynamic SLC storage area. In other words, when there is only valid hot data in a physical block, the physical block may be moved as a whole to another physical block in the first storage area, or the physical block may not be recycled, that is, no data movement is performed.

[0273] (2) The SLC physical block contains only the first type of data and invalid data

[0274] Since there are valid first type data (for example, hot data) and invalid data in the physical block, and the invalid data eventually needs to be erased to release space, and the erasing operation must be performed in blocks, it is necessary to move the first type data on the physical block to other physical blocks in the first storage area that do not need to be recycled, and then erase the invalid data in the physical block (only invalid data is left at this time), so that the space on the physical block can be released and a free physical block can be obtained.

[0275] (3) The SLC physical block contains only the second type of data, or only the second type of data and invalid data.

[0276] Since the second type of data (for example, cold data) needs to be moved from the physical blocks in the first storage area 1031 to the physical blocks in the second storage area 1032, after all the cold data are moved to the second storage area 1032, all the data in the source physical blocks in the first storage area 1031 can be set to invalid, and then all the invalid data can be erased to release the free physical blocks.

[0277] The same principle applies when the physical block contains both cold data and invalid data. That is, after the cold data is moved, all that remains in the source physical block are invalid data (including the original invalid data and the data set to invalid after this move). Therefore, all invalid data can be erased to release a free physical block.

[0278] (4) The SLC physical block contains both the first type of data and the second type of data, or the first type of data, the second type of data, and invalid data.

[0279] When a physical block contains both the first type of data and the second type of data (for example, hot data and cold data), since erasure is performed in blocks in NAND Flash, it is not possible to move only the cold data to the second storage area while keeping the hot data in the original physical block. Therefore, the hot data needs to be moved to another physical block in the first storage area 1031, and the cold data needs to be moved to a physical block in the second storage area 1032.

[0280] It should be noted that moving data is actually a process of rewriting the data in a new physical block and setting the data in the source physical block to invalid.

[0281] In one possible implementation, assume that the first storage area is a storage-class memory SCM medium, and the second storage area is other media with relatively poor storage performance than SCM. For example, the first storage area is a 3D stacked phase change memory X3D (3D-Xpoint), and the second storage area is a TLC storage area. Then, according to the storage characteristics of X3D, the garbage collection of the first storage area only needs "in-place update", that is, when performing garbage collection operations, the first type of data resides in one or more physical pages in the first storage area and does not need to be moved. The garbage collection operation for the second type of data requires movement. In other words, the first type of data is still stored in the original Block, and the second type of data only needs to be moved from the physical block of X3D to the physical block of TLC. That is, SCM is different from NAND and is faster than SLC, while SLC belongs to "off-site update".

[0282] 4. How does the host read data from the storage device?

[0283] Based on the data after the above-mentioned shunting storage, when the host side reads the data, it is directly read from the SLC storage area where the data is currently located to the internal memory 101 through the host controller 102, or directly read from the MLC / TLC area where the data is currently located to the internal memory 101. That is, in the process of the host 10 reading data, there is no need to identify or classify the data type identifier, that is, the cold data stored in the above-mentioned TLC or MLC storage area does not need to be further read into the dynamic and static SLC storage area. In a possible implementation, after the host 10 reads the data, it still needs to store the data type identifier of the read data, so that when a write command is issued for the data next time, it does not need to be identified again, but the data type identifier can be directly carried in the write command, wherein the data type identifier can be stored in the file system metadata (META), and the file system metadata will be refreshed to the external memory (i.e., the storage device 103) for long-term storage, and will also be imported into the internal memory 101 for use when the host is running.

[0284] Compared with the prior art, when data is written into a solid-state storage device, the data is first uniformly written into the SLC with higher performance, and when garbage collection is required, the data is uniformly written into the TLC or MLC with lower performance; in the embodiment of the present invention, the data is first uniformly written into the SLC with higher performance, and when garbage collection is required, the second type of data (such as cold data) is written into the TLC or MLC with lower performance, while the first type of data (such as hot data) continues to be stored in the SLC (this process does not mean that the data is completely immobile, but it is possible that the data is moved within different blocks within the SLC storage area, which is an off-site update mechanism). It should be noted that compared with MLC / TLC, SLC has higher read and write performance, that is, faster read and write speed, longer endurance and data retention, but higher cost. Therefore, in the present application, the function of the second storage area can be realized by adopting the lower-cost MLC / TLC, and the function of the first storage area can be realized by converting a part of the MLC / TLC into SLC. Since the performance of the first storage area is better than that of the second storage area, the first type of data with higher storage performance requirements can be kept in the first storage area from beginning to end to ensure its read and write performance, and the second type of data with lower storage performance requirements is initially stored in the first storage area to ensure the initial write performance, but is subsequently further transferred and stored in the second storage area with larger capacity and lower cost through the garbage collection mechanism, thereby reducing costs while achieving higher overall data storage performance.

[0285] Of course, in the above process of converting from TLC or MLC to dynamic SLC. If converted from TLC to SLC, the storage space is reduced to one third, and if converted from MLC to SLC, the storage space is reduced to one half. Assuming there is a 256G TLC, if it is converted to SLC for use, then it is 256 / 3G, that is, the storage space size becomes one third of the original; if it is a 256G MLC converted to SLC, then it is 256 / 2G, that is, the storage space size becomes half of the original. The above conversion process can be completed by the controller in the solid-state storage device.

[0286] It should be noted that, although in some of the above-mentioned embodiments of the invention, the first storage area is an SLC memory and the second storage area is an MLC / TLC memory as examples, according to the data storage method disclosed in this application, the first storage area and the second storage area can also be other storage media or other types of memories, which are not listed here one by one.

[0287] Fig. 9AThe flow chart of a data storage method provided by an embodiment of the present invention is shown. The method is applied to electronic equipment. Fig. 9B , Fig. 9B A structural diagram of another electronic device provided for an embodiment of the invention, the electronic device 20 may include a processor 100, an internal memory 101 and an external memory 103, the internal memory 101 includes a normal partition 1011 and a SWAP partition 1012, wherein the normal partition 1011 is a partition in the internal memory 101 that normally provides memory space, and the SWAP partition 1012 is used to compress part of the data in the normal partition 1011 and store it in the SWAP partition 1012 when the space of the normal partition 1011 is insufficient; the external memory 103 includes a first storage area 1031 and a second storage area 1032, and the storage performance of the first storage area 1031 is better than that of the second storage area 1032. For the relevant description of the internal memory 101 and the external memory 103, please refer to the above Figure 2A-Figure 8C The description of the host 10 and the storage device 103 in the above description is repeated, wherein the external memory 103 is equivalent to the aforementioned storage device 103, which will not be repeated here. The method flow mainly describes the method steps on the electronic device side, and the method may include:

[0288] S101: The electronic device runs N applications, and the running data of the N applications are stored in the internal memory; the N applications include a first application, the first application is an application running in the foreground, the first application occupies part of the space of the common partition, and N is a positive integer.

[0289] Specifically, assuming that multiple applications are currently running on the electronic device (for example, the user opens Taobao, WeChat, QQ, video, reading, etc. on the mobile phone at the same time), the running data of these applications are currently loaded into the common partition in the internal memory 101, so that the processor 100 of the electronic device 10 can run any one of the above N applications in the foreground at any time. Assume that the current user runs the first application, such as WeChat, in the foreground of the electronic device, that is, chatting through the WeChat application.

[0290] S102: In response to a start-up operation of a second application, the electronic device determines a remaining space of the common partition and a remaining space of the swap partition.

[0291] Specifically, for example, when the user clicks on the start icon of the second application, such as the icon of the video application, the electronic device 20 needs to determine the remaining space of the current common partition and the remaining space of the SWAP partition, so as to provide the second application with sufficient space in the common partition 1011 of the internal memory 101 to store its running data, so that it can run normally in the processor 100. It should be noted that the start operation of the second application is not necessarily to click on the start icon of the second application, but may also be through clicking on the associated button, switch button, trigger button, etc. in other applications, or the trigger operation of the system background, etc., which is not specifically limited here.

[0292] S103: If the remaining space of the common partition and the remaining space of the SWAP partition are both insufficient, the data of the SWAP partition is determined as the first type of data, stored in the first storage area, and the SWAP partition is cleared.

[0293] S104: compressing the running data of M applications among the N applications, storing the compressed running data in the SWAP partition, and releasing the common partition occupied by the M applications; wherein the M applications include the first application.

[0294] S105: The second application is run in the foreground; the second application occupies part or all of the common partitions occupied by the M applications that have been released.

[0295] Specifically, after the determination in step S102, the following situations may be involved:

[0296] Case 1: the remaining space of the ordinary partition 1011 is sufficient, and the remaining space of the SWAP partition 1012 is sufficient or insufficient. At this time, since the remaining space of the ordinary partition is sufficient, the running data of the second application can be loaded into the ordinary partition 1011 normally, that is, the second application can run normally under this case 1.

[0297] Case 2: If the remaining space in the ordinary partition 1011 is insufficient but the remaining space in the SWAP partition 1012 is sufficient, the running data of some applications in the ordinary partition 1011 may be compressed and stored in the SWAP partition 1012, thereby releasing the space occupied by the application in the ordinary partition 1011, thereby freeing up part of the space in the ordinary partition 1011 for the normal operation of the second application.

[0298] Case 3: When the remaining space of the ordinary partition 1011 and the remaining space of the SWAP partition 1012 are insufficient, in an embodiment of the present invention, the data of the SWAP partition is first determined as the first type of data, and the data of the SWAP partition is stored in the first storage area 1031, and the SWAP partition 1012 is cleared, that is, the SWAP partition is released; further, the running data of M of the N applications are compressed, and the compressed running data are stored in the SWAP partition 1012, and the ordinary partition 1011 occupied by the M applications is released. At this time, the running data of the second application can be loaded from the external memory 103 into the above-mentioned released ordinary partition 1011, that is, the second application can run normally. Furthermore, since the data of the SWAP partition is stored as the first type of data in the first storage area 1031 at this time (i.e., it will not be subsequently recovered to the second storage area 1032), when the running data of any application in the data of the SWAP partition needs to be restored, it can be quickly restored from the first storage area 1031 to the internal memory 101 based on the superior storage performance of the first storage area 1031 (for example, first read out to the SWAP partition 1012, and then restored to the ordinary partition 1011), thereby achieving the effect of effectively expanding the SWAP partition.

[0299] S106: In response to the start operation of the first application, read the running data of the first application from the SWAP partition.

[0300] S107: Decompress the running data of the first application and run the first application in the foreground.

[0301] Specifically, when the user wants to reopen the first application that was used before, at this time, since the data of the first application has been compressed into the SWAP partition in step S104, it needs to be decompressed from the SWAP partition to the ordinary partition 1011 to run normally. And it can run in the foreground according to the user's use requirements. It should be noted that the start operation of the first application is not necessarily to click the start icon of the first application, but may also be through clicking the associated button, switch button, trigger button, etc. in other applications, or the trigger operation of the system background, etc., which is not specifically limited here.

[0302] It should also be noted that since the data in the SWAP partition retains all the data during the application's runtime, such as the context data required for the application's runtime, when the data in the SWAP partition is restored to the ordinary partition, the corresponding application can return to the interface when it was originally killed. In other words, from the user's perception, the application is not actually killed (terminated), but suspended. That is, when the user or the system triggers the start of the first application again, it can still return to the user interface used by the user last time.

[0303] In an embodiment of the present invention, when the memory space of the electronic device is insufficient, including the insufficient space of the SWAP partition in the memory, the data of the SWAP partition can be determined as the first type of data in the embodiment of the present invention, and the first type of data is stored in the first storage area 1031 in the external memory 103, so that the space of the SWAP partition in the internal memory 101 can be released, so that part of the data of the ordinary partition in the internal memory 101 can be further compressed to the SWAP partition and the space of the ordinary partition can be released again to meet the memory space requirements of more applications. Based on the above, the application that may need to be killed can be kept in the first storage area 1031 with a faster storage speed instead of being killed, so as to achieve the effect of expanding the SWAP partition. The survival rate of the background application when the memory space is insufficient is improved, that is, under the condition of the same memory space size, the electronic device provided by the embodiment of the present invention can make more applications retain their runtime data (including their context state) and achieve the purpose of not being checked and killed. When the user needs to call it back from the background, it can return to the state where the application is suspended, which greatly improves the user experience.

[0304] In a possible implementation, before reading the running data of the first application from the SWAP partition, the method further includes: searching for the running data of the first application in the first storage area; reading the running data of the first application contained in the first storage area into the SWAP partition. In some possible situations, for example, when the second application is running in the foreground, the user runs other applications, resulting in insufficient remaining space in the ordinary partition 1011 and the SWAP partition 1012. In this case, it is necessary to execute the process of determining the data of the SWAP partition as the first type of data, storing it in the first storage area, and clearing the SWAP partition again; that is, the compressed running data of the M applications among the above-mentioned N applications will be transferred from the SWAP partition 1012 to the first storage area 1031, and the SWAP partition 1012 will be cleared. Since the compressed running data of the M applications include the compressed running data of the first application, if the user needs to restore the first application later, the compressed running data of the first application can be searched in the first storage area 1031, reloaded into the SWAP partition 1012, and then restored from the SWAP partition 1012 to the common partition 1011 for normal operation. It should be noted that if the remaining space of the SWAP partition is insufficient at this time, the data in the SWAP partition 1012 needs to be transferred to the first storage area 1031 to make room for the data restored from the first storage area 1031 or the data compressed from the common partition 1011.

[0305] In a possible implementation, the method further includes: selecting M applications with high priority from the N applications to be determined as the M applications, and releasing the space of the common partition occupied by L applications with low priority among the N applications. In an embodiment of the present invention, for applications with low frequency of use or low priority by some users, they can be checked and killed when the memory space (such as the remaining space of the common partition) is insufficient, and the space occupied by them in the common partition is directly released, that is, they are not allowed to occupy the space of the SWAP partition 1012, and the space of the common partition and the SWAP partition is left for applications with high priority or programs with high frequency of use by users. Among them, the priority of the application can be determined by the electronic device by monitoring the frequency of use of the user, or it can be manually set by the user, such as setting the application that he wants to keep alive more to a high priority and setting other common applications to a low priority. For example, if the user often uses WeChat, it can be set to a high priority, and the mailbox application that the user rarely uses can be set to a low priority.

[0306] In a possible implementation, the determining the data of the SWAP partition as the first type of data and storing it in the first storage area includes: generating a write command for the data of the SWAP partition, the write command including the first type of data type identifier of the data of the SWAP partition; according to the write command, storing the data of the SWAP partition and the first type of data type identifier in the first storage area. In an embodiment of the present invention, after the data of the SWAP partition is determined as the first type of data, the data type identifier of the data of the SWAP partition is carried in the write command of the data of the SWAP partition, and the corresponding data type identifier is stored while writing the data of the SWAP partition. Therefore, when the storage space occupied by the data of the SWAP partition (such as the physical block) is to be reclaimed later, it can be determined according to the data type identifier that the data of the SWAP partition can continue to reside in the first storage area with better storage performance, rather than being recycled as the second type of data to the second storage area with relatively poor storage performance.

[0307] In a possible implementation, the method further includes: if the storage space of the first storage area meets the recycling condition, the first type of data is retained in the first storage area, and the second type of data is recycled to the second storage area; wherein the storage performance requirement of the first type of data is higher than that of the second type of data. In an embodiment of the present invention, each type of data can be uniformly written to a first storage area with better storage performance (such as random read / write performance, etc.) to improve the write performance of the initial storage of each type of data; because the data type identifier of the data is carried in the data write command, and the corresponding data type identifier is stored while writing the data, therefore, when the storage space occupied by the data (such as the physical block) is to be recycled later, it can be determined according to the data type identifier whether the data continues to reside in the first storage area with better storage performance, or is recycled to the second storage area with relatively poor storage performance.

[0308] In a possible implementation, storing the data of the SWAP partition and the data type identifier of the first type in the first storage area includes: storing the data of the SWAP partition and the data type identifier of the first type in the first storage block Block in the first storage area; if the storage space of the first storage area meets the recycling condition, retaining the data of the first type in the first storage area includes: if the storage space of the first storage area meets the recycling condition, moving the data of the SWAP partition and the data type identifier of the first type from the first storage block Block in the first storage area to the second Block in the first storage area. In an embodiment of the present invention, when the storage space occupied by the data of the SWAP partition in the first storage area is recycled, according to the characteristics of certain storage media, it may be necessary to rewrite the data of the SWAP partition into other physical blocks in the first storage area, thereby freeing up the storage space occupied by the data of the SWAP partition. For example, in SLC, storage space is recovered in units of physical blocks (i.e., erasure is in units of blocks). Therefore, when the storage space occupied by the data of the SWAP partition is reclaimed, it is actually recovered as a whole for the physical block where the data of the SWAP partition is located. Therefore, it is necessary to move all valid data in the physical block where the data of the SWAP partition is located. Specifically, the storage space of the entire physical block is reclaimed by moving the data of the first type of SWAP partition to another physical block in the first storage area, and moving other data of the second type to the second storage area.

[0309] It should be noted that the specific process of the data storage method described in the embodiment of the present invention can be found in the above Figure 2A-Figure 8C The relevant description in the embodiments of the invention described in will not be repeated here.

[0310] The following takes the electronic device 20 as a smart phone and further describes the data storage method in the present application in combination with actual application scenarios.

[0311] See also Figure 9C-9E , Figure 9C-9E Schematic diagram of some user application user interfaces provided by the embodiments of the present invention. For example, a user starts up a computer and logs into an application ( Shopping applications, game applications or entertainment applications, etc.), and assuming that the application is exited or the user suspends the above application, how the host 10 and the storage device 103 interact based on the data storage method in this application. Among them,

[0312] 1. When a user wants to run a social application installed on the electronic device 20, such as application, see user interface 91, at this time the user can click on the input device of the electronic device 20 such as the display screen 106 Icon 901.

[0313] 2. The sensor in the display screen 106 of the electronic device 20 sends a click instruction to the processor 100 .

[0314] 3. After receiving the instruction, the processor 100 controls the host controller 102 to The relevant instructions and data of the application are loaded from the external memory (the first storage area 1031 in the external memory 103) to the internal memory 101 (such as the ordinary partition 1011 of the internal memory 101 in the host) (loading does not need to pass through the processor, but is directly loaded from the external memory to the internal memory).

[0315] 4. After the relevant instructions and data of the application are loaded into the internal memory 101, the processor 100 starts to run app.

[0316] 5. After the application is executed in the processor 100, the processor 100 will display the running results through the output device (such as the display screen 106), that is, display part of the data in the memory to the display screen 106, which can be completed by the GPU and the CPU. For example, referring to the user interface 92, at this time, the user is prompted to log in by filling in the account number and password through the account input box 902 and the password input box 903. The application interface is the user interface 93. Assuming that the user clicks on the chat window with the user Arvin, the chat interface shown in the user interface 94 is entered.

[0317] 6. Please see Fig.9D In the user interface 95 shown in the figure, suppose the user needs to take a photo at this time. At this time, the user takes a photo by clicking the camera button 906 and enters the user interface 96. The user takes a photo by clicking the photo button 907. After clicking the photo button, the photo picture shown in the user interface 97 is obtained. At this time, this picture can be temporarily saved in the ordinary partition 1011 of the internal memory 101. Without exiting the photo interface, the user can edit the picture (for example, add emoticons, add text, mosaic processing, etc.). When the user clicks the send button 908, the picture needs to be saved and sent. At this time, the picture is saved from the internal memory 103 to the external memory 103. That is, after the user executes the save or send 908 operation, the processor 100 will write the data corresponding to the picture from the internal memory to the external memory. Specifically, based on Figure 3A As described in , assuming that the user sets is "fast mode", so about this Part or all of the data of the application is identified as the first type of data by the host 10 side. At this time, when the processor 100 sends the image to the external memory 103 for storage through the host controller 102, it is necessary to carry the first type of data type identifier in the write command for the image. In this way, the external memory 103 can store the image and the corresponding first type of data type identifier in the first storage area 1031 in the external memory 103. When garbage collection is performed for the block where the image is located, the image can continue to reside in the first storage area 1031 with the first type of data type identifier, and can be quickly read out from the first storage area 1031 when it needs to be read out again later.

[0318] 7. Please see Fig.9E As shown in the user interface 98 and the user interface 99, it is assumed that when the user is in the user interface 98, he suddenly receives a call from his colleague Mary, clicks the answer button 911 to make the call, and enters the user interface 100 for answering the call. After talking with his colleague Mary for a while, the user ends the call by clicking the hang up button 912. Assuming that during this period, many applications are opened in the background of the electronic device 20 (for example, the remaining space of the ordinary partition 1011 and the SWAP partition 1012 included in the memory 101 is insufficient), if in the prior art, the user may cause the previous The application interface, i.e., the user interface 98, is kicked out of the memory space, i.e., it is forcibly closed by the background. That is, after the call in the user interface 100 ends, the user cannot quickly or directly return to the user interface 98, because at this time The application has been forcibly closed by the system background due to memory shortage. Fig. 9A The data storage method in the embodiment is to transfer the data in the Swap partition to the first storage area 1031, so that the Swap partition 1012 is cleared, and the The running data of the application is compressed from the normal partition 1011 to the Swap partition 1012. The running data of the application can be quickly returned from the Swap partition 1012 to the normal partition, so the user can quickly or directly return to the user interface 98. Further, in this process, assuming that the space of the Swap partition 1011 is further limited, it is necessary to convert the compressed When the data of the Swap partition including the running data of the application is transferred to the first storage area 1031, since the data saved in the Swap partition is determined by the host side as the first type of data (which will not be recovered to the second storage area 1032 later), when the user ends the call, The running data of the application can still be quickly restored from the first storage area 1031 with better read / write performance to the internal memory 101, so as to have faster reading performance. Therefore, after using the data storage method in the present application, after the user hangs up the call in the user interface 100, the user can quickly restore to the user interface 101, that is, restore to the user interface 98 before answering the call.

[0319] 8. When the user clicks When other functions or contents of the application are used, the above steps are repeated. That is, the processor 100 retrieves the contents from the memory according to the instructions issued by the user. The processor 100 processes the relevant data of the application and calculates the result, and then temporarily stores the result data in the memory. When the user receives an instruction that the data needs to be stored in the external memory 103 for a long time, the processor 100 controls the host controller 102 to read the part of the data from the memory and write it to the external memory 103.

[0320] 9. When the user clicks to exit the When executing an application program, the processor 100 sends an instruction to flush the data in the memory (internal memory 101) and stores the historical data or cached data in the first storage area 1031 of the external memory 103. The data type identifier of the first type of data can then be used to reside in the first storage area 1031 with better performance for a long time, thereby improving the user experience.

[0321] Fig.10 The overall process of a data storage method provided by an embodiment of the present invention is shown. The method is applied to a host and a storage device. The storage device is a non-volatile memory, which includes at least a first storage area and a second storage area. The storage performance of the first storage area is better than that of the second storage area. The relevant description of the host and the storage device can be found in the above Figure 2A-Figure 8C The description of the relevant devices or equipment in the method flow mainly describes the method steps of interaction between the host side and the storage device side, and the method may include:

[0322] S201: The host determines the data type of target data to be written into the storage device.

[0323] S202: The host generates a write command for the target data, where the write command includes a data type identifier for the target data; the data type identifier is used to identify the first type or the second type.

[0324] S203: The host sends the write command to the storage device, where the write command is used to instruct the storage device to store the target data and the data type identifier; the storage device receives the write command for the target data sent by the host side, where the write command includes the data type identifier of the target data.

[0325] S204: The storage device writes the target data and the data type identifier into the first storage area according to the write command.

[0326] S205: If the storage space occupied by the target data needs to be reclaimed, the storage device identifies the data type of the target data according to the data type identifier, where the data type includes a first type and a second data type.

[0327] S206A: If the storage device determines that the target data is of the first type, the target data is retained in the first storage area.

[0328] S206B: If the storage device determines that the target data is of the second type, the target data is moved to the second storage area; wherein the storage performance requirement of the first type of data is higher than that of the second type of data.

[0329] S207: The host sends a read command for the target data to the storage device; the storage device receives the read command for the target data sent by the host.

[0330] S208A: If the target data is of the first type, the storage device controls to read the target data from the first storage area; the host reads the target data and the data type identifier from the first storage area;

[0331] S208B: If the target data is of the second type, the storage device controls to read the target data from the second storage area, and the host reads the target data and the data type identifier from the second storage area.

[0332] S209: The host stores the read target data and the data type identifier in the internal memory, wherein the host includes the internal memory, and the internal memory is a volatile memory.

[0333] In a possible implementation, if it is determined that the target data is of the first type, retaining the target data in the first storage area includes: if it is determined that the target data is of the first type, retaining the target data and the data type identifier in the first storage area.

[0334] In a possible implementation, the storage device is one or more of a universal flash memory UFS, an embedded multimedia card eMMC, a universal flash storage multi-chip package uMCP memory, and an embedded multimedia card multi-chip package eMCP memory; the first storage area includes one or more of a single-layer unit SLC storage area, a fast and non-Fast NAND memory, a phase change memory PCM, and a 3D stacked phase change memory X3D, and the second storage area includes one or more of a multi-layer unit MLC storage area, a three-layer unit TLC storage area, a four-layer unit QLC storage area, and a five-layer unit PLC storage area.

[0335] In a possible implementation, the writing the target data and the data type identifier into the first storage area includes: writing the target data and the data type identifier into a first storage block Block in the first storage area; if it is determined that the target data is of the first type, retaining the target data in the first storage area includes: if it is determined that the target data is of the first type, moving the target data and the data type identifier from a first Block in the first storage area to a second Block in the first storage area.

[0336] In a possible implementation, the first storage area includes an SLC storage area; the SLC storage area includes a static SLC storage area and a dynamic SLC storage area; the first Block is a Block in the static SLC storage area, and the second Block is a Block in the dynamic SLC storage area; or, the first Block is a Block in the dynamic SLC storage area, and the second Block is a Block in the static SLC storage area, or, both the first Block and the second Block are Blocks in the static SLC storage area; or, both the first Block and the second Block are Blocks in the extended dynamic SLC storage area.

[0337] In one possible implementation, if it is determined that the target data type is the second type, the target data is moved to the second storage area, including: if it is determined that the target data type is the second type, the target data and the data type identifier are rewritten into the second storage area, and the target data in the first storage area is set to invalid.

[0338] In a possible implementation, the storage performance includes one or more of random read performance, random write performance, and storage life.

[0339] In a possible implementation, the first type of data includes one or more of file system metadata, a high-frequency access database, and swap area SWAP data. Optionally, the host side determines whether the target data is any one of the file system metadata, the high-frequency access database, or the swap area SWAP data; if so, the target data is determined to be the first type of data; if not, the target data is determined to be the second type of data, and the storage performance requirement of the first type of data is higher than that of the second type of data.

[0340] It should be noted that the specific process of the data storage method described in the embodiment of the present invention can be found in the above Figure 2A-Figure 9E The relevant description in the embodiments of the invention described in will not be repeated here.

[0341] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium may store a program, and when the program is executed by a host or a storage device, it implements part or all of the steps of any one of the data storage methods recorded in the above method embodiments.

[0342] An embodiment of the present invention further provides a computer program, which includes instructions. When the computer program is executed by a host or a storage device, the host or the storage device can execute part or all of the steps of any data storage method.

[0343] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0344] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0345] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the above-mentioned units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0346] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0347] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0348] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc., specifically a processor in a computer device) to perform all or part of the steps of the above-mentioned methods of each embodiment of the present application. Among them, the aforementioned storage medium may include: U disk, mobile hard disk, magnetic disk, optical disk, read-only memory (Read-Only Memory, abbreviated: ROM) or random access memory (Random Access Memory, abbreviated: RAM) and other media that can store program codes.

[0349] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A data storage method, characterized in that: Applied to a storage device, the storage device is a non-volatile memory, at least comprising a first storage area and a second storage area, the storage performance of the first storage area being better than that of the second storage area; the first storage area comprising one or more of a single-layer cell SLC storage area, a fast and non-Fast NAND memory, a phase change memory PCM, and a 3D stacked phase change memory X3D, and the second storage area comprising one or more of a multi-layer cell MLC storage area, a three-layer cell TLC storage area, a four-layer cell QLC storage area, and a five-layer cell PLC storage area; the method comprising: Receive a write command for target data, the write command including a data type identifier of a data type of the target data; wherein the data type includes a first type and a second type; the first type of data includes one or more of file system metadata, a high-frequency access database, and swap area SWAP data, and the second type of data is different from the first type of data in data type; According to the write command, no matter the target data is of the first type or the second type, the target data and the data type identifier are written into the first storage area; If the storage space occupied by the target data in the first storage area needs to be reclaimed, identifying the data type of the target data according to the data type identifier; If it is determined that the target data is of the first type, the target data and the data type identifier are retained in the first storage area; if it is determined that the target data is of the second type, the target data and the data type identifier are moved to the second storage area; wherein the storage performance requirement of the first type of data is higher than that of the second type of data.

2. The method according to claim 1, characterized in that The method further comprises: receiving a read command for the target data; If the target data is of the first type, controlling to read the target data from the first storage area; If the target data is of the second type, the control reads the target data from the second storage area.

3. The method according to claim 1 or 2, characterized in that The storage device is one or more of a universal flash memory UFS, an embedded multimedia card eMMC, a universal flash storage multi-chip package uMCP memory, and an embedded multimedia card multi-chip package eMCP memory.

4. The method according to claim 3, characterized in that The writing the target data and the data type identifier into the first storage area includes: writing the target data and the data type identifier into a first storage block Block in the first storage area; If it is determined that the target data is of the first type, retaining the target data and the data type identifier in the first storage area includes: If it is determined that the target data is of the first type, the target data and the data type identifier are moved from the first Block in the first storage area to the second Block in the first storage area.

5. The method according to claim 4, characterized in that The first storage area includes an SLC storage area; the SLC storage area includes a static SLC storage area and a dynamic SLC storage area; The first Block is a Block in the static SLC storage area, and the second Block is a Block in the dynamic SLC storage area; or, The first Block is a Block in the dynamic SLC storage area, and the second Block is a Block in the static SLC storage area, or, The first Block and the second Block are both Blocks in the static SLC storage area; or, The first Block and the second Block are both Blocks in the dynamic SLC storage area.

6. The method according to any one of claims 1 to 2, characterized in that: If it is determined that the target data is of the second type, moving the target data and the data type identifier to the second storage area includes: If it is determined that the data type of the target data is the second type, the target data and the data type identifier are rewritten into the second storage area, and the target data in the first storage area is set to be invalid.

7. The method according to any one of claims 1 to 2, characterized in that: The storage performance includes one or more of random read performance, random write performance and storage life.

8. A storage device, characterized in that: A non-volatile memory, comprising: a storage controller, a solid-state storage array coupled to the storage controller, the solid-state storage array comprising at least a first storage area and a second storage area, the storage performance of the first storage area being better than that of the second storage area; the first storage area comprising one or more of a single-layer cell SLC storage area, a fast and non-Fast NAND memory, a phase change memory PCM, and a 3D stacked phase change memory X3D, the second storage area comprising one or more of a multi-layer cell MLC storage area, a three-layer cell TLC storage area, a four-layer cell QLC storage area, and a five-layer cell PLC storage area; wherein, The storage controller is used for: Receive a write command for target data, the write command including a data type identifier of a data type of the target data; wherein the data type includes a first type and a second type; the first type of data includes one or more of file system metadata, a high-frequency access database, and swap area SWAP data, and the second type of data is different from the first type of data in data type; According to the write command, no matter the target data is of the first type or the second type, the target data and the data type identifier are written into the first storage area; If the storage space occupied by the target data in the first storage area needs to be reclaimed, identifying the data type of the target data according to the data type identifier; If it is determined that the target data is of the first type, the target data and the data type identifier are retained in the first storage area; if it is determined that the target data is of the second type, the target data and the data type identifier are moved to the second storage area; wherein the storage performance requirement of the first type of data is higher than that of the second type of data.

9. The storage device according to claim 8, characterized in that: The storage controller is further configured to: receiving a read command for the target data; If the target data is of the first type, controlling to read the target data from the first storage area; If the target data is of the second type, the control reads the target data from the second storage area.

10. The storage device according to claim 8 or 9, characterized in that: The storage device is one or more of a universal flash memory UFS, an embedded multimedia card eMMC, a universal flash storage multi-chip package uMCP memory, and an embedded multimedia card multi-chip package eMCP memory.

11. The storage device according to claim 10, wherein: The storage controller is specifically used for: Writing the target data and the data type identifier into a first storage block Block in the first storage area; If it is determined that the target data is of the first type, the target data and the data type identifier are moved from the first Block in the first storage area to the second Block in the first storage area.

12. The storage device according to claim 11, wherein: The first storage area includes an SLC storage area; the SLC storage area includes a static SLC storage area and a dynamic SLC storage area; The first Block is a Block in the static SLC storage area, and the second Block is a Block in the dynamic SLC storage area; or, The first Block is a Block in the dynamic SLC storage area, and the second Block is a Block in the static SLC storage area, or, The first Block and the second Block are both Blocks in the static SLC storage area; or, The first Block and the second Block are both Blocks in the dynamic SLC storage area.

13. The storage device according to any one of claims 8 to 9, characterized in that: The storage controller is specifically used for: If it is determined that the data type of the target data is the second type, the target data and the data type identifier are rewritten into the second storage area, and the target data in the first storage area is set to be invalid.

14. The storage device according to any one of claims 8 to 9, characterized in that: The storage performance includes one or more of random read performance, random write performance and storage life.

15. An electronic device, characterized in that: include: A host and a storage device coupled to the host; The storage device is a storage device as described in any one of claims 8 to 14.

16. A data storage method, characterized in that: Applied to an electronic device, the electronic device comprises an internal memory and an external memory, the internal memory comprises a common partition and a SWAP partition, the external memory comprises a first storage area and a second storage area, the storage performance of the first storage area is better than that of the second storage area, the first storage area comprises one or more of a single-layer cell SLC storage area, a fast and non-Fast NAND memory, a phase change memory PCM, and a 3D stacked phase change memory X3D, and the second storage area comprises one or more of a multi-layer cell MLC storage area, a three-layer cell TLC storage area, a four-layer cell QLC storage area, and a five-layer cell PLC storage area; the method comprises: The electronic device runs N applications, and the running data of the N applications are stored in the internal memory; the N applications include a first application, the first application is an application running in the foreground, the first application occupies part of the space of the common partition, and N is a positive integer; In response to a start-up operation of a second application, the electronic device determines a remaining space of the common partition and a remaining space of the SWAP partition; If the remaining space of the common partition and the remaining space of the SWAP partition are both insufficient, the data of the SWAP partition is determined as the first type of data, stored in the first storage area, and the SWAP partition is cleared; the running data of M applications among the N applications are compressed, and the compressed running data is stored in the SWAP partition, and the common partition occupied by the M applications is released; wherein the M applications include the first application; The second application is run in the foreground; the second application occupies part or all of the common partitions occupied by the released M applications; In response to a start-up operation on the first application, reading the running data of the first application from the SWAP partition; decompressing the running data of the first application program, and running the first application program in the foreground; The step of determining the data of the SWAP partition as the first type of data and storing the data in the first storage area includes: Generate a write command for the data of the SWAP partition, the write command including a data type identifier of a first type of the data of the SWAP partition; According to the write command, the data of the SWAP partition and the data type identifier of the first type are stored in the first storage area; The method further comprises: If the storage space of the first storage area meets the recycling conditions, the first type of data is retained in the first storage area, and the second type of data and the data type identifier of the second type are recycled to the second storage area; wherein the storage performance requirement of the first type of data is higher than that of the second type of data.

17. The method according to claim 16, characterized in that Before reading the running data of the first application from the SWAP partition, the method further includes: searching the first storage area for the running data of the first application; The running data of the first application program included in the first storage area is read into the SWAP partition.

18. The method according to claim 16 or 17, characterized in that The method further comprises: M applications with high priorities are selected from the N applications to be determined as the M applications, and the space of the common partition occupied by L applications with low priorities among the N applications is released.

19. The method according to claim 18, characterized in that The storing the data of the SWAP partition and the data type identifier of the first type in the first storage area includes: storing the data of the SWAP partition and the data type identifier of the first type in a first storage block Block in the first storage area; If the storage space of the first storage area meets the recycling condition, retaining the first type of data in the first storage area includes: If the storage space of the first storage area meets the recycling condition, the data of the SWAP partition and the data type identifier of the first type are moved from the first storage block Block in the first storage area to the second Block in the first storage area.

20. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory is used to store program code, and the processor is used to call the program code stored in the memory so that the electronic device executes the method as claimed in any one of claims 16 to 19.

21. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a storage device, implements the method described in any one of claims 1 to 7.

22. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by an electronic device, implements the method described in any one of claims 16 to 19.

23. A computer program product, characterized in that The computer program product comprises instructions, and when the computer program product is executed by a storage device, the storage device is caused to perform the method according to any one of claims 1 to 7.

24. A computer program product, characterized in that The computer program product comprises instructions, and when the computer program product is executed by an electronic device, the electronic device executes the method according to any one of claims 16 to 19.

Citation Information

Patent Citations

  • Hyper-converged storage system-based data layering method, terminal and system

    CN107807796A