CN116909485A - Data write-back method and device, electronic equipment and computer readable storage medium - Google Patents

Data write-back method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN116909485A
CN116909485A CN202310970133.0A CN202310970133A CN116909485A CN 116909485 A CN116909485 A CN 116909485A CN 202310970133 A CN202310970133 A CN 202310970133A CN 116909485 A CN116909485 A CN 116909485A
Authority
CN
China
Prior art keywords
metadata
user data
disk
write
writing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310970133.0A
Other languages
Chinese (zh)
Inventor
陈少杰
周斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
TP Link Technologies Co Ltd
Original Assignee
TP Link Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by TP Link Technologies Co Ltd filed Critical TP Link Technologies Co Ltd
Priority to CN202310970133.0A priority Critical patent/CN116909485A/en
Publication of CN116909485A publication Critical patent/CN116909485A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0656Data buffering arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0676Magnetic disk device

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A data write-back method, device, electronic equipment and computer readable storage medium; the data write-back method comprises the following steps: obtaining data to be written back in a cache, wherein the data to be written back comprises metadata and user data; and if the number of times of writing back the user data to the disk reaches a preset number of times threshold, writing back the metadata to the disk. According to the method, based on a mechanism that metadata and user data are respectively written back, when the number of times of writing back the user data reaches a preset number threshold, the metadata is written back once, namely, the metadata is written back once corresponding to the user data writing back for a plurality of times, and the refreshing number of the metadata writing back is reduced; therefore, by delaying the write-back of the metadata, the write-back efficiency of an operating system is improved, and the input and output performance of the disk is improved.

Description

