Data storage method and apparatus, and computer-readable storage medium

By identifying empty primary storage sectors in the storage device and writing data to them before erasing the data in the next sector, the problem of low storage efficiency in existing technologies is solved, achieving more efficient data storage.

WO2025241226A1PCT designated stage Publication Date: 2025-11-27SINENG ELECTRIC CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/097536
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-05-22
Filing Date
2024-06-05
Publication Date
2025-11-27

AI Technical Summary

Technical Problem

Existing technologies are inefficient at storing data because they require erasing the data in the storage sectors before storing new data, resulting in low efficiency.

Method used

By identifying the first empty primary storage sector among multiple primary storage sectors of the storage device, the data to be stored is written to that sector, and the data in the next primary storage sector is erased, ensuring that the storage device always has empty sectors available and avoiding repeated erasure operations.

Benefits of technology

It improves the efficiency of data storage, avoids the erasure step when storing new data, and enhances the overall efficiency of data storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024097536_27112025_PF_FP_ABST
    Figure CN2024097536_27112025_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the field of data storage. Provided are a data storage method and apparatus, and a computer-readable storage medium, which can improve the data storage efficiency. The method comprises: determining a first primary storage sector among a plurality of primary storage sectors of a storage device, wherein each primary storage sector comprises a plurality of primary storage pages, each primary storage page comprises a first storage region, the first storage region is used for storing external data, there is no first primary storage page among a plurality of primary storage pages of the first primary storage sector, and there is external data in the first storage region of the first primary storage page; storing, in the first primary storage sector, external data to be stored; and erasing data from a second primary storage sector among the plurality of primary storage sectors, wherein the second primary storage sector is the next primary storage sector after the first primary storage sector.
Need to check novelty before this filing date? Find Prior Art

Description

Data storage method, device and computer readable storage medium TECHNICAL FIELD

[0001] The present application relates to the field of data storage, and in particular to a data storage method, device and computer readable storage medium. BACKGROUND

[0002] To store data, the data is usually stored in a storage device. For example, the storage device can be a flash memory.

[0003] The existing solution has the problem of low data storage efficiency when storing data. TECHNICAL PROBLEM

[0004] [According to Rule 91, the present application is corrected on 24.06.2024] One of the purposes of the embodiments of the present application is to provide a data storage method, device and computer readable storage medium. TECHNICAL SOLUTION

[0005] The present application adopts the following technical solutions:

[0006] In a first aspect, a data storage method is provided. The method includes determining a first main storage sector of a plurality of main storage sectors of a storage device; the main storage sector includes a plurality of main storage pages, and the main storage page includes a first storage area, the first storage area being used to store external data, and there is no first main storage page in the plurality of main storage pages of the first main storage sector, and the first storage area of the first main storage page has external data; storing the to-be-stored external data to the first main storage sector; erasing data in a second main storage sector of the plurality of main storage sectors; and the second main storage sector is the next main storage sector of the first main storage sector.

[0007] In a second aspect, a data storage device is provided for implementing the data storage method of the first aspect. The data storage device includes modules, units or means corresponding to the above-mentioned method, which can be implemented by hardware, software or by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the above-mentioned functions.

[0008] In combination with the second aspect, in some embodiments of the second aspect, the apparatus comprises: a determining module and a processing module; the determining module is configured to determine a first main storage sector in a plurality of main storage sectors of a storage device; the main storage sector comprises a plurality of main storage pages, and the main storage page comprises a first storage area, the first storage area is configured to store external data, and there is no first main storage page in the plurality of main storage pages of the first main storage sector, and the first storage area of the first main storage page has external data; the processing module is configured to store the to-be-stored external data to the first main storage sector; and the processing module is further configured to erase data in a second main storage sector of the plurality of main storage sectors; the second main storage sector is a next main storage sector of the first main storage sector.

[0009] In a third aspect, a data storage apparatus is provided, comprising: at least one processor, and a memory storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the method provided in the first aspect and any possible implementation thereof.

[0010] In a fourth aspect, a computer-readable storage medium is provided, which, when the instructions in the computer-readable storage medium are executed by a processor of a data storage apparatus, enables the data storage apparatus to perform the method provided in the first aspect and any possible implementation thereof.

[0011] In a fifth aspect, a computer program product containing instructions, which, when run on a computer, enables the computer to perform the method provided in the first aspect and any possible implementation thereof.

[0012] In a sixth aspect, a chip system is provided, comprising: a processor and an interface circuit; the interface circuit is configured to receive a computer program or instructions and transmit to the processor; the processor is configured to execute the computer program or instructions, so that the chip system performs the method provided in the first aspect and any possible implementation thereof. Advantageous effects

[0013] Based on the scheme, by determining a first main storage sector which is empty in a plurality of main storage sectors of a storage device, then storing to-be-stored external data to the first main storage sector, and then erasing data in a second main storage sector of the plurality of main storage sectors. Since the second main storage sector is a next main storage sector of the first main storage sector, the data in the next main storage sector can be erased at the same time when the external data is stored to the first main storage sector, so that the storage device always has an empty main storage sector, and when the data is stored again subsequently, the data can be directly stored without the need of erasing the data in advance, thereby improving the efficiency of storing the data. BRIEF DESCRIPTION OF DRAWINGS

[0014] FIG. 1 is a schematic diagram of an architecture of a data storage system provided in the present application;

[0015] Figure 2 is a flow diagram of a data storage method provided by the present application;

[0016] Figure 3 is a flow diagram of another data storage method provided by the present application;

[0017] Figure 4 is a flow diagram of another data storage method provided by the present application;

[0018] Figure 5 is a flow diagram of another data storage method provided by the present application;

[0019] Figure 6 is a flow diagram of another data storage method provided by the present application;

[0020] Figure 7 is a structural diagram of a data storage device provided by the present application;

[0021] Figure 8 is a structural diagram of another data storage device provided by the present application. Embodiments of the present application

[0022] To store data, the data is usually stored in a storage device. For example, the storage device can be a flash memory.

[0023] In the prior art, when storing data, it is usually determined whether there is a free storage sector in a plurality of storage sectors of a storage device. If there is no free storage sector, the data of a storage sector needs to be erased, and then the data is stored in the storage sector.

[0024] With the passage of time, each storage sector of the plurality of storage sectors of the storage device will store data. Therefore, in the prior art, the data of the storage sector needs to be erased before the data is stored, and the data cannot be directly stored, which results in a low data storage efficiency.

[0025] To solve the above problem, the present application provides a data storage method. The method comprises the following steps: determining a first main storage sector in a plurality of main storage sectors of a storage device; the main storage sector comprises a plurality of main storage pages, and each main storage page comprises a first storage area, the first storage area being used to store external data; there is no first main storage page in the plurality of main storage pages of the first main storage sector, and the first storage area of the first main storage page stores external data; storing to-be-stored external data in the first main storage sector; erasing data in a second main storage sector of the plurality of main storage sectors; the second main storage sector is a next main storage sector of the first main storage sector.

[0026] Figure 1 is a structural diagram of a data storage system provided by the present application. The technical solution of the present application can be applied to the data storage system shown in Figure 1. As shown in Figure 1, the data storage system 10 comprises a data storage device 11 and a storage device 12.

[0027] The data storage device 11 is directly or indirectly connected with the storage device 12, and the connection relationship can be wired connection or wireless connection, which is not limited in the embodiments of the present application.

[0028] The data storage device 11 can obtain data from the storage device 12 or store data to the storage device 12.

[0029] It should be noted that the data storage device 11 and the storage device 12 can be independent devices or integrated into the same device, which is not limited in the present application.

[0030] In the following embodiments provided by the present application, the data storage device 11 and the storage device 12 are set as an example for description.

[0031] In actual application, the data storage method provided by the embodiments of the present application can be applied to the data storage device 11 or the device included in the data storage device 11.

[0032] The data storage method provided by the embodiments of the present application will be described below by taking the data storage method applied to the data storage device 11 as an example.

[0033] FIG. 2 is a flowchart of a data storage method provided by the present application, as shown in FIG. 2, the method includes the following steps:

[0034] S201, the data storage device determines a first main storage sector in a plurality of main storage sectors of the storage device.

[0035] The main storage sector includes a plurality of main storage pages, and the main storage page includes a first storage area, the first storage area is used to store external data, there is no first main storage page in the plurality of main storage pages of the first main storage sector, and the first storage area of the first main storage page has external data.

[0036] It should be noted that the storage device can be a flash memory.

[0037] The storage device can further include a state storage area, and the state storage area is used to store the number of erasures of the storage device.

[0038] The number of the plurality of main storage sectors can be 8, which is not limited in the present application.

[0039] The capacity of the main storage page can be 256 bytes, which is not limited in the present application.

[0040] The main storage page can further include a second storage area, a third storage area, and a fourth storage area, the second storage area is configured to store a check value of the external data in the first storage area of the main storage page, the third storage area is configured to store a write count of the main storage page, and the fourth storage area is configured to store a location identification value of the main storage page.

[0041] The second storage area can be located after the first storage area, the third storage area can be located before the first storage area, and the fourth storage area can be located before the third storage area, which are not limited in the present application.

[0042] In the case that the capacity of the main storage page is 256 bytes, the capacity of the second storage area can be 2 bytes, the capacity of the third storage area can be 1 byte, and the capacity of the fourth storage area can be 1 byte, which are not limited in the present application.

[0043] The storage device can further include a backup storage sector corresponding to each main storage sector, the backup storage sector includes a plurality of backup storage pages, the plurality of main storage pages of the main storage sector and the plurality of backup storage pages of the backup storage sector corresponding to the main storage sector are in one-to-one correspondence, the capacity of the main storage page and the backup storage page is the same, the backup storage page includes a fifth storage area, a sixth storage area, a seventh storage area, and an eighth storage area, the fifth storage area is configured to store mirror data of the external data in the first storage area of the main storage page corresponding to the backup storage page, the sixth storage area is configured to store a check value of the external data in the fifth storage area of the backup storage page, the seventh storage area is configured to store a write count of the backup storage page, and the eighth storage area is configured to store a location identification value of the backup storage page.

[0044] For example, if the storage device includes 4 main storage sectors, each main storage sector includes 16 main storage pages, each main storage page includes 256 bytes, the first byte of the 256 bytes is the fourth storage area, the second byte is the third storage area, the last two bytes are the second storage area, and the remaining bytes are the first storage area, the storage device also includes 4 backup storage sectors, each backup storage sector includes 16 backup storage pages, each backup storage page includes 256 bytes, the first byte of the 256 bytes is the eighth storage area, the second byte is the seventh storage area, the last two bytes are the sixth storage area, and the remaining bytes are the fifth storage area.

[0045] The check value can be a cyclic redundancy check (CRC) value.

[0046] The first main storage sector corresponds to the first backup main storage sector, the second main storage sector corresponds to the second backup main storage sector, the third main storage sector corresponds to the third backup main storage sector, and the fourth main storage sector corresponds to the fourth backup main storage sector.

[0047] The first main storage page of the first main storage sector corresponds to the first backup main storage page of the first backup main storage sector, the second main storage page of the first main storage sector corresponds to the second backup main storage page of the first backup main storage sector, the third main storage page of the first main storage sector corresponds to the third backup main storage page of the first backup main storage sector, and so on.

[0048] As a possible implementation manner, the data storage device traverses the plurality of main storage pages of the first main storage sector, and determines whether the first main storage page exists in the plurality of main storage pages. If not, the first main storage sector is determined as the first main storage sector.

[0049] If yes, the data storage device determines the first main storage sector as the third main storage sector, traverses the plurality of main storage pages of the second main storage sector, and determines whether the first main storage page exists in the plurality of main storage pages. If not, the second main storage sector is determined as the first main storage sector.

[0050] If yes, the data storage device determines the second main storage sector as the third main storage sector, traverses the plurality of main storage pages of the third main storage sector, and determines whether the first main storage page exists in the plurality of main storage pages. If not, the third main storage sector is determined as the first main storage sector.

[0051] If yes, the data storage device determines the third main storage sector as the third main storage sector, and so on, until the first main storage sector in the plurality of main storage sectors of the storage device is determined.

[0052] S202, the data storage device stores the external data to be stored to the first main storage sector.

[0053] As a possible implementation manner, in the case that the main storage page further includes a second storage area, a third storage area and a fourth storage area, the data storage device determines, according to the external data to be stored and the capacity of the first storage area, the plurality of second main storage pages in the first main storage sector and the sub-external data to be stored corresponding to each second main storage page.

[0054] The external data to be stored includes a plurality of sub-external data to be stored, and the second main storage page is used to store the corresponding sub-external data.

[0055] The data storage device determines, for each of the plurality of sub-external data to be stored, a first check value of the sub-external data to be stored, stores the sub-external data to be stored to a first storage area in a corresponding second main storage page, stores the first check value to a second storage area in the corresponding second main storage page, increments a position identifier value of a third main storage page in the plurality of second main storage pages by 1, and increments a write count of the corresponding second main storage page by 1.

[0056] The first storage area of the third main storage page contains external data.

[0057] It should be noted that the specific description of this possible implementation can refer to the subsequent part of the specific embodiment of the present application. The present application will not be described here.

[0058] As another possible implementation, in the case where the main storage page only includes the first storage area, the data storage device stores the external data to be stored to the first storage area in the main storage page of the first main storage sector.

[0059] S203, the data storage device erases data in the second main storage sector of the plurality of main storage sectors.

[0060] The second main storage sector is the next main storage sector of the first main storage sector.

[0061] As a possible implementation, the data storage device determines the next main storage sector of the first main storage sector as the second main storage sector.

[0062] After that, the data storage device erases data in the second main storage sector.

[0063] It should be noted that the specific scheme of erasing data in this possible implementation can refer to the existing scheme, which will not be described here.

[0064] Based on this scheme, by determining the empty first main storage sector in the plurality of main storage sectors of the storage device, then storing the external data to be stored to the first main storage sector, and then erasing data in the second main storage sector of the plurality of main storage sectors. Since the second main storage sector is the next main storage sector of the first main storage sector, the data in the next main storage sector can be erased at the same time as the external data is stored to the first main storage sector. In this way, the storage device always has an empty main storage sector, and when storing data again, the data can be directly stored without first erasing the data, thereby improving the efficiency of storing data.

[0065] The above is a general description of the data storage method provided by the present application. The data storage method provided by the present application will be further described below in combination with the drawings.

[0066] In one design, in a case where the storage page includes the second storage area, the third storage area, and the fourth storage area, FIG. 3 is a flowchart of another data storage method provided by the present application. As shown in FIG. 3, S202 provided by the embodiment of the present application can specifically include the following steps:

[0067] S301, the data storage device determines, according to the to-be-stored external data and the capacity of the first storage area, a plurality of second main storage pages in the first main storage sector and the sub to-be-stored external data corresponding to each second main storage page.

[0068] The to-be-stored external data includes a plurality of sub to-be-stored external data, and the second main storage page is used to store the corresponding sub external data.

[0069] As a possible implementation manner, the data storage device divides the to-be-stored external data into a plurality of sub to-be-stored external data with the capacity of the first storage area as the division step.

[0070] The data storage device determines that the first sub to-be-stored external data corresponds to the first second main storage page in the first main storage sector.

[0071] The data storage device determines that the second sub to-be-stored external data corresponds to the second second main storage page in the first main storage sector.

[0072] [Corrected according to Rule 91 on 24.06.2024] The data storage device determines that the third sub to-be-stored external data corresponds to the third second main storage page in the first main storage sector.

[0073] By analogy, the data storage device determines the plurality of second main storage pages in the first main storage sector and the sub to-be-stored external data corresponding to each second main storage page.

[0074] S302, the data storage device determines, for each sub to-be-stored external data in the plurality of sub to-be-stored external data, a first check value of the sub to-be-stored external data, stores the sub to-be-stored external data into the first storage area in the corresponding second main storage page, stores the first check value into the second storage area in the corresponding second main storage page, adds 1 to the position identification value of the third main storage page in the plurality of second main storage pages, and adds 1 to the write frequency of the corresponding second main storage page.

[0075] The first storage area of the third main storage page has external data.

[0076] As a possible implementation, first, the data storage device determines a first check value of a first sub-external data to be stored, stores the first check value to a second storage area of a first second main storage page, stores the first sub-external data to be stored to a first storage area of the first second main storage page, and adds 1 to a write-in times of the first second main storage page.

[0077] Since the first storage area of the first second main storage page has external data, the data storage device determines the first second main storage page as a third main storage page, and adds 1 to a position identification value of the third main storage page.

[0078] Thereafter, the data storage device determines a first check value of a second sub-external data to be stored, stores the first check value to a second storage area of a second second main storage page, stores the second sub-external data to be stored to a first storage area of the second second main storage page, and adds 1 to a write-in times of the second second main storage page.

[0079] Since the first storage areas of the first second main storage page and the second second main storage page have external data, the data storage device determines the first second main storage page and the second second main storage page as a third main storage page, and adds 1 to a position identification value of the third main storage page.

[0080] Thereafter, the data storage device determines a first check value of a third sub-external data to be stored, stores the first check value to a second storage area of a third second main storage page, stores the third sub-external data to be stored to a first storage area of the third second main storage page, and adds 1 to a write-in times of the third second main storage page.

[0081] Since the first storage areas of the first second main storage page, the second second main storage page and the third second main storage page have external data, the data storage device determines the first second main storage page, the second second main storage page and the third second main storage page as a third main storage page, and adds 1 to a position identification value of the third main storage page.

[0082] In this way, until the data storage device stores each sub-external data to be stored.

[0083] Based on the scheme, in the case that the storage page includes the second storage region, the third storage region and the fourth storage region, by determining the plurality of second main storage pages in the first main storage sector and the sub-external data corresponding to each second main storage page according to the to-be-stored external data and the capacity of the first storage region, then for each of the plurality of sub-external data, determining the first check value of the sub-external data, storing the sub-external data to the first storage region in the corresponding second main storage page, storing the first check value to the second storage region in the corresponding second main storage page, adding 1 to the position identification value of the third main storage page in the plurality of second main storage pages where the external data exists, and adding 1 to the write times of the corresponding second main storage page, the scheme of storing the to-be-stored external data to the first main storage sector can be realized.

[0084] In one design, FIG. 4 is a flow diagram of another data storage method provided by the present application. As shown in FIG. 4, the data storage method provided by the present application can further include the following steps:

[0085] S401, the data storage device determines the first backup storage page corresponding to the fourth main storage page in the plurality of second main storage pages.

[0086] The fourth main storage page is the main storage page with the latest write time in the plurality of second main storage pages.

[0087] As a possible implementation manner, after the data storage device writes data into a second main storage page, the data storage device determines the second main storage page as the main storage page with the latest write time, i.e., the fourth main storage page, and then determines the backup storage page corresponding to the fourth main storage page as the first backup storage page.

[0088] S402, the data storage device determines the second check value of the target mirror data of the sub-external data in the fourth main storage page, stores the target mirror data to the fifth storage region of the first backup storage page, stores the second check value to the sixth storage region of the first backup storage page, adds 1 to the position identification value of the second backup storage page in the backup storage sector where the first backup storage page is located, and adds 1 to the write times of the first backup storage page.

[0089] The fifth storage region of the second backup storage page stores external data.

[0090] As a possible implementation manner, the data storage device determines the target mirror data of the sub-external data in the fourth main storage page.

[0091] Afterwards, the data storage device determines a second check value of the target image data, stores the target image data to the fifth storage area of the first backup storage page, stores the second check value to the sixth storage area of the first backup storage page, and increases the write times of the first backup storage page by 1.

[0092] Afterwards, the data storage device finds the second backup storage page in the backup storage sector where the first backup storage page is located, and increases the position identification value of the second backup storage page by 1.

[0093] Based on the scheme, the first backup storage page corresponding to the fourth main storage page in the plurality of second main storage pages is determined, then the second check value of the target image data of the sub-external data in the fourth main storage page is determined, the target image data is stored to the fifth storage area of the first backup storage page, the second check value is stored to the sixth storage area of the first backup storage page, the position identification value of the second backup storage page in the backup storage sector where the first backup storage page is located is increased by 1, and the write times of the first backup storage page are increased by 1. Since the fourth main storage page is the main storage page with the latest write time in the plurality of second main storage pages, after the data is stored to the main storage page, the image data of the data is stored to the corresponding backup storage page, and the data can be backed up.

[0094] In one design, FIG. 5 is a flow diagram of another data storage method provided by the present application. As shown in FIG. 5, the data storage method provided by the present application can further include the following steps:

[0095] S501, in response to a target instruction, the data storage device acquires the write times of each main storage page of the plurality of main storage pages of the storage device.

[0096] The target instruction is used to acquire target external data in the first storage area of the fifth main storage page of the storage device, and the fifth main storage page is the main storage page with the latest write time in the plurality of main storage pages of the storage device.

[0097] It should be noted that the target instruction can be a data acquisition instruction, which is not limited in the present application.

[0098] As a possible implementation manner, the data storage device receives the target instruction and acquires the write times in the third storage area of each main storage page of the storage device in response to the target instruction.

[0099] S502, the data storage device determines the main storage page with the most write times as the fifth main storage page.

[0100] As a possible implementation manner, the data storage device determines the maximum value in the plurality of write times, and determines the main storage page corresponding to the maximum value as the fifth main storage page.

[0101] S503, the data storage device determines, according to the check value in the fifth main storage page, a first check result of the external data in the first storage area of the fifth main storage page.

[0102] As a possible implementation manner, the data storage device calculates a third check value of the external data in the first storage area of the fifth main storage page, and acquires the first check value in the second storage area of the fifth main storage page.

[0103] The data storage device compares the third check value and the first check value, and in a case where the third check value is same as the first check value, determines that the first check result indicates that the check passes; in a case where the third check value is not same as the first check value, determines that the first check result indicates that the check fails.

[0104] In a case where the first check result indicates that the check passes, the data storage device determines the external data in the first storage area of the fifth main storage page as target external data.

[0105] In a case where the first check result indicates that the check fails, the data storage device performs S504.

[0106] S504, in a case where the first check result indicates that the check fails, the data storage device determines, according to a check value in a second backup storage page corresponding to the fifth main storage page, a second check result of the external data in a fifth storage area of the second backup storage page.

[0107] As a possible implementation manner, in a case where the first check result indicates that the check fails, the data storage device determines the second backup storage page corresponding to the fifth main storage page, calculates a fourth check value of the external data in the fifth storage area of the second backup storage page, and acquires a second check value in a sixth storage area of the second backup storage page.

[0108] The data storage device compares the fourth check value and the second check value, and in a case where the fourth check value is same as the second check value, determines that the second check result indicates that the check passes; in a case where the fourth check value is not same as the second check value, determines that the second check result indicates that the check fails.

[0109] In a case where the second check result indicates that the check fails, the data storage device performs initialization processing on the fifth main storage page and the second backup storage page.

[0110] In a case where the first check result indicates that the check passes, the data storage device performs S505.

[0111] S505, in a case where the second check result indicates that the check passes, the data storage device determines the external data in the fifth storage area of the second backup storage page as target external data.

[0112] Based on the scheme, since the data is stored in the plurality of main storage pages in sequence when storing data, it can be considered that the data in the main storage page with the most write times is the latest written, and thus, when obtaining the target external data, the first check result of the external data in the first storage area of the fifth main storage page is determined according to the check value in the fifth main storage page with the most write times, then, in the case where the first check result indicates that the check fails, the second check result of the external data in the fifth storage area of the second backup storage page corresponding to the fifth main storage page is determined according to the check value in the second backup storage page, then, in the case where the second check result indicates that the check passes, the external data in the fifth storage area of the second backup storage page is determined as the target external data, the correctness of the data in the main storage page can be judged, and the target data is obtained from the corresponding backup storage page when the data in the main storage page is incorrect.

[0113] In a design, in the case where the storage device includes a state storage area, FIG. 6 is a flow diagram of another data storage method provided by the application, as shown in FIG. 6, the data storage method provided by the application can further include the following steps:

[0114] S601, the data storage device determines the number of third main storage sectors in the plurality of main storage sectors of the storage device.

[0115] Among them, the first main storage page exists in the plurality of main storage pages of the third main storage sector.

[0116] As a possible implementation manner, the data storage device traverses the plurality of main storage pages of the first main storage sector in the plurality of main storage sectors, judges whether the first main storage page exists in the plurality of main storage pages, and if not, determines the first main storage sector as the first main storage sector.

[0117] If yes, the data storage device determines the first main storage sector as the third main storage sector, traverses the plurality of main storage pages of the second main storage sector in the plurality of main storage sectors, judges whether the first main storage page exists in the plurality of main storage pages, and if not, determines the second main storage sector as the first main storage sector.

[0118] If yes, the data storage device determines the second main storage sector as the third main storage sector, traverses the plurality of main storage pages of the third main storage sector in the plurality of main storage sectors, judges whether the first main storage page exists in the plurality of main storage pages, and if not, determines the third main storage sector as the first main storage sector.

[0119] If yes, the data storage device determines the third main storage sector as the third main storage sector, and so on, and determines the number of the third main storage sectors.

[0120] In S602, the data storage device erases the data in each third main storage sector and adds 1 to the number of erasures if the number of the third main storage sectors is greater than the preset threshold.

[0121] It should be noted that the preset threshold can be 3, which is not limited in the present application.

[0122] As a possible implementation, the data storage device determines whether the number of the third main storage sectors is greater than the preset threshold.

[0123] If yes, the data storage device erases the data in each third main storage sector and adds 1 to the number of erasures, or the data storage device erases the data in each third main storage sector and the data in the backup storage sector corresponding to each third main storage sector and adds 1 to the number of erasures.

[0124] If no, the data storage device does not perform any action.

[0125] Based on the scheme, in the case that the storage device includes a state storage area, by determining the number of the third main storage sectors in the plurality of main storage sectors of the storage device, since the first main storage page exists in the plurality of main storage pages of the third main storage sector, if the number is greater than the preset threshold, it indicates that the storage space of the storage device is insufficient, the data in each third main storage sector is erased, and the number of erasures is added by 1. On the one hand, the storage space of the storage device can be released, and on the other hand, the number of erasures of the storage device can be recorded.

[0126] The embodiments of the present application can divide the data storage device into functional modules according to the above method examples.

[0127] In the case of adopting functional module division, FIG. 7 shows a structural schematic diagram of a data storage device. As shown in FIG. 7, the data storage device 70 includes a determination module 701 and a processing module 702.

[0128] In some embodiments, the data storage device 70 can further include a storage module (not shown in FIG. 7) for storing program instructions and data.

[0129] The determining module 701 is configured to determine a first main storage sector of a plurality of main storage sectors of a storage device; the main storage sector comprises a plurality of main storage pages, the main storage page comprises a first storage area, the first storage area is configured to store external data, there is no first main storage page in the plurality of main storage pages of the first main storage sector, and the first storage area of the first main storage page has external data.

[0130] All related contents of each step involved in the above method embodiments can be cited to the function description of the corresponding function module, which will not be repeated here.

[0131] In the case of realizing the functions of the above function modules in the form of hardware, FIG. 8 shows a structural schematic diagram of another data storage device. As shown in FIG. 8, the data storage device 80 comprises a processor 801, a memory 802 and a bus 803. The processor 801 and the memory 802 can be connected through the bus 803.

[0132] It should be noted that the structure shown in FIG. 8 does not constitute a limitation on the data storage device 80. In addition to the components shown in FIG. 8, the data storage device 80 can include more or fewer components than shown, or combine certain components, or different component arrangements.

[0133] As an example, in combination with FIG. 7, the functions realized by the determining module 701 and the processing module 702 in the data storage device 70 are the same as the functions of the processor 801 in FIG. 8.

[0134] Optionally, as shown in FIG. 8, the data storage device 80 provided by the embodiments of the present application can further comprise a communication interface 804.

[0135] A computer readable storage medium, on which a computer program or instructions are stored, the computer program or instructions are executed to make the computer execute each step in the method flow shown in the above method embodiments.

[0136] The embodiments of the present application provide a computer program product containing instructions, which, when executed on a computer, make the computer execute each step in the method flow shown in the above method embodiments.

[0137] The embodiments of the present application provide a chip system, comprising: a processor and an interface circuit; the interface circuit is configured to receive a computer program or instructions and transmit to the processor; the processor is configured to execute the computer program or instructions, so that the chip system executes each step in the method flow shown in the above method embodiments.

[0138] Since the data storage apparatus, the computer readable storage medium and the computer program product provided by the embodiment can be applied to the data storage method provided by the embodiment, the technical effects that can be obtained by the data storage apparatus, the computer readable storage medium and the computer program product can be referred to the method embodiment, and the embodiment of the application will not be repeated here.

Claims

1. A data storage method, characterized by, The method comprises: determining a first main storage sector of a plurality of main storage sectors of a storage device; the main storage sector comprises a plurality of main storage pages, the main storage page comprises a first storage area, the first storage area is used for storing external data, there is no first main storage page in the plurality of main storage pages of the first main storage sector, and there is external data in the first storage area of the first main storage page; storing the to-be-stored external data to the first main storage sector; erasing data in a second main storage sector of the plurality of main storage sectors; the second main storage sector is a next main storage sector of the first main storage sector.

2. The method of claim 1, wherein, The main storage page further comprises a second storage area, a third storage area and a fourth storage area, the second storage area is used for storing a check value of external data in the first storage area of the main storage page, the third storage area is used for storing a write number of the main storage page, and the fourth storage area is used for storing a position identification value of the main storage page. The method further comprises: determining a plurality of second main storage pages in the first main storage sector and sub-to-be-stored external data corresponding to each second main storage page according to the to-be-stored external data and a capacity of the first storage area; the to-be-stored external data comprises a plurality of sub-to-be-stored external data, and a second main storage page is used for storing corresponding sub-external data; 3. The method of claim 2, wherein, for each sub-to-be-stored external data in the plurality of sub-to-be-stored external data, determining a first check value of the sub-to-be-stored external data, storing the sub-to-be-stored external data to the first storage area in the corresponding second main storage page, storing the first check value to the second storage area in the corresponding second main storage page, adding 1 to a position identification value of a third main storage page in the plurality of second main storage pages, and adding 1 to a write number of the corresponding second main storage page; the first storage area of the third main storage page has external data.

4. The method of claim 3, wherein, The storage device further comprises a backup storage sector corresponding to each main storage sector, the backup storage sector comprises a plurality of backup storage pages, the plurality of main storage pages of the main storage sector and the plurality of backup storage pages of the backup storage sector corresponding to the main storage sector are in one-to-one correspondence, the capacity of the main storage page and the backup storage page is the same, the backup storage page comprises a fifth storage area, a sixth storage area, a seventh storage area and an eighth storage area, the fifth storage area is used for storing mirror data of external data in the first storage area of the main storage page corresponding to the backup storage page, the sixth storage area is used for storing a check value of external data in the fifth storage area of the backup storage page, the seventh storage area is used for storing a write number of the backup storage page, and the eighth storage area is used for storing a position identification value of the backup storage page. The method further comprises: determining a first backup storage page corresponding to a fourth main storage page in the plurality of second main storage pages; the fourth main storage page is a main storage page with the latest write time in the plurality of second main storage pages. determining a second check value of target mirror data of the sub-external data in the fourth main storage page, storing the target mirror data to a fifth storage area of the first backup storage page, storing the second check value to a sixth storage area of the first backup storage page, adding 1 to a position identification value of a second backup storage page in a backup storage sector where the first backup storage page is located, and adding 1 to a write-in times of the first backup storage page; the fifth storage area of the second backup storage page stores external data.

5. The method of claim 4, wherein, The method further comprises: in response to a target instruction, acquiring a write-in times of each main storage page in a plurality of main storage pages of the storage device; the target instruction is used to acquire target external data in a first storage area of a fifth main storage page of the storage device, and the fifth main storage page is a main storage page with the latest write-in time in the plurality of main storage pages of the storage device; determining the main storage page with the most write-in times as the fifth main storage page; determining a first check result of the external data in the first storage area of the fifth main storage page according to a check value in the fifth main storage page; in a case where the first check result indicates that the check fails, determining a second check result of the external data in a fifth storage area of a second backup storage page according to a check value in the second backup storage page corresponding to the fifth main storage page; in a case where the second check result indicates that the check passes, determining the external data in the fifth storage area of the second backup storage page as the target external data.

6. The method of claim 5, wherein, in a case where the second check result indicates that the check fails, the method further comprises: performing initialization processing on the fifth main storage page and the second backup storage page.

7. The method according to any one of claims 1 to 6, characterized in that, The storage device further comprises a state storage area used to store an erase times of the storage device, and the method further comprises: determining a number of third main storage sectors in a plurality of main storage sectors of the storage device; there is a first main storage page in a plurality of main storage pages of the third main storage sector; in a case where the number is greater than a preset threshold, erasing data in each third main storage sector and adding 1 to the erase times.

8. A data storage device, characterized by The apparatus comprises a determining module and a processing module. The determining module is configured to determine a first main storage sector in a plurality of main storage sectors of a storage device; the main storage sector comprises a plurality of main storage pages, the main storage page comprises a first storage area, the first storage area is used to store external data, there is no first main storage page in a plurality of main storage pages of the first main storage sector, and the first storage area of the first main storage page stores external data. The processing module is configured to store to-be-stored external data to the first main storage sector. The processing module is further configured to erase data in a second main storage sector of the plurality of main storage sectors; the second main storage sector is a next main storage sector of the first main storage sector.

9. A data storage device, characterized by The data storage device comprises a processor coupled with a memory for storing programs or instructions that, when executed by the processor, cause the device to perform the method of any of claims 1 to 7.

10. A computer readable storage medium having stored thereon a computer program or instructions, characterized in that, The computer programs or instructions, when executed, cause a computer to perform the method of any of claims 1 to 7.

Citation Information

Patent Citations

  • To-be-stored data storage method, device and equipment

    CN112653539A

  • Data storage method and electronic equipment

    CN114371816A

  • Data processing method and related device

    CN116107506A

  • SRAM type FPGA data storage method and device

    CN116431073A

  • Data processing method and device, computer equipment and storage medium

    CN116521062A