Data write-back method and device, equipment and medium

By identifying and deleting invalid data in the cache area, and merging data information to write back when a certain amount of threshold is reached, the problem of flash memory storage devices containing invalid data during data writeback is solved, and the writeback efficiency and reliability of storage devices are improved.

CN119597218APending Publication Date: 2025-03-11SUGON INFORMATION IND +2
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411690050.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

In the prior art, flash memory storage devices tend to contain invalid data during data write-back, resulting in low write-back efficiency and increased storage device load.

Method used

By obtaining data information in the cache area, including the cache page identification, bitmap identification and write timestamp, identifying and deleting invalid data, only valid data is retained, and when a certain amount of threshold is reached, the data information is saved in a read-only linked list for merge and write back.

Benefits of technology

Improves the efficiency of data write back, reduces the number of accesses and workloads to storage devices, and reduces equipment losses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119597218A_ABST
    Figure CN119597218A_ABST
Patent Text Reader

Abstract

The invention provides a data write-back method and device, equipment and a medium. The data write-back method and device are used for quickly and efficiently performing data write-back. In the method, an identifier of a cache page where data is written, a bitmap identifier and a writing timestamp are recorded in data information of a cache region, and the bitmap identifier is generated according to whether the data is written into each sub-storage position of the cache page after the data is written into the cache page; for any data information in the cache region, judging whether other data information of which the identifier and the bitmap identifier of the cache page are the same as those of the cache page and the bitmap identifier of the data information exists in the cache region or not; if yes, determining the data information reserved in the cache region according to the write-in timestamp of the data information and the write-in timestamps of other data information; the corresponding data is written back into the storage device based on the data information reserved in the cache region, so that invalid data can be prevented from entering a write-back process, and the write-back efficiency is quickly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a data write-back method, device, equipment and medium. Background Art

[0002] Storage devices such as solid-state drives based on flash memory are widely used due to their absolute advantages in performance, energy consumption, reliability, and size. Due to the special storage characteristics of flash memory itself, when a user writes data, the data is first stored in the cache area, which can quickly respond to user operations. After that, the data will be asynchronously written from the cache area to the storage device (this process can be called write-back) to reduce direct access to storage devices such as solid-state drives and improve overall performance.

[0003] In the related art, when data written by the user is stored in the cache area, the data written by the user each time is usually stored in the cache area, resulting in the presence of some invalid data in the cache area that has been corrected by the user. These invalid data will subsequently enter the write-back process, thereby affecting the write-back efficiency, increasing the number of accesses to storage devices such as solid-state drives, and increasing the workload and loss of storage devices.

[0004] Therefore, how to write back data quickly and efficiently is a technical problem that needs to be solved urgently. Summary of the invention

[0005] The present application provides a data write-back method, device, equipment and medium for quickly and efficiently performing data write-back.

[0006] In a first aspect, the present application provides a data write-back method, the method comprising:

[0007] Acquire data information of a cache page stored in a cache area, wherein the data information records an identifier of the cache page to which the data is written, a bitmap identifier, and a write timestamp, wherein the bitmap identifier is generated based on whether data is written into each sub-storage location of the cache page after the data is written into the cache page;

[0008] For any data information, determine whether there is other data information in the cache area whose cache page identifier and bitmap identifier are the same as the cache page identifier and bitmap identifier of the data information; if so, determine the data information retained in the cache area according to the write timestamp of the data information and the write timestamp of the other data information;

[0009] Based on the data information retained in the buffer area, the corresponding data is written back to the storage device.

[0010] Through the above method, for each data information in the cache area, the invalid data in the cache area that has been corrected by the user can be identified based on the identifier of the cache page where the data recorded in the data information is written, the bitmap identifier and the write timestamp, and these invalid data can be deleted, and only the valid data can be retained. Therefore, when the corresponding data is written back to the storage device based on the data information retained in the cache area, the invalid data can be avoided from entering the write-back process, thereby quickly improving the write-back efficiency to a certain extent, reducing the number of write-backs, reducing the number of accesses to storage devices such as solid-state hard drives, and reducing the workload and loss of storage devices.

[0011] In a possible implementation, writing corresponding data back to a storage device based on the data information retained in the cache area includes:

[0012] When the amount of data information in the buffer area reaches a first amount threshold, saving the data information in the buffer area into a read-only linked list;

[0013] Merging multiple pieces of data information with the same identifier of the cache page recorded in the read-only linked list;

[0014] According to the data information in the read-only linked list after the data information is merged, the corresponding data is written back to the storage device.

[0015] Through the above method, since multiple data information with the same identifier of the cache page recorded in the read-only linked list can be merged, the corresponding data in the read-only linked list after the merged data information is written back to the storage device, thereby minimizing the number of accesses to storage devices such as solid-state drives and improving write-back efficiency.

[0016] In a possible implementation, the process of determining the first quantity threshold includes:

[0017] Get the target number of read-only linked lists whose data has not yet been written back to the storage device;

[0018] According to the correspondence between the number of pre-configured read-only linked lists and the number threshold, the number threshold corresponding to the target number is determined as the first number threshold.

[0019] Through the above method, since the size of the first quantity threshold can be adaptively and dynamically adjusted based on the target number of read-only linked lists whose data has not yet been written back to the storage device, it is possible to, to a certain extent, take into account both timely recovery of cache space and reduction of the number of times the solid-state hard disk is accessed, thereby improving the flexibility and effectiveness of data write-back.