Data write-back method and device, electronic equipment and computer readable storage medium
Technical Field
The present application relates to the field of data storage technologies, and in particular, to a data write-back method, a data write-back device, an electronic device, and a computer readable storage medium.
Background
In the process of executing data write-back by the operating system, the data needing write-back is copied into a cache of the kernel, and a corresponding page in the cache is marked as a dirty page. When the dirty pages in the memory reach a certain threshold value, the data of the dirty pages need to be written back into storage units such as a disk of the equipment.
Currently, for a file system of a disk, a write-back process synchronously refreshes user data and metadata. In order to ensure data atomicity, a lock is required to be held in the process of writing back metadata; after the metadata is written into the disk, the file system can copy the user data into the cache to form a new dirty page, so that the writing of the user data is blocked in the process of writing back the metadata, and the writing back efficiency of the operating system is lower.
Disclosure of Invention
According to various embodiments of the present application, a data write-back method, apparatus, electronic device, and computer-readable storage medium are provided.
In a first aspect, the present application provides a data write-back method, including: obtaining data to be written back in a cache, wherein the data to be written back comprises metadata and user data; and if the number of times of writing back the user data to the disk reaches a preset number of times threshold, writing back the metadata to the disk.
By the method, an original mechanism for synchronously refreshing the user data and the metadata is changed, and when the number of times of user data write-back reaches a preset number threshold, a mechanism for carrying out write-back of the metadata once is adopted, namely, a plurality of times of user data write-back corresponds to one time of metadata write-back, and the number of times of metadata refresh can be reduced, the write-back efficiency of an operating system is improved, and the input and output performance of a magnetic disk is improved by delaying the write-back of the metadata; has stronger usability and practicability.
In a possible implementation manner of the first aspect, the user data is stored in a dirty page of the normal file inode; writing back the user data to disk, comprising:
moving the ordinary file index node corresponding to the dirty page of the user data to be written back from a dirty linked list to an input-output linked list; and writing the user data back to a disk according to the common file index node of the input/output linked list.
In a possible implementation manner of the first aspect, the metadata is stored in a dirty page of the metafile inode; before writing the metadata back to disk, the method further comprises:
and executing locking operation on the metadata metafile index node, wherein the locking operation is used for suspending the write-back processing of the metadata when the number of times of write-back of the user data does not reach the number threshold.
In one possible implementation manner of the first aspect, writing metadata back to the disk includes:
moving the metafile index node corresponding to the dirty page of the metadata to be written back from a dirty linked list to an input-output linked list; and writing the metadata back to a disk according to the metafile index node of the input-output linked list.
In a possible implementation manner of the first aspect, before acquiring the data to be written back in the cache, the method further includes:
pre-reading target metadata of a file system of a disk; and storing the pre-read target metadata in a cache, wherein the target metadata is used for indicating unoccupied space address information in the disk.
In a possible implementation manner of the first aspect, the method further includes:
acquiring a file transmission ending message corresponding to the user data; and writing the metadata corresponding to the user data back to the disk based on the file transmission ending message.
In a possible implementation manner of the first aspect, the method further includes:
and when the duration information of the dirty pages of the metadata to be written back in the cache reaches a duration threshold, writing back the metadata in the dirty pages to the disk.
In a second aspect, the present application provides a data write-back apparatus, including:
the device comprises an acquisition unit, a storage unit and a storage unit, wherein the acquisition unit is used for acquiring data to be written back in a cache, and the data to be written back comprises metadata and user data;
and the write-back unit is used for writing back the metadata to the disk if the number of times of writing back the user data to the disk reaches a preset number of times threshold.
In a third aspect, the application provides an electronic device comprising a memory storing a computer program and a processor implementing the method of any of the first aspects when executing the computer program.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of any of the first aspects.
In a fifth aspect, the application provides a computer program product for, when run on an electronic device, causing the electronic device to perform the method of any one of the first aspects.
It will be appreciated that the advantages of the second to fifth aspects may be found in the relevant description of the first aspect, and are not described here again.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of writing a data structure according to an embodiment of the present application;
fig. 2 is a schematic diagram of an implementation flow of a data write-back method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a data write-back process according to an embodiment of the present application;
FIG. 4 is a timing diagram of a write-back thread according to an embodiment of the present application;
FIG. 5 is a schematic diagram illustrating the comparison of write-back frequency between user data and metadata according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a data write-back device according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the technical scheme of the present application will be described in detail below with reference to the accompanying drawings. The following examples are only for more clearly illustrating the technical aspects of the present application, and thus are merely examples, and are not intended to limit the scope of the present application.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having" and any variations thereof in the description of the application and the claims and the description of the drawings above are intended to cover a non-exclusive inclusion.
In the description of embodiments of the present application, the technical terms "first," "second," and the like are used merely to distinguish between different objects and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated, a particular order or a primary or secondary relationship. In the description of the embodiments of the present application, the meaning of "plurality" is two or more unless explicitly defined otherwise.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
In the description of the embodiments of the present application, the term "and/or" is merely an association relationship describing an association object, and indicates that three relationships may exist, for example, a and/or B may indicate: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
Since the speed of access to memory by the cpu is much greater than the speed of access to disk, and once accessed, the data may be accessed again in a short period of time. Therefore, the system kernel introduces a page buffer mechanism to buffer a part of data on the disk into the memory, thereby reducing the input and output operations on the disk. Meanwhile, in order to ensure that the data in the page cache can be synchronized to the disk, a write-back mechanism is further arranged in the system kernel, and after the corresponding page of the page cache is marked, the data is written back to the disk through a write-back thread.
The page buffer may contain two parts of data: metadata and user data; the metadata is used for recording information such as the length of the user data and the storage position of the user data on the disk. In the write-back process, the metadata and the user data can be written back independently and refreshed synchronously, and the user data is written back once for every write-back. In order to ensure the atomicity of data, metadata needs to be locked in the write-back process, that is, after the file system waits for the metadata to be written back to the disk, the user data can be copied to a page cache (cache of a system memory) to generate a new marked page, so that the write-back process of the metadata can block the writing of the user data, and the input and output performance of the disk is reduced.
In addition, for file systems with more metadata types, such as a new technology file system (New Technology File System, NTFS), metadata in multiple locations needs to be modified in each write-back process of metadata, for example, only the access time needs to be updated, so that the main file entry of the file, the directory attribute or directory cache entry of the parent directory, the modification time of the main file table itself need to be modified, and general file operations also need to involve a disk bitmap file and the like; thus resulting in a file system with less writing performance and lower overall write-back efficiency.
In view of the above problems, an embodiment of the present application provides a data write-back method, which improves write-in performance of a file system and input/output performance of a disk by delaying write-back timing of metadata in a data write-back process.
As shown in fig. 1, a schematic diagram of each module architecture of a data write-back process provided by an embodiment of the present application may include a dirty linked list for a block device write-back mechanism, where the dirty linked list may include a metafile inode and a normal file inode. Wherein a block device is a device that stores data in a fixed-size block, such as a disk, SD card, etc.; the dirty linked list is a linked list formed by writing user data or metadata into a cache page of the memory to generate common file index nodes or metafile index nodes corresponding to a plurality of marked pages (namely dirty pages). Accordingly, dirty pages of user data are located under the normal file inode, and dirty pages of metadata are located under the metafile inode.
The index node can comprise two mutually independent dirty marks, namely, the dirty mark of the index node and the dirty mark of the subordinate dirty page, the write-back process is to write back each dirty page, and when the data in the dirty page is written back, the dirty mark of the dirty page is removed; if a dirty page under an inode is not written, the dirty flag of the inode is present until all dirty pages under the inode are written.
Based on the module architecture, the embodiment of the application separately writes back the metadata and the user data under the index nodes based on the metafile index nodes and the common file index nodes, delays the write back time of the metadata, reduces the write back frequency of the metadata, and improves the average speed of data write back, thereby improving the overall efficiency of a data write back mechanism and the write-in performance of a disk.
The specific implementation process of the data write-back method is further described by the embodiment, and the application optimizes the process of writing back the data (including metadata and user data) in the memory to the disk. As shown in fig. 2, the data write-back method may include the steps of:
s201, obtaining data to be written back in a cache, wherein the data to be written back comprises metadata and user data.
In some embodiments, the cache is a buffer in memory, i.e., a page cache. Metadata is attribute information describing the disk location or the user data size, such as disk bitmaps, directory entries, and master file entries; the user data is data copied from the user mode cache to the memory cache, i.e. data content to be actually written into the disk, such as text files or picture files.
For example, before user data is written back, metadata of the disk is read first, where the metadata is used to determine an empty location in the disk, that is, the available space in the disk needs to be determined by reading and writing the metadata of the disk into the cache before the data is written into the disk. Based on the module architecture in fig. 1, the read metadata is stored in a lower page cache of a metafile index node of a dirty linked list to form a dirty page of the metadata, and the user data to be written back is stored in a page cache under a common file index node to form a dirty page of the user data.
It can be appreciated that based on the size of the user data, the corresponding file index node can be stored in a plurality of page caches to form a plurality of dirty pages; similarly, the read metadata may also be stored in a plurality of page caches under the metafile inode, forming a plurality of dirty pages.
In some embodiments, before acquiring the data to be written back in the cache, the method further comprises:
pre-reading target metadata of a file system of a disk; and storing the pre-read target metadata in a cache, wherein the target metadata is used for indicating unoccupied space address information in the disk.
The target metadata is, for example, address information corresponding to a free storage unit in the disk. The metadata of the disk is required to be read before the data is written back, the address information of the idle storage unit in the disk is determined, and the speed of the processor accessing the disk is much slower than the speed of accessing the memory, so that the address information of the idle storage unit in the disk can be read in advance, namely the address information is read into the memory in advance, and the storage space in the disk is reserved in advance; when the data needs to be written back, the user data writing back process can be directly executed based on the metadata in the memory, the metadata does not need to be read from the disk, the time consumption of the whole writing process is saved, and the whole efficiency of writing the data into the disk is improved.
According to the embodiment of the application, metadata related to user data is cached in the memory in advance in the form of index nodes, and because the memory is possibly consumed too much when all metadata information is read in advance, the metadata information of all subdirectories and sub-files in the directory can be cached only when a user accesses the disk parent directory. The original directory opening logic of the file system is not affected, and the file system returns after the parent directory is successfully opened, and the read-ahead work is transferred to the read-ahead process to finish.
S202, if the number of times of writing back the user data to the disk reaches a preset number of times threshold, writing back the metadata to the disk.
In some embodiments, when the user data is large, the amount of data written back at a time is limited, so it may be necessary to write back the user data multiple times before the entire write is completed.
Illustratively, a dirty page under a common file inode that includes multiple user data, one dirty page of user data may be written back to disk at a time; for example, a dirty page is 4k in size, and user data of 4k in size is written back each time.
In the process of writing back the user data, by setting the frequency threshold value of writing back the user data, the frequency of writing back the metadata is not synchronous with the frequency of writing back the user data one to one, writing back the metadata is delayed, the frequency of writing back the metadata is reduced, and the integral writing back time of the data to be written back is saved. For example, the time threshold is set to be two or three times, and in the process of writing back the user data, when the number of times of writing back the user data reaches two or three times, the metadata is written back once; therefore, the frequency of metadata write-back is reduced, and the overall write-back efficiency is improved.
A specific implementation of performing a write-back operation on user data and metadata is further described below in conjunction with fig. 3. As shown in FIG. 3, the queues of the inodes that the kernel thread for write back needs to operate also include I/O linked list queues, and may also include wait I/O linked list queues, timestamp dirty linked list queues (not shown).
When data is written back, the original file system write back mechanism is to process the data successively according to the dirty time based on the index node corresponding to the user data and the index node corresponding to the metadata.
In some embodiments, user data is stored on dirty pages of a common file inode; writing back user data to disk, comprising:
moving a common file index node corresponding to a dirty page of user data to be written back from a dirty linked list to an input-output linked list; and writing the user data back to the disk according to the common file index node of the input/output linked list.
Illustratively, the method provided by the file system layer places write requests in a block device request queue, and the block device driver is responsible for writing the data in the cache to the device disk. And moving the index node (modified or page buffer of the dirty page) on the dirty linked list to the input/output linked list, transmitting the user data to the file system driver based on the index node on the input/output linked list, and indicating the driver to execute the write-back operation on the user data.
For example, in the user data write-back process, a file address space corresponding to the user data is first obtained, and then a data page of the user data is written into the corresponding file address space.
It should be noted that, in the process of writing back the user data, metadata modification may be accompanied, for example, when verifying the content of the written user data, it is necessary to access the address space of the written user data again, update the effective size and time information corresponding to the user data, update the corresponding size and writing time information of the user data corresponding to the file address space, thereby generating new metadata, and add the new metadata to the metafile inode on the dirty link table.
In some embodiments, the metadata is stored on a dirty page of the metafile inode; before writing the metadata back to disk, the method further comprises:
and executing locking operation on the metadata metafile index node, wherein the locking operation is used for suspending the write-back processing of the metadata when the number of times of write-back of the user data does not reach the number threshold.
Before user data is written back, the free address information in the disk is required to be read, so that page cache in the metafile index node is modified first and changed into a dirty page storing new metadata, and a queue for queuing is participated in the writing back; after the user data is written back, a new data head is generated (namely new metadata is generated), so that the metafile index node becomes dirty again, the metafile index node participates in the writing back twice, the writing back efficiency is low, and the disk IO performance is poor. As shown in fig. 3, in the data write-back process, the embodiment of the application locks the metafile index node, does not participate in write-back of the user data, namely only moves the normal file index node corresponding to the user data to the normal file index node on the input-output linked list, and carries out write-back on the user data of the index node of the normal file based on the input-output linked list. Because the metafile index node is locked, the write-back time of the metafile is delayed, so that the write-back frequency of the metafile is reduced, the write-back times are reduced, the number of times of locking the write-back metadata is reduced, and the influence on copying the user data from the user mode cache to the memory cache is reduced.
For example, the locking operation is performed on the metafile index node of the metadata, so that the queuing sequence of the metafile index node is moved backward, that is, the dirty page queue corresponding to the user data and the ordering of the dirty page queue corresponding to the metadata are reset, the metafile index node corresponding to the dirty page of the metadata is not moved to the input/output linked list, and then the metafile index node on the dirty linked list is locked, the write-back time of the metadata is delayed, and the write-back times of the metadata are reduced.
In some embodiments, writing metadata back to disk includes:
moving a metafile index node corresponding to a dirty page of metadata to be written back from a dirty linked list to an input-output linked list; and writing the metadata back to the disk according to the metafile index node of the input/output linked list.
Illustratively, the metadata written back includes metadata corresponding to the free address information of the read disk before writing back the user data, and new metadata generated after writing back the user data. Taking the time of writing back the user data for many times along with writing back the metadata as the limitation of writing back the round, namely writing back the metadata once after writing back the user data for N times as one writing back round, for example, when N is 2 or 3, moving the index node of the modified dirty page metafile in the dirty linked list and the index node of the dirty page of the metadata newly generated after writing back the user data to the input/output linked list together, and writing back the metadata once to finish the data writing back operation of one round; and then, continuing the data write-back of the next round until the user data is written and the last metadata is correspondingly written.
As shown in fig. 4, at the file system layer, metadata is written in the form of a cache header to the address space of a metafile inode in the cache, and user data is written in the form of a dirty page to the address space of a normal file inode in the cache. And in the write-back thread, writing back the user data and the metadata based on the IO stack, and writing back the metadata once after writing back the user data for n times until all the user data and the metadata are written back.
Where, after user data (e.g., any one file) is written back, it is possible to correspond to a plurality of location information where metadata needs to be updated, such as a disk bitmap, a main file entry of the present file, information at a directory entry of a parent directory, and the like. When the number of times of writing back the user data reaches a number threshold, the metafile index node is moved from the dirty linked list to the input-output linked list, and the metadata modified before and the updated metadata are written back together through file system driving.
Illustratively, when there is a modification to the content of the user data, and the size and modification time of the user data are unchanged, write-back of the address space, i.e., write-back of the user data portion, is performed based on the dirty page identification under the inode; when metadata such as the size or time of the user data is modified, the content of the user data is unchanged, and the write-back of the index node, namely the write-back metadata part, is performed based on the dirty page identification of the index node.
In some embodiments, after the user data write-back is finished, the user data to be written to the disk is about to be written completely, and the method further includes:
acquiring a file transmission ending message corresponding to user data; and writing the metadata corresponding to the user data back to the disk based on the file transmission ending message.
The method includes the steps that after user data write-back is finished, metadata can be completely written into a disk, the problem of asynchronous caching of the kernel and disk data is avoided, when all user data transmission is finished, a user-state file sharing program is triggered to send message information of finishing user data transmission, the kernel is informed of finishing file transmission corresponding to the user data, the kernel does not monitor write-back times of the write-back user data any more, and metadata corresponding to the user data written back in the last round are written back into the disk.
In some embodiments, to ensure that the free memory is not so small as to affect processor performance, the kernel must write the dirty page back to disk that times out when the dirty page resides in memory beyond a certain threshold to ensure that the dirty page does not reside in memory indefinitely. The method further comprises the steps of:
and when the duration information of the dirty pages of the metadata to be written back in the cache reaches a duration threshold, writing back the metadata in the dirty pages to the disk.
For example, the kernel system may monitor the retention time information of the metadata to be written back in the memory cache, for example, may record based on a modification timestamp or an update timestamp of the metadata; when the user data write-back is finished and the message information of the write-back is not received, judging whether write-back operation is required to be executed or not based on the time length information reserved in the cache of the corresponding metadata, and when the reserved time length information corresponding to the metadata reaches a set time threshold, moving a metafile index node of a dirty page of a dirty linked list to an input-output linked list to write-back the metadata in the dirty page; therefore, after the file transmission is finished, metadata can be completely written into the disk, and the problem of asynchronous caching of the kernel and data of the disk is avoided.
The metadata write-back mechanism shown in fig. 5, where the diagram (a) in fig. 5 corresponds to synchronous refresh of user data and metadata write-back, i.e. write-back user data corresponds to write-back metadata once; the (b) diagram in fig. 5 corresponds to an optimized data write-back mechanism, delays write-back timing of metadata, and improves overall efficiency of data write-back and IO performance of a disk by reducing the number of times of metadata write-back.
According to the embodiment of the application, a brand new caching mechanism is designed for the metadata, so that the utilization efficiency of the metadata is improved; the number of times of page missing interruption is reduced by pre-reading more metadata at one time; and by delaying the write-back metadata, the write-back times of the metadata are reduced, and the IO performance of the whole data write-back is improved.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
Corresponding to the data write-back method provided in the above embodiment, fig. 6 shows a schematic structural diagram of the metadata write-back device provided in the embodiment of the present application, and for convenience of explanation, only the portion relevant to the embodiment of the present application is shown.
Referring to fig. 6, the data write-back apparatus includes:
an obtaining unit 61, configured to obtain data to be written back in a cache, where the data to be written back includes metadata and user data;
the write-back unit 62 is configured to write back metadata to the disk if the number of times of writing back the user data to the disk reaches a preset number of times threshold.
In one possible implementation, the user data is stored on dirty pages of a common file inode; the write-back unit 62 is further configured to move the normal file inode corresponding to the dirty page of the user data to be written back from a dirty linked list to an input-output linked list; and writing the user data back to a disk according to the common file index node of the input/output linked list.
In one possible implementation, the metadata is stored on dirty pages of the metafile inode; the write-back unit 62 is further configured to perform a locking operation on the metafile index node of the metadata, where the locking operation is configured to suspend write-back processing of the metadata when the number of times of writing back the user data does not reach the number threshold.
In a possible implementation manner, the write-back unit 62 is further configured to move the metafile inode corresponding to the dirty page of the metadata to be written back from a dirty linked list to an input-output linked list; and writing the metadata back to a disk according to the metafile index node of the input-output linked list.
In a possible implementation manner, the apparatus further includes a pre-reading unit, configured to pre-read target metadata of a file system of the disk; and storing the pre-read target metadata in a cache, wherein the target metadata is used for indicating unoccupied space address information in the disk.
In a possible implementation manner, the write-back unit 62 is further configured to obtain a file transmission end packet corresponding to the user data; and writing the metadata corresponding to the user data back to the disk based on the file transmission ending message.
In one possible implementation, the write-back unit 62 is further configured to write back metadata in a dirty page to the disk when duration information of the dirty page of the metadata to be written back in the cache reaches a duration threshold.
According to the embodiment of the application, based on the mechanism of respectively carrying out the write-back of the metadata and the user data, when the number of times of write-back of the user data reaches the preset number threshold, write-back of the metadata is carried out once, namely, the write-back of the metadata is carried out for a plurality of times, namely, the write-back of the user data corresponds to one time, and the refresh number of the write-back of the metadata is reduced; therefore, by delaying the write-back of the metadata, the write-back efficiency of an operating system is improved, and the input and output performance of the disk is improved.
Fig. 7 shows a schematic diagram of the hardware configuration of the electronic device 7.
As shown in fig. 7, the electronic device 7 of this embodiment includes: at least one processor 70 (only one shown in fig. 7), a memory 71, said memory 71 having stored therein a computer program 72 executable on said processor 70. The steps in the above-described method embodiments are implemented by the processor 70 when executing the computer program 72, e.g. S201 to S202 shown in fig. 2. Alternatively, the processor 70, when executing the computer program 72, performs the functions of the modules/units of the apparatus embodiments described above.
It should be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 7. In other embodiments of the application, the electronic device 7 may include more or less components than shown, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The electronic device 7 may be a computing device such as a desktop computer, a notebook computer, a palm computer, a cloud server, etc. The electronic device 7 may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is merely an example of the electronic device 7 and is not meant to be limiting of the electronic device 7, and may include more or fewer components than shown, or may combine certain components, or different components, e.g., the server may also include an input transmitting device, a network access device, a bus, etc.
The processor 70 may be a central processing unit (Central Processing Unit, CPU), or may be another general purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
A memory may also be provided in the processor 70 for storing instructions and data. In some embodiments, the memory in the processor 70 is a cache memory. The memory may hold instructions or data that has just been used or recycled by the processor 70. If the processor 70 needs to reuse the instruction or data, it may be called directly from the memory. Repeated accesses are avoided and the latency of the processor 70 is reduced, thereby improving the efficiency of the system.
The above-mentioned memory 71 may in some embodiments be an internal storage unit of the electronic device 7, such as a hard disk or a memory of the electronic device 7. The memory 71 may be an external storage device of the electronic device 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided in the electronic device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the electronic device 7. The memory 71 is used for storing an operating system, application programs, boot loader (BootLoader), data, other programs, and the like, such as program codes of computer programs, and the like. The memory 71 may also be used for temporarily storing data that has been transmitted or is to be transmitted.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
It should be noted that the structure of the electronic device is only illustrated by way of example, and other entity structures may be included based on different application scenarios, and the entity structure of the electronic device is not limited herein.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Embodiments of the present application also provide a computer readable storage medium storing a computer program which, when executed by a processor, implements steps for implementing the various method embodiments described above.
Embodiments of the present application provide a computer program product which, when run on a server, causes the server to perform steps that enable the implementation of the method embodiments described above.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the steps of each method embodiment described above may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, executable files or in some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth.
The algorithm development platform, the electronic device, the computer storage medium and the computer program product provided by the embodiments of the present application are all used for executing the method provided above, so that the beneficial effects achieved by the algorithm development platform, the electronic device, the computer storage medium and the computer program product can refer to the beneficial effects corresponding to the method provided above, and are not described herein again.
It should be understood that the above description is only intended to assist those skilled in the art in better understanding the embodiments of the present application, and is not intended to limit the scope of the embodiments of the present application. It will be apparent to those skilled in the art from the foregoing examples that various equivalent modifications or variations can be made, for example, certain steps may not be necessary in the various embodiments of the detection methods described above, or certain steps may be newly added, etc. Or a combination of any two or more of the above. Such modifications, variations, or combinations are also within the scope of embodiments of the present application.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
It should be understood that the above description is only intended to assist those skilled in the art in better understanding the embodiments of the present application, and is not intended to limit the scope of the embodiments of the present application. It will be apparent to those skilled in the art from the foregoing examples that various equivalent modifications or variations can be made, for example, certain steps may not be necessary in the various embodiments of the detection methods described above, or certain steps may be newly added, etc. Or a combination of any two or more of the above. Such modifications, variations, or combinations are also within the scope of embodiments of the present application.
It should also be understood that the manner, the case, the category, and the division of the embodiments in the embodiments of the present application are merely for convenience of description, should not be construed as a particular limitation, and the features in the various manners, the categories, the cases, and the embodiments may be combined without contradiction.
It is also to be understood that in the various embodiments of the application, where no special description or logic conflict exists, the terms and/or descriptions between the various embodiments are consistent and may reference each other, and features of the various embodiments may be combined to form new embodiments in accordance with their inherent logic relationships.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/network device and method may be implemented in other manners. For example, the apparatus/network device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.
Finally, it should be noted that: the foregoing is merely illustrative of specific embodiments of the present application, and the scope of the present application is not limited thereto, but any changes or substitutions within the technical scope of the present application should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A data write-back method, comprising:
obtaining data to be written back in a cache, wherein the data to be written back comprises metadata and user data;
and if the number of times of writing the user data back to the disk reaches a preset number of times threshold, writing the metadata back to the disk.
2. The method of claim 1, wherein the user data is stored on dirty pages of a common file inode; the writing back the user data to the disk includes:
moving the ordinary file index node corresponding to the dirty page of the user data to be written back from a dirty linked list to an input-output linked list;
and writing the user data back to a disk according to the common file index node of the input/output linked list.
3. The method of claim 1, wherein the metadata is stored on a dirty page of a metafile inode; before said writing back the metadata to disk, the method further comprises:
and executing locking operation on the metafile index node of the metadata, wherein the locking operation is used for suspending the write-back processing of the metadata when the number of times of write-back of the user data does not reach the number threshold.
4. The method of claim 3, wherein writing the metadata back to disk comprises:
moving the metafile index node corresponding to the dirty page of the metadata to be written back from a dirty linked list to an input-output linked list;
and writing the metadata back to a disk according to the metafile index node of the input-output linked list.
5. The method of claim 1, wherein prior to obtaining the data in the cache to be written back, the method further comprises:
pre-reading target metadata of a file system of the magnetic disk;
and storing the pre-read target metadata in the cache, wherein the target metadata are used for indicating unoccupied space address information in the disk.
6. The method according to any one of claims 1 to 5, further comprising:
acquiring a file transmission ending message corresponding to the user data;
and writing the metadata corresponding to the user data back to the disk based on the file transmission ending message.
7. The method according to any one of claims 1 to 5, further comprising:
and when the duration information reserved in the cache of the dirty pages of the metadata to be written back reaches a duration threshold value, writing back the metadata in the dirty pages to the disk.
8. A data write-back apparatus, comprising:
the device comprises an acquisition unit, a storage unit and a storage unit, wherein the acquisition unit is used for acquiring data to be written back in a cache, and the data to be written back comprises metadata and user data;
and the write-back unit is used for writing back the metadata to the disk if the number of times of writing back the user data to the disk reaches a preset number of times threshold.
9. An electronic device comprising a memory storing a computer program and a processor implementing the method of any one of claims 1 to 7 when the computer program is executed by the processor.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the method of any of claims 1 to 7.
CN202310970133.0A 2023-08-02 2023-08-02 Data write-back method and device, electronic equipment and computer readable storage medium Pending CN116909485A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310970133.0A CN116909485A (en) 2023-08-02 2023-08-02 Data write-back method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310970133.0A CN116909485A (en) 2023-08-02 2023-08-02 Data write-back method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN116909485A true CN116909485A (en) 2023-10-20

