WO2013097229A1 - 易失性存储设备持久化过程中的数据更新方法及装置 - Google Patents

易失性存储设备持久化过程中的数据更新方法及装置 Download PDF

Info

Publication number
WO2013097229A1
WO2013097229A1 PCT/CN2011/085165 CN2011085165W WO2013097229A1 WO 2013097229 A1 WO2013097229 A1 WO 2013097229A1 CN 2011085165 W CN2011085165 W CN 2011085165W WO 2013097229 A1 WO2013097229 A1 WO 2013097229A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage device
volatile storage
data
persistence
data block
Prior art date
Application number
PCT/CN2011/085165
Other languages
English (en)
French (fr)
Inventor
岳银亮
张敬亮
王凤
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201180003627.7A priority Critical patent/CN103403679B/zh
Priority to PCT/CN2011/085165 priority patent/WO2013097229A1/zh
Publication of WO2013097229A1 publication Critical patent/WO2013097229A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1471Saving, restoring, recovering or retrying involving logging of persistent data for recovery
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/84Using snapshots, i.e. a logical point-in-time copy of the data

Definitions

  • Embodiments of the present invention relate to computer technologies, and in particular, to a data update method and apparatus in a persistent storage device. Background technique
  • Persistence is a data protection technique that saves data from volatile storage devices to non-volatile storage devices.
  • Volatile storage devices such as Random Access Memory (RAM) store data that is lost when power is lost; non-volatile storage devices such as disk (Hard Disk) or flash memory (Flash Memory) , its stored data will not be lost when power is lost.
  • RAM Random Access Memory
  • non-volatile storage devices such as disk (Hard Disk) or flash memory (Flash Memory)
  • flash Memory flash memory
  • the existing persistence scheme has the following typical schemes: The first scheme is to synchronize each change of data in the volatile storage device to a non-volatile storage device, which will greatly reduce the system's Performance; the second option is to periodically persist all data in the volatile storage device to the non-volatile storage device, which will lose all new writes and losses since the last time the system was powered down.
  • the third solution is to record each change of data in the volatile storage device to the log file at the same time. This solution will lead to the continuous increase of the log file and occupy a large amount of non-volatile storage device space; And all the records in the log file will be played back when the system is powered down, and playback takes a long time.
  • the solution periodically persists all data in the volatile storage device to the non-volatile storage device, and records each change since the last persistence into the log file.
  • the periodic persistence of the solution uses a snapshot of Copy on Write (COW) or Redirect on Write (ROW).
  • COW Copy on Write
  • ROW Redirect on Write
  • pointer points to the data block C in the volatile storage device, that is, the data block C is snapshotted, and the data needs to be saved to the non-volatile device in the current persistent period data block C.
  • the original data in the data block C is read first, and the original data in the data block C is written to New data block Z, then new data Write to block C and point the snapshot area pointer to block C to the new block z.
  • the new data is directly written to the new data block Z, and the pointer of the active data area originally pointing to the data block c is directed to the data block Z, and the pointer of the snapshot area to the data block C is unchanged.
  • Embodiments of the present invention provide a data update method and apparatus in a persistent storage device persistent process, which are used to solve the existing method of combining periodic persistence and persistence logs, and a volatile storage device. The occupation of the medium space increases linearly with the increase of the update operation.
  • Embodiments of the present invention provide a method for updating data in a persistent storage device of a volatile storage device, including:
  • the snapshot data block is the volatile in the current persistence period A block of data in a storage device that needs to be persisted to a non-volatile storage device;
  • New data is written to the snapshot data block, and an operation log in which the data in the snapshot data block is updated to the new data is recorded in a log file.
  • the embodiment of the invention provides a data updating device in a process of persisting a volatile storage device, including:
  • a write request receiving module configured to periodically persist snapshot data in the volatile storage device to the non-volatile storage device, and receive a write request for updating data in the snapshot data block;
  • the snapshot data block is currently persistent Data blocks that need to be persisted to the non-volatile storage device in the volatile storage device during the period;
  • an update module configured to write new data into the snapshot data block, and record, in the log file, an operation log in which the data in the snapshot data block is updated to the new data.
  • FIG. 1 is a flowchart of a method for updating data in a persistent storage device of a volatile storage device according to an embodiment of the present invention
  • FIG. 2 is a flowchart of another method for updating data in a persistent storage device according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of a tree structure of a data block in a memory according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of a persistence time according to an embodiment of the present invention
  • FIG. 5 is a schematic structural diagram of Embodiment 1 of a data updating apparatus in a process of persisting a volatile storage device according to the present invention
  • FIG. 6 is a schematic structural diagram of Embodiment 2 of a data updating device in a process of persisting a volatile storage device according to the present invention. detailed description
  • FIG. 1 is a flowchart of a data update method in a persistent storage device of a volatile storage device according to an embodiment of the present invention. As shown in FIG. 1, the method provided in this embodiment includes:
  • Step 1 1 Periodically persist the snapshot data in the volatile storage device to the non-volatile storage device, and receive a write request for updating the data in the snapshot data block.
  • a snapshot data block is a block of data in a volatile storage device that needs to be synchronized to a non-volatile storage device during the current persistence period.
  • Step 12 Write new data to the snapshot data block, and record in the log file that the data in the snapshot data block is updated to the new data.
  • the block that is, the snapshot data block in which the data has been persisted, directly writes new data into the snapshot data block, overwrites the old data in the snapshot data block, and records the data in the snapshot data block in the log file. Update to a log of new data. Since the data in the snapshot data block has been synchronized before updating the data in the snapshot data block, it is not necessary to retain the old data in the snapshot data block in the volatile storage device. If the volatile storage device loses power, the data in the snapshot data block can be recovered from the log file.
  • the snapshot data in the volatile storage device is periodically persisted to the non-volatile storage device
  • the write request for updating the data in the snapshot data block is received
  • the snapshot data block is a snapshot data block that has not been persisted
  • the old data in the snapshot data block before the update does not need to be synchronized to the non-volatile storage device. Therefore, the data in the snapshot data block does not need to be synchronized to the current persistent period when the volatile storage device is snapshotted.
  • a non-volatile storage device so that data in a snapshot data block that is not persistent when the volatile storage device is snapshotted is not required to be retained in the volatile storage device, and no additional space is needed in the volatile storage device.
  • the data update method in the process of persisting the volatile storage device provided by the embodiment of the present invention, in the persistence process, for the update of the data in the snapshot data block, whether it is a persistent snapshot data block or an un-persistent snapshot
  • the data block directly write new data into the snapshot data block, does not need to additionally open up space in the volatile storage device to save the data in the snapshot data block that is not persistent when the volatile storage device is snapshot. Therefore, the occupation of space in the volatile storage device is reduced in the persistence process, and the drawback that the space occupancy in the volatile storage device increases linearly with the increase of the update operation is overcome.
  • the embodiment of the present invention records in the log file that the data in the snapshot data block is updated to the new data.
  • the operation log also includes the following steps: Step 13a: If the data in the snapshot data block is not persistent to the non-volatile storage device, identify the operation log of the snapshot data block as a pre-persistence update. For example, the identifier is R to indicate that this update occurred before the snapshot data block was persisted.
  • Step 13b If the data in the snapshot data block has been persisted to the non-volatile storage device, the operation log of the snapshot data block is identified as being updated and updated. For example, the identifier is L to indicate that this update occurred after the snapshot data block was persisted.
  • Step 14 After the period of persisting the snapshot data in the volatile storage device to the non-volatile storage device, delete the operation log identified in the log file as the pre-persistency update, and update the log file to the thin log file.
  • An operation log that is identified as a pre-persistency update in the log file. It records the update of the data in the non-persistent snapshot data block during the persistence process.
  • the snapshot data blocks are persistent to non- In a volatile storage device, the old data stored before the snapshot data block is persisted to the non-volatile storage device and generated during the persistence process is not persisted to the non-volatile storage device during data recovery.
  • the old data of these intermediate versions does not need to be recovered, so it is not necessary to keep the operation log generated during the persistence process before the snapshot data blocks are persisted to the non-volatile storage device.
  • T ( i+1 ) is the current start period start time
  • T(i+1) time is the current persistence period end time
  • T(i+2) the time is the next persistent period start time.
  • the data stored in the time snapshot data block C is CO, after the start of the current persistence period and before the snapshot data block C is not persisted to the non-volatile storage device, in the data block C
  • the following updates were made, C0-C1, C1-C2, C2 ⁇ C3.
  • C3 in block C is persisted to the non-volatile storage device, and the following updated operation log is deleted from the log file generated after T ( i+1 ), the time starts: C0—C1 , C1—C2, C2—C3, become T ( i+1 ), a streamlined log file generated after the moment.
  • the data in block C is updated from C3 to C4.
  • the lossy storage device is powered down, using the non-volatile storage device data file generated at time T(i+1), playing back T ( i+1 ), the streamlined log file generated after the time starts, and the T(i+1) time
  • the log file generated after the start can restore the data in block C to C4.
  • the streamlined log file generated after the start of the time the following update process is not played back: C0—C1, C1—C2, C2—C3, thereby improving the end of the persistent storage of the volatile storage device. Data recovery efficiency after power failure.
  • the data recovery method after the volatile storage device is powered off is as follows: In the process of persisting snapshot data in the volatile storage device to the non-volatile storage device, if the volatile storage device is powered off, according to the last persistent Non-volatile storage device data file at the end of the cycle, a streamlined log file at the end of the last persistence cycle, log files from the end of the last persistence cycle to the beginning of the current persistence cycle, and after the current persistence cycle begins The generated log file restores the data in the volatile storage device.
  • the non-volatile storage device After the period of the snapshot data in the volatile storage device is persisted to the non-volatile storage device, if the volatile storage device is powered down, the non-volatile storage device data file according to the end of the last persistent period The streamlined files at the end of the last persistence period and the log files generated after the last persistence period are restored to recover the data in the volatile storage device.
  • FIG. 3 is a schematic diagram of a tree structure of a data block in an internal memory according to an embodiment of the present invention. As shown in Figure 3, one node in the tree represents a data block, and the relationship between the nodes is the relationship between the data blocks. After the data is written in data block A1, the update operation is also logged in the log file.
  • FIG. 4 is a schematic diagram of a persistence moment according to an embodiment of the present invention.
  • the time T(i) is the i-th persistence end time, T(i+1), the time is the i+1th persistence start time, and the T(i+1) time is the i+th 1 time to end the persistence.
  • the files on the disk are V(i) and Log(i)L.
  • V(i) represents the data file generated on the disk after the end of the i-th persistence
  • Log(i)L represents the log file generated on the disk after the end of the i-th persistence.
  • V(i) combined with Log(i)L can represent a snapshot version.
  • a log file Log(i+l) is created for recording the operation log of the node data update operation in the memory tree from the T(i) time.
  • the system satisfies the persistence condition and starts to persist. For example, the time interval of T(i+1)' time distance T(i) reaches a preset threshold, or, to T(i+1), the time memory is more The ratio of new data to total data has reached a preset threshold and the system has become persistent.
  • the data in all nodes in Figure 3 is sequentially persisted to disk according to the principle of depth-first traversal. Data persistence takes the node as the basic unit. When a node is persisted to the disk, a global lock is added to the memory tree. If there is a node update operation, it enters the wait queue. After the current node is persisted, the persistence operation releases the lock, the memory tree update operation acquires the lock, suspends the persistence of the subsequent node, and updates the memory tree node.
  • Log. V(i+1) represents the data file generated on the disk after the end of the i+1th persistence.
  • the log format in the log file Log(i+ 1 )LR is: Log identifier + operation command + node Key + node Value 0
  • the updated node B1 is an un-persistent snapshot data block, and the node B1 is After the update, the recorded operation log format is: R+P+NodeB1+NodeValue.
  • R is the operation log identifier, indicating that the update occurs before node B1 persists;
  • P is the operation command, and node value is the updated data in node B1.
  • the updated node A1 is a persistent snapshot data block.
  • the recorded operation log format is: L+P+Node B1+node Value; where L is the operation log identifier. , indicating that this update occurred after node A1 persistence. If the persistence process ends normally, the operation log with the identifier R in the log file Log(i+l)LR is deleted, which can be achieved by changing the identifier R to C.
  • the log file Log(i+l)LR deletes the operation log of the identifier R into a log file of Log(i+l)L.
  • the system loses power during the persistence process, for example, at some point between T(i+1), time and T(i+1) time, the system is powered down.
  • the steps to rebuild the memory tree after the system restarts are as follows: Rebuild the memory tree with V(i); the second step is to play back the log file Log(i)L; the third step is to play back the log file Log(i+l)L; the fourth step is to play back the log file Log(i+l ) LR. If the system is powered down after the persistence is completed, for example, at time T(i+ 1 ) and T(i+2), the system is powered down at some point between the moments.
  • FIG. 5 is a schematic structural diagram of Embodiment 1 of a data updating apparatus in a process of persisting a volatile storage device according to the present invention.
  • the apparatus provided in this embodiment includes: a write request receiving module 51 and an update module 52.
  • the write request receiving module 51 is configured to periodically persist snapshot data in the volatile storage device to the non-volatile storage device, and receive a write request for updating data in the snapshot data block.
  • the snapshot data block is a data block in the volatile storage device that needs to be persisted to the non-volatile storage device during the current persistence period.
  • the update module 52 is configured to write new data into the snapshot data block, and record, in the log file, an operation log in which the data in the snapshot data block is updated to the new data.
  • the data updating apparatus in the process of persisting the volatile storage device provided by the embodiment of the present invention, in the persistence process, updates the data in the snapshot data block, whether it is a persistent snapshot data block or an un-persistent snapshot.
  • the data block directly write new data into the snapshot data block, does not need to additionally open up space in the volatile storage device to save the data in the snapshot data block that is not persistent when the volatile storage device is snapshot. Therefore, the occupation of space in the volatile storage device is reduced in the persistence process, and the drawback that the space occupancy in the volatile storage device increases linearly with the increase of the update operation is overcome.
  • the embodiment may further include: a log identifier module 53 and a log deletion module 54. .
  • the log identification module 53 is configured to: if the data in the snapshot data block is not persistent to the non-volatile storage device, identify an operation log of the snapshot data block as a pre-persistence update; if the data in the snapshot data block The non-volatile storage device has been persisted, and the operation log of the snapshot data block is identified as a post-persistency update.
  • the log deletion module 54 is configured to delete an operation identifier in the log file that is identified as a pre-persistence update, and update the log file to a condensed log file.
  • An operation log that is identified as a pre-persistency update in the log file. It records the update of the data in the non-persistent snapshot data block during the persistence process.
  • the snapshot data blocks are persistent to non- In a volatile storage device, the old data stored before the snapshot data block is persisted to the non-volatile storage device and generated during the persistence process is not persisted to Non-volatile storage devices, these intermediate versions of old data are not necessary to recover during data recovery, so it is not necessary to retain the persistence process before the snapshot data blocks are persisted to the non-volatile storage device. Operation log.
  • the data in the data blocks can be quickly restored to the data at the end of the persistent period by playing back the reduced log file, thereby improving the data after the volatile storage device is powered off. Restore efficiency.
  • the embodiment may further include:
  • a first recovery module configured to use a non-volatile storage device data file at the end of the last persistence period, a reduced log file at the end of the last persistence period, from the end of the last persistence period to the current persistence period
  • the generated log file and the log file generated after the start of the current persistence period restore the data in the volatile storage device.
  • a second recovery module configured to restore the non-volatile storage device data file according to the end of the last persistent period, the reduced log file at the end of the last persistence period, and the log file generated after the last persistent period ends The data in the volatile storage device.

Abstract

提供一种易失性存储设备持久化过程中的数据更新方法及装置。该方法包括:将易失性存储设备中快照数据周期性持久化到非易失性存储设备过程中,接收更新快照数据块中数据的写请求(11);将新数据写入所述快照数据块,并在日志文件中记录所述快照数据块中数据更新为所述新数据的操作日志(12)。本方案在持久化过程中减少了对易失性存储设备中空间的占用,克服了易失性存储设备中空间的占用随更新操作的增加而线性增加的缺陷。

Description

技术领域 本发明实施例涉及计算机技术, 尤其涉及一种易失性存储设备持久化 过程中的数据更新方法及装置。 背景技术
持久化是一种将易失性存储设备中的数据保存到非易失性存储设备 中的一种数据保护技术。 易失性存储设备如随机存取存储器(Random Access Memory, 简称 RAM), 其存储的数据在掉电时会丟失; 非易失性存 储设备如磁盘(Hard Disk )或闪速存储器( Flash Memory ) , 其存储的数 据在掉电时不会丟失。 已有的持久化方案有以下几种典型方案: 第一种方 案是将易失性存储设备中数据的每次更改均同步持久化到非易失性存储 设备, 该方案将极大降低系统的性能; 第二种方案是将易失性存储设备中 所有数据周期性持久化到非易失性存储设备,该方案在系统掉电时将丟失 自最近一次持久化之后所有新写入易失性存储设备的数据; 第三种方案是 将易失性存储设备中数据的每个更改均同时记录到日志文件中,该方案将 导致日志文件不断增大, 占用大量非易失性存储设备空间; 并且在系统掉 电时将回放日志文件中所有记录, 回放需较长时间。
综合上述已有持久化方案的优缺点基础上,出现了将周期性持久化与 记录持久化期间日志文件相结合的方案。该方案将易失性存储设备中所有 数据周期性持久化到非易失性存储设备, 并且将自最近一次持久化开始的 每个更改均同时记录到日志文件中,该方案的周期性持久化操作采用写时 拷贝 ( Copy on Write, COW ) 或重定向写 ( Redirect on Write, ROW ) 的快 照方式。 例如, 在当前持久化周期快照区指针指向易失性存储设备中数据 块 C, 也就是, 数据块 C被快照, 在当前持久化周期数据块 C中数据需要 保存到非易失性设备。 在持久化过程中, 如果应用程序需要更新数据块 C 被快照时数据块 C中的数据, 在 Copy on Write方案中, 先读取数据块 C 中原始数据, 将数据块 C 中原始数据写到新数据块 Z 中, 之后将新数据 写到数据块 C中, 并将指向数据块 C的快照区指针指向新数据块 z。 在 Redirect on Write方案中, 直接将新数据写到新数据块 Z, 将活动数据区 原来指向数据块 c的指针指向数据块 Z,快照区指向数据块 C的指针不变。
分析上述周期性持久化与记录持久化期间日志文件相结合的方案可 以看出, 快照数据持久化过程中, 采用写时拷贝或重定向写两个方案对未 持久化的快照数据块中数据进行更新时, 需要占用额外的空间存储易失性 存储设备被快照时该快照数据块中的数据, 因而易失性存储设备中空间的 占用随更新操作的增加而线性增加。 发明内容 本发明实施例提供一种易失性存储设备持久化过程中的数据更新方 法及装置, 用以解决现有周期性持久化与持久化间日志相结合的方法中, 易失性存储设备中空间的占用随更新操作的增加而线性增加的缺陷。
本发明实施例提供一种易失性存储设备持久化过程中的数据更新方 法, 包括:
将易失性存储设备中快照数据周期性持久化到非易失性存储设备过 程中, 接收更新快照数据块中数据的写请求; 所述快照数据块为当前持久 化周期内所述易失性存储设备中需要持久化到非易失性存储设备的数据 块;
将新数据写入所述快照数据块, 并在日志文件中记录所述快照数据块 中数据更新为所述新数据的操作日志。 本发明实施例提供一种易失性存储设备持久化过程中的数据更新装 置, 包括:
写请求接收模块, 用于将易失性存储设备中快照数据周期性持久化到 非易失性存储设备过程中, 接收更新快照数据块中数据的写请求; 所述快 照数据块为当前持久化周期内所述易失性存储设备中需要持久化到非易 失性存储设备的数据块;
更新模块, 用于将新数据写入所述快照数据块, 并在日志文件中记录 所述快照数据块中数据更新为所述新数据的操作日志。
本发明实施例提供的易失性存储设备持久化过程中的数据更新方法 及装置, 在持久化过程中, 对于快照数据块中数据的更新, 无论是已持久 化的快照数据块还是未持久化的快照数据块, 都直接将新数据写入该快照 数据块中, 不需要额外在易失性存储设备中开辟空间来保存易失性存储设 备被快照时未持久化的快照数据块中的数据。 因此, 在持久化过程中减少 了对易失性存储设备中空间的占用, 克服了易失性存储设备中空间的占用 随更新操作的增加而线性增加的缺陷。 附图说明 图 1为本发明实施例提供的一种易失性存储设备持久化过程中的数据 更新方法流程图;
图 2为本发明实施例提供的另一种易失性存储设备持久化过程中的数 据更新方法流程图;
图 3为本发明实施例提供的内存中数据块的树形结构示意图; 图 4为本发明实施例提供的持久化时刻示意图;
图 5为本发明提供的一种易失性存储设备持久化过程中的数据更新装 置实施例一结构示意图;
图 6为本发明提供的一种易失性存储设备持久化过程中的数据更新装 置实施例二结构示意图。 具体实施方式
图 1为本发明实施例提供的一种易失性存储设备持久化过程中的数据 更新方法流程图。 如图 1所示, 本实施例提供的方法包括:
步骤 1 1 :将易失性存储设备中快照数据周期性持久化到非易失性存储 设备过程中, 接收更新快照数据块中数据的写请求。
快照数据块为当前持久化周期内易失性存储设备中需要同步到非易 失性存储设备的数据块。
步骤 12: 将新数据写入所述快照数据块, 并在日志文件中记录所述快 照数据块中数据更新为所述新数据的日志。
将易失性存储设备中快照数据周期性持久化到非易失性存储设备过 程中, 接收更新快照数据块中数据的写请求时, 对于已持久化的快照数据 块, 也就是已对其中数据持久化过的快照数据块, 直接将新数据写入该快 照数据块中, 覆盖该快照数据块中旧数据, 并在日志文件中记录所述快照 数据块中数据更新为新数据的日志。 由于在更新该快照数据块中数据之 前, 已同步过该快照数据块中数据, 不需要在易失性存储设备中保留该快 照数据块中旧数据。 如果易失性存储设备掉电, 可通过日志文件恢复该快 照数据块中数据。
将易失性存储设备中快照数据周期性持久化到非易失性存储设备过 程中, 接收更新快照数据块中数据的写请求时, 如果该快照数据块为还未 持久化的快照数据块, 该快照数据块中在此次更新之前的旧数据不需要同 步到非易失性存储设备, 因此, 当前持久化周期易失性存储设备被快照时 该快照数据块中的数据也不需要同步到非易失性存储设备, 因而不需要在 易失性存储设备中保留易失性存储设备被快照时未持久化的快照数据块 中的数据, 不需要额外在易失性存储设备中开辟空间来保存易失性存储设 备被快照时未持久化的快照数据块中的数据。 因此, 对于未持久化的快照 数据块,也直接将新数据写入该快照数据块,覆盖该快照数据块中旧数据, 并在日志文件中记录所述快照数据块中数据更新为新数据的日志。 另夕卜, 不论是持久化过程中易失性存储设备掉电还是持久化结束后易失性存储 设备掉电, 均可通过日志文件恢复该快照数据块中数据。 因此, 在易失性 存储设备中不保存未持久化的快照数据块被快照时保存的数据, 不会对系 统产生影响。
本发明实施例提供的易失性存储设备持久化过程中的数据更新方法, 在持久化过程中, 对于快照数据块中数据的更新, 无论是已持久化的快照 数据块还是未持久化的快照数据块, 都直接将新数据写入该快照数据块 中, 不需要额外在易失性存储设备中开辟空间来保存易失性存储设备被快 照时未持久化的快照数据块中的数据。 因此, 在持久化过程中减少了对易 失性存储设备中空间的占用, 克服了易失性存储设备中空间的占用随更新 操作的增加而线性增加的缺陷。
进一步, 如图 2所示, 为提高易失性存储设备在持久化正常结束后掉 电时数据恢复效率, 本发明实施例在日志文件中记录所述快照数据块中数 据更新为所述新数据的操作日志之后还包括以下步骤: 步骤 13a: 若所述快照数据块中数据未持久化到所述非易失性存储设 备, 将所述快照数据块的操作日志标识为持久化前更新。 例如标识为 R, 以表示此次更新发生在该快照数据块持久化之前。
步骤 13b: 若快照数据块中数据已持久化到所述非易失性存储设备, 将所述快照数据块的操作日志标识为持久化后更新。 例如标识为 L, 以表 示此次更新发生在该快照数据块持久化之后。
步骤 14:在将易失性存储设备中快照数据持久化到非易失性存储设备 的周期结束后, 删除日志文件中标识为持久化前更新的操作日志, 使日志 文件更新为精简日志文件。
日志文件中标识为持久化前更新的操作日志, 记录的是持久化过程中 对未持久化的快照数据块中数据的更新, 在持久化正常结束后, 该些快照 数据块已持久化到非易失性存储设备中, 该些快照数据块持久化到非易失 性存储设备之前所存储的且在持久化过程中产生的旧数据没有持久化到 非易失性存储设备, 在数据恢复时这些中间版本的旧数据没有必要恢复, 因此, 没有必要保留在持久化过程中产生的有关该些快照数据块持久化到 非易失性存储设备之前的操作日志。 在持久化正常结束后, 如果易失性存 储设备掉电, 通过回放精简日志文件可将该些数据块中数据快速恢复为持 久化结束时刻的数据, 从而提高易失性存储设备掉电后数据恢复效率。 例 如, T ( i+1 ) ,时刻为当前持久化周期开始时刻, T(i+1)时刻为当前持久化 周期结束时刻, T(i+2),时刻为下一持久化周期开始时刻。 在 T(i+1),时刻快 照数据块 C中存储的数据为 CO, 在当前持久化周期开始后且在快照数据 块 C未持久化到非易失性存储设备之前, 对数据块 C中进行了如下更新, C0— C1 , C1— C2, C2→C3。 在当前持久化周期结束后, 数据块 C中 C3 被持久化到非易失性存储设备, 在 T ( i+1 ) ,时刻开始后产生的日志文件 中删除以下更新的操作日志: C0— C1 , C1— C2, C2— C3 , 成为 T ( i+1 ) , 时刻开始后产生的精简日志文件。 在当前持久化周期结束之后且在下一持 久化周期开始之前, 即在 T(i+1) 时刻和 T(i+2),时刻之间, 数据块 C中数 据由 C3更新为 C4, 此后易失性存储设备掉电, 利用 T(i+1)时刻产生的非 易失性存储设备数据文件, 回放 T ( i+1 ) ,时刻开始后产生的精简日志文 件和 T(i+1)时刻开始后产生的日志文件可将数据块 C中数据恢复为 C4。 在回放 T ( i+1 ) ,时刻开始后产生的精简日志文件时, 没有回放以下更新 过程: C0— C1 , C1— C2, C2— C3 , 从而提高了易失性存储设备在持久化 正常结束后掉电时数据恢复效率。
易失性存储设备掉电后的数据恢复方法如下: 在将易失性存储设备中 快照数据持久化到非易失性存储设备的过程中, 若易失性存储设备掉电, 根据上一持久化周期结束时刻的非易失性存储设备数据文件、 上一持久化 周期结束时刻的精简日志文件、 自上一持久化周期结束至当前持久化周期 开始产生的日志文件和当前持久化周期开始后产生的日志文件, 恢复所述 易失性存储设备中数据。 在将易失性存储设备中快照数据持久化到非易失 性存储设备的周期结束后, 若易失性存储设备掉电, 根据上一持久化周期 结束时刻的非易失性存储设备数据文件、 上一持久化周期结束时刻的精简 曰志文件和上一持久化周期结束后产生的日志文件, 恢复所述易失性存储 设备中数据。
易失性存储设备中数据块可以树形结构组织也可以线性结构组织。 内 存为典型的易失性存储设备, 磁盘为典型的非易失性存储设备。 下面以将 内存中数据持久化到磁盘为例, 结合图 3和图 4说明易失性存储设备持久 化过程中的数据更新方法和系统掉电后数据恢复方法。 图 3为本发明实施 例提供的内存中数据块的树形结构示意图。 如图 3所示, 树中一个节点表 述一个数据块, 节点之间的关系即为数据块之间的关系。 在数据块 A1 中 写入数据后, 还将更新操作记录在日志文件中。 图 4为本发明实施例提供 的持久化时刻示意图。
如图 4所示, T(i)时刻为第 i次持久化结束时刻, T(i+1),时刻为第 i+1 次持久化开始时刻, T(i+1) 时刻为第 i+1次持久化结束时刻。 第 i次持久 化结束后, 磁盘上的文件为 V(i)和 Log(i)L。 其中 V(i)表示第 i次持久化结 束后在磁盘上产生的数据文件, Log(i)L表示第 i次持久化结束后在磁盘上 产生的日志文件。 V(i)与 Log(i)L结合可表示一个快照版本。 自 T(i)时刻开 始, 即第 i次持久化结束后, 建立日志文件 Log(i+l), 用于记录自 T(i)时 刻对内存树中节点数据更新操作的操作日志。
T(i+1)'时刻, 系统满足持久化条件开始持久化。 例如, T(i+1)'时刻距 离 T(i)时刻的时间间隔达到了预设阈值, 或者, 到 T(i+1),时刻内存中被更 新的数据占数据总量的比例已经达到了预设阈值, 系统开始持久化。 持久 化过程中, 按照深度优先遍历的原则, 顺次将图 3中所有节点中数据持久 化到磁盘。 数据持久化以节点为基本单位, 某节点持久化到磁盘过程中, 对内存树加全局锁, 如有节点更新操作, 则进入等待队列。 待当前节点持 久化完毕, 持久化操作释放锁, 内存树更新操作获取锁, 暂停持久化后续 节点, 对内存树节点进行更新操作。
T(i+1),时刻 , 系统开始持久化, 创建一个新的日志文件 Log(i+l)LR, 用于记录持久化期间自 T(i+1),时刻对内存树更新操作的操作日志。 V(i+1) 表示第 i+1 次持久化结束后在磁盘上产生的数据文件。 日志文件 Log(i+ 1 )LR 中的日志格式为: 日志标识符 +操作命令 +节点 Key+节点 Value 0 例如, 系统持久化期间, 被更新的节点 B1为未持久化的快照数据 块,对节点 B1更新后,记录的操作日志格式为: R+P+节点 B1+节点 Value。 其中, R为操作日志标识符, 表示此次更新发生在节点 B1持久化之前; P 为操作命令, 节点 Value为节点 B1 中更新后的数据。 又例如, 系统持久 化期间, 被更新的节点 A1为已持久化的快照数据块, 对节点 A1更新后, 记录的操作日志格式为: L+P+节点 B1+节点 Value; 其中, L为操作日志 标识符, 表示此次更新发生在节点 A1持久化之后。 如果持久化过程正常 结束, 则将日志文件 Log(i+l)LR中标识符为 R的操作日志删除, 可通过 将标识符 R更改为 C来实现。系统掉电重启后回放日志文件重建内存树结 构时, 直接跳过标识符为 C的操作日志即可。 日志文件 Log(i+l)LR删除 标识符为 R的操作日志后形成的精简日志文件为 Log(i+l)L。
如果持久化过程中系统掉电,例如在 T(i+1),时刻和 T(i+1)时刻之间的 某一时刻系统掉电, 系统重启后重建内存树的步骤如下: 第一步, 利用 V(i)重建内存树; 第二步, 回放日志文件 Log(i)L; 第三步, 回放日志文件 Log(i+l)L; 第四步, 回放日志文件 Log(i+l)LR。 如果持久化完成后系统 掉电, 例如在 T(i+ 1 )时刻和 T(i+2),时刻之间的某一时刻系统掉电, 重启后 重建内存树的步骤如下: 第一步, 利用 V(i+1)重建内存树; 第二步, 回放 曰志文件 Log(i+l)L; 第三步, 回放曰志文件 Log(i+2)。 其中, Log(i+2) 曰 志文件为在 T(i+1)时刻新增的日志文件, 用于记录自 T(i+1)时刻对内存树 更新的操作日志。 图 5为本发明提供的一种易失性存储设备持久化过程中的数据更新装 置实施例一结构示意图。 如图 5所示, 本实施例提供的装置包括: 写请求 接收模块 51和更新模块 52。
写请求接收模块 51 ,用于将易失性存储设备中快照数据周期性持久化 到非易失性存储设备过程中, 接收更新快照数据块中数据的写请求。 所述 快照数据块为当前持久化周期内所述易失性存储设备中需要持久化到非 易失性存储设备的数据块。
更新模块 52 , 用于将新数据写入所述快照数据块, 并在日志文件中记 录所述快照数据块中数据更新为所述新数据的操作日志。
上述各模块实现的功能可参见图 1对应实施例中描述,在此不再赘述。 本发明实施例提供的易失性存储设备持久化过程中的数据更新装置, 在持久化过程中, 对于快照数据块中数据的更新, 无论是已持久化的快照 数据块还是未持久化的快照数据块, 都直接将新数据写入该快照数据块 中, 不需要额外在易失性存储设备中开辟空间来保存易失性存储设备被快 照时未持久化的快照数据块中的数据。 因此, 在持久化过程中减少了对易 失性存储设备中空间的占用, 克服了易失性存储设备中空间的占用随更新 操作的增加而线性增加的缺陷。
进一步, 为提高易失性存储设备在持久化正常结束后掉电时数据恢复 效率, 如图 6所示, 在图 5的基础上本实施例还可包括: 日志标识模块 53 和日志删除模块 54。
日志标识模块 53 ,用于若所述快照数据块中数据未持久化到所述非易 失性存储设备, 将所述快照数据块的操作日志标识为持久化前更新; 若快 照数据块中数据已持久化到所述非易失性存储设备, 将所述快照数据块的 操作日志标识为持久化后更新。
日志删除模块 54 ,用于删除所述日志文件中标识为持久化前更新的操 作曰志, 使日志文件更新为精简日志文件。
日志文件中标识为持久化前更新的操作日志, 记录的是持久化过程中 对未持久化的快照数据块中数据的更新, 在持久化正常结束后, 该些快照 数据块已持久化到非易失性存储设备中, 该些快照数据块持久化到非易失 性存储设备之前所存储的且在持久化过程中产生的旧数据没有持久化到 非易失性存储设备, 在数据恢复时这些中间版本的旧数据没有必要恢复, 因此, 没有必要保留在持久化过程中产生的有关该些快照数据块持久化到 非易失性存储设备之前的操作日志。 在持久化正常结束后, 如果易失性存 储设备掉电, 通过回放精简日志文件可将该些数据块中数据快速恢复为持 久化结束时刻的数据, 从而提高易失性存储设备掉电后数据恢复效率。
进一步, 在图 6的基础上本实施例还可包括:
第一恢复模块, 用于根据上一持久化周期结束时刻的非易失性存储设 备数据文件、 上一持久化周期结束时刻的精简日志文件、 自上一持久化周 期结束至当前持久化周期开始产生的日志文件和当前持久化周期开始后 产生的日志文件, 恢复所述易失性存储设备中数据。
第二恢复模块, 用于根据上一持久化周期结束时刻的非易失性存储设 备数据文件、 上一持久化周期结束时刻的精简日志文件和上一持久化周期 结束后产生的日志文件, 恢复所述易失性存储设备中数据。
上述各模块实现的功能可参见图 2对应实施例中描述,在此不再赘述。 本实施例提高了易失性存储设备在持久化正常结束后掉电时数据恢 复效率。
本领域普通技术人员可以理解: 实现上述方法实施例的全部或部分步 骤可以通过程序指令相关的硬件来完成, 前述的程序可以存储于一计算机 可读取存储介质中, 该程序在执行时, 执行包括上述方法实施例的步骤; 而前述的存储介质包括: ROM、 RAM, 磁碟或者光盘等各种可以存储程 序代码的介质。
最后应说明的是: 以上各实施例仅用以说明本发明的技术方案, 而非对 其限制; 尽管参照前述各实施例对本发明进行了详细的说明, 本领域的普通 技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改, 或者对其中部分或者全部技术特征进行等同替换; 而这些修改或者替换, 并 不使相应技术方案的本质脱离本发明各实施例技术方案的范围。

Claims

权 利 要 求 书
1、 一种易失性存储设备持久化过程中的数据更新方法, 其特征在于, 包括:
将易失性存储设备中快照数据周期性持久化到非易失性存储设备过 程中, 接收更新快照数据块中数据的写请求; 所述快照数据块为当前持久 化周期内所述易失性存储设备中需要持久化到非易失性存储设备的数据 块;
将新数据写入所述快照数据块, 并在日志文件中记录所述快照数据块 中数据更新为所述新数据的操作日志。
2、 根据权利要求 1 所述方法, 其特征在于, 所述在日志文件中记录 所述快照数据块中数据更新为所述新数据的操作日志之后还包括:
若所述快照数据块中数据未持久化到所述非易失性存储设备, 将所述 快照数据块的操作日志标识为持久化前更新;
若快照数据块中数据已持久化到所述非易失性存储设备, 将所述快照 数据块的操作日志标识为持久化后更新。
3、 根据权利要求 2所述方法, 其特征在于, 在将易失性存储设备中 快照数据持久化到非易失性存储设备的周期结束后还包括:
删除所述日志文件中标识为持久化前更新的操作日志, 使日志文件更 新为精简日志文件。
4、 根据权利要求 3 所述方法, 其特征在于, 在所述将易失性存储设 备中快照数据持久化到非易失性存储设备的过程中, 若所述易失性存储设 备掉电, 所述方法还包括:
根据上一持久化周期结束时刻的非易失性存储设备数据文件、 上一持 久化周期结束时刻的精简日志文件、 自上一持久化周期结束至当前持久化 周期开始产生的日志文件和当前持久化周期开始后产生的日志文件, 恢复 所述易失性存储设备中数据。
5、 根据权利要求 3或 4所述方法, 其特征在于, 在所述将易失性存 储设备中快照数据持久化到非易失性存储设备的周期结束后, 若所述易失 性存储设备掉电, 所述方法还包括:
根据上一持久化周期结束时刻的非易失性存储设备数据文件、 上一持 久化周期结束时刻的精简日志文件和上一持久化周期结束后产生的日志 文件, 恢复所述易失性存储设备中数据。
6、 一种易失性存储设备持久化过程中的数据更新装置, 其特征在于, 包括:
写请求接收模块, 用于将易失性存储设备中快照数据周期性持久化到 非易失性存储设备过程中, 接收更新快照数据块中数据的写请求; 所述快 照数据块为当前持久化周期内所述易失性存储设备中需要持久化到非易 失性存储设备的数据块;
更新模块, 用于将新数据写入所述快照数据块, 并在日志文件中记录 所述快照数据块中数据更新为所述新数据的操作日志。
7、 根据权利要求 6所述的装置, 其特征在于, 还包括:
日志标识模块, 用于若所述快照数据块中数据未持久化到所述非易失 性存储设备, 将所述快照数据块的操作日志标识为持久化前更新; 若快照 数据块中数据已持久化到所述非易失性存储设备, 将所述快照数据块的操 作日志标识为持久化后更新。
8、 根据权利要求 7所述的装置, 其特征在于, 还包括:
日志删除模块, 用于删除所述日志文件中标识为持久化前更新的操作 曰志, 使日志文件更新为精简日志文件。
9、 根据权利要求 8所述的装置, 其特征在于, 还包括:
第一恢复模块, 用于根据上一持久化周期结束时刻的非易失性存储设 备数据文件、 上一持久化周期结束时刻的精简日志文件、 自上一持久化周 期结束至当前持久化周期开始产生的日志文件和当前持久化周期开始后 产生的日志文件, 恢复所述易失性存储设备中数据。
10、 根据权利要求 8或 9所述的装置, 其特征在于, 还包括: 第二恢复模块, 用于根据上一持久化周期结束时刻的非易失性存储设 备数据文件、 上一持久化周期结束时刻的精简日志文件和上一持久化周期 结束后产生的日志文件, 恢复所述易失性存储设备中数据。
PCT/CN2011/085165 2011-12-31 2011-12-31 易失性存储设备持久化过程中的数据更新方法及装置 WO2013097229A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201180003627.7A CN103403679B (zh) 2011-12-31 2011-12-31 易失性存储设备持久化过程中的数据更新方法及装置
PCT/CN2011/085165 WO2013097229A1 (zh) 2011-12-31 2011-12-31 易失性存储设备持久化过程中的数据更新方法及装置

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/085165 WO2013097229A1 (zh) 2011-12-31 2011-12-31 易失性存储设备持久化过程中的数据更新方法及装置

Publications (1)

Publication Number Publication Date
WO2013097229A1 true WO2013097229A1 (zh) 2013-07-04

Family

ID=48696284

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/085165 WO2013097229A1 (zh) 2011-12-31 2011-12-31 易失性存储设备持久化过程中的数据更新方法及装置

Country Status (2)

Country Link
CN (1) CN103403679B (zh)
WO (1) WO2013097229A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109684338A (zh) * 2018-11-20 2019-04-26 深圳花儿数据技术有限公司 一种存储系统的数据更新方法
CN109557937B (zh) * 2018-12-07 2021-07-09 江西洪都航空工业集团有限责任公司 一种飞行模拟器数据多周期存储和回放方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101876949A (zh) * 2009-11-30 2010-11-03 威盛电子股份有限公司 数据储存系统与方法
US20110072226A1 (en) * 2009-09-22 2011-03-24 Emc Corporation Snapshotting of a performance storage system in a system for performance improvement of a capacity optimized storage system
CN102004681A (zh) * 2009-09-01 2011-04-06 Lsi公司 使用写时分配快照以实现持续数据保护的方法

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7440966B2 (en) * 2004-02-12 2008-10-21 International Business Machines Corporation Method and apparatus for file system snapshot persistence

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102004681A (zh) * 2009-09-01 2011-04-06 Lsi公司 使用写时分配快照以实现持续数据保护的方法
US20110072226A1 (en) * 2009-09-22 2011-03-24 Emc Corporation Snapshotting of a performance storage system in a system for performance improvement of a capacity optimized storage system
CN101876949A (zh) * 2009-11-30 2010-11-03 威盛电子股份有限公司 数据储存系统与方法

Also Published As

Publication number Publication date
CN103403679B (zh) 2016-08-31
CN103403679A (zh) 2013-11-20

Similar Documents

Publication Publication Date Title
US8560790B2 (en) Incremental backup of source to target storage volume
CN108319602B (zh) 数据库管理方法及数据库系统
EP3724764B1 (en) Write-ahead style logging in a persistent memory device
CN102955720B (zh) 一种提高ext文件系统稳定性的方法
CN102033786B (zh) 一种对象存储系统中修复副本一致性的方法
WO2015054897A1 (zh) 数据存储方法、数据存储装置和存储设备
US11422703B2 (en) Data updating technology
US10643668B1 (en) Power loss data block marking
WO2014100492A2 (en) Main-memory database checkpointing
WO2013123855A1 (zh) 存储器的读写控制方法及对应的存储器和服务器
JP2017079053A (ja) ストレージジャーナリングを改善する方法およびシステム
CN101707633A (zh) 一种基于文件系统的消息中间件持久消息的存储方法
CN114461456B (zh) 基于连续写cdp备份方法、系统、存储介质及恢复方法
WO2013091349A1 (zh) 数据库内的描述信息的恢复和数据的缓存方法及设备
WO2020042850A1 (zh) 数据的存储方法、装置和存储系统
CN103164528B (zh) 一种音视频数据的索引建立方法
US20210034477A1 (en) Transaction recovery from a failure associated with a database server
US10642508B2 (en) Method to limit impact of partial media failure of disk drive and detect/report the loss of data for objects due to partial failure of media
CN103226965A (zh) 基于时间位图的音视频数据存取方法
US20230251997A1 (en) Recovering the Metadata of Data Backed Up in Cloud Object Storage
KR101738965B1 (ko) 가비지 컬렉션 저널링 장치 및 방법
US7234078B2 (en) Data recovery method and data recording apparatus
CN105915595B (zh) 一种集群存储系统存取数据的方法以及集群存储系统
WO2013097229A1 (zh) 易失性存储设备持久化过程中的数据更新方法及装置
CN107402841B (zh) 大规模分布式文件系统数据修复方法及设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11878463

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11878463

Country of ref document: EP

Kind code of ref document: A1