[0020] In a possible implementation, merging multiple pieces of data information with the same identifier of the cache page recorded in the read-only linked list includes:

[0021] Identify each target data information that records the same cache page identifier, and for any sub-storage location of the cache page, determine the target data information of the sub-data that was most recently written in the sub-storage location based on the bitmap identifier of the cache page and the write timestamp recorded in each target data information; based on the sub-data of the sub-storage location recorded in the target data information, record in the merged data information that the sub-storage location stores the sub-data.

[0022] Through the above method, since each target data information recorded with the same cache page identifier can be identified, for any sub-storage location of the cache page, the target data information of the sub-data most recently written in the sub-storage location is determined based on the bitmap identifier of the cache page recorded in each target data information and the write timestamp, and multiple data information with the same cache page identifier are merged, which can improve the efficiency and accuracy of data information merging.

[0023] In a possible implementation, the process of generating the data information includes:

[0024] For any received write input / output (IO) instruction, identifying the write position information and the write timestamp of the data to be written carried by the write IO instruction;

[0025] Determine, according to a predetermined target cache page size, an identifier of a write cache page and a sub-storage location of the write cache page that match the write location information; and generate a bitmap identifier of the write cache page based on the sub-storage location of the write cache page;

[0026] The identifier of the write cache page, the bitmap identifier of the write cache page, and the corresponding write timestamp are recorded in the data information of the write cache page.

[0027] Through the above method, since the identifier of the write cache page, the bitmap identifier and the corresponding write timestamp can be recorded in the corresponding data information, fine-grained data information including the identifier of the cache page and the bitmap identifier can be obtained. Subsequently, based on these fine-grained data information, invalid data corrected by the user can be quickly and easily identified by occupying less computing power resources. While improving the write-back efficiency, it can minimize the impact on the efficiency of quickly storing the data written by the user in the cache area to quickly respond to user operations.

[0028] In a possible implementation, the process of determining the target cache page size includes:

[0029] Identify the identifier of the target storage volume carried by the write IO instruction;

[0030] According to the pre-saved correspondence between the storage volume identifier and the cache page size, the cache page size corresponding to the target storage volume is determined as the target cache page size.

[0031] In the above manner, the target cache page size applicable to the data to be written can be determined according to the pre-saved correspondence between the storage volume identifier and the cache page size, thereby improving the flexibility and accuracy of writing data.

[0032] In a second aspect, the present application provides a data write-back device, which has the function of implementing the behavior of the electronic device in the method embodiment of the first aspect above, and the beneficial effects can be found in the description of the first aspect and will not be repeated here. The data write-back device includes:

[0033] An acquisition module is used to acquire data information of a cache page stored in a cache area, wherein the data information records an identifier of the cache page to which data is written, a bitmap identifier, and a write timestamp, wherein the bitmap identifier is generated based on whether data is written into each sub-storage location of the cache page after the data is written into the cache page;

[0034] A decision module, for determining, for any data information, whether there is other data information in the cache area whose cache page identifier and bitmap identifier are the same as the cache page identifier and bitmap identifier of the data information; if so, determining the data information retained in the cache area according to the write timestamp of the data information and the write timestamp of the other data information;

[0035] The write-back module is used to write the corresponding data back to the storage device based on the data information retained in the cache area.

[0036] In a possible implementation, the write-back module is specifically used to:

[0037] When the amount of data information in the buffer area reaches a first amount threshold, saving the data information in the buffer area into a read-only linked list;

[0038] Merging multiple pieces of data information with the same identifier of the cache page recorded in the read-only linked list;

[0039] According to the data information in the read-only linked list after the data information is merged, the corresponding data is written back to the storage device.

[0040] In a possible implementation, the write-back module is specifically used to:

[0041] Get the target number of read-only linked lists whose data has not yet been written back to the storage device;

[0042] According to the correspondence between the number of pre-configured read-only linked lists and the number threshold, the number threshold corresponding to the target number is determined as the first number threshold.

[0043] In a possible implementation, the write-back module is specifically used to:

[0044] Identify each target data information that records the same cache page identifier, and for any sub-storage location of the cache page, determine the target data information of the sub-data that was most recently written in the sub-storage location based on the bitmap identifier of the cache page and the write timestamp recorded in each target data information; based on the sub-data of the sub-storage location recorded in the target data information, record in the merged data information that the sub-storage location stores the sub-data.

[0045] In a possible implementation, the acquisition module is specifically used to:

[0046] For any received write input / output (IO) instruction, identifying the write position information and the write timestamp of the data to be written carried by the write IO instruction;

[0047] Determine, according to a predetermined target cache page size, an identifier of a write cache page and a sub-storage location of the write cache page that match the write location information; and generate a bitmap identifier of the write cache page based on the sub-storage location of the write cache page;

[0048] The identifier of the write cache page, the bitmap identifier of the write cache page, and the corresponding write timestamp are recorded in the data information of the write cache page.

[0049] In a possible implementation, the acquisition module is specifically used to:

[0050] Identify the identifier of the target storage volume carried by the write IO instruction;

[0051] The target cache page size corresponding to the target storage volume is determined according to the pre-saved correspondence between the storage volume identifier and the cache page size.

[0052] In a third aspect, the present application further provides an electronic device, which includes at least a processor and a memory, and the processor is used to implement the steps of the data write-back method as described in any one of the first aspects when executing a computer program stored in the memory.

[0053] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer performs the steps of the data write-back method as described in any one of the first aspects.

[0054] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes: a computer program code, which, when executed on a computer, enables the computer to execute the steps of the data write-back method as described in any one of the first aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] In order to more clearly illustrate the implementation methods in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technology descriptions. Obviously, the drawings described below are some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.

[0056] Figure 1 A schematic diagram of a data write-back process provided in an embodiment of the present application;

[0057] Figure 2 A schematic diagram of a process of writing data to be written into a cache page provided in an embodiment of the present application;

[0058] Figure 3A A schematic diagram of a data information merging process provided in an embodiment of the present application;

[0059] Figure 3B A schematic diagram of another data information merging process provided in an embodiment of the present application;

[0060] Figure 4 A schematic diagram of another data information merging process provided in an embodiment of the present application;

[0061] Figure 5 A schematic diagram of another data write-back process provided in an embodiment of the present application;

[0062] Figure 6 A schematic diagram of the structure of a data write-back device provided in an embodiment of the present application;

[0063] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0064] In order to make the purpose and implementation method of the present application clearer, the exemplary implementation method of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.

[0065] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.

[0066] The terms "first", "second", "third", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances.

[0067] The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.

[0068] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.

[0069] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. 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 replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

[0070] For the convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are to better explain the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.

[0071] An embodiment of the present application provides a data write-back method, apparatus, device and medium. In the method, the data information of the cache page stored in the cache area may record the identifier of the cache page to which the data is written, a bitmap identifier and a write timestamp, wherein the bitmap identifier is generated based on whether data is written into each sub-storage location of the cache page after the data is written to the cache page; for any data information, it can be determined whether there is a cache page identifier and other data information in the cache area whose bitmap identifier is the same as the cache page identifier and bitmap identifier of the data information; if so, the data information retained in the cache area can be determined based on the write timestamp of the data information and the write timestamp of the other data information; thereafter, the corresponding data can be written back to the storage device based on the data information retained in the cache area. Because in the embodiment of the present application, for each data information in the cache area, the invalid data in the cache area that has been corrected by the user can be identified based on the identifier of the cache page to which the data recorded in the data information is written, the bitmap identifier and the write timestamp, and these invalid data can be deleted, and only the valid data can be retained. Therefore, when the corresponding data is written back to the storage device based on the data information retained in the cache area, the invalid data can be avoided from entering the subsequent write-back process, thereby quickly improving the write-back efficiency to a certain extent, reducing the number of write-backs, reducing the number of accesses to storage devices such as solid-state hard drives, and reducing the workload and loss of storage devices.

[0072] Embodiment 1:

[0073] Figure 1 A schematic diagram of a data write-back process provided in an embodiment of the present application, the process includes:

[0074] S101: Obtain data information of a cache page stored in a cache area, wherein the data information records an identifier of the cache page to which data is written, a bitmap identifier, and a data write timestamp, and the bitmap identifier is generated based on whether data is written into each sub-storage location of the cache page after the data is written into the cache page.

[0075] The data write-back method provided in the embodiment of the present application is applied to an electronic device, which may be, for example, a personal computer (PC), a mobile terminal, a server, etc., and the present application does not make any specific limitation on this.

[0076] In a possible implementation, when a user writes data, a front-end thread in an electronic device may receive a write input output (IO) instruction triggered by the user. For the received write IO instruction, the electronic device may identify the write position information and write timestamp of the data to be written carried in the write IO instruction. Among them, the write position information may include the start write position (lba) of the data to be written and the total write length (len), etc., which is not specifically limited in the present application. For example, the start write position and the total write length in the write position information may be based on sectors as the basic unit. Among them, sectors refer to the areas divided on the disk, and each track on the disk is equally divided into several arc segments, which are the sectors of the disk. The reading and writing of the hard disk is based on sectors as the basic unit, which will not be repeated here.

[0077] In one possible implementation, the write timestamp carried in the write IO instruction can be the timestamp when the user starts writing data, or it can be the timestamp when the data writing is completed. This application does not make specific limitations on this and can be flexibly set according to needs.

[0078] After identifying the write location information of the data to be written carried by the write IO instruction, the data to be written can be written to the corresponding cache page according to the predetermined cache page size (for ease of description, referred to as the target cache page size) with the cache page as the granularity. Among them, the target cache page size can be based on sectors as the basic unit, such as the target cache page size is 16 sectors, etc. The target cache page size can be flexibly set according to demand, and this application does not make specific restrictions on this.

[0079] In a possible implementation, in order to improve the flexibility and accuracy of writing data, different storage volumes may correspond to different cache page sizes, and the correspondence between different storage volume identifiers and cache page sizes may be pre-saved. Among them, the storage volume and the corresponding cache page size may be flexibly set according to demand. When determining the target cache page size suitable for the data to be written, the identifier of the target storage volume carried in the write IO instruction may be identified, and then, based on the pre-saved correspondence between the storage volume identifier and the cache page size, the cache page size corresponding to the target storage volume carried in the write IO instruction may be determined as the target cache page size applicable to the data to be written.

[0080] Since the present application can determine the target cache page size applicable to the data to be written according to the correspondence between the pre-saved storage volume identifier and the cache page size, the flexibility and accuracy of writing data can be improved.

[0081] In a possible implementation, a target cache page size applicable to the data to be written is determined. When the data to be written is written into the corresponding cache page according to the target cache page size, the identifier of the cache page (referred to as the write cache page for ease of description) matching the write location information and the sub-storage location of the write cache page can be determined, and the data to be written is written into the sub-storage locations of the corresponding plurality of cache pages (write cache pages). For example, see Figure 2 , Figure 2 A schematic diagram of a process of writing data to be written into a cache page is provided for an embodiment of the present application. Assume that in the write position information carried by the write IO instruction, the start write position is the 10th sector of a storage volume (Lun), and the total write length is 16×5, that is, 80 sectors. Assuming that the target cache page size applicable to the data to be written is 16 sectors, a total of 7 sectors of data to be written can be written in the 10th to 16th sectors (sub-storage positions) of the first cache page, and the data to be written can be written in all sectors of the second cache page, the third cache page, the fourth cache page, and the fifth cache page, respectively, and a total of 9 sectors of data to be written can be written in the 1st to 9th sectors of the sixth cache page.

[0082] In a possible implementation, in order to facilitate identification of whether data is written into each sub-storage location of a cache page, a bitmap identifier of the cache page may be generated based on whether each sub-storage location of the cache page is written with data to be written. Exemplarily, when a sub-storage location is written with the above-mentioned data to be written, the sub-bitmap identifier of the sub-storage location may be a first set value such as 1, and conversely, when a sub-storage location is not written with the above-mentioned data to be written, the sub-bitmap identifier of the sub-storage location may be a second set value such as 0, and the bitmap identifier of the cache page may be generated based on the sub-bitmap identifiers of each sub-storage location. The bitmap identifier of a cache page may be a binary or hexadecimal value, which is not specifically limited in the present application. Taking the bitmap identifier of the cache page in hexadecimal as an example, when all 16 sectors of a cache page are written with the data to be written (that is, the cache page is a full page), the sub-bitmap identifier set (binary) of each sub-storage location of the cache page can be {1111111111111111}. After converting the binary sub-bitmap identifier set to hexadecimal, the generated cache page bitmap identifier (bitmap) can be 0xffff.

[0083] As another example, a total of 7 sectors, including the 10th to 16th sectors of the first cache page, are written with data to be written, and 9 sectors are not written with data to be written. Based on the reverse sorting rule (the sub-bitmap identifier of the last sector is placed first, and the sub-bitmap identifier of the first sector is placed last), the sub-bitmap identifier set (binary) of each sub-storage location (sector) of the first cache page can be {1111111000000000}. After converting the binary sub-bitmap identifier set to hexadecimal, the generated cache page bitmap identifier (bitmap) can be 0xfe00, which will not be repeated here.

[0084] In a possible implementation, for each write cache page, information such as the identifier of the write cache page, the bitmap identifier, the data (sub-data) written in each sub-storage location, and the corresponding write timestamp can be recorded in the data information of the write cache page.

[0085] In a possible implementation, for each write IO instruction, when the data to be written of the write IO instruction is written into several cache pages (write cache pages), the data information of these cache pages can be saved in the cache area. Exemplarily, the data information of these cache pages can be saved in an ordered linked list (memtable) in the cache area. The electronic device can obtain (identify) each data information stored in the cache area.

[0086] S102: For any data information, determine whether there is other data information in the cache area whose cache page identifier and bitmap identifier are the same as the cache page identifier and bitmap identifier of the data information; if so, determine the data information retained in the cache area based on the write timestamp of the data information and the write timestamp of the other data information; based on the data information retained in the cache area, write the corresponding data back to the storage device.

[0087] In a possible implementation, for each data information in the cache area, it can be determined whether there is other data information in the cache area whose cache page identifier and bitmap identifier are the same as the cache page identifier and bitmap identifier of the data information. If so, it can be considered that there is invalid data (invalid data information) that has been corrected by the user in the data information and the other data information. Wherein, when determining invalid data, the data information with a newer write timestamp can be determined as the data information retained in the cache area according to the write timestamp of the data information and the write timestamp of the other data information, and the data information with an older write timestamp can be determined as invalid data (invalid data information). The invalid data (invalid data information) can be deleted, so that when the corresponding data is subsequently written back to the storage device based on the data information retained in the cache area, the invalid data can be avoided from entering the subsequent write-back process, thereby improving the write-back efficiency to a certain extent, reducing the number of write-backs, reducing the number of accesses to storage devices such as solid-state hard drives, and reducing the workload and loss of storage devices.

[0088] For example, assume that the 10th to 16th sectors of a cache page are written with data A by the user at 8:00 am, generating data information 1; the 10th to 16th sectors of the cache page are written with data B by the user at 9:00 am, generating data information 2, at which time data A becomes invalid data. The cache page identifier and bitmap identifier in data information 1 and data information 2 are the same, the write timestamp of data information 2 is newer, and the write timestamp of data information 1 is older, then data information 2 can be retained in the cache area, and data information 1 can be deleted.

[0089] In an embodiment of the present application, for each data information in the cache area, invalid data in the cache area that has been corrected by the user can be identified based on the identifier of the cache page to which the data recorded in the data information is written, the bitmap identifier, and the write timestamp, and these invalid data can be deleted, and only valid data can be retained. Therefore, when the corresponding data is written back to the storage device based on the data information retained in the cache area, the invalid data can be avoided from entering the subsequent write-back process, thereby quickly improving the write-back efficiency to a certain extent, reducing the number of write-backs, reducing the number of accesses to storage devices such as solid-state hard drives, and reducing the workload and loss of storage devices.

[0090] In addition, since the present application can identify the write location information and write timestamp of the data to be written carried by the received write IO instruction; determine the identifier of the write cache page and the sub-storage location of the write cache page that match the write location information according to the predetermined target cache page size; generate a bitmap identifier of the write cache page based on the sub-storage location of the write cache page, and record the identifier of the write cache page, the bitmap identifier and the corresponding write timestamp in the corresponding data information, so that fine-grained data information such as the bitmap identifier of the cache page can be obtained, and subsequently, based on these fine-grained data information, invalid data corrected by the user can be quickly and easily identified by occupying less computing power resources, while improving the write-back efficiency, the efficiency of quickly storing the data written by the user in the cache area to quickly respond to user operations can be minimized.

[0091] Embodiment 2:

[0092] In order to write back data quickly and efficiently, based on the above embodiment, in the embodiment of the present application, writing back the corresponding data to the storage device based on the data information retained in the cache area includes:

[0093] When the amount of data information in the buffer area reaches a first amount threshold, saving the data information in the buffer area into a read-only linked list;

[0094] Merging multiple pieces of data information with the same identifier of the cache page recorded in the read-only linked list;

[0095] According to the data information in the read-only linked list after the data information is merged, the corresponding data is written back to the storage device.

[0096] In a possible implementation, no matter all sectors in the cache page are written with data (the cache page is full page) or only some sectors are written with data (the cache page is not full page), the data information of the cache page of full page and not full page can be saved in the same ordered linked list (memtable) in the cache area. When the amount of data information in the cache area reaches the first quantity threshold, that is, when the amount of data information in the ordered linked list reaches the first quantity threshold, the data information can be saved in a read-only linked list (immtable), and the ordered linked list can be cleared at the same time, and the cache area space can be reclaimed in time to facilitate receiving the data information of the new cache page.

[0097] In one possible implementation, in order to improve the flexibility of data write-back, the first quantity threshold value can be configured as a value that can adaptively and dynamically change with the number of read-only linked lists. Specifically, the total number of read-only linked lists whose data has not yet been written back to the storage device can be obtained (for ease of description, referred to as the target number), and the quantity threshold value corresponding to the target number can be determined as the above-mentioned first quantity threshold value based on the correspondence between the number of pre-configured read-only linked lists (the number can also be a quantity interval) and the quantity threshold value. Among them, the first quantity threshold value can also be referred to as the write-back trigger threshold value. Among them, the quantity threshold value (write-back trigger threshold value) corresponding to the number of read-only linked lists that have not yet been written back to the storage device can be flexibly set according to demand, and this application does not make specific restrictions on this.

[0098] Exemplarily, when the number of read-only linked lists that have not been written back to the storage device is larger, the corresponding first quantity threshold (write-back trigger threshold) can be larger, thereby avoiding to a certain extent the situation where the write-back trigger threshold is too small and there is too little data in each read-only linked list, resulting in the need to frequently write data back to the solid-state drive (storage device). Conversely, when the number of read-only linked lists that have not been written back to the storage device is smaller, the corresponding first quantity threshold can be smaller, thereby avoiding to a certain extent the situation where the write-back trigger threshold is too large and the write-back is not timely, resulting in the inability to reclaim the cache space in time.

[0099] Since the present application can adaptively and dynamically adjust the size of the first quantity threshold based on the target number of read-only linked lists whose data has not yet been written back to the storage device, it can, to a certain extent, take into account both the timely recovery of cache space and the reduction of the number of times the solid-state hard disk is accessed, thereby improving the flexibility and effectiveness of data write-back.

[0100] In a possible implementation, considering that in scenarios such as supporting multi-user editing of shared documents, some sectors of a cache page can be written by user A to generate a data information, and other sectors of the cache page can be written by user B to generate another data information, this will cause multiple data information with the same cache page identifier to exist in the read-only linked list. If these data information are written back to the solid-state drive separately, the number of accesses to the solid-state drive may increase, reducing the write-back efficiency. In order to improve the write-back efficiency, the multiple data information with the same cache page identifier recorded in the read-only linked list can be merged first, and then the corresponding data can be written back to the storage device based on the data information in the read-only linked list after the data information is merged, thereby minimizing the number of accesses to the solid-state drive and improving the write-back efficiency.

[0101] In a possible implementation, taking the cache page identifier as a number or letter as an example, in order to improve the merging speed of data information with the same cache page identifier, the data information can be sorted in order from small to large or from large to small according to the cache page number (identifier), and the data information with the same cache page number can be sorted together, thereby avoiding traversing all the data information each time to find the data information with the same cache page identifier, thereby improving the merging speed.

[0102] In a possible implementation, while sorting the data information according to the size of the cache page number (identifier), for cache pages with the same identifier, the data information can also be sorted in the order of small to large or large to small according to the bitmap identifier of the cache page, so as to maximize the merging speed. In addition, the data information stored in the cache area can also be sorted according to the process of sorting the data information according to the cache page number (identifier) ​​and the size of the bitmap identifier as described above, which will not be repeated here.

[0103] In addition, sorting the data information according to the number (identifier) ​​of the cache page and the size of the bitmap identifier is also beneficial for quickly identifying the cache page and sub-storage position corresponding to the data to be read carried in the read IO instruction when a user-triggered read IO instruction is received later, without traversing all data information to obtain the cache page and sub-storage position corresponding to the data to be read, which can improve the reading efficiency. Exemplarily, after receiving a read IO instruction triggered by a user, the read position information of the data to be read carried in the read IO instruction can be identified, and then the identifier and sub-storage position of the cache page matching the read position information can be determined according to the target cache page size, and then the data information recording the identifier and sub-storage position of the cache page can be identified from the read-only linked list or the cache area ordered linked list, and the corresponding data can be read from the data information. Similar to the write position information, the read position information can include the start reading position and the total read length, and the read position information can also be based on sectors as the basic unit, which will not be repeated here.

[0104] In one possible implementation, when merging multiple data information with the same cache page identifier recorded in a read-only linked list, each data information (referred to as target data information for ease of description) with the same cache page identifier can be identified first, and for any sub-storage location of the cache page with the identifier, the target data information of the sub-data most recently written in the sub-storage location can be determined based on the bitmap identifier and write timestamp of the cache page recorded in each target data information, and then, based on the sub-data of the sub-storage location recorded in the target data information, it can be recorded in the merged data information that the sub-data is stored in the sub-storage location.

[0105] For example, see Figure 3A, Figure 3A A schematic diagram of a data information merging process provided for an embodiment of the present application. Assuming that the identifiers of the cache pages recorded in data information A and data information B in the read-only linked list are the same, based on the bitmap identifiers of the two data information, it is known that all sectors of the cache page of data information A have data written, and the 15th to 16th sectors (sectors) of the cache page of data information B have data written. When the time in the write timestamp of data information A is earlier and the time in the write timestamp of data information B is later, it can be considered that the latest written data (sub-data) of the 15th to 16th sectors of the cache page is the corresponding sub-data in data information B, and the sub-data of the 15th to 16th sectors recorded in data information B can be determined as the sub-data of the 15th to 16th sectors of the cache page in the merged data information. That is to say, after merging data information A and data information B, the 1st to 14th sectors in the obtained data information are sub-data of the 1st to 14th sectors in data information A, and the 15th to 16th sectors are sub-data of the 15th to 16th sectors in data information B.

[0106] See also Figure 3B , Figure 3B Another schematic diagram of a data information merging process provided in an embodiment of the present application. Figure 3A The difference is, Figure 3B If the writing time of data information A is later, and the writing time of data information B is earlier, then after merging data information A and data information B, the 1st to 16th sectors in the obtained data information are the sub-data of the 1st to 16th sectors in data information A.

[0107] For further illustration, see Figure 4 , Figure 4A schematic diagram of another data information merging process provided for an embodiment of the present application. Assuming that the identifiers of the cache pages recorded by data information A and data information B in the read-only linked list are the same, based on the bitmap identifiers of the two data information, it is known that data is written in the 15th to 16th sectors (sectors) of the cache page of data information A, and data is written in the 2nd to 15th sectors of the cache page of data information B. Assuming that the time in the write timestamp of data information A is earlier, and the time in the write timestamp of data information B is later, when merging data information A and data information B, the sub-data written in the 16th sector of the cache page of data information A can be copied to the corresponding 16th sector of data information B based on the data information with the later timestamp time (data information B), so as to reduce the number of copies and improve the merging efficiency. Specifically, after merging data information A and data information B, the sub-data of the 2nd to 15th sectors in the obtained data information are the sub-data of the 2nd to 15th sectors in data information B, and the sub-data of the 16th sector in the data information obtained after merging are the sub-data of the 16th sector in data information A. At this time, the first sector of the cache page in the data information obtained after merging has no data written, and the cache page can be considered as a non-full page. In a possible implementation, a bitmap identifier of the cache page recorded in the merged data information can be generated based on whether each sub-storage location of the cache page in the merged data information is written with data (sub-data), wherein the process of generating the bitmap identifier is the same as the process of generating the bitmap identifier described in the above embodiment, and will not be repeated here.

[0108] Since the present application can identify each target data information recorded with the same cache page identifier, for any sub-storage location of the cache page, based on the bitmap identifier and write timestamp of the cache page recorded in each target data information, the target data information of the sub-data most recently written in the sub-storage location is determined, and multiple data information with the same cache page identifier are merged, thereby improving the efficiency and accuracy of data information merging.

[0109] In a possible implementation, in order to ensure that the data is written back to the disk in the order of writing time, when there are data in multiple read-only linked lists that need to be written back, the data can be written back in order from the generation time of the read-only linked lists. Exemplarily, the write-back thread in the electronic device can periodically process the read-only linked lists at a preset time interval, wherein the read-only linked lists with an earlier generation time can be processed first, and the read-only linked lists with a later generation time can be processed later.

[0110] Since the present application can merge multiple data information with the same identifier of the cache page recorded in the read-only linked list, and write the corresponding data back to the storage device for the data information in the read-only linked list after the data information is merged, the number of accesses to storage devices such as solid-state drives can be minimized, thereby improving the write-back efficiency.

[0111] Embodiment 3:

[0112] For ease of understanding, the data write-back process provided by the present application is explained below through a specific embodiment. Figure 5 , Figure 5 Another data write-back process diagram provided in an embodiment of the present application includes the following steps:

[0113] S500: For any received write IO instruction, identify the write location information and write timestamp of the data to be written carried by the write IO instruction; determine the identifier of the write cache page and the sub-storage location of the write cache page that match the write location information according to a predetermined target cache page size; generate a bitmap identifier of the write cache page based on the sub-storage location of the write cache page; record the identifier of the write cache page, the bitmap identifier and the corresponding write timestamp in the data information of the write cache page.

[0114] Among them, when determining the target cache page size, the identifier of the target storage volume carried by the write IO instruction can be identified; according to the pre-saved correspondence between the storage volume identifier and the cache page size, the cache page size corresponding to the target storage volume is determined as the above-mentioned target cache page size.

[0115] S501: For any data information stored in the cache area, determine whether there is other data information in the cache area whose cache page identifier and bitmap identifier are the same as the cache page identifier and bitmap identifier of the data information; if so, determine the data information to be deleted and the data information to be retained in the cache area based on the write timestamp of the data information and the write timestamp of the other data information.

[0116] S502: When the amount of data information in the cache area reaches a first amount threshold, the data information in the cache area is saved in a read-only linked list.

[0117] Among them, when determining the first quantity threshold, the target number of read-only linked lists whose data has not yet been written back to the storage device can be obtained; according to the correspondence between the number (quantity interval) of pre-configured read-only linked lists and the quantity threshold, the quantity threshold corresponding to the target number is determined as the above-mentioned first quantity threshold.

[0118] S503: The write-back thread periodically processes the read-only linked list at a preset time interval. For example, a read-only linked list is processed every five minutes, and the read-only linked list with an earlier generation time is processed first, and the data in the read-only linked list is written back to the storage device. Among them, when processing any read-only linked list, multiple data information with the same identifier of the cache page recorded in the read-only linked list can be merged first, and then the corresponding data is written back to the storage device according to the data information in the read-only linked list after the merged data information.

[0119] Among them, when multiple data information with the same cache page identifier recorded in a read-only linked list are merged, each target data information with the same cache page identifier can be identified, and for any sub-storage location of the cache page, according to the bitmap identifier and write timestamp of the cache page recorded in each target data information, the target data information of the sub-data most recently written in the sub-storage location is determined; according to the sub-data of the sub-storage location recorded in the target data information, it is recorded in the merged data information that the sub-storage location stores the sub-data.

[0120] Embodiment 4:

[0121] Based on the same technical concept, on the basis of the above embodiments, the present application provides a data write-back device. Figure 6 A schematic diagram of the structure of a data write-back device provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the device comprises:

[0122] The acquisition module 601 is used to acquire data information of a cache page stored in a cache area, wherein the data information records an identifier of the cache page to which data is written, a bitmap identifier, and a write timestamp, wherein the bitmap identifier is generated based on whether data is written into each sub-storage location of the cache page after the data is written into the cache page;

[0123] The decision module 602 is used to determine, for any data information, whether there is other data information in the cache area whose cache page identifier and bitmap identifier are the same as the cache page identifier and bitmap identifier of the data information; if so, determine the data information retained in the cache area according to the write timestamp of the data information and the write timestamp of the other data information;

[0124] The write-back module 603 is used to write the corresponding data back to the storage device based on the data information retained in the cache area.

[0125] In a possible implementation, the write-back module 603 is specifically configured to:

[0126] When the amount of data information in the buffer area reaches a first amount threshold, saving the data information in the buffer area into a read-only linked list;

[0127] Merging multiple pieces of data information with the same identifier of the cache page recorded in the read-only linked list;

[0128] According to the data information in the read-only linked list after the data information is merged, the corresponding data is written back to the storage device.

[0129] In a possible implementation, the write-back module 603 is specifically configured to:

[0130] Get the target number of read-only linked lists whose data has not yet been written back to the storage device;

[0131] According to the correspondence between the number of pre-configured read-only linked lists and the number threshold, the number threshold corresponding to the target number is determined as the first number threshold.

[0132] In a possible implementation, the write-back module 603 is specifically configured to:

[0133] Identify each target data information that records the same cache page identifier, and for any sub-storage location of the cache page, determine the target data information of the sub-data that was most recently written in the sub-storage location based on the bitmap identifier of the cache page and the write timestamp recorded in each target data information; based on the sub-data of the sub-storage location recorded in the target data information, record in the merged data information that the sub-storage location stores the sub-data.

[0134] In a possible implementation, the acquisition module 601 is specifically configured to:

[0135] For any received write input / output (IO) instruction, identifying the write position information and the write timestamp of the data to be written carried by the write IO instruction;

[0136] Determine, according to a predetermined target cache page size, an identifier of a write cache page and a sub-storage location of the write cache page that match the write location information; and generate a bitmap identifier of the write cache page based on the sub-storage location of the write cache page;