Family

ID=88364762

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310970133.0A Pending CN116909485A (en) 2023-08-02 2023-08-02 Data write-back method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN116909485A (en)

Similar Documents

Publication Publication Date Title
US10599637B2 (en) Granular buffering of metadata changes for journaling file systems
US11386065B2 (en) Database concurrency control through hash-bucket latching
US20180011791A1 (en) Systems and methods for maintaining the coherency of a store coalescing cache and a load cache
CN101189584B (en) Managing memory pages
US9690737B2 (en) Systems and methods for controlling access to a shared data structure with reader-writer locks using multiple sub-locks
CN104951240A (en) Data processing method and processors
CN109804359A (en) For the system and method by write back data to storage equipment
US11048422B2 (en) Method, device, and computer readable storage medium for allocating access rights to data among storage processors
US10860480B2 (en) Method and device for cache management
CN112334891A (en) Centralized storage for search servers
WO1998026352A1 (en) Method of file pre-read control in computer system
CN112100093B (en) Method for maintaining consistency of multiprocessor shared memory data and multiprocessor system
CN112306980A (en) Log processing method and terminal equipment
CN116909485A (en) Data write-back method and device, electronic equipment and computer readable storage medium
US11586353B2 (en) Optimized access to high-speed storage device
CN114201551A (en) Data storage method and data storage device
US10942898B2 (en) System and method for a persistent hierarchical work manager
CN113448897B (en) Optimization method suitable for pure user mode far-end direct memory access
KR101881039B1 (en) Method for asynchronous atomic update of memory mapped files stored in non-volatile memory and control apparatus thereof
US20210034580A1 (en) Method, apparatus and computer program product for maintaining metadata
KR101881038B1 (en) Method for atomic update of memory mapped files stored in non-volatile memory and control apparatus thereof
CN117076087A (en) Method, system, equipment and storage medium for accelerating single-stream reading and writing
KR101847861B1 (en) Apparatus and method of computing and storage for data management
CN118331512A (en) Processing method and device based on memory control card
CN117539650A (en) Decentralised record lock management method of data management system and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination