Data storage method and electronic device
By generating feature encoding and writing commands based on attribute information in video recording data storage technology, the data fragmentation problem is solved and the performance and life of the storage device are improved.
Patent Information
- Application Number
- PCT/CN2023/093612
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-08
- Filing Date
- 2023-05-11
- Publication Date
- 2024-11-14
AI Technical Summary
In video recording data storage technology, the host side only uses standard commands to write, resulting in fragmentation of data in the storage device and affecting the writing performance and service life.
By generating feature encoding based on data attribute information on the host side, generating corresponding write commands, and writing data to the storage area corresponding to the feature encoding, ensuring that the feature encoding corresponds to the storage area one by one, avoiding data fragmentation.
It effectively avoids data fragmentation and improves the writing performance and service life of the storage device.
Smart Images

Figure CN2023093612_14112024_PF_FP_ABST
Abstract
Description
Data storage method and electronic device
[0001] This application claims priority to Chinese patent application number 2023105141382, the contents of which are incorporated herein by reference.
Technical field
[0002] The present application relates to the field of storage, and in particular to a data storage method and electronic device. [Background Technology]
[0003] In conventional video recording data storage technology, the host side only uses standard commands when writing, retaining only the starting address and length of the data. When receiving data, the storage device side can only simply identify the size of each data entry and perform simple data diversion by setting a data size threshold. When the host side receives multiple channels of video recording data, it writes the multiple channels of video recording data together, causing the data stored in the storage device to become overly fragmented, as shown in Figure 1, which is a schematic diagram of a two-channel data write. Fragmented storage requires the storage device to continuously perform GC (garbage collection), affecting the smoothness of continuous write performance and the service life of the storage device.
[0004] [Summary of the invention]
[0005] The main purpose of this application is to provide a data storage method and electronic device, which can solve the technical problem that data fragmentation stored in a storage device affects the writing performance and service life.
[0006] To solve the above technical problems, the first technical solution adopted in this application is to provide a data storage method. This method is applied to a host and includes: obtaining data to be written; generating a characteristic code based on attribute information of the data to be written, wherein the characteristic code corresponds to the attribute information; generating a write command based on the characteristic code; and sending the write command and the corresponding data to be written to a storage device, so that the storage device receives the write command and, based on the characteristic code in the write command, writes the data to be written to a storage area corresponding to the characteristic code, wherein the characteristic code corresponds to the storage area.
[0007] To solve the above technical problems, the second technical solution adopted by this application is to provide a data storage method. This method is applied to a storage device and includes: receiving a write command and corresponding data to be written, where the write command is generated based on a feature code, which is generated based on attribute information of the data to be written, and the feature code and the attribute information have a one-to-one correspondence; based on the feature code in the write command, writing the corresponding data to be written to a storage area corresponding to the feature code; wherein the feature code and the storage area have a one-to-one correspondence.
[0008] To solve the above technical problems, the third technical solution adopted in this application is to provide a data storage method. This method is applied to a storage system comprising a host and a storage device, and comprises: the host obtaining data to be written; the host generating a feature code based on attribute information of the data to be written, wherein the feature code corresponds to the attribute information; the host generating a write command based on the feature code; the host sending the write command and the corresponding data to be written to the storage device; the storage device receiving the write command and the corresponding data to be written; and the storage device writing the corresponding data to be written to a storage area corresponding to the feature code based on the feature code in the write command; wherein the feature code corresponds to the storage device.
[0009] To solve the above technical problems, the fourth technical solution adopted in this application is to provide an electronic device. The electronic device includes a memory and a processor, wherein the memory is used to store program data, and the program data can be executed by the processor to implement the method described in any of the above technical solutions.
[0010] The beneficial effects of the present application are as follows: by generating a characteristic code based on the attribute information of the data to be written, the generated characteristic code corresponds one-to-one with the attribute information, and then generating a write command based on the characteristic code, a storage device that receives the write command can store the corresponding data to be written based on the characteristic code in the write command, storing it in a storage area corresponding to the characteristic code. Since the characteristic code and the storage area also correspond one-to-one, data to be written with different attributes will be stored in different storage areas, thus preventing the fragmentation of stored data, avoiding the impact of data fragmentation on the data writing performance of the storage device, and improving the service life of the storage device.
Brief Description of the Drawings
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without inventive efforts. Among them:
[0012] Figure 1 is a schematic diagram of a 2-way data writing;
[0013] FIG2 is a flow chart of a first embodiment of a data storage method of the present application;
[0014] FIG3 is a schematic diagram of a two-way data writing method according to the present invention;
[0015] FIG4 is a flow chart of a second embodiment of the data storage method of the present application;
[0016] FIG5 is a flow chart of a third embodiment of the data storage method of the present application;
[0017] FIG6 is a flow chart of a fourth embodiment of the data storage method of the present application;
[0018] FIG7 is a flowchart of a fifth embodiment of the data storage method of the present application;
[0019] FIG8 is a schematic structural diagram of the first embodiment of the electronic device of the present application. [Specific implementation method]
[0020] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0021] The terms "first," "second," and the like in this application are used to distinguish between different objects, not to describe a particular order. Furthermore, the terms "including," "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements, but may optionally include steps or elements not listed, or may optionally include other steps or elements inherent to the process, method, product, or apparatus.
[0022] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0023] 2, which is a flow chart of a first embodiment of the data storage method of the present application. The method is applied to the host side and includes the following steps:
[0024] S11: Obtain the data to be written.
[0025] The data to be written is data acquired by the host and needs to be written to the storage device for storage.
[0026] S12: Generate a feature code based on the attribute information of the data to be written, where the feature code corresponds to the attribute information one-to-one.
[0027] Obtain the attribute information of the data to be written and generate the corresponding feature code based on the attribute information. The feature code corresponds to the attribute information one-to-one, and different attribute information corresponds to different feature codes.
[0028] S13: Generate a write command based on the feature code.
[0029] Write the feature code into the write command.
[0030] S14: Sending a write command and the corresponding data to be written to the storage device, so that the storage device receives the write command and writes the data to be written to the storage area corresponding to the feature code based on the feature code in the write command; wherein the feature code corresponds to the storage area one-to-one.
[0031] The write command and the data to be written corresponding to the command are sent to the storage device together. The storage device writes the data to be written into the corresponding storage area according to the feature code in the write command. Since the feature code corresponds to the storage area one by one, the data corresponding to different feature codes will be written into different storage areas. Therefore, the data to be written with different attribute information will be stored in different storage areas, and will not be stored in the same area, resulting in fragmentation of the stored data and affecting the data writing performance of the storage device. As shown in Figure 3, Figure 3 is a schematic diagram of 2-way data writing under the technical solution of the present application. During the data writing process, the two-way data are stored in different storage blocks respectively, storage block 1 only stores the data of 1 way, and storage block 2 only stores the data of 2 ways.
[0032] The storage area includes at least two minimum write units, indicating that the data volume corresponding to the storage area includes the data volume corresponding to at least two minimum write units, and the data volume corresponding to the minimum write unit is the minimum amount of data required to be written by the storage device during a single write process. The data volume of the minimum write unit can be set based on actual data requirements or the actual situation of the storage device and is not limited here.
[0033] Based on the technical solution of the present application, in actual situations, the storage area is an entire area formed by at least two adjacent minimum write units.
[0034] In some embodiments, the storage area can be a memory block or a bare die (DIE), and the specific size can be customized based on actual usage. The technical solution of this application stores data with different attribute information, such as data on different paths, in different memory blocks or bare die storage areas to achieve data partitioning, avoid data fragmentation, and improve the performance of the storage device.
[0035] In this embodiment, a characteristic code is generated based on the attribute information of the data to be written, and the generated characteristic code corresponds one-to-one with the attribute information. A write command is then generated based on the characteristic code, so that a storage device receiving the write command can store the corresponding data to be written based on the characteristic code in the write command, storing it in the storage area corresponding to the characteristic code. Since the characteristic code and the storage area also have a one-to-one correspondence, data to be written with different attributes will be stored in different storage areas, thus preventing the fragmentation of stored data, avoiding the impact of data fragmentation on the data write performance of the storage device, and improving the service life of the storage device.
[0036] In one embodiment, the attribute information may include at least one of the source of the data to be written, the data type, and the importance. Each attribute corresponds to at least two pieces of attribute information. For example, if the attribute is data source, the attribute information may correspond to data source A, data source B, and data source C, etc. If the attribute is importance, the attribute information may correspond to important, moderately important, and unimportant, etc.
[0037] In one embodiment, generating a feature code based on the attribute information of the data to be written includes generating a feature code based on the attribute information of at least one attribute. The feature code can be generated based on the attribute information of only one attribute, or it can be generated based on the attribute information of multiple attributes. For example, for the attribute of data source, the attribute information corresponds to data source A and data source B, and for the attribute of importance, the attribute information corresponds to important and unimportant, then there are four corresponding attribute information, data source A and important, data source A and unimportant, data source B and important, and data source B and unimportant. The host side can perform feature coding according to the four different attribute information, so that the data to be written with the same attribute information can be stored in the same storage area, avoiding data fragmentation. The host side can also perform feature coding only according to the data source attribute, so that the data to be written of data source A and data source B are respectively stored in corresponding storage areas, avoiding data fragmentation.
[0038] 3, which is a flow chart of a second embodiment of the data storage method of the present application. This method is a further extension of step S12 and includes the following steps:
[0039] S21: Receive a data diversion function start command.
[0040] In conjunction with the execution of the aforementioned feature code generation step, a data diversion function status command is set. The data diversion function status command includes a data diversion function start command and a data diversion function shutdown command. When the command is enabled, the feature code generation step is executed to divert data. When the command is disabled, the feature code generation step is not executed, and data diversion is not performed.
[0041] S22: In response to the data diversion function being enabled, attribute information of the data to be written is obtained.
[0042] When a data offloading function start command is received, attribute information of the data to be written is obtained for generating a feature code.
[0043] In one embodiment, the data offload function status command is implemented by a FEATURE command, and may also be implemented by other function commands according to actual conditions, which is not limited here.
[0044] 4 is a flow chart of a third embodiment of the data storage method of the present application. The method is applied to a storage device and includes the following steps:
[0045] S31: receiving a write command and corresponding data to be written, wherein the write command is generated based on a feature code, and the feature code is generated based on attribute information of the data to be written, and the feature code and the attribute information correspond one to one.
[0046] After receiving the write command, the corresponding data to be written is processed according to the write command.
[0047] S32: Based on the feature code in the write command, the corresponding data to be written is written into a storage area corresponding to the feature code; wherein the feature code and the storage area have a one-to-one correspondence.
[0048] Since the write command contains a feature code, the feature code is generated based on the attribute information of the data to be written. The feature code corresponds one-to-one to the attribute information, and different attribute information corresponds to different feature codes. Therefore, a one-to-one corresponding storage area is set based on the feature code to store the data to be written with different attribute information in different storage areas.
[0049] 5 , which is a flow chart of a fourth embodiment of the data storage method of the present application. This method is a further extension of step S32 and includes the following steps:
[0050] S41: In response to the storage area corresponding to the feature code being full of useful data, obtaining an available storage area.
[0051] After receiving a write command, the characteristic code in the write command is further obtained. A determination is made as to whether the storage area corresponding to the characteristic code is already full of data or already full of useful data, and an available storage area is obtained. An available storage area can be a storage area that has data stored but is useless and can be deleted, or it can be an idle storage area that has not yet stored any data. The specific available storage area can be determined based on actual usage.
[0052] S42: Align the available storage area with the characteristic code to store the data to be written corresponding to the characteristic code.
[0053] The newly acquired available storage area is matched with the characteristic code so as to be used for storing the to-be-written data corresponding to the characteristic code in the following.
[0054] When the available storage area obtained is matched with the feature code, the previous storage area corresponding to the feature code is cancelled, so that the feature code and the storage area correspond one to one. In the correspondence list, the data is kept simple, which is convenient for the storage device to search.
[0055] S43: Based on the feature code, the corresponding data to be written is written into the available storage area corresponding to the feature code.
[0056] After determining the available storage area, the data to be written is stored.
[0057] 6, which is a flow chart of a fifth embodiment of the data storage method of the present application. The method is applied to a storage system and includes the following steps:
[0058] S51: The host obtains the data to be written.
[0059] The data to be written is data acquired by the host and needs to be written to the storage device for storage.
[0060] S52: The host generates a feature code based on the attribute information of the data to be written, and the feature code corresponds to the attribute information one by one.
[0061] Obtain the attribute information of the data to be written and generate the corresponding feature code based on the attribute information. The feature code corresponds to the attribute information one-to-one, and different attribute information corresponds to different feature codes.
[0062] S53: The host generates a write command based on the feature code.
[0063] Write the feature code into the write command.
[0064] S54: The host sends the write command and the corresponding data to be written to the storage device.
[0065] S55: The storage device receives the write command and the corresponding data to be written.
[0066] S56: The storage device writes the corresponding data to be written into the storage area corresponding to the feature code based on the feature code in the write command; wherein the feature code corresponds to the storage device one-to-one.
[0067] A write command and the corresponding data to be written are sent to the storage device. The storage device writes the data to the corresponding storage area based on the characteristic code in the write command. Because characteristic codes correspond to storage areas, data with different attribute information will be stored in different storage areas rather than in the same area. This causes data fragmentation and affects the storage device's data writing performance.
[0068] The same or similar steps can be described in the above embodiments and will not be repeated here.
[0069] The data storage method of the present application is described in more detail with reference to a specific embodiment below.
[0070] The host defines a protocol mode, the Multichannel video acceleration (MVA) protocol mode, and the host turns this mode on and off by setting FFEATURE. After turning on the MVA mode, the host will number each channel of video data and encode the code into the reserved field of the write command. By passing different numbers, data diversion on the host side is achieved. After receiving the write command, the storage device diverts the data according to the different numbers in the write command, and data with the same number will be stored in the same area. Using the above method can greatly reduce the fragmentation of data storage, reduce unnecessary garbage collection of the storage device, and improve the smoothness of continuous write performance and the service life of the storage device.
[0071] Reserved fields are unused fields in a command. For example, up to now, the Write DMA Ext command 35h and most other standard write commands have many unused fields. These reserved fields can be used to execute the data storage method of this application.
[0072] As shown in FIG7 , FIG7 is a schematic structural diagram of the first embodiment of the electronic device of the present application.
[0073] The electronic device includes a processor 110 and a memory 120 .
[0074] The processor 110 controls the operation of the electronic device and may also be referred to as a CPU (Central Processing Unit). The processor 110 may be an integrated circuit chip with the ability to process signal sequences. The processor 110 may also be a general-purpose processor, a digital signal sequence processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The general-purpose processor may be a microprocessor or any conventional processor.
[0075] The memory 120 stores instructions and program data required for the processor 110 to operate. The memory 120 may include a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), or other media that can store program instructions.
[0076] The processor 110 is communicatively connected to the memory 120 to implement the method provided by any one of the first to fifth embodiments of the aforementioned data storage method of the present application and any possible combination thereof.
[0077] In summary, by generating a characteristic code based on the attribute information of the data to be written, the generated characteristic code corresponds one-to-one with the attribute information, and then generating a write command based on the characteristic code, the storage device that receives the write command can store the corresponding data to be written based on the characteristic code in the write command, and store it in the storage area corresponding to the characteristic code. Since the characteristic code and the storage area also correspond one-to-one, the data to be written with different attributes will be stored in different storage areas, and the fragmentation of the stored data will not occur, thereby avoiding the impact of data fragmentation on the data writing performance of the storage device and improving the service life of the storage device.
[0078] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules or units is merely a logical functional division. In actual implementation, other division methods may be used, such as combining or integrating multiple units or components into another system, or ignoring or not implementing certain features.
[0079] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of this embodiment.
[0080] In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The above-mentioned integrated units may be implemented in the form of hardware or software functional units.
[0081] If the integrated units in the above other embodiments are implemented in the form of software functional units and sold or used as independent products, they 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 for enabling a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0082] The above description is merely an embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A data storage method, characterized in that: Applied to the host side, the method includes: Get the data to be written; Generate a feature code based on the attribute information of the data to be written, wherein the feature code corresponds to the attribute information one by one; generating a write command based on the feature code; Sending the write command and the corresponding data to be written to a storage device, so that the storage device receives the write command and writes the data to be written to a storage area corresponding to the feature code based on the feature code in the write command; The characteristic codes correspond to the storage areas one by one.
2. The method according to claim 1, characterized in that Before generating the feature code based on the attribute information of the data to be written, the method includes: Receive data diversion function start command; In response to the data diversion function being enabled, attribute information of the data to be written is obtained.
3. The method according to claim 2, characterized in that The data diversion function enabling command is implemented through the FEATURE command.
4. The method according to claim 1, characterized in that The attribute to which the attribute information belongs may include at least one of the source, data type, and importance of the data to be written.
5. The method according to claim 4, characterized in that Each of the attributes corresponds to at least two pieces of attribute information.
6. The method according to claim 5, characterized in that The generating the feature code based on the attribute information of the data to be written includes: The feature code is generated based on the attribute information of at least one attribute.
7. A data storage method, characterized in that: Applied to a storage device, the method comprises: receiving a write command and corresponding data to be written, wherein the write command is generated based on a feature code, the feature code is generated based on attribute information of the data to be written, and the feature code corresponds to the attribute information in a one-to-one manner; Based on the feature code in the write command, write the corresponding data to be written into a storage area corresponding to the feature code; The characteristic codes correspond to the storage areas one by one.
8. The method according to claim 7, characterized in that The step of writing the corresponding data to be written into a storage area corresponding to the feature code based on the feature code in the write command comprises: In response to the storage area corresponding to the feature code being full of useful data, obtaining an available storage area; The available storage area is associated with the feature code to store the to-be-written data corresponding to the feature code; Based on the feature code, the corresponding data to be written is written into the available storage area corresponding to the feature code.
9. A data storage method, characterized in that: Applied to a storage system, the storage system includes a host end and a storage device, the method includes: The host end obtains the data to be written; The host generates a feature code based on the attribute information of the data to be written, wherein the feature code corresponds to the attribute information one by one; The host generates a write command based on the feature code; The host sends the write command and the corresponding data to be written to the storage device; The storage device receives a write command and corresponding data to be written; The storage device writes the corresponding data to be written into a storage area corresponding to the feature code based on the feature code in the write command; Therein, the characteristic codes correspond one to one with the storage devices.
10. An electronic device, characterized in that: The invention comprises a memory and a processor, wherein the memory is used to store program data, and the program data can be executed by the processor to implement the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Method for improving performance of solid state disk
CN108241471A
Data storage method and related equipment
CN113590501A
Data storage method, intelligent terminal and computer readable storage medium
CN115878016A