[0137] The identifier of the write cache page, the bitmap identifier of the write cache page, and the corresponding write timestamp are recorded in the data information of the write cache page.

[0138] In a possible implementation, the acquisition module 601 is specifically configured to:

[0139] Identify the identifier of the target storage volume carried by the write IO instruction;

[0140] The target cache page size corresponding to the target storage volume is determined according to the pre-saved correspondence between the storage volume identifier and the cache page size.

[0141] Embodiment 5:

[0142] Based on the same technical concept, the present application also provides an electronic device, Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, it includes: a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704;

[0143] The memory 703 stores a computer program, and when the program is executed by the processor 701, the processor 701 implements any of the above embodiments. Since the principle of solving the problem by the electronic device is similar to the data write-back method, the implementation of the electronic device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0144] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0145] The communication interface 702 is used for communication between the electronic device and other devices.

[0146] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0147] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0148] Embodiment 6:

[0149] Based on the same technical concept, an embodiment of the present application provides a computer-readable storage medium, in which a computer program executable by an electronic device is stored, and when the program is run on the electronic device, the electronic device implements any of the above embodiments when executing. Since the principle of solving the problem by the computer-readable storage medium is similar to that of the data write-back method, the implementation of the computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.

[0150] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in the electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical storage such as CD, DVD, BD, HVD, etc., and semiconductor storage such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD), etc.

[0151] Based on the same technical concept, the embodiment of the present application also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the above embodiments. Since the principle of solving the problem by the above computer program product is similar to that of the data write-back method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.

[0152] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0153] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0154] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0155] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0156] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A data write-back method, characterized in that: The method comprises: Acquire data information of a cache page stored in a cache area, wherein the data information records an identifier of the cache page to which the data is written, a bitmap identifier, and a write timestamp, wherein the bitmap identifier is generated based on whether data is written into each sub-storage location of the cache page after the data is written into the cache page; For any data information, determine whether there is other data information in the cache area whose cache page identifier and bitmap identifier are the same as the cache page identifier and bitmap identifier of the data information; if so, determine the data information retained in the cache area according to the write timestamp of the data information and the write timestamp of the other data information; Based on the data information retained in the buffer area, the corresponding data is written back to the storage device.

2. The method according to claim 1, characterized in that The step of writing corresponding data back to the storage device based on the data information retained in the cache area includes: When the amount of data information in the buffer area reaches a first amount threshold, saving the data information in the buffer area into a read-only linked list; Merging multiple pieces of data information with the same identifier of the cache page recorded in the read-only linked list; According to the data information in the read-only linked list after the data information is merged, the corresponding data is written back to the storage device.

3. The method according to claim 2, characterized in that The process of determining the first quantity threshold comprises: Get the target number of read-only linked lists whose data has not yet been written back to the storage device; According to the correspondence between the number of pre-configured read-only linked lists and the number threshold, the number threshold corresponding to the target number is determined as the first number threshold.

4. The method according to claim 2, characterized in that: The merging of multiple data information with the same identifier of the cache page recorded in the read-only linked list includes: Identify each target data information that records the same cache page identifier, and for any sub-storage location of the cache page, determine the target data information of the sub-data that was most recently written in the sub-storage location based on the bitmap identifier of the cache page and the write timestamp recorded in each target data information; based on the sub-data of the sub-storage location recorded in the target data information, record in the merged data information that the sub-storage location stores the sub-data.

5. The method according to claim 1, characterized in that The process of generating the data information includes: For any received write input / output (IO) instruction, identifying the write position information and the write timestamp of the data to be written carried by the write IO instruction; Determine, according to a predetermined target cache page size, an identifier of a write cache page and a sub-storage location of the write cache page that match the write location information; and generate a bitmap identifier of the write cache page based on the sub-storage location of the write cache page; The identifier of the write cache page, the bitmap identifier of the write cache page, and the corresponding write timestamp are recorded in the data information of the write cache page.

6. The method according to claim 5, characterized in that The process of determining the target cache page size includes: Identify the identifier of the target storage volume carried by the write IO instruction; According to the pre-saved correspondence between the storage volume identifier and the cache page size, the cache page size corresponding to the target storage volume is determined as the target cache page size.

7. A data write-back device, characterized in that: The device comprises: An acquisition module is used to acquire data information of a cache page stored in a cache area, wherein the data information records an identifier of the cache page to which data is written, a bitmap identifier, and a write timestamp, wherein the bitmap identifier is generated based on whether data is written into each sub-storage location of the cache page after the data is written into the cache page; A decision module, for determining, for any data information, whether there is other data information in the cache area whose cache page identifier and bitmap identifier are the same as the cache page identifier and bitmap identifier of the data information; if so, determining the data information retained in the cache area according to the write timestamp of the data information and the write timestamp of the other data information; The write-back module is used to write the corresponding data back to the storage device based on the data information retained in the cache area.

8. An electronic device, characterized in that: The electronic device comprises at least a processor and a memory, and the processor is configured to implement the steps of the method according to any one of claims 1 to 6 when executing a computer program stored in the memory.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the method according to any one of claims 1 to 6.

Citation Information

Cited By

  • Data writing method and system, electronic equipment, storage medium and program product

    CN121029106A

  • Data writing method, system, electronic device, storage medium and program product

    CN121029106B