Dirty data deletion method, device and electronic device

By replacing the damaged main disk with a new main disk and deleting its dirty data without formatting the cache, the problem of performance degradation caused by damaged main disk taking up storage space is solved, and the risk of offline services is avoided, and more efficient storage management is achieved.

CN115016733BActive Publication Date: 2025-04-22CHINA TELECOM CLOUD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210587631.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-26
Publication Date
2025-04-22
Estimated Expiration
2042-05-26

AI Technical Summary

Technical Problem

When the main storage disk is damaged, if the cache memory is not formatted, the dirty data corresponding to the damaged main storage disk will occupy the storage space of the cache memory, resulting in a degradation in the cache memory performance after replacing the main storage disk. If the cache is formatted, other main disk bearers that share the cache may be offline.

Method used

Replace the damaged main disk with the new main disk, and register the new main disk with the unique identity of the damaged main disk, and delete the corresponding dirty data in the cache through the driver in the new main disk.

Benefits of technology

The damaged main storage disk can be deleted without formatting the cache memory, avoiding the offline business caused by formatting and improving the cache memory performance after replacing the main storage disk.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115016733B_ABST
    Figure CN115016733B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a dirty data deletion method, device and electronic device, which relates to the field of computer storage technology and is used to delete dirty data corresponding to a damaged main storage disk. The method includes: determining a unique identifier of a first main storage disk; setting a unique identifier of a second main storage disk as the unique identifier of the first main storage disk; the second main storage disk is used to replace the first main storage disk; and deleting dirty data corresponding to the unique identifier in a cache memory through a driver in the second main storage disk.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer storage technology, and in particular to a dirty data deletion method, device and electronic device. Background Art

[0002] "Digital transformation" has recently become a hot word in all walks of life. It has redefined the processes, scenarios, relationships and participants in the business. Among them, digital transformation involves information technology (IT) such as computing, storage, transmission, and interaction. Storage technology is the IT foundation of digital transformation. Since the storage speed of solid-state drives (SSDs) is fast but their capacity is small and they are expensive, while the storage speed of hard disk drives (HDDs) is slow but their capacity is large and they are cheap, most business systems use small-capacity SSDs as high-speed cache memory (cache) for large-capacity HDDs as a low-cost storage acceleration solution. Among them, block cache (bcache) is a cache memory at the Linux kernel block device layer, which is the most common type of this solution. It allows high-speed hard disk drives (such as SSDs) to act as cache for one or more low-speed hard disk drives (such as HDDs).

[0003] However, when the main storage disk (such as HDD) is damaged, if the cache memory is not formatted, the dirty data corresponding to the damaged main storage disk will continue to occupy the storage space in the cache memory, resulting in reduced performance of the cache memory after the damaged main storage disk is replaced. If the cache memory is formatted, it may cause other main storage disks that share the cache memory to carry services offline. Summary of the invention

[0004] The embodiments of the present application provide a dirty data deletion method, device and electronic device for deleting dirty data corresponding to a damaged main memory disk without formatting a cache memory.

[0005] In a first aspect, an embodiment of the present application provides a dirty data deletion method, including:

[0006] Determine the unique identifier of the first main storage disk. Optionally, the first main storage disk may be a main storage disk that needs to be replaced, such as a damaged main storage disk. Set the unique identifier of the second main storage disk to be the unique identifier of the first main storage disk. The second main storage disk is used to replace the first main storage disk. Delete the dirty data corresponding to the unique identifier in the cache memory through the driver in the second main storage disk.

[0007] Based on the above solution, when the main memory disk is damaged, the dirty data of the damaged main memory disk can be deleted without formatting the cache memory. Therefore, the problem of multiple services sharing the cache memory going offline when formatting the cache memory can be avoided, which is more business-friendly.

[0008] In a possible implementation, determining the unique identifier of the first main storage disk specifically includes: obtaining the unique identifiers of each main storage disk of the shared high-speed cache memory. Optionally, each main storage disk of the shared high-speed cache memory does not include the second main storage disk. Obtaining the unique identifier of an undamaged main storage disk. Comparing the unique identifier of the undamaged main storage disk with the unique identifiers of each main storage disk to determine the unique identifier of the first main storage disk.

[0009] Based on the above solution, the unique identifier of the damaged main storage disk can be determined by deriving the unique identifiers of each main storage disk pre-stored in the cache memory and the unique identifiers of the undamaged main storage disk.

[0010] In a possible implementation, obtaining the unique identifier of each main storage disk of the shared high-speed cache memory specifically includes: obtaining a mapping relationship between each main storage disk and the high-speed cache memory, wherein the mapping relationship is pre-stored in the high-speed cache memory, and obtaining the unique identifier of each main storage disk included in the mapping relationship.

[0011] Based on the above solution, the unique identifier of each main storage disk can be obtained by obtaining the mapping relationship between each main storage disk and the cache memory, thereby determining the unique identifier of the first main storage disk.

[0012] In a possible implementation, before deleting the dirty data corresponding to the unique identifier in the cache memory by the driver in the second main storage disk, the method further includes: deleting the configuration information stored in the memory of the operating system kernel corresponding to the main storage disk corresponding to the unique identifier and the device identifier corresponding to the unique identifier stored in the cache memory. The device identifier is used to identify the cache disk corresponding to the main storage disk in the cache memory. The device identifier of the second main storage disk is set to the device identifier corresponding to the unique identifier.

[0013] Based on the above solution, the memory and device identifier corresponding to the damaged main storage disk can be reused, which can be more business-friendly.

[0014] In a possible implementation, deleting dirty data corresponding to a unique identifier in a cache memory by a driver in a second main storage disk specifically includes: obtaining an index node corresponding to the unique identifier, the index node being used to identify the main storage disk to which the data belongs. Setting the index node of the second main storage disk as the index node corresponding to the unique identifier. Determining that the dirty data corresponding to the index node is dirty data of the second main storage disk. Deleting the dirty data corresponding to the index node in the cache memory by a driver in the second main storage disk.

[0015] Based on the above scheme, since the index node is used to identify the main storage disk to which the data belongs, the index node corresponding to the unique identifier of the damaged main storage disk can be reused, and the dirty data corresponding to the index node can be deleted through the new main storage disk, thereby deleting the dirty data of the damaged main storage disk.

[0016] In a possible implementation, obtaining the index node corresponding to the unique identifier specifically includes: obtaining the correspondence between the unique identifier and the index node stored in the cache memory. The unique identifier and the index node are in one-to-one correspondence. According to the correspondence, obtaining the index node corresponding to the unique identifier.

[0017] Based on the above solution, since the unique identifier and the index node are in one-to-one correspondence, the server can obtain the index node corresponding to the unique identifier through the unique identifier, thereby determining and deleting the dirty data corresponding to the unique identifier.

[0018] In a possible implementation, setting the unique identifier of the second main storage disk as the unique identifier of the first main storage disk specifically includes: when formatting the second main storage disk, setting the unique identifier of the second main storage disk as the unique identifier of the first main storage disk.

[0019] Based on the above solution, the server can set the unique identifier of the second main storage disk to the unique identifier of the first main storage disk when formatting the second main storage disk, thereby achieving the effect of reusing the unique identifier of the first main storage disk and replacing the first main storage disk with the second main storage disk.

[0020] In a second aspect, an embodiment of the present application provides a dirty data deletion device, including:

[0021] The processing unit is used to determine the unique identifier of the first main storage disk. Optionally, the first main storage disk may be a main storage disk that needs to be replaced, such as a damaged main storage disk. The unique identifier of the second main storage disk is set to be the unique identifier of the first main storage disk. The second main storage disk is used to replace the first main storage disk. The dirty data corresponding to the unique identifier in the cache memory is deleted through a driver in the second main storage disk.

[0022] In a possible implementation, the dirty data deletion device further includes an acquisition unit. The acquisition unit is used to acquire the unique identifier of each main storage disk of the shared high-speed cache memory. Optionally, each main storage disk of the shared high-speed cache memory does not include the second main storage disk. The unique identifier of the undamaged main storage disk is acquired. The processing unit is used to compare the unique identifier of the undamaged main storage disk with the unique identifiers of each main storage disk to determine the unique identifier of the first main storage disk.

[0023] In a possible implementation, when the acquisition unit acquires the unique identifiers of each main storage disk of the shared high-speed cache memory, it is specifically used to: acquire the mapping relationship between each main storage disk and the high-speed cache memory. The mapping relationship is pre-stored in the high-speed cache memory. Acquire the unique identifiers of each main storage disk included in the mapping relationship.

[0024] In a possible implementation, before the processing unit deletes the dirty data corresponding to the unique identifier in the cache memory through the driver in the second main storage disk, it is also used to: delete the configuration information stored in the memory of the operating system kernel corresponding to the main storage disk corresponding to the unique identifier and the device identifier corresponding to the unique identifier stored in the cache memory. The device identifier is used to identify the cache disk corresponding to the main storage disk in the cache memory. The device identifier of the second main storage disk is set to the device identifier corresponding to the unique identifier.

[0025] In a possible implementation, the acquisition unit is used to acquire an index node corresponding to the unique identifier. The index node is used to identify the main storage disk to which the data belongs. The processing unit is used to set the index node of the second main storage disk as the index node corresponding to the unique identifier. It is determined that the dirty data corresponding to the index node is the dirty data of the second main storage disk. The dirty data corresponding to the index node in the cache memory is deleted by a driver in the second main storage disk.

[0026] In a possible implementation, when the acquisition unit acquires the index node corresponding to the unique identifier, it is specifically used to: acquire the correspondence between the unique identifier and the index node stored in the cache memory. The unique identifier and the index node are in one-to-one correspondence. According to the correspondence, the index node corresponding to the unique identifier is acquired.

[0027] In a possible implementation, when the processing unit sets the unique identifier of the second main storage disk as the unique identifier of the first main storage disk, it is specifically used to: when formatting the second main storage disk, set the unique identifier of the second main storage disk as the unique identifier of the first main storage disk.

[0028] In a third aspect, an embodiment of the present application provides an electronic device, including:

[0029] Memory, for storing computer instructions;

[0030] A processor is connected to the memory, and is used to execute computer instructions in the memory, and implement the method as described in the first aspect when executing the computer instructions.

[0031] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, including:

[0032] The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer is enabled to perform the method as described in any one of the first aspects.

[0033] For each aspect from the second to the fourth aspect and the technical effects that may be achieved by each aspect, please refer to the above description of the technical effects that can be achieved by the first aspect or various possible schemes in the first aspect, and no further details will be given here. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for describing the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application.

[0035] Figure 1 One of the data flow diagrams provided in the embodiment of the present application;

[0036] Figure 2 One of the data flow diagrams provided in the embodiment of the present application;

[0037] Figure 3 A flowchart of the master storage cancellation provided in the embodiment of the present application;

[0038] Figure 4 A new main storage disk registration flow chart provided for an embodiment of the present application;

[0039] Figure 5 A schematic diagram of an application scenario of a dirty data deletion method provided in an embodiment of the present application;

[0040] Figure 6 One of the bcache architecture diagrams provided in the embodiment of the present application;

