This application relates to the field of information technologies, and in particular, to a super block management method and apparatus.
Currently, a general-purpose architecture of a computer device, for example, a terminal device, includes a file system (for example, a flash-friendly file system (F2FS)) and a universal memory (for example, a universal flash storage (UFS) and an embedded multi-media card (EMMC)). The file system and the memory run independently without any coupling. The file system is configured to manage a logical address space. The memory is configured to store application layer data.
In a current flash-based memory, due to a physical limitation of flash page programming block erasing, valid data in a super block needs to be reclaimed according to a garbage collection (GC) algorithm, to release the super block for writing of subsequent data. Currently, the industry has put forward some new architectures that streamline two layers of GC respectively corresponding to the memory and the file system into one layer of GC, for example, unified storage and zoned name spaces (ZNS), to reduce write amplification caused by the two layers of GC.
However, in an existing architecture, a probability that a critical request is blocked on a memory side is high. In addition, with improvement of a future memory process, in the foregoing architecture with one layer of GC, a capacity of a physical block on a single die (die) in the memory increases significantly. As a result, a capacity of the super block (Super Block) also increases significantly. However, an excessively large super block increases a GC load, and severely affects performance of the memory.
Embodiments of this application provide a super block management method and apparatus. A size of a super block may be dynamically configured to reduce a probability that a critical request is blocked and impact of an excessively large super block on storage performance, to improve overall performance.
According to a first aspect, this application provides a super block management method. The method includes: obtaining a parameter of a memory and a type of target data, where the target data is data to be written into the memory; configuring a capacity of a section in a file system based on the type of the target data and/or the parameter, where the section is a logical address space management unit in the file system, and the configured capacity of the section matches a capacity of a super block in the memory; and managing, based on the configured capacity of the section, a logical address space corresponding to the memory.
The type of the target data may be hot data, warm data, and cold data. The section is a unit of a logical address space managed by the file system.
Optionally, the foregoing embodiment may be implemented by running the file system on a processor.
From the perspective of technical effects, compared with the conventional technology in which the capacity of the section is constant, in this embodiment of this application, the capacity of the section may be dynamically adjusted based on different scenarios (corresponding to different types of the target data and/or different parameters of the memory). The capacity of the section matches the capacity of the super block in the memory, so that when the capacity of the section is dynamically configured, the capacity of the super block in the memory is synchronously adjusted, to meet requirements of different scenarios. In this way, overall performance is improved. For example, with improvement of a manufacturing process in the future, the capacity of the super block continuously increases when the conventional technology is used for super block management, and a quantity of idle super blocks is continuously reduced under a condition that a capacity of the memory is constant. In this embodiment of this application, the capacity of the super block in the memory may be synchronously reduced by reducing the capacity of the section. In this way, a quantity of redundant blocks (that is, super blocks in redundant space (OP)) in the memory is increased, and the overall performance is improved.
In a feasible implementation, the memory includes at least one die (die). Each of the at least one die includes at least one physical block. The super block is a management unit in the memory. The super block includes at least one physical block. Each of the at least one physical block is located on a different die.
It should be understood that the capacity of the section is equal to the capacity of the super block in the memory, and the super block includes at least one physical block. Therefore, the capacity of the section corresponds to at least one physical block in the memory. In other words, the capacity of the section is equal to a product of a quantity of physical blocks, in the memory, corresponding to the capacity of the section and a capacity of a single physical block.
The die and the physical block on the die are hardware structures in the memory. The super block is a logical structure in the memory.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is less than or equal to a preset quantity, a quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is less than the quantity of dies.
From the perspective of technical effects, when the quantity of idle super blocks in the memory is less than or equal to the preset quantity, a data read/write process in the memory is seriously affected. In this embodiment of this application, the capacity of the section may be dynamically configured. For example, the capacity of the section is reduced, so that the quantity of physical blocks, in the memory, corresponding to the capacity of the section is less than the quantity of dies, that is, the capacity of the super block in the memory is synchronously reduced. In this way, the quantity of redundant blocks in the memory is increased, and the overall performance is improved.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is greater than a preset quantity, a quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is less than or equal to the quantity of dies.
Optionally, when the type of the target data is hot data, the quantity of physical blocks, in the memory, corresponding to the capacity of the section is equal to the quantity of dies; or when the type of the target data is warm data or cold data, the quantity of physical blocks, in the memory, corresponding to the capacity of the section is less than the quantity of dies.
From the perspective of technical effects, in the conventional technology, sizes of super blocks, in the memory, respectively corresponding to a critical request (that is, a hot data read/write request) and a non-critical request (that is, a warm data or cold data read/write request) are the same, that is, quantities of physical blocks included in the super blocks each are equal to the quantity of dies. As a result, when the critical request is inserted for processing before the non-critical request, there is a high probability that the two requests fall on a same die, causing blocking of the critical request. In this embodiment of this application, for the non-critical request, the capacity of the section may be configured to a small value, that is, a quantity of physical blocks included in the super block in the memory is less than the quantity of dies. For the critical request, the capacity of the section may be configured to a large value, that is, a quantity of physical blocks included in the super block in the memory is equal to the quantity of dies. Therefore, when the critical request is inserted for processing before the non-critical request, because the quantities of physical blocks included in the super blocks, in the memory, respectively corresponding to the two requests are different, there is a low probability that the two requests fall on a same die. In other words, in this embodiment of this application, a probability that the critical request is blocked may be reduced.
In a feasible implementation, the managing, based on the configured capacity of the section, a logical address space corresponding to the memory includes: determining E configured sections from the logical address space corresponding to the memory, where the E configured sections respectively correspond to E super blocks in the memory; and indieating the processor to reclaim data in the E super blocks to F idle super blocks, where E is greater than F, and E and F are positive integers.
From the perspective of technical effects, the capacity of the section in the file system is configured, and in a process in which the memory performs GC based on the capacity of the section, when the quantity of physical blocks corresponding to the configured capacity of the section in the file system is less than the quantity of dies, compared with the conventional technology in which the quantity of physical blocks corresponding to the capacity of the section is equal to the quantity of dies, when a same quantity of idle super blocks are released, in this embodiment of this application, a quantity of times of valid data migration may be reduced by reducing the capacity of the super block in the memory. Alternatively, when a same amount of valid data is migrated, in this embodiment of this application, because the capacity of the super block is small, more super blocks may be released, that is, efficiency of releasing a redundant block in the GC process is improved. In this way, the overall performance is improved.
In a feasible implementation, the managing, based on the configured capacity of the section, a logical address space corresponding to the memory includes: determining K configured sections from the logical address space corresponding to the memory, where the K configured sections respectively correspond to K super blocks in the memory; and indieating the memory to write the target data into the K super blocks, where K is a positive integer.
From the perspective of technical effects, the capacity of the section in the file system is configured, and the memory performs a process of writing the target data based on the capacity of the section. When writing the target data is a critical request that is inserted, it may be learned from the foregoing embodiment that in this embodiment of this application, a blocking probability during writing of the target data may be reduced.
According to a second aspect, this application provides a super block management apparatus. The apparatus includes: an obtaining unit, configured to obtain a parameter of a memory and a type of target data, where the target data is data to be written into the memory; a configuration unit, configured to configure a capacity of a section in a file system based on the type of the target data and/or the parameter, where the section is a logical address space management unit in the file system, and the configured capacity of the section matches a capacity of a super block in the memory; and a management unit, configured to manage, based on the configured capacity of the section, a logical address space corresponding to the memory.
In a feasible implementation, the memory includes at least one die (die). Each of the at least one die includes at least one physical block. The super block is a management unit in the memory. The super block includes at least one physical block. Each of the at least one physical block is located on a different die.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is less than or equal to a preset quantity, a quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is less than the quantity of dies.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is greater than a preset quantity, a quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is less than or equal to the quantity of dies.
In a feasible implementation, the management unit is specifically configured to: determine E configured sections from the logical address space corresponding to the memory, where the E configured sections respectively correspond to E super blocks in the memory; and indieate a processor to reclaim data in the E super blocks to F idle super blocks, where E is greater than F, and E and F are positive integers.
In a feasible implementation, the management unit is specifically configured to: determine K configured sections from the logical address space corresponding to the memory, where the K configured sections respectively correspond to K super blocks in the memory; and indieate the memory to write the target data into the K super blocks, where K is a positive integer.
According to a third aspect, this application provides a computer device. The computer device includes a processor and a memory. The processor is configured to: obtain a parameter of the memory and a type of target data, where the target data is data to be written into the memory; configure a capacity of a section in a file system based on the type of the target data and/or the parameter, where the section is a logical address space management unit in the file system, and the configured capacity of the section matches a capacity of a super block in the memory; and manage, based on the configured capacity of the section, a logical address space corresponding to the memory.
In a feasible implementation, the memory includes at least one die (die). Each of the at least one die includes at least one physical block. The super block is a management unit in the memory. The super block includes at least one physical block. Each of the at least one physical block is located on a different die.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is less than or equal to a preset quantity, a quantity of physical blocks, in the memory, corresponding to the capacity of the section is less than the quantity of dies.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is greater than a preset quantity, a quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is less than or equal to the quantity of dies.
In a feasible implementation, in the aspect of managing, based on the configured capacity of the section, the logical address space corresponding to the memory, the processor is specifically configured to determine E configured sections from the logical address space corresponding to the memory. The E configured sections respectively correspond to E super blocks in the memory. The memory is configured to reclaim data in the E super blocks to F idle super blocks. E is greater than F. E and F are positive integers.
In a feasible implementation, in the aspect of managing, based on the configured capacity of the section, the logical address space corresponding to the memory, the processor is specifically configured to determine K configured sections from the logical address space corresponding to the memory. The K configured sections respectively correspond to K super blocks in the memory. The memory is configured to write the target data into the K super blocks. K is a positive integer.
According to a fourth aspect, this application provides a chip system. The chip system includes at least one processor, a memory, and an interface circuit. The memory, the interface circuit, and the at least one processor are connected to each other through a line. The at least one memory stores instructions. When the instructions are executed by the processor, the method in the first aspect is implemented.
According to a fifth aspect, this application provides a computer-readable storage medium. The computer-readable storage medium stores program instructions. When the program instructions run on one or more processors, the method in the first aspect is implemented.
According to a sixth aspect, this application provides a computer program product. When the computer program product runs on a computer device, the method in the first aspect is implemented.
The following describes the accompanying drawings used in embodiments of this application.
The following describes embodiments of this application with reference to the accompanying drawings in embodiments of this application.
In the specification, claims, and accompanying drawings of this application, terms “first”, “second”, “third”, “fourth”, and the like are intended to distinguish between different objects but do not indicate a particular order. In addition, terms “include” and “have” and any variant thereof are intended to cover a non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes an unlisted step or unit, or optionally further includes another inherent step or unit of the process, the method, the product, or the device. “Embodiment” mentioned in this specification means that a particular feature, structure, or characteristic described with reference to this embodiment may be included in at least one embodiment of this application. The phrase shown in various locations in this specification may not necessarily refer to a same embodiment, and is not an independent or optional embodiment exclusive from another embodiment. It is explicitly and implicitly understood by persons skilled in the art that embodiments described in this specification may be combined with another embodiment.
Terms “part”, “module”, “system”, and the like used in this specification are intended to indicate a computer-related entity, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a part may be but is not limited to a process that runs on a processor, the processor, an object, an executable file, an execution thread, a program, and/or a computer. As illustrated by using figures, both an application that runs on a computing device and the computing device may be parts. One or more parts may reside within a process and/or an execution thread, and a part may be located on one computer and/or distributed between two or more computers. In addition, these parts may be implemented by various computer-readable media that store various data structures. The parts may communicate through local and/or remote processes based on, for example, a signal with one or more data packets (for example, data from two parts, in a local system, a distributed system, and/or a network, interacting with the other part, for example, the internet interacting with another system by using the signal).
The following describes embodiments of this application with reference to the accompanying drawings in embodiments of this application.
Related terms in embodiments of this application are first explained.
(1) Flash (flash): It is also referred to as a non-volatile memory. Data may be written and erased for a plurality of times, and can be retained for a long time without current and voltage supply.
(2) File system: It is a software organization that manages and stores file information in an operating system. The file system has functions of: managing and scheduling storage space of a file, providing a logical structure, a physical structure, and a storage method of the file, implementing mapping of the file from an identifier to an actual address, implementing file control and access operations, implementing file information sharing, providing reliable file confidentiality and protection measures, and providing a file security measure.
(3) GC algorithm (that is, garbage collection (GC) algorithm): This algorithm is used to migrate a valid page in a block to another idle block, so that the block from which the valid data is transferred is idle for subsequent writing.
(4) OP (that is, over provisioning): It may be referred to as redundant space or reserved space. OP is a capacity of a memory that cannot be operated by a user, whose value is an actual capacity of the memory minus a capacity available to the user. An OP region is generally used for optimization operations, for example, GC. An OP block (or referred to as a redundant block) is a super block included in the redundant space. A larger quantity of OP blocks indicates a higher GC load.
(5) Section: It is a block management unit on a file system side. In a flash file system (Flash File System), a capacity of the section on the file system side corresponds to that of a super block (Super block) in the memory. In an F2FS, a section is section in three logical address space management units (zone, section, and segment) included in the F2FS.
(6) Super block (super block): It is a minimum management unit in the memory, which is a logical structure division of the memory. The memory performs data read/write, garbage collection, and other operations based on super blocks.
As shown in
The memory 100 maintains a queue during request processing. Requests delivered by a host are arranged in the queue in sequence. A high-priority critical request may be inserted to a header of a low-priority non-critical request and then processed in serial according to a first in first out principle.
Optionally, the memory 100 may be a universal flash storage UFS, an embedded multi-media card EMMC, or the like in a computer device such as a mobile phone. This is not limited in this solution. In unified storage, ZNS, and other architectures, core algorithms such as a GC algorithm and a block management algorithm under the flash translation layer (FTL) may be handed over to a kernel for management, an overall FTL policy remains unchanged, and composition of the super block remains unchanged. In this way, GC on the memory side and GC on a file system side are streamlined into one layer of GC.
However, with improvement of a manufacturing process, a memory such as a flash memory will evolve towards a higher density in the future, which is represented as an increase of a quantity of stacking layers and an increase of a storage capacity of a single storage unit, so that a capacity of a single physical block also increases significantly. Currently, a super block on the memory side includes one physical block on each die. Therefore, when the capacity of a single physical block increases in the future, a capacity of a single super block also increases significantly. An excessively large super block increases a quantity of times that valid data is repeatedly written in a GC process, that is, increases a GC load, affecting an overall throughput of the memory. Especially, at an end of capacity (a quantity of idle super blocks is less than or equal to a preset quantity), each super block stores much valid data, and additional overheads brought by data migration in the GC algorithm are further amplified.
In addition, if the host delivers a high-priority critical request when the memory is processing a low-priority non-critical request, the high-priority critical request is arranged at a header of the low-priority non-critical request. In this case, the low-priority non-critical request is being processed, so that there is a high probability that the two requests are on a same die. However, only one request may be processed on a single die at a time. Therefore, although arranged before the low-priority non-critical request, the high-priority critical request can be processed only after the low-priority non-critical request is processed. As a result, the high-priority critical request is blocked.
Optionally, the computer device 200 may be a mobile phone, a computer, a tablet, a wearable device, or the like. This is not limited in this application.
Optionally, the application layer 210 may include an application program layer 211 and an application program framework layer 212. The application program layer 211 may include a series of application program packages. The application program packages may include application programs (or referred to as applications) such as Camera, Gallery, Calendar, Phone, Maps, Navigation, WLAN, Bluetooth, Music, Videos, and Messages. The application program framework layer 212 provides an application programming interface (API) and a programming framework for the application program at the application program layer. The application program framework layer includes some predefined functions.
Optionally, the operating system 220 may include a file system 221, a block layer 222, and a device driver 223. The file system 221 is configured to manage and schedule storage space of a file, and provide a logical structure, a physical structure, and a storage method of the file. The block layer 222 is an interface for the file system 221 to access the device layer 230, and is configured to connect the file system 221 to the device driver 223. The block layer 222 may be divided into two layers: one is a bio layer, and the other is a request layer. The block layer 222 is configured to encapsulate/decapsulate a related request. The device driver 223 may include a display driver, a camera driver, an audio driver, a sensor driver, and the like.
Optionally, the device layer 230 may include a memory 100.
In some feasible implementations, a program may run in a user mode and a kernel mode. When the program runs in the user mode, a processor can access only some data in the memory, and is not allowed to access a peripheral device such as a hard disk or a network adapter. When the program runs in the kernel mode, a processor may access all data in the memory, including a peripheral device such as a hard disk or a network adapter. In addition, the processor may also switch from one program to another program. Generally, the application program in the application layer 210 runs in the user mode, and the operating system 220 runs in the kernel mode.
In a running process of the computer device 200, the application layer 210 first initiates a read/write request. The file system 221 determines a logical address of data corresponding to the read/write request in the memory 100. The block layer 222 is configured to distribute the read/write request to the device driver 223. The device driver 223 is configured to encapsulate the read/write request, and send the encapsulated read/write request and the logical address corresponding to the read/write request to the memory 100. The memory 100 decapsulates the encapsulated read/write request, and converts the logical address corresponding to the read/write request into a corresponding physical address in the memory 100. Then, based on the read/write request, data is written into the physical address or data is read from the physical address.
Step S310: Obtain a parameter of a memory and a type of target data, where the target data is data to be written into the memory.
Step S320: Configure a capacity of a section in a file system based on the type of the target data and/or the parameter, where the section is a logical address space management unit in the file system, and the configured capacity of the section matches a capacity of a super block in the memory.
Step S330: Manage, based on the configured capacity of the section, a logical address space corresponding to the memory.
The type of the target data may be any one of cold data (Cold data), warm data (Warm data), or hot data (Hot data), or any data type in other data type division manners. The memory may be the memory 100 in the embodiment corresponding to
The parameter of the memory may include a quantity of idle super blocks in the memory and a quantity of dies (dies) in the memory (as shown in the memory in
Optionally, the operations in steps S310, S320, and S330 may be implemented by a processor by running the file system.
The file system may be a flash file system (Flash File System) or any one of other feasible file systems. The flash file system may include a journaling flash file system version 2 (JFFS2), a YAFFS (YAFFS), a flash-friendly file system (F2FS), and the like.
Different file systems may use different hierarchical management units to manage corresponding logical address spaces. Optionally, for example, the F2FS may include three hierarchical management units for the logical address space: zone, section, and segment. Each zone may include at least one section, and each section may include at least one segment.
Specifically,
It should be understood that in
Specifically, there may be two cases for configuration of the capacity of the section in the file system based on the type of the target data and/or the parameter in step S320.
(1) When the memory is at an end of capacity (that is, the quantity of idle super blocks in the memory is less than or equal to a preset quantity), the capacity of the section in the file system is configured based on the parameter of the memory.
(2) When the memory is not at an end of capacity (that is, the quantity of idle super blocks in the memory is greater than a preset quantity), the capacity of the section in the file system is configured based on the type of the target data and the parameter of the memory.
Specifically, in step S330, managing, based on the configured capacity of the section, the logical address space corresponding to the memory may include:
configuring the capacity of the section in the file system based on a specific application scenario (determined based on the type of the target data and the parameter of the memory), and dividing the logical address space corresponding to the memory by using the configured capacity of the section as a unit, where the configured capacity of the section matches the capacity of the super block in the memory, and the memory performs data read/write and other operations by using the super block as a basic unit. Therefore, in this embodiment of this application, the capacity of the super block in the memory is synchronously adjusted by dynamically configuring the capacity of the section in the file system, and the memory is indicated to perform data read/write, garbage collection GC, and other operations in units of adjusted super blocks.
From the perspective of technical effects, compared with the conventional technology in which the capacity of the section is constant, in this embodiment of this application, the capacity of the section may be dynamically adjusted based on different scenarios (corresponding to different types of the target data and/or different parameters of the memory). The capacity of the section matches the capacity of the super block in the memory, so that when the capacity of the section is dynamically configured, the capacity of the super block in the memory is synchronously adjusted, to meet requirements of different scenarios. In this way, overall performance is improved. For example, with improvement of a manufacturing process in the future, the capacity of the super block continuously increases when the conventional technology is used for super block management, and the quantity of idle super blocks is continuously reduced under a condition that the capacity of the memory is constant. In this embodiment of this application, the capacity of the super block in the memory may be synchronously reduced by reducing the capacity of the section. In this way, a quantity of redundant blocks (that is, super blocks in redundant space (OP)) in the memory is increased, and the overall performance is improved.
In a feasible implementation, the memory includes at least one die (die). Each of the at least one die includes at least one physical block. A management unit in the memory is the super block. The super block includes at least one physical block. Each of the at least one physical block is located on a different die.
It should be understood that the capacity of the section is equal to the capacity of the super block in the memory, and the super block includes at least one physical block. Therefore, the capacity of the section corresponds to at least one physical block in the memory. In other words, the capacity of the section is equal to a product of a quantity of physical blocks, in the memory, corresponding to the capacity of the section and a capacity of a single physical block.
Specifically, as shown in
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is less than or equal to a preset quantity, a quantity of physical blocks, in the memory, corresponding to the capacity of the section is less than the quantity of dies.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is greater than a preset quantity, a quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is less than or equal to the quantity of dies.
The idle super block is a super block that does not include any data. The idle super block may be located in storage space visible to a user or redundant space OP.
The preset quantity may be a value that is set based on a specific scenario. This is not limited in this application.
Specifically, there may be two cases for configuration of the capacity of the section in the file system based on the type of the target data and/or the parameter.
(1) When the memory is at the end of capacity (that is, the quantity of idle super blocks in the memory is less than or equal to the preset quantity), the capacity of the section in the file system is configured based on the parameter (the quantity of dies herein) of the memory, so that the quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is less than the quantity of dies. The size of the logical address space corresponding to each section is consistent with the size of the logical address space corresponding to the super block in the memory, so that the capacity of the super block in the memory changes synchronously with the capacity of the section. That is, in this case, the quantity of physical blocks included in each super block in the memory is less than the quantity of dies in the memory. In this manner, a quantity of redundant blocks in the memory is increased, and a quantity of times of valid data migration in a GC reclamation process is reduced, so that performance of a computer device is improved.
From the perspective of technical effects, when the quantity of idle super blocks in the memory is less than or equal to the preset quantity, a data read/write process in the memory is seriously affected. In this embodiment of this application, the capacity of the section may be dynamically configured. For example, the capacity of the section is reduced, so that the quantity of physical blocks, in the memory, corresponding to the capacity of the section is less than the quantity of dies, that is, the capacity of the super block in the memory is synchronously reduced. In this way, the quantity of redundant blocks in the memory is increased, and the overall performance is improved.
(2) When the memory is not at the end of capacity (that is, the quantity of idle super blocks in the memory is greater than the preset quantity), the capacity of the section is configured based on the type of the target data and the parameter (the quantity of dies herein) of the memory. Optionally, a configuration manner in this case may be as follows: When the type of the target data is hot data (a critical request), the capacity of the section is configured, so that the quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is equal to the quantity of dies, that is, a quantity of physical blocks included in the super block in the memory is equal to the quantity of dies in the memory. In this scenario, in this application, a performance requirement of hot data may be met by synchronously increasing the capacities of the section and the super block. When the type of the target data is warm data or cold data (a non-critical request), the capacity of the section is configured, so that the quantity of physical blocks that is in the memory and that correspond to the configured capacity of the section is less than the quantity of dies, that is, a quantity of physical blocks included in the super block in the memory is less than the quantity of dies in the memory.
From the perspective of technical effects, in this scenario with a low performance requirement, the capacity of the section and the capacity of the super block may be configured to a small value. Therefore, when the critical request (that is, a hot data read/write request) is inserted into a request queue maintained by the memory, because the critical request and the non-critical request correspond to different quantities of physical blocks in the memory, a probability that the critical request is blocked may be effectively reduced, and data read/write performance may be further improved.
The following describes a request blocking process with reference to
In the conventional technology, sizes of super blocks respectively corresponding to the critical request and the non-critical request are the same, and quantities of physical blocks in the super blocks each are equal to the quantity of dies. As a result, when the critical request is inserted for processing before the non-critical request, there is a high probability that the two requests fall on a same die.
However, in this embodiment of this application, the capacity of the section in the file system may be dynamically configured, that is, the critical request and the non-critical request correspond to super blocks of different capacities. As shown in
Table 1 is a table of the probability that the critical request is blocked under different capacity ratios of the section. The quantity of dies in the memory is 4. In this case, the super block corresponding to the configured capacity of the section in the file system includes a maximum of four physical blocks and a minimum of one physical block. In Table 1, a horizontal direction indicates a quantity of physical blocks included in the super block corresponding to a capacity of the section configured for the critical request. In Table 1, a vertical direction indicates a quantity of physical blocks included in the super block corresponding to a capacity of the section configured for the non-critical request.
As shown in Table 1, when the quantity of physical blocks included in the super block for the critical request is the same as the quantity of physical blocks included in the super block for the non-critical request, the probability that the critical request is blocked is 100%. When the quantity of physical blocks included in the super block for the critical request is larger, and the quantity of physical blocks included in the super block for the non-critical request is smaller, the probability that the critical request is blocked is lower.
In a feasible implementation, managing, based on the configured capacity of the section, the logical address space corresponding to the memory includes: determining E configured sections from the logical address space corresponding to the memory, where the E configured sections respectively correspond to E super blocks in the memory; and indieating the processor to reclaim data in the E super blocks to F idle super blocks, where E is greater than F, and E and F are positive integers.
After the capacity of the section in the file system is configured based on the type of the target data and/or the parameter of the memory, the file system may manage, based on the configured capacity of the section, the logical address space corresponding to the memory. A management process may include: dividing the logical address space corresponding to the memory by using the configured capacity of the section as a unit, and indicating the memory to perform garbage collection in units of super blocks, to release an idle super block in the memory. The capacity of the super block in the memory is the same as the configured capacity of the section.
Specifically, after the logical address space corresponding to the memory is divided based on the configured capacity of the section, the E configured sections may be determined from the logical address space corresponding to the memory, and E logical addresses respectively corresponding to the E configured sections are sent to the memory. Then, the memory is indicated to map the E logical addresses to E physical addresses respectively. The E physical addresses correspond to the E super blocks in the memory. Finally, valid data in the E super blocks is migrated to the F idle super blocks, to release the E super blocks. E is greater than F. Both E and F are positive integers.
From the perspective of technical effects, the capacity of the section in the file system is configured, and in a process in which the memory performs GC based on the capacity of the section, when the quantity of physical blocks corresponding to the configured capacity of the section in the file system is less than the quantity of dies, compared with the conventional technology in which the quantity of physical blocks corresponding to the capacity of the section is equal to the quantity of dies, when a same quantity of idle super blocks are released, in this embodiment of this application, a quantity of times of valid data migration may be reduced by reducing the capacity of the super block in the memory. Alternatively, when a same amount of valid data is migrated, in this embodiment of this application, because the capacity of the super block is small, more super blocks may be released, that is, efficiency of releasing a redundant block in the GC process is improved. In this way, the overall performance is improved.
In a garbage collection process GC_A, the super block corresponding to the configured capacity of the section includes nine storage units. The memory includes eight super blocks. Data stored in storage units 1 to 7 is valid data. When two idle super blocks need to be released, the memory needs to reclaim valid data in the storage unit 1, a storage unit 2, a storage unit 3, a storage unit 4, and a storage unit 5 to one idle super block. When the valid data stored in the storage units 1 to 7 needs to be reclaimed, four idle super blocks may be released.
In a garbage collection process GC_B, a size of the super block corresponding to the configured capacity of the section in the file system is 18 storage units. The memory includes four super blocks. Data stored in storage units 1 to 7 is valid data. When two idle super blocks need to be released, the memory needs to reclaim the valid data in the storage units 1 to 7 to one idle super block. When the valid data stored in the storage units 1 to 7 needs to be reclaimed, two idle super blocks are released.
A size of storage space of each storage unit may be limited by a specific scenario, and is not limited in this application.
In conclusion, compared with a case in which the capacity of the super block is large, in a case in which the capacity of the super block is small, less valid data needs to be migrated to release a same quantity of idle super blocks in the GC reclamation process, or more idle super blocks are released when a same amount of valid data is migrated. It is easy to understand that in this embodiment of this application, in a read/write scenario at the end of capacity or with a low performance requirement, the file system may configure a small capacity for each section, that is, each super block corresponds to a small capacity, so that the overall performance of the computer device is effectively improved.
In a feasible implementation, managing, based on the configured capacity of the section, the logical address space corresponding to the memory includes: determining K configured sections from the logical address space corresponding to the memory, where the K configured sections respectively correspond to K super blocks in the memory; and indicating the memory to write the target data into the K super blocks, where K is a positive integer.
After the capacity of the section in the file system is configured based on the type of the target data and/or the parameter of the memory, the logical address space corresponding to the memory may be managed based on the configured capacity of the section. A management process includes: dividing the logical address space corresponding to the memory by using the configured capacity of the section as a unit, and indicating the memory to perform data read/write in units of super blocks. The capacity of the super block in the memory is the same as the configured capacity of the section.
Specifically, after the logical address space corresponding to the memory is divided based on the configured capacity of the section, the K configured sections may be determined from the logical address space corresponding to the memory, and the target data and K logical addresses respectively corresponding to the K configured sections are sent to the memory. The memory is indicated to map the K logical addresses to K physical addresses respectively. The K physical addresses correspond to the K super blocks in the memory. Finally, the target data is written into the K super blocks. K is a positive integer.
From the perspective of technical effects, the capacity of the section in the file system is configured, and the memory performs a process of writing the target data based on the capacity of the section. When writing the target data is a critical request that is inserted, it may be learned from the foregoing embodiment that in this embodiment of this application, a blocking probability during writing of the target data may be reduced.
The following describes in detail, by using
The application program layer 211 may further initiate a second read/write request. Data corresponding to the second read/write request is cold data. In this case, the file system 221 receives the second read/write request, and obtains a memory parameter. The file system determines, based on the memory parameter, whether the memory is at the end of capacity. If the memory is at the end of capacity at this time, the file system 221 may configure the capacity of the section small (for example, a section N shown in
In a feasible implementation, the memory includes at least one die (die). Each of the at least one die includes at least one physical block. The super block is a management unit in the memory. The super block includes at least one physical block. Each of the at least one physical block is located on a different die.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is less than or equal to a preset quantity, a quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is less than the quantity of dies.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is greater than a preset quantity, a quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is less than or equal to the quantity of dies.
In a feasible implementation, the management unit is specifically configured to: determine E configured sections from the logical address space corresponding to the memory, where the E configured sections respectively correspond to E super blocks in the memory; and indicate a processor to reclaim data in the E super blocks to F idle super blocks, where E is greater than F, and E and F are positive integers.
In a feasible implementation, the management unit is specifically configured to: determine K configured sections from the logical address space corresponding to the memory, where the K configured sections respectively correspond to K super blocks in the memory; and indicate the memory to write the target data into the K super blocks, where K is a positive integer.
It should be understood that for a specific running process of the super block management apparatus in this embodiment of this application, refer to a corresponding process in the foregoing method embodiment. Details are not described herein again.
The processor 901 is configured to: obtain a parameter of the memory 902 and a type of target data through the interface circuit 903, where the target data is data to be written into the memory; configure a capacity of a section in a file system based on the type of the target data and/or the parameter, where the section is a logical address space management unit in the file system, and the configured capacity of the section matches a capacity of a super block in the memory; and manage, based on the configured capacity of the section, a logical address space corresponding to the memory.
The processor 901, the memory 902, and the interface circuit 903 perform data transmission through the bus 904.
In a feasible implementation, the memory includes at least one die (die). Each of the at least one die includes at least one physical block. The super block is a management unit in the memory. The super block includes at least one physical block. Each of the at least one physical block is located on a different die.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is less than or equal to a preset quantity, a quantity of physical blocks, in the memory, corresponding to the capacity of the section is less than the quantity of dies.
In a feasible implementation, the parameter includes a quantity of idle super blocks in the memory and a quantity of dies. When the quantity of idle super blocks is greater than a preset quantity, a quantity of physical blocks, in the memory, corresponding to the configured capacity of the section is less than or equal to the quantity of dies.
In a feasible implementation, in the aspect of managing, based on the configured capacity of the section, the logical address space corresponding to the memory, the processor is specifically configured to determine E configured sections from the logical address space corresponding to the memory. The E configured sections respectively correspond to E super blocks in the memory. The memory is configured to reclaim data in the E super blocks to F idle super blocks. E is greater than F. E and F are positive integers.
In a feasible implementation, in the aspect of managing, based on the configured capacity of the section, the logical address space corresponding to the memory, the processor is specifically configured to determine K configured sections from the logical address space corresponding to the memory. The K configured sections respectively correspond to K super blocks in the memory. The memory is configured to write the target data into the K super blocks. K is a positive integer.
It should be understood that for a specific running process of the processor and the memory of the computer device in this embodiment of this application, refer to a corresponding process in the foregoing method embodiment. Details are not described herein again.
This application provides a computer-readable storage medium. The computer-readable storage medium stores program instructions. When the program instructions run on one or more processors, some or all of the steps in the foregoing super block management method are implemented.
This application provides a computer program product. When the computer program product runs on a computer device, some or all of the steps in the foregoing super block management method are implemented.
In the foregoing embodiments, descriptions of each embodiment have different focuses. For a part that is not described in detail in an embodiment, refer to related descriptions of other embodiments. It should be noted that for case of description, the foregoing method embodiments are described as a series of combinations of actions. However, persons skilled in the art should be aware that this application is not limited to the described order of the actions, because some steps may be performed in another order or simultaneously according to this application. In addition, persons skilled in the art should also aware that all embodiments described in this specification are example embodiments, and the related actions and modules are not necessarily mandatory to this application.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the described apparatus embodiment is merely an example. For example, division of the units is merely logical function division, and may be other division in actual implementation. For example, a plurality of units or components may be combined or integrated into another system, or some features may be ignored or not performed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections may be indirect couplings or communication connections through some interfaces, apparatuses or units, and may be implemented in electrical or other forms.
The foregoing units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located at one location, or may be distributed on a plurality of network units. Some or all of the units may be selected based on actual requirements to achieve the objective of the solution of this embodiment.
In conclusion, the foregoing embodiments are merely intended to describe the technical solutions of this application, but not to limit this application. Although this application is described in detail with reference to the foregoing embodiments, persons of ordinary skill in the art should understand that they may still make modifications to the technical solutions described in the foregoing embodiments or make equivalent replacements to some technical features thereof, without departing from the spirit and scope of the technical solutions in embodiments of this application.
Number | Date | Country | Kind |
---|---|---|---|
202110971602.1 | Aug 2021 | CN | national |
This application is a continuation of International Application No. PCT/CN2022/113493, filed on Aug. 19, 2022, which claims priority to Chinese Patent Application No. 202110971602.1, filed on Aug. 23, 2021. The disclosures of the aforementioned applications are hereby incorporated by reference in their entireties.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2022/113493 | Aug 2022 | WO |
Child | 18584329 | US |