[0041] Figure 7 One of the bcache architecture diagrams provided in the embodiment of the present application;

[0042] Figure 8 One of the exemplary flow charts of a dirty data deletion method provided in an embodiment of the present application;

[0043] Fig. 9 A schematic diagram of the mapping relationship between each main storage disk and cache disk provided in the embodiment of the present application;

[0044] Fig.10 A schematic diagram of the mapping relationship between an undamaged main storage disk and a cache disk provided in an embodiment of the present application;

[0045] Fig.11 A schematic diagram of the organizational relationship between bcache internal data and metadata provided in an embodiment of the present application;

[0046] Fig.12 One of the data flow diagrams provided in the embodiment of the present application;

[0047] Fig.13 One of the exemplary flow charts of a dirty data deletion method provided in an embodiment of the present application;

[0048] Fig.14 A schematic diagram of a device provided in an embodiment of the present application;

[0049] Fig.15 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] In order to facilitate understanding of the technical solutions provided by the embodiments of the present application, the professional terms involved in the embodiments of the present application are introduced below.

[0051] (1) Cache memory: Also known as cache disk, it is located between the central processing unit (CPU) and the internal memory (Dynamic Random Access Memory, DRAM). It is a small-scale but high-speed memory, usually composed of static random access memory (SRAM). It is a small-capacity but high-speed memory located between the CPU and the internal memory. The speed of the CPU is much higher than that of the internal memory. When the CPU directly accesses data from the internal memory, it has to wait for a certain period of time. The cache disk can save part of the data that the CPU has just used or recycled. If the CPU needs to use this part of the data again, it can directly call it from the cache disk. This avoids repeated access to data, reduces the CPU's waiting time, and thus improves the efficiency of the system.

[0052] (2) bcache: bcache is a high-speed cache memory at the block device layer of the Linux kernel that supports multiple main storage disks (such as HDDs) using the same cache disk (such as SSD).

[0053] (3) Dirty data: refers to data that is only stored in the cache disk and not stored in the hard disk.

[0054] (4) Foreground business: In the storage industry, the business that interacts with the storage system is called the foreground business. In the embodiment of the present application, the foreground business refers to the business that interacts with bcache.

[0055] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.

[0056] The terms "first" and "second" in the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.

[0057] In addition, the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article, unless otherwise specified, generally indicates that the associated objects before and after are in an "or" relationship.

[0058] Currently, most manufacturers use bcache as a low-cost storage acceleration solution. Bcache supports three modes: writeback, writethrough, and writearound. The default mode of bcache is writethrough mode. In this mode, bcache does not cache sequential read and write data, but only caches random read and write data. In order to avoid random writes, bcache changes the mode to writeback mode. In writeback mode, the data in bcache is first written to the cache memory (cache disk) and then written to the hard disk. Bcache writes the cache dirty data in writeback mode to the hard disk to form the following Figure 1 See the data flow diagram shown in Figure 1. Figure 1One of the data flow diagrams provided for the embodiments of the present application. As shown in the figure, assuming that the foreground business wants to write data to the main storage disk a in bcache, it can enter the foreground write input-output (IO) logic to write the data to bcache. The data is then persisted in IO and stored in the dirty data space of the cache disk. Then bcache can return the IO write result to the foreground business. bcache enters the background IO write thread and reads the dirty data of the main storage disk a. The dirty data of the main storage disk a is then persisted in IO so that the dirty data of the main storage disk is stored in the main storage disk a, and finally the dirty data space attributes are updated.

[0059] When bcache is used, if the main storage disk a is damaged, the system will stop the background IO write thread and uninstall the driver corresponding to the main storage disk a, resulting in the following situation: Figure 2 See the data flow diagram shown in Figure 1. Figure 2 One of the data flow diagrams provided for the embodiment of the present application. As shown in the figure, after the driver corresponding to the main storage disk a is uninstalled, the foreground service cannot write data to bcache. And because the background IO write thread is stopped, the dirty data in the dirty data space of the cache disk cannot be read or updated. Therefore, the dirty data of the main storage disk a in the dirty data space of the cache disk will always be retained.

[0060] When the server detects that the main storage disk is damaged, the server will use the main storage disk deregistration process for the damaged main storage disk. Figure 3 A flowchart of the master storage disk cancellation provided in an embodiment of the present application. As shown in the figure, in the prior art, when a master storage disk is cancelled, the universally unique identifier (UUID) of the master storage disk is set to an invalid UUID. In addition, when the server is connected to a new master storage disk used to replace the damaged master storage disk, the new master storage disk registration process is performed on the new master storage disk. See Figure 4 A new main storage disk registration flow chart provided for an embodiment of the present application. As shown in the figure, in the existing main storage disk registration method, the new main storage disk will be formatted with a new UUID and a new index node will be generated. The UUID and index node of the damaged main storage disk will not be reused, resulting in the unique identifier and the dirty data corresponding to the index node being unable to be updated and deleted in the cache disk dirty data space.

[0061] That is to say, there is currently a technical problem that if the main memory disk in bcache is damaged and the cache disk is not formatted, the dirty data of the damaged main memory disk in the dirty data space of the cache disk cannot be deleted, resulting in reduced cache disk performance.

[0062] In view of this, an embodiment of the present application provides a dirty data deletion method, device and electronic device, the method comprising: when replacing a damaged main storage disk with a new main storage disk, the new main storage disk can be registered using the unique identifier of the damaged main storage disk. Then, the dirty data of the damaged main storage disk in the dirty data space of the cache disk is deleted through the driver in the new main storage disk. Through this method, the damaged main storage disk can be replaced without formatting the cache memory. And the dirty data of the damaged main storage disk in the dirty data space of the cache disk is deleted.

[0063] See also Figure 5 A schematic diagram of an application scenario of a dirty data deletion method provided in an embodiment of the present application. Figure 5 As shown, the scenario may be a server 500. The server 500 may include a processor 501, a cache memory 502, and a main storage disk 503. The processor 501 is the final execution unit for information processing and program execution, and may be used to read data from or write data to the cache memory 502. The cache memory 502 may also be called a cache disk, and may be an SSD or a storage class memory (SCM), and may be used to store data and program codes that have been recently used by the processor 501. It may also be used to write data to or read data from the main storage disk 503. The main storage disk 503 may be one or more HDDs, and may be used to store data written by the cache memory 502.

[0064] Figure 5 The cache memory 502 and main storage disk 503 in the can be applied to the server through bcache. Figure 6 This is one of the bcache architecture diagrams provided in the embodiment of the present application. Figure 5 As shown in the example, the main storage disk uses HDD and the cache memory uses SSD. The main storage disk includes 4 HDD disks: sda, sdb, sdc and sdd. The SSD disk can be abstracted as a cache disk inside bcache, and a device identifier is assigned to each HDD disk to distinguish each HDD disk, so that multiple main storage disks can share a cache disk. The server can assign the device identifier of the main storage disk sda to bcache0, the device identifier of the main storage disk sdb to bcache1, the device identifier of the main storage disk sdc to bcache2, and the device identifier of the main storage disk sdd to bcache3.

[0065] Optionally, in addition to being used to distinguish between various HDD disks, the device identifier can also be used to identify the cache disks corresponding to each main storage disk in the cache disk. For example, the server can assign the device identifier of the main storage disk sda as bcache0, and use the storage space identified as bcache0 in the cache disk as the cache disk of the main storage disk sda. The server can assign the device identifier of the main storage disk sdb as bcache1, and use the storage space identified as bcache1 in the cache disk as the cache disk of the main storage disk sdb. The server can assign the device identifier of the main storage disk sdc as bcache2, and use the storage space identified as bcache2 in the cache disk as the cache disk of the main storage disk sdc. The server can assign the device identifier of the main storage disk sdd as bcache3, and use the storage space identified as bcache3 in the cache disk as the cache disk of the main storage disk sdd.

[0066] In a possible implementation, the SSD can be abstracted as a cache set (cset) inside bcache, where the cache set can include one or more cache memories. Figure 7 One of the bcache architecture diagrams provided in the embodiment of the present application. As shown in the figure, it is assumed that the cache memory set includes two cache memories: cache1 and cache2. Then the main storage disk sda and the main storage disk sdb can share cache1, and cache1 is used as the cache memory of the main storage disk sda and the main storage disk sdb. The main storage disk sdc and the main storage disk sdd can share cache2, and cache2 is used as the cache memory of the main storage disk sdc and the main storage disk sdd.

[0067] See also Figure 8 This is one of the exemplary flow charts of a dirty data deletion method provided in an embodiment of the present application. The method can be applied to Figure 5 The server 500 shown may include the following process, in which the cache memory is referred to as a cache disk and the cache memory set is referred to as a cache set:

[0068] S801, the server determines the unique identifier of the first primary storage disk.

[0069] The unique identifier may be used to identify the first main storage disk, such as the UUID of the first main storage disk. Optionally, the first main storage disk may be a main storage disk that is to be replaced, such as a damaged main storage disk, which is not limited in this application. The embodiment of this application is described by taking the first main storage disk as a damaged main storage disk as an example.

[0070] When the main memory disk is damaged, the server will first stop the background IO write process and then uninstall the damaged main memory disk driver. Figure 2 It can be seen that at this time the server cannot directly obtain the unique identifier of the damaged main storage disk.

[0071] Therefore, in a possible implementation, the server may obtain the unique identifiers of the main storage disks that share the same cache disk. Optionally, the unique identifiers of the main storage disks that share the same cache disk may be pre-stored in the cache disk. The server may also obtain the unique identifier of an undamaged main storage disk. The server may compare the unique identifiers of the main storage disks that share the same cache disk with the unique identifier of the undamaged main storage disk to determine the unique identifier of the first main storage disk.

[0072] For example, the unique identifiers of the main storage disks that share the same cache disk obtained by the server include the UUID of the main storage disk sda, the UUID of the main storage disk sdb, the UUID of the main storage disk sdc, and the UUID of the main storage disk sdd. The UUIDs of the undamaged main storage disks obtained by the server include the UUID of the main storage disk sdb, the UUID of the main storage disk sdc, and the UUID of the main storage disk sdd. Then, by comparing the UUIDs of the main storage disks that share the same cache disk with the UUID of the undamaged main storage disk, since the UUID of the main storage disk sda only appears in the UUIDs of the main storage disks that share the same cache disk, but not in the UUID of the undamaged main storage disk. Therefore, the server can determine that the main storage disk sda is a damaged main storage disk, and the UUID of the main storage disk sda can be the UUID of the aforementioned first main storage disk.

[0073] Based on the above scheme, the unique identifier of the damaged main storage disk can be determined by deriving the unique identifiers of each main storage disk pre-stored in the cache memory and the unique identifiers of the undamaged main storage disk. In one example, the server can obtain the mapping relationship between each main storage disk pre-stored in the cache disk and the cache disk, and obtain the unique identifiers of each main storage disk that shares the same cache disk through the mapping relationship.

[0074] In a possible implementation, the mapping relationship between each main storage disk and the cache disk pre-stored in the cache disk obtained by the server may include the unique identifier of the cache disk and the relationship between the cache disk and each main storage disk. For example, a cache disk is shared by main storage disk HDD1, main storage disk HDD2, main storage disk HDD3 and main storage disk HDD4. Therefore, the above mapping relationship may include the UUID of the cache disk and the UUID of the main storage disk HDD1, the UUID of the main storage disk HDD2, the UUID of the main storage disk HDD3 and the UUID of the main storage disk HDD4 corresponding to the UUID of the cache disk. Optionally, the above mapping relationship may also include the name of the cache disk.

[0075] Optionally, one or more caches may form a cache set. In one possible case, the above mapping relationship may also include the relationship between the cache set and the cache disk. For example, the mapping relationship may include the name of each cache disk included in the cache set and the UUID of each cache disk. The mapping relationship may also include the relationship between the cache disk and the main storage disk. Optionally, the mapping relationship may also include the number of cache disks included in the cache set.

[0076] For example, see Fig. 9 A schematic diagram of the mapping relationship between each main storage disk and cache disk provided in the embodiment of the present application. Fig. 9 As shown in the figure, the cache set includes a cache disk. The name of the cache set is CSET, and the name of the cache disk is CACHE. The cache disk is shared by four main storage disks, namely main storage disk HDD1, main storage disk HDD2, main storage disk HDD3, and main storage disk HDD4. In addition, the figure also shows the UUID of the cache set, the UUID of the cache disk, the UUID of the main storage disk HDD1, the UUID of the main storage disk HDD2, the UUID of the main storage disk HDD3, and the UUID of the main storage disk HDD4. For example, the server can obtain the following by obtaining the command "find / sys-name uuid_tree|xargs cat": Fig. 9 The mapping relationship between each main storage disk and cache disk is shown. The mapping relationship may include the UUID of the cache set, the UUID of the cache disk included in the cache set, and the UUID of the main storage disk HDD1, the UUID of the main storage disk HDD2, the UUID of the main storage disk HDD3, and the UUID of the main storage disk HDD4 corresponding to the UUID of the cache disk. Optionally, the above mapping relationship may also include the name of the cache set.

[0077] Based on the above solution, the unique identifier of each main storage disk can be obtained by obtaining the mapping relationship between each main storage disk and the cache memory, so as to reuse the unique identifier of the damaged main storage disk and delete the dirty data corresponding to the unique identifier.

[0078] In a possible implementation, the unique identifier of the undamaged main storage disk that shares the same cache disk can be obtained by the server by acquiring the mapping relationship between the undamaged main storage disk and the cache disk. It can be understood that the mapping relationship between the undamaged main storage disk and the cache disk can be implemented with reference to the above-mentioned mapping relationship between each main storage disk and the cache memory.

[0079] For example, see Fig.10A schematic diagram of the mapping relationship between an undamaged main storage disk and a cache disk provided for an embodiment of the present application. It can be seen that the cache set in the figure includes a cache disk, the name of the cache set is CSET, and the name of the cache disk is CACHE. The cache disk is shared by three undamaged main storage disks: HDD1, HDD2, and HDD4. The mapping relationship may include the UUID of the cache set, the UUID of the cache disk, the UUID of the main storage disk HDD1, the UUID of the main storage disk HDD2, and the UUID of the main storage disk HDD4.

[0080] Optionally, the server obtains Fig.10 When the mapping relationship between the undamaged main storage disk and the cache disk is shown, the server can obtain it by receiving the "bcache show --more" instruction.

[0081] It should be understood that the above cache set may include one or more cache disks. Fig. 9 and Fig.10 In the description, a cache set including one cache disk is used as an example. This application does not limit the number of cache disks included in the cache set.

[0082] S802: The server sets the unique identifier of the second main storage disk as the unique identifier of the first main storage disk.

[0083] The second main storage disk is used to replace the first main storage disk.

[0084] In a possible implementation, the server can set the unique identifier of the second main storage disk to the unique identifier of the first main storage disk when formatting the second main storage disk. For example, assuming that the first main storage disk is sda and the second main storage disk is main storage disk sdg, the server can format the main storage disk sdg by obtaining the instruction "make-bcache-B--uuid${UUID}--cset-uuid${SET UUID} / dev / sdg" and set the UUID of the main storage disk sdg to the UUID of the main storage disk sda. Among them, ${UUID} in the instruction is the UUID of the main storage disk sda, and ${SET UUID} in the instruction is the UUID of the cache set.

[0085] Based on the above solution, the server can set the unique identifier of the second main storage disk to the unique identifier of the first main storage disk when formatting the second main storage disk, thereby achieving the effect of reusing the unique identifier of the first main storage disk and replacing the first main storage disk with the second main storage disk.

[0086] Optionally, when the second main storage disk is connected to the server, the server may obtain the name of the second main storage disk, and may determine that the main storage disk is a new main storage disk through the name of the second main storage disk, and then format the second main storage disk. For example, the main storage disks connected to the server may include main storage disk sda, main storage disk sdb, main storage disk sdc, and main storage disk sdd. When a main storage disk is connected to the server, the server may recognize that the name of the main storage disk is sde, and when the server determines that the main storage disk sde is not included in the connected main storage disks, it may determine that the main storage disk is the second main storage disk.

[0087] S803: The server deletes the dirty data corresponding to the unique identifier in the cache memory through the driver program in the second main storage disk.

[0088] After replacing the first main storage disk with the second main storage disk, the server can access the storage space of the first main storage disk by running the second main storage disk driver, and delete the dirty data corresponding to the unique identifier of the first main storage disk in the cache disk, that is, delete the dirty data of the first main storage disk in the cache disk.

[0089] In one example, the server can set the device identification of the second main storage disk as the device identification of the first main storage disk, so that the memory of the second main storage disk is the memory of the first main storage disk, and the cache disk corresponding to the second main storage disk in the cache disk is the cache disk corresponding to the first main storage disk. It can also be made that the device identification remains unchanged after the second main storage disk replaces the first main storage disk, thereby being more business-friendly. It can be understood that the above-mentioned memory can be understood as the space allocated in the operating system kernel for the main storage disk for storing configuration information. The operating system kernel can be understood as the system software in the server for providing functions such as hardware abstraction layer, disk and file system control, and multitasking. In other words, after the device identification of the second main storage disk is set to the device identification of the first main storage disk, the second main storage disk can store the configuration information of the second main storage disk in the space allocated in the operating system kernel for the first main storage disk for storing configuration information.

[0090] For example, the device ID of the first main storage disk is bcache1. After the first main storage disk is replaced with the second main storage disk, the server can set the device ID of the second main storage disk to bcache1, so that the device ID of the second main storage disk is the same as the device ID of the first main storage disk. And because the device IDs are the same, the memory corresponding to the second main storage disk is the memory corresponding to the device ID bcache1, that is, the memory corresponding to the first main storage disk. The cache disk of the second main storage disk is the cache disk corresponding to the device ID bcache1, that is, the cache disk of the first main storage disk.

[0091] Since the device identifier assigned by the server to each main memory disk is unique, that is to say, when the device identifier exists in the server, even if the main memory disk corresponding to the device identifier is damaged, the main memory disk newly connected to the server will not use the existing device identifier as the device identifier of the main memory disk. For example, when the main memory disks with device identifiers bcache0, bcache1 and bcache2 exist in the server, the main memory disk with device identifier bcache2 is damaged. When a new main memory disk is connected to the server, the server can assign the device identifier of the main memory disk to bcache3. Although the main memory disk with device identifier bcache2 is damaged, the device identifier bcache2 is still in an occupied state, and the server will not assign the device identifier bcache2 to the main memory disk. Therefore, the server can delete the device identifier of the first main memory disk stored in the cache disk before setting the device identifier of the second main memory disk as the device identifier of the first main memory disk. In addition, the server can also delete the configuration information stored in the memory corresponding to the unique identifier in the operating system kernel, that is, the configuration information stored in the memory corresponding to the first main memory disk in the operating system kernel.

[0092] Based on the above solution, the memory and device identifier corresponding to the damaged main storage disk can be reused, which can be more business-friendly.

[0093] In a possible implementation, the server may also obtain an index node corresponding to the unique identifier of the first main storage disk, and set the index node as the index node of the second main storage disk, so that the dirty data corresponding to the index node is the dirty data of the second main storage disk. Then, the server may delete the dirty data corresponding to the index node in the cache disk by running the second main storage disk driver, that is, delete the dirty data corresponding to the unique identifier of the first main storage disk in the cache disk.

[0094] For example, the server can obtain the index node corresponding to the UUID of the first main storage disk. Assuming that the index node corresponding to the UUID of the first main storage disk is 1, the index node of the second main storage disk is set to 1, so that the dirty data with index node 1 in the cache disk is the dirty data of the second main storage disk. The server can delete the dirty data with index node 1 in the cache disk by running the driver of the second main storage disk, that is, delete the dirty data corresponding to the UUID of the first main storage disk in the cache disk.

[0095] The index node can be used to identify the main storage disk to which the data belongs. Specifically, since the internal data mapping method of bcache is a fully connected mapping method, the storage space of the cache disk except the cache metadata location may be mapped to any space of the main storage disk. Fig.11 A schematic diagram of the organizational relationship between bcache internal data and metadata provided in the embodiment of the present application, Fig.11 It includes three segments of 64 bits of metadata. The arrows indicate the mapping relationship between metadata and data. For example, bits 0-20 of the first segment of metadata are the index node (inode), which is used to identify the main storage disk to which the data corresponding to the metadata belongs. Bits 21-36 of the first segment of metadata are the data length (size), which is used to identify the length of the data corresponding to the metadata. Bit 37 of the first segment of metadata is the dirty data mark (dty), which is used to identify whether the data corresponding to the metadata is dirty data. Bits 0-63 of the second segment of metadata are the back-end device attributes (Back-device offset), which are used to identify the location where the data corresponding to the metadata is stored in the main storage disk. Bits 51 to 63 of the third segment of metadata are the device identifier (dev-bits). Bits 8 to 51 of the third segment of metadata are the cache disk attributes (cache offset), which are used to identify the location where the data corresponding to the metadata is stored in the cache disk.

[0096] In one example, the server can obtain the correspondence between the unique identifier and the index node pre-stored in the cache disk, and then obtain the index node corresponding to the unique identifier based on the correspondence and the unique identifier of the first main storage disk. The unique identifier and the index node are one-to-one corresponding. For example, the server can obtain the correspondence between the UUID and the index node pre-stored in the cache disk by receiving instructions: UUID1 corresponds to inode1, UUID2 corresponds to inode2, and UUID3 corresponds to inode3. When it is determined that the UUID of the first main storage disk is UUID1, it can be determined that the index node corresponding to the UUID of the first main storage disk is inode1.

[0097] Based on the above solution, since the unique identifier and the index node are in one-to-one correspondence, the server can obtain the index node corresponding to the unique identifier through the unique identifier, thereby determining and deleting the dirty data corresponding to the unique identifier.

[0098] In another example, the mapping relationship between each main storage disk and the cache disk stored in the cache disk may also include an index node corresponding to the unique identifier of each main storage disk. Therefore, the server can obtain the index node corresponding to the unique identifier of each main storage disk that shares the same cache disk through the mapping relationship. In this way, the index node corresponding to the unique identifier of the first main storage disk is obtained.

[0099] Based on the above scheme, since the index node is used to identify the main storage disk to which the data belongs, the index node corresponding to the unique identifier of the damaged main storage disk can be reused so that the dirty data corresponding to the index node can be deleted through the new main storage disk, thereby deleting the dirty data of the damaged main storage disk.

[0100] See also Fig.12 , which is one of the data flow diagrams provided in the embodiment of the present application. Fig.12 As shown, after adopting the dirty data method provided in the embodiment of the present application, the server can read and delete the dirty data according to the unique identifier of the first main storage disk. Fig.12 Taking the unique identifier as UUID as an example, the unique identifiers of the six main storage disks HDD1-HDD6 that share the same cache disk are UUID1-UUID6 respectively. For example, when the main storage disk HDD1 is damaged, even if the driver of the main storage disk HDD1 has been uninstalled and the dirty data of the main storage disk HDD1 in the dirty data space of the cache disk cannot be accessed, the server can replace the main storage disk HDD1 with the main storage disk HDD7, set the UUID of the main storage disk HDD7 to the UUID1 of the main storage disk HDD1, and delete the dirty data of UUID1 in the dirty data space of the cache disk by running the driver of the main storage disk HDD7, thereby deleting the dirty data of the main storage disk HDD1.

[0101] Based on the above solution, when the main storage disk is damaged, the dirty data of the damaged main storage disk can be deleted without formatting the cache disk. Therefore, it can avoid the offline of the shared cache disk caused by formatting the cache disk, which is more business-friendly.

[0102] In order to more clearly understand the solution proposed in the embodiment of the present application, Fig.13 A dirty data deletion method provided in this application is introduced.

[0103] See also Fig.13 , is one of the exemplary flow charts of a dirty data deletion method provided in an embodiment of the present application. Fig.13 In the illustrated embodiment, the unique identifier is UUID as an example for description. The process may include the following operations.

[0104] S1301, the server obtains the UUID of the first main storage disk.

[0105] The server can obtain the mapping relationship between each main storage disk and the cache disk pre-stored in the cache disk by receiving the instruction, and obtain the UUID of the first main storage disk. The specific method can be referred to as above. Figure 8 The relevant description of S801 in the illustrated method embodiment will not be repeated here.

[0106] S1302: The server sets the UUID of the second main storage disk to the UUID of the first main storage disk.

[0107] The server can set the UUID of the second main storage disk to the UUID of the first main storage disk when formatting the second main storage disk. Figure 8The relevant description of S802 in the illustrated method embodiment will not be repeated here.

[0108] S1303: The server deletes the device identifier corresponding to the UUID of the first main storage disk and the configuration information stored in the memory.

[0109] In order to allow the second main storage disk to reuse the memory corresponding to the first main storage disk and the device identification of the first main storage disk, the server can delete the configuration information stored in the memory corresponding to the UUID and the device identification corresponding to the UUID according to the UUID of the first main storage disk. Figure 8 The relevant description of S803 in the illustrated method embodiment will not be repeated here.

[0110] S1304, the server allocates a device identifier for the second main storage disk.

[0111] After the device ID of the first main storage disk is deleted, the server can set the device ID of the second main storage disk to the device ID of the first main storage disk. Figure 8 The relevant description of S803 in the illustrated method embodiment will not be repeated here.

[0112] S1305: The server sets the index node of the second main storage disk as the index node of the first main storage disk.

[0113] The server can read the dirty data of the first main storage disk in the dirty data space of the cache disk by setting the index node of the second main storage disk as the index node of the first main storage disk. The specific method can be referred to as above. Figure 8 The relevant description of S803 in the illustrated method embodiment will not be repeated here.

[0114] S1306, the server deletes the dirty data in the first main storage disk.

[0115] After the second main storage disk is registered, the server can delete the dirty data of the first main storage disk in the dirty data space of the cache disk by starting the driver of the second main storage disk.

[0116] Based on the same concept of the above method, see Fig.14 , is a dirty data deletion device 1400 provided in an embodiment of the present application. The device 1400 can perform each step in the above method. To avoid repetition, it is not described in detail here. The device 1400 includes an acquisition unit 1401 and a processing unit 1402. In one scenario:

[0117] The processing unit 1402 is used to perform the following processing:

[0118] Determine the unique identifier of the first main storage disk. Optionally, the first main storage disk may be a main storage disk that needs to be replaced, such as a damaged main storage disk. Set the unique identifier of the second main storage disk to be the unique identifier of the first main storage disk. The second main storage disk is used to replace the first main storage disk. Delete the dirty data corresponding to the unique identifier in the cache memory through the driver in the second main storage disk.

[0119] In a possible implementation, the acquisition unit 1401 is used to acquire the unique identification of each main storage disk of the shared high-speed cache memory. Optionally, the main storage disks of the shared high-speed cache memory do not include the second main storage disk. The unique identification of the undamaged main storage disk is acquired. The processing unit 1402 is used to compare the unique identification of the undamaged main storage disk with the unique identification of each main storage disk to determine the unique identification of the first main storage disk.

[0120] In a possible implementation, when the acquisition unit 1401 acquires the unique identifiers of each main storage disk of the shared high-speed cache memory, it is specifically used to: acquire the mapping relationship between each main storage disk and the high-speed cache memory. The mapping relationship is pre-stored in the high-speed cache memory. Acquire the unique identifiers of each main storage disk included in the mapping relationship.

[0121] In a possible implementation, before the processing unit 1402 deletes the dirty data corresponding to the unique identifier in the cache memory through the driver in the second main storage disk, it is also used to: delete the configuration information stored in the memory of the operating system kernel corresponding to the main storage disk corresponding to the unique identifier and the device identifier corresponding to the unique identifier stored in the cache memory. The device identifier is used to identify the cache disk corresponding to the main storage disk in the cache memory. The device identifier of the second main storage disk is set to the device identifier corresponding to the unique identifier.

[0122] In a possible implementation, the acquisition unit 1401 is used to acquire an index node corresponding to a unique identifier. The index node is used to identify the main storage disk to which the data belongs. The processing unit 1402 is used to set the index node of the second main storage disk as the index node corresponding to the unique identifier. Determine that the dirty data corresponding to the index node is the dirty data of the second main storage disk. Delete the dirty data corresponding to the index node in the cache memory through the driver in the second main storage disk.

[0123] In a possible implementation, when the acquisition unit 1401 acquires the index node corresponding to the unique identifier, it is specifically used to: acquire the correspondence between the unique identifier and the index node stored in the cache memory. The unique identifier and the index node are in one-to-one correspondence. According to the correspondence, the index node corresponding to the unique identifier is acquired.

[0124] In a possible implementation, when the processing unit 1402 sets the unique identifier of the second main storage disk as the unique identifier of the first main storage disk, it is specifically configured to: when formatting the second main storage disk, set the unique identifier of the second main storage disk as the unique identifier of the first main storage disk.

[0125] Based on the same concept of the above method, see Fig.15 , an electronic device is provided for an embodiment of the present application, the electronic device includes a processor 1501 and a memory 1502. The memory 1502 is used to store computer instructions, and the processor 1501 is connected to the memory and is used to execute the computer instructions in the memory, and implement the steps of any of the above methods when executing the computer instructions.

[0126] The embodiment of the present application further provides a computer-readable storage medium on which computer instructions are stored. When the computer instructions are executed on a computer, the computer executes the steps of any of the above methods.

[0127] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0128] Although the specific embodiments of the present application are described above, it should be understood by those skilled in the art that these are merely examples, and the scope of protection of the present application is limited by the attached claims. Those skilled in the art may make various changes or modifications to these embodiments without departing from the principles and essence of the present application, but these changes and modifications all fall within the scope of protection of the present application. Although the preferred embodiments of the present application have been described, once those skilled in the art are aware of the basic creative concepts, additional changes and modifications may be made to these embodiments. Therefore, the attached claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

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

Claims

1. A dirty data deletion method, characterized in that: include: Determine the unique identifier of the first main storage disk; Setting the unique identifier of the second main storage disk to the unique identifier of the first main storage disk; The second main storage disk is used to replace the first main storage disk; Acquire the correspondence between the unique identifier and the index node stored in the cache memory, and acquire the index node corresponding to the unique identifier according to the correspondence; The unique identifier corresponds to the index node one by one; the index node is used to identify the main storage disk to which the data belongs; Setting the index node of the second main storage disk as the index node corresponding to the unique identifier; Determine that the dirty data corresponding to the index node is the dirty data of the second main storage disk; The dirty data corresponding to the index node in the cache memory is deleted through the driver program in the second main storage disk.

2. The method according to claim 1, characterized in that The determining of the unique identifier of the first main storage disk specifically includes: Obtaining unique identifiers of each main storage disk that shares the high-speed cache memory; Get the unique identifier of the undamaged main storage disk; The unique identifier of the undamaged main storage disk is compared with the unique identifiers of each main storage disk to determine the unique identifier of the first main storage disk.

3. The method according to claim 2, characterized in that The obtaining of the unique identifiers of the main storage disks sharing the high-speed cache memory specifically includes: Acquire a mapping relationship between each main storage disk and the high-speed cache memory; the mapping relationship is pre-stored in the high-speed cache memory; The unique identifier of each main storage disk included in the mapping relationship is obtained.

4. The method according to any one of claims 1 to 3, characterized in that: Before acquiring the correspondence between the unique identifier and the index node stored in the cache memory, the method further includes: Deleting the configuration information stored in the memory of the operating system kernel corresponding to the main storage disk corresponding to the unique identifier and the device identifier corresponding to the unique identifier stored in the cache memory; the device identifier is used to identify the cache disk corresponding to the main storage disk; The device identification of the second main storage disk is set to the device identification corresponding to the unique identification.

5. The method according to claim 1, characterized in that The step of setting the unique identifier of the second main storage disk as the unique identifier of the first main storage disk specifically includes: When formatting the second main storage disk, the unique identifier of the second main storage disk is set to be the unique identifier of the first main storage disk.

6. A dirty data deletion device, characterized in that: include: A processing unit, configured to determine a unique identifier of a first main storage disk; Setting the unique identifier of the second main storage disk to the unique identifier of the first main storage disk; The second main storage disk is used to replace the first main storage disk; the correspondence between the unique identifier and the index node stored in the cache memory is obtained, and the index node corresponding to the unique identifier is obtained according to the correspondence; the unique identifier and the index node are in one-to-one correspondence; the index node is used to identify the main storage disk to which the data belongs; Setting the index node of the second main storage disk as the index node corresponding to the unique identifier; Determine that the dirty data corresponding to the index node is the dirty data of the second main storage disk; and delete the dirty data corresponding to the index node in the cache memory through a driver in the second main storage disk.

7. An electronic device, characterized in that: include: Memory, for storing computer instructions; A processor is connected to the memory, and is used to execute computer instructions in the memory, and implement the method according to any one of claims 1 to 5 when executing the computer instructions.

8. A computer-readable storage medium, characterized in that: include: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer is caused to perform the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data storage method, device and system, and portable electronic equipment

    CN106959819A

  • Global shared cache method and device for multi-control storage system

    CN107992270A