Method for managing storage resources, electronic device, and computer readable storage medium
By providing the capability information of storage resources and configuring physical storage blocks, the problem of low storage resource management efficiency in terminal devices is solved, fast response and efficient access are achieved, and user experience is improved.
Patent Information
- Application Number
- PCT/CN2024/073613
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-08
- Filing Date
- 2024-01-23
- Publication Date
- 2024-11-14
AI Technical Summary
The prior art is difficult to quickly and flexibly manage storage resources in terminal devices, resulting in increased response delays, reduced access efficiency, and affecting user experience.
By providing the capability information of storage resources, the requesting application allows the requesting application to generate storage resource requests, and determine the matching storage segments from storage resources of different characteristics, and configure physical storage blocks to facilitate the file system to quickly match storage resources and reduce response time Delay and improve access efficiency.
It realizes flexible storage resource matching for different applications in different scenarios, significantly reducing response delay, improving access efficiency, and improving user operation experience.
Smart Images

Figure CN2024073613_14112024_PF_FP_ABST
Abstract
Description
Method for managing storage resources, electronic device, and computer-readable storage medium Technical Field
[0001] The present disclosure relates to the field of computers, and more particularly, to a method, apparatus, electronic device, and computer-readable storage medium for managing storage resources. Background Art
[0002] In a terminal device, data is stored on the terminal device's storage device. The stored data can usually be managed through the terminal device's file system. After the terminal device's file system receives an access request from the requesting application, it converts the access request into a read / write operation for the data stored in the storage device. This operation is then sent to the storage device through the block device layer and device driver, thereby enabling access to the data. Currently, the storage device used in terminal devices is typically flash memory, such as NAND flash memory. Storage devices using flash memory as a medium are widely used in various electronic devices or systems, such as mobile terminals, desktop computers, servers, and data centers, due to their advantages in speed, latency, power consumption, and other aspects.
[0003] Summary of the Invention
[0004] Embodiments of the present application provide a method for managing storage resources, an electronic device, and a computer-readable storage medium for managing storage resources to facilitate rapid and flexible matching of storage resources for requesting applications that initiate requests, thereby significantly reducing response latency and improving access efficiency.
[0005] In a first aspect of the present disclosure, a method for managing storage resources is provided, the method comprising: providing capability information related to the storage resource; receiving a storage resource request for the storage resource, the storage resource request being generated by a requesting application according to demand and based on the capability information; determining, according to the storage resource request, at least one storage segment that satisfies the storage resource request from storage resources of different characteristics; and determining, according to the determined at least one storage segment, a physical storage block in a storage device for the storage resource request.
[0006] Thus, in the embodiments of the present disclosure, by providing capability information to the requesting application that initiates the request and receiving a storage resource request generated by the requesting application based on the capability information according to its own needs, the file system can more conveniently, quickly and flexibly match storage resources for the requesting application, thereby not only meeting the different requirements of different applications in different scenarios, but also significantly reducing response latency and improving access efficiency, thereby significantly improving the user's operating experience.
[0007] In some embodiments of the first aspect, the capability information may include capability parameters, and the capability parameters may include at least one of the following items: storage capacity, response latency level, data retention time level, or data writing method.
[0008] In some embodiments of the first aspect, the requirement may include one or more of the following items: the size of the stored data from the requesting application, the hotness or coldness of the stored data, or the response speed.
[0009] In some embodiments of the first aspect, providing the capability information related to the storage resource may include: providing the capability information related to the storage resource via a middleware interface. Accordingly, in some embodiments, the storage request may be generated by calling the middleware interface.
[0010] In some embodiments of the first aspect, the method may further include: recording a segment parameter of each storage segment in the storage resource, wherein the segment parameter corresponds to a capability parameter in the capability information.
[0011] In some embodiments of the first aspect, determining at least one storage segment that satisfies a storage request from storage resources of different characteristics includes: determining request parameters in the storage request, wherein the request parameters correspond to capability parameters in the capability information; and selecting one or more storage segments whose segment parameters match the request parameters from the storage resources as the determined at least one storage segment.
[0012] In this way, by matching the segment parameters with the request parameters, it is possible to conveniently select the appropriate storage segment from the storage resources for the storage resource request, which can further reduce the response delay and improve the access efficiency, thereby significantly improving the user's operating experience.
[0013] In some embodiments of the first aspect, the method may further include obtaining physical parameters of the storage device; and configuring the physical parameters of each storage segment in the storage resource based on the physical parameters of the storage device, wherein the physical parameters of the storage segment include at least one of the storage capacity size or the writing mode of the corresponding storage segment, the storage capacity size is equal to or an integer multiple of the storage capacity size of the physical block of the storage device, and the writing mode includes at least one of sequential writing and random writing.
[0014] In this way, by obtaining the physical parameters of the storage device, the file system can configure the physical parameters of the storage segments in the file system according to the physical parameters of the storage device, so that it can adapt to various types of storage devices. In addition, it can also ensure the alignment of the storage segments in the file system with the physical storage blocks in the storage device, which is conducive to the smoothness and stability of the file system in the process of managing the physical storage blocks in the storage device.
[0015] In some embodiments of the first aspect, the method may further include: sending a configuration request to one or more physically erased storage blocks, the configuration request including configuration information for configuring at least one of a write mode or a storage medium type of the one or more physically erased storage blocks; receiving response information to the configuration request from the storage device; and confirming that the one or more physically erased storage blocks are correctly configured according to the configuration request.
[0016] In some embodiments of the first aspect, the storage medium type may include at least one of single-bit cell (SLC), multi-bit cell (MLC), triple-level cell (TLC), or quad-level cell (QLC).
[0017] In some embodiments of the first aspect, the method may further include: mapping one or more physically erased storage blocks to corresponding storage segments, wherein the total storage capacity of the one or more physically erased storage blocks is equal to the storage capacity of the corresponding storage segment; and based on the mapping, updating the segment parameters of the corresponding storage segment with the physical parameters of the corresponding storage segment, the segment parameters including the storage capacity, writing mode and storage medium type of the corresponding storage segment, wherein the writing mode and storage medium type of the corresponding storage segment are respectively consistent with the writing mode and storage medium type of the one or more physically erased storage blocks mapped to the storage segment.
[0018] In some embodiments of the first aspect, mapping the corresponding storage segment with one or more physically erased storage blocks in the storage device includes: mapping an identifier of the corresponding storage segment with an identifier of the one or more physically erased storage blocks; for the corresponding storage segment and the one or more physically erased storage blocks mapped in pairs, mapping an identifier of a storage unit determined based on storage granularity in the corresponding storage segment with an identifier of a storage unit determined based on storage granularity in the one or more physically erased storage blocks; and for the corresponding storage segment and the one or more physically erased storage blocks mapped in pairs, synchronizing a write position (write pointer) in the storage segment with a write position in the one or more physically erased storage blocks.
[0019] In some embodiments of the first aspect, the method may further include: performing a garbage collection operation in a storage area composed of one or more storage segments whose writing mode is sequential writing; and based on the garbage collection operation, simultaneously completing a garbage collection operation in a corresponding storage area in a storage device, wherein the corresponding storage area in the storage device is composed of corresponding physically erased storage blocks aligned with one or more sequentially written storage segments, and wherein the writing mode of the corresponding physically erased storage blocks is sequential writing.
[0020] By aligning the sequential write storage area of the file system with the sequential write storage area of the storage device, garbage collection operations in the file system and those in the storage device can be merged. Consequently, by having the file system perform garbage collection operations in both the file system and the storage device, the duplicate data movement that occurs when both the file system and the storage device perform garbage collection simultaneously can be avoided, significantly reducing response latency and increasing the storage device's write capacity.
[0021] In some embodiments of the first aspect, the physical parameters of the storage device include at least one or more of the storage capacity size, physical page size, physical page identifier, plane size, plane identifier, super block size or super block identifier of the physical storage block of the storage device.
[0022] In some embodiments of the first aspect, the method may further include: updating a state of the storage resource during a write operation using the determined at least one storage segment, where the state includes an idle state, an open state, or a closed state.
[0023] In some embodiments of the first aspect, updating the status of a storage resource may include: updating the status of a storage segment that is ready for a write operation to an open state; updating the status of a storage segment that is full of data to a closed state; and updating the status of a storage segment that has all its data moved and can be used again for data storage to an idle state.
[0024] In some embodiments of the first aspect, the method may further include: determining, for a storage segment in an idle state, that a write mode of the storage segment is to be changed; sending a notification to a storage device indicating that a write mode of one or more physically erased storage blocks mapped to the storage segment is to be changed; and changing the write mode of the storage segment in response to receiving response information indicating that the change is successful from the storage device.
[0025] In some embodiments of the first aspect, in response to the notification, the storage device adds the one or more physically erased storage blocks to a free storage block resource pool of the storage device.
[0026] In some embodiments of the first aspect, the method may further include: receiving a request for one or more newly added physically erased storage blocks from the storage device, wherein the one or more newly added physically erased storage blocks are selected by the storage device from a free storage block resource pool in the storage device.
[0027] In this way, by switching the writing mode of the storage segment with idle state between random writing and sequential writing, the boundary between the random writing storage area and the sequential writing storage area of the file system can be made flexible and elastic, which makes it convenient to flexibly configure storage resources according to user needs.
[0028] In a second aspect of the present disclosure, a device for managing storage resources is provided, which may include: a capability information providing module, configured to provide capability information related to storage resources; a request receiving module, configured to receive a storage resource request for a storage resource, which storage resource request is generated by a requesting application according to demand and based on the capability information; a storage segment determination module, configured to determine, according to the storage resource request, at least one storage segment that meets the storage resource request from storage resources with different characteristics; and a storage block determination module, configured to determine, according to the determined at least one storage segment, a physical storage block in a storage device for the storage resource request.
[0029] Thus, in the embodiments of the present disclosure, by providing capability information to the requesting application that initiates the access request and receiving the storage resource request generated by the requesting application based on the capability information according to its own needs, the file system can more conveniently, quickly and flexibly match storage resources for the requesting application, thereby not only meeting the different requirements of different applications in different scenarios, but also significantly reducing response latency and improving access efficiency, thereby significantly improving the user's operating experience.
[0030] In some embodiments of the second aspect, the capability information may include capability parameters, and the capability parameters may include at least one of the following items: storage capacity size, response delay level, data retention time level, or data writing method.
[0031] In some embodiments of the second aspect, the requirements may include one or more of the following items: the size of the stored data from the requesting application, the hotness or coldness of the stored data, or the response speed.
[0032] In some embodiments of the second aspect, the capability information providing module may be configured to provide capability information related to the storage resource through a middleware interface. Accordingly, in some embodiments, the storage request may be generated by calling the middleware interface.
[0033] In some embodiments of the second aspect, the apparatus may further include: a recording module configured to record segment parameters of each storage segment in the storage resource, wherein the segment parameters correspond to capability parameters in the capability information.
[0034] In some embodiments of the second aspect, the storage segment determination module may include a determination submodule and a selection submodule, the determination submodule may be configured to determine a request parameter in a storage request, wherein the request parameter corresponds to a capability parameter in the capability information, and the selection submodule may be configured to select one or more storage segments whose segment parameters match the request parameter from the storage resource as the determined at least one storage segment.
[0035] In this way, by matching the segment parameters with the request parameters, it is possible to conveniently select the appropriate storage segment from the storage resources for the storage resource request, which can further reduce the response delay and improve the access efficiency, thereby significantly improving the user's operating experience.
[0036] In some embodiments of the second aspect, the apparatus may further include: an acquisition module configured to acquire physical parameters of a storage device; and a configuration module configured to configure the physical parameters of each storage segment in the storage resource based on the physical parameters of the storage device, wherein the physical parameters of the storage segment include at least one of the storage capacity size or the writing mode of the corresponding storage segment, wherein the storage capacity size is equal to or an integer multiple of the storage capacity size of the physical block of the storage device, and the writing mode includes at least one of sequential writing and random writing.
[0037] In this way, by obtaining the physical parameters of the storage device, the file system can configure the physical parameters of the storage segments in the file system according to the physical parameters of the storage device, so that it can adapt to various types of storage devices. In addition, it can also ensure the alignment of the storage segments in the file system with the physical storage blocks in the storage device, which is conducive to the smoothness and stability of the file system in the process of managing the physical storage blocks in the storage device.
[0038] In some embodiments of the second aspect, the apparatus may further include: a sending module configured to send a configuration request to one or more physically erased storage blocks, the configuration request including configuration information for configuring at least one of a writing mode or a storage medium type of the one or more physically erased storage blocks; a receiving module configured to receive response information corresponding to the configuration request from the storage device; and a confirmation module configured to confirm that the one or more physically erased storage blocks are correctly configured according to the configuration request, wherein the physical storage blocks include one or more physically erased storage blocks.
[0039] In some embodiments of the second aspect, the configuration request may include configuration information for configuring one or both of a writing method or a storage medium type for one or more physically erased storage blocks.
[0040] In some embodiments of the second aspect, the storage medium type may include at least one of single-bit cell (SLC), multi-bit cell (MLC), triple-level cell (TLC), or quad-level cell (QLC).
[0041] In some embodiments of the second aspect, the device may further include: a mapping module configured to map one or more physically erased storage blocks to corresponding storage segments, wherein the total storage capacity of the one or more physically erased storage blocks is equal to the storage capacity of the corresponding storage segment; and an update module configured to update the segment parameters of the corresponding storage segment with the physical parameters of the corresponding storage segment based on the mapping, the segment parameters including the storage capacity, writing mode and storage medium type of the corresponding storage segment, wherein the writing mode and storage medium type of the corresponding storage segment are respectively consistent with the writing mode and storage medium type of one or more physically erased storage blocks mapped to the storage segment.
[0042] In some embodiments of the second aspect, the mapping module includes a first mapping submodule, a second mapping submodule and a synchronization submodule, wherein the first mapping submodule can be configured to map the identifier of the corresponding storage segment with the identifier of one or more physically erased storage blocks; the second mapping submodule can be configured to map, for the corresponding storage segment and the one or more physically erased storage blocks mapped in pairs, the identifier of the storage unit determined based on the storage granularity in the corresponding storage segment with the identifier of the storage unit determined based on the storage granularity in the one or more physically erased storage blocks; and the synchronization submodule can be configured to synchronize, for the corresponding storage segment and the one or more physically erased storage blocks mapped in pairs, the write position in the storage segment with the write position in the one or more physically erased storage blocks.
[0043] In some embodiments of the second aspect, the apparatus may further include: a garbage collection operation module configured to perform a garbage collection operation in a storage area composed of one or more storage segments whose writing mode is sequential writing, and based on the garbage collection operation, simultaneously complete a garbage collection operation in a corresponding storage area in the storage device, wherein the corresponding storage area in the storage device is composed of corresponding physically erased storage blocks aligned with one or more sequentially written storage segments, and wherein the writing mode of the corresponding physically erased storage blocks is sequential writing.
[0044] By aligning the sequential write storage area of the file system with the sequential write storage area of the storage device, garbage collection operations in the file system and those in the storage device can be merged. Consequently, by having the file system perform garbage collection operations in both the file system and the storage device, the duplicate data movement that occurs when both the file system and the storage device perform garbage collection simultaneously can be avoided, significantly reducing response latency and increasing the storage device's write capacity.
[0045] In some embodiments of the second aspect, the physical parameters of the storage device include at least one or more of the capacity size of the physical storage block of the storage device, the physical page size, the physical page identifier, the plane size, the plane identifier, the super block size or the super block identifier.
[0046] In some embodiments of the second aspect, the apparatus may further include: an update module configured to update a state of a storage resource during a write operation using the determined at least one storage segment, where the state includes an idle state, an open state, or a closed state.
[0047] In some embodiments of the second aspect, the update module can be configured to: update the status of a storage segment that is ready for a write operation to an open state; update the status of a storage segment that is full of data to a closed state; and update the status of a storage segment that has all its data moved and can be used again for data storage to an idle state.
[0048] In some embodiments of the second aspect, the apparatus may further include: a determination module configured to determine, for a storage segment in an idle state, that a usage mode of the storage segment is to be changed; a sending module configured to send a notification to a storage device indicating that a write mode of one or more physically erased storage blocks mapped to the storage segment is to be changed; and a change module configured to change the write mode of the storage segment in response to receiving response information from the storage device indicating that the change is successful.
[0049] In some embodiments of the second aspect, in response to the notification, the storage device may add the one or more physically erased storage blocks to a free storage block resource pool of the storage device.
[0050] In some embodiments of the second aspect, the apparatus may further include: a receiving module configured to receive a request for the newly added one or more physically erased storage blocks from a storage device, wherein the newly added one or more physically erased storage blocks are selected by the storage device from a free storage block resource pool in the storage device.
[0051] In this way, by switching the writing mode of the storage segment in the idle state between random writing and sequential writing, the boundary change between the random write storage area and the sequential write storage area of the file system can be flexibly changed, which can facilitate the flexible configuration of storage resources according to user needs.
[0052] In a third aspect of the present disclosure, an electronic device is provided, including an interface and a processor coupled to the interface, wherein the processor is configured to execute operations according to the method according to the first aspect or any embodiment thereof.
[0053] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the operations of the method according to the first aspect or any embodiment thereof are implemented.
[0054] In a fifth aspect of the present disclosure, a chip or a chip system is provided, which includes a processing circuit configured to perform the operations according to the method of the first aspect or any embodiment thereof.
[0055] In a sixth aspect of the present disclosure, a computer program or computer program product is provided. The computer program or computer program product is tangibly stored on a computer-readable storage medium and includes computer-executable instructions that, when executed, cause a device to perform the operations according to the method of the first aspect or any embodiment thereof.
[0056] By implementing one or more of the above aspects of the present application, by providing capability information to the requesting application that initiates the access request, and the requesting application generates a storage resource request based on the capability information according to its own needs, it is possible to match storage resources for the requesting application more conveniently, quickly and flexibly, thereby not only meeting the different requirements of different applications in different scenarios, but also significantly reducing response latency and improving access efficiency, thereby significantly improving the user's operating experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:
[0058] FIG1 schematically shows a diagram of an electronic device to which an embodiment of the present disclosure may be applied;
[0059] FIG2 schematically illustrates an exemplary flow chart for managing storage resources according to some embodiments of the present disclosure;
[0060] 3 schematically illustrates an example process of setting physical parameters of a storage segment and configuring a storage device through interaction between a file system and a storage device according to an embodiment of the present disclosure;
[0061] 4A and 4B schematically illustrate a schematic diagram of a physically erased storage block configured in a storage device after alignment with a storage segment in a file system according to an embodiment of the present disclosure;
[0062] FIG5 schematically shows a flowchart of a method for mapping physically erased storage blocks in a storage device to storage sections of a file system according to an embodiment of the present disclosure;
[0063] FIG6 schematically shows a schematic diagram of mapping storage cells in a storage segment and storage cells in a physically erased storage block according to an embodiment of the present disclosure;
[0064] 7A and 7B schematically illustrate a schematic diagram of performing a garbage collection operation in a sequential write area according to an embodiment of the present disclosure;
[0065] FIG8 schematically shows a schematic diagram of transitions between various states according to an embodiment of the present disclosure;
[0066] 9A and 9B schematically illustrate an operational process of a storage device in response to changing a write mode of physically erasing a storage block from sequential write to random write;
[0067] 10A and 10B schematically illustrate an operational process of a storage device in response to changing a write mode of physically erasing a storage block from random write to sequential write;
[0068] FIG11 schematically shows a schematic block diagram of an apparatus 1100 for managing storage resources according to an embodiment of the present disclosure; and
[0069] FIG12 shows a schematic block diagram of an example device for implementing embodiments of the present disclosure according to some embodiments of the present disclosure. DETAILED DESCRIPTION
[0070] The embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is merely a description of the association relationship of associated objects, indicating that three relationships can exist, for example, A and / or B can mean: the existence of A alone, the existence of A and B at the same time, and the existence of B alone.
[0071] The terms used in the following embodiments of this application are for the purpose of describing specific embodiments only and are not intended to limit the present application. As used in the specification and appended claims of this application, the singular expressions "a," "an," "the," "the," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the listed items. In the description of the embodiments of this application, the terms "including" and "based on" and similar terms should be understood as open-ended inclusion, i.e., "including but not limited to." The term "based on" should be understood as "based, at least in part, on." The terms "one embodiment" or "the embodiment" should be understood as "at least one embodiment." It should be understood that expressions such as "first," "second," and "third" are intended to indicate that multiple items may be different, but do not exclude the possibility that two items are the same. Expressions such as "first," "second," and "third" should not be construed as limiting the embodiments. The terms "first" and "second" are used for descriptive purposes only and should not be understood to imply or suggest relative importance or implicitly indicate the number of technical features indicated. Therefore, features defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more. Other explicit and implicit definitions may also be included below.
[0072] Mention of "embodiment" in this application means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is understood explicitly and implicitly by those skilled in the art that the embodiments described in this application can be combined with other embodiments. The term "garbage collection operation" in the embodiments of the present disclosure refers to when the file system copies valid data stored in a storage segment to other storage segments and then erases the storage segment to complete the garbage collection process.
[0073] Currently, data in terminal devices is stored on their storage devices. This stored data can be managed through the terminal device's file system. The logical address space in the file system is mapped to the physical address space in the storage device. The storage device can write user logical data to the physical address space and record the mapping between the logical address and the physical address. When a requesting application needs to read the data, the storage device, based on this mapping, reads the data from the corresponding physical address and returns it to the requester.
[0074] When a requesting application requests storage resources, it typically includes the starting address of the requested storage resource and the length of the data in the request. Upon receiving this request, the file system can allocate storage resources to the requesting application. While existing technologies can differentiate between different levels of storage space based on the hotness or coldness of stored data—for example, hot data can be migrated to high-performance media, while cold data can be migrated to low-performance media—this hierarchical management of storage resources requires the storage device administrator to specify the performance level of the corresponding storage space. This designation relies on the administrator's expertise, which raises the barrier to entry for using storage devices. Furthermore, to provide appropriate storage resources to the requesting application, the file system often needs to analyze the application's characteristics (such as required response time, need for continuous data, performance requirements, and data hotness / coldness) before providing appropriate storage resources. However, file systems struggle to accurately perform this analysis, and it takes a considerable amount of time. This significantly reduces access efficiency, increases response latency, and impacts the user experience.
[0075] In order to at least avoid or reduce the occurrence of the above-mentioned problems, improve access efficiency and reduce response delay, the present disclosure proposes a method for managing storage resources. The method may include: providing capability information related to storage resources; receiving a storage resource request for storage resources, the storage resource request being generated by a requesting application according to demand and based on capability information; determining, according to the storage resource request, at least one storage segment that satisfies the storage resource request from storage resources with different characteristics; and determining, according to the determined at least one storage segment, a physical storage block in the storage device for the storage resource request. In this way, by providing capability information to the requesting application that initiates the access request, it is possible to facilitate the requesting application to generate a storage resource request based on the capability information according to its own needs. Based on the storage resource request, the file system can quickly and flexibly match storage resources for the requesting application, thereby not only meeting the different requirements of different applications in different scenarios, but also significantly reducing response delay and improving access efficiency, thereby significantly improving the user's operating experience.
[0076] FIG1 shows a schematic diagram of an electronic device 100 to which an embodiment of the present disclosure can be applied. An illustrative electronic device 100 may be an electronic device 100 including a storage device. The electronic device 100 may have an operating system. In one embodiment, taking the operating system of the electronic device 100 as an example of a Linux system, as shown in FIG1 , the electronic device 100 can be logically divided into an application layer 110, a kernel layer 120, and a hardware layer 130. The application layer 110 may include one or more application programs (e.g., application 112 and application 114). The kernel layer 120 may be a software middleware between the application layer 110 and the hardware layer 130, and may include a computer program for managing and controlling hardware and software resources. The hardware layer 130 may include hardware such as a processor 132 and a storage device 134. It will be understood that the hardware layer 130 may also include other hardware, and for the sake of clarity, not all hardware is shown in FIG1 .
[0077] The kernel typically contains modules closely related to the hardware (e.g., interrupt handlers, device drivers, etc.), basic, common, and frequently processed modules (e.g., clock management, process scheduling, etc.), and critical data. The kernel is essentially a piece of program code. The program code corresponding to the kernel can be called by the processor 132 to implement the kernel's functions. The kernel can be the core of the operating system 120, providing underlying system components and services, including but not limited to power management, storage management, thread management, and hardware drivers.
[0078] In one embodiment, the kernel layer 120 may include a file system 122, a block device layer 124, a storage device protocol stack layer 126, and a storage device driver layer 128. The file system 122 may manage data generated by various applications in the application layer 110 and stored in the storage device 134 in the form of files. The block device layer 124 may perform operations such as merging and sorting requests from applications. The storage device protocol stack layer 126 may include one or more storage protocols, such as the Small Computer System Interface (SCSI) and the Non-Volatile Memory Host Controller Interface Specification (NVME), which are used to define standards and rules for data transmission between applications and storage devices. The storage device driver layer 128 may be an interface used by applications and file systems to access a variety of different storage devices.
[0079] When the file system 122 receives an access request sent by an application (e.g., application 112) in the application layer 110, the file system 122 may generate an access request and send the access request to the block device layer 124. The block device layer 124 may perform scheduling management on the received access requests, such as merging and sorting, and call the corresponding driver function in the driver layer 128 according to the storage protocol defined in the storage device protocol stack layer 126, thereby sending the access request to the storage device 134. Thus, the application's access operation to the storage device 134 is implemented through the file system 122, the block device layer 124, and the storage device driver layer 128. In the embodiment of the present application, the file system 122 may be a flash-friendly file system (F2FS), or may be other types of file systems, which are not limited by the present disclosure.
[0080] The electronic device 100 exemplarily illustrated in FIG1 may include, but is not limited to, a mobile phone, a laptop computer, a tablet computer (portable Android device, PAD), a desktop computer, a laptop computer, a handheld computer, an electronic whiteboard, an augmented reality (AR) device, a virtual reality (VR) device, a personal computer (PC), a mobile terminal device, etc., and may also include other smart wearable devices (such as smart bracelets, smart watches, etc.), various types of smart home devices (such as electronic photo frames, smart TVs, smart speakers, etc.), artificial intelligence (AI) devices, in-vehicle electronic devices, game consoles, servers, cloud hosts / cloud servers, and other electronic devices with computing functions. The present disclosure does not impose any restrictions on the types of electronic devices.
[0081] In addition, FIG1 describes the logical layering of the electronic device 100 in conjunction with the Linux operating system, and the file system 122 and its related logical layers are all located in the kernel layer 120. It is understandable that the file system is not limited to the file system of the Linux operating system. The file system according to the embodiment of the present disclosure can also be a file system in various known operating systems and operating systems developed in the future. Moreover, the file system can be divided into various suitable logical layers based on other hierarchical division methods of the electronic device. The present disclosure does not limit the hierarchical division method of the operating system and the electronic device related to the file system.
[0082] FIG2 shows an exemplary flow chart of a method 200 for managing storage resources according to an embodiment of the present disclosure. The method 200 for managing storage resources can be executed at the kernel layer 120 in the electronic device 100 as shown in FIG1 . Specifically, it can be executed by the file system 122 in the electronic device 100. For example, when the file system 122 is implemented by software, the operation of the file system 122 can be implemented by the execution of the software by the processor 132. Although the various steps shown in FIG2 perform the corresponding functions of the method for managing storage resources in a specific order, it is understood that the order of execution of the various steps in FIG2 can be changed relative to the order shown. For example, two or more steps shown in succession can be executed simultaneously or some steps can be executed simultaneously. In addition, specific steps in the method 200 can be omitted. In addition, other steps can be added to the flow chart of FIG2 . It is understood that all these changes are within the scope of the present disclosure.
[0083] As shown in FIG2 , in block 202, the file system 122 may provide capability information related to a storage resource. A storage resource may include a combination of storage segments with different characteristics. The characteristics of a storage segment may be implemented by configuring the storage segment and the physical storage block, and may be characterized by one or more parameters (referred to herein as “segment parameters”). In some embodiments, the capability information related to the storage resource includes capability parameters, and the capability parameters may include one or more of the storage capacity of the storage resource, the response latency level, the data retention time level, or the data writing method.
[0084] Specifically, the storage capacity size can reflect the storage capacity of the storage resource, which corresponds to the storage capacity of the storage device used. For example, depending on the storage device used, the storage capacity size can be (but is not limited to) 256G, 512G, 1TB, etc. The response latency level can represent the file system's response latency to storage resource requests. The file system can provide this capability information to applications by setting the response latency level. For example, response latency levels can include but are not limited to response latency in the tens of microseconds, response latency in the hundreds of microseconds, response latency in the milliseconds, and response latency in the tens of milliseconds. Data retention time indicates the length of time that data can be stored in the storage device. Similarly, the file system can provide this capability information to applications by setting the data retention time level. For example, data retention time levels can include but are not limited to data retention time in units of hours, days, months, years, etc. In addition, the data writing mode indicates the mode of writing data, which may include sequential writing and random writing. Accordingly, the file system may provide the application with capability information that the data writing mode includes sequential writing and random writing.
[0085] Continuing with reference to FIG2 , in block 204, the file system 122 may receive a storage resource request for a storage resource, which may be generated by a requesting application (e.g., application 112) based on its own needs and based on the capability information provided by the file system. In some embodiments, the requesting application's own needs may include one or more of the size of the storage data from the requesting application, the hotness or coldness of the storage data, or the speed of response required by the requesting application. Accordingly, the requesting application may generate a storage resource request based on its own needs and based on the capability information provided by the file system 122. The storage resource request may reflect the needs of the requesting application. In some embodiments, the storage resource request may include request parameters, and the request parameters may include one or more of whether the current storage capacity size meets the data length requirements, the required response latency level, the data retention time level, the data writing method, and the like.
[0086] For example, assume that the capability information provided by the file system includes: storage capacity of 1TB; response latency levels of tens of microseconds, hundreds of microseconds, milliseconds, and tens of milliseconds; data retention levels of hours, days, months, and years; and data write methods of sequential and random writes. Furthermore, assume that application 112, initiating a storage resource request, requests storage resources for image storage. This application has low requirements for response latency during image storage, and the image data is cold data (e.g., it is not frequently accessed but needs to be stored on a storage device for a long time). This image data needs to be stored continuously. Application 112 can generate a storage resource request based on its own requirements and the capability information provided by the file system. This storage resource request can reflect the requirements of application 112. For example, the format of a storage resource request might be: {Current storage capacity meets the required data length; Response latency in the hundreds of microseconds; Data retention in years; Sequential write mode}. Each item in the above storage resource request corresponds to its own request parameters. Based on the capability information provided by the file system, the requesting application can generate a storage resource request that meets its needs.
[0087] In some embodiments, the file system 122 can provide capability information related to storage resources through a middleware interface. Accordingly, a requesting application issuing a storage resource request can generate a storage resource request based on its own needs by invoking the middleware interface. It is understood that the file system can also use other methods to provide capability information, which is not limited in this disclosure.
[0088] Returning to Figure 2, in box 206, the file system can 122 determine at least one storage segment that meets the storage resource request from storage resources with different characteristics based on the storage resource request. As described above, the storage resource may include a combination of multiple storage segments. The characteristics of the storage segment can be achieved by configuring the storage segment and the physically erased storage block in the storage device 134, and can be characterized by one or more parameters (referred to as "segment parameters" in this article). The combination of storage segments with different characteristics constitutes storage resources with different characteristics. The file system provides capability information related to the storage resource based on the different characteristics of the storage segment. In other words, the capability information related to the storage resource provided by the file system actually reflects the different characteristics of the storage resource.
[0089] In some embodiments, the file system 122 can record the segment parameters of each storage segment in storage resources with different characteristics. In some embodiments, the segment parameters of the storage segment can be updated based on the physical parameters of the storage segment, and the physical parameters of the storage segment can be set based on the physical parameters of the storage device. The detailed process of setting the physical parameters of the storage segment through the interaction between the file system 122 and the storage device 134 will be described in detail below in conjunction with the accompanying drawings. In some embodiments, the segment parameters of the storage segment may include, but are not limited to, the storage capacity size of the storage segment, the write method, or the corresponding storage medium type. The write method includes at least one of sequential write and random write, and the storage medium type includes at least one of single-bit cell (SLC), multi-bit cell (MLC), triple-level cell (TLC), or quad-level cell (QLC). The storage medium type indicates the storage medium type of the physical storage block mapped to the storage segment. The storage medium type can represent the number of bits stored in a storage cell of the same area. SLC means that 1 bit of data is stored in a storage cell, MLC means that 2 bits of data are stored in a storage cell, TLC means that 3 bits of data are stored in a storage cell, and QLC means that 4 bits of data are stored in a storage cell. The smaller the number of bits stored in a storage cell of the same area, the shorter the read time of the storage cell and the faster the response. For example, the read time for SLC can be 25 microseconds, the read time for MLC can be 50 microseconds, the read time for TLC can be 75 microseconds, and the read time for QLC can be even longer. For example, the segment parameters of storage segment Q can be {a1MB; sequential write; SLC}. This segment parameter can indicate that the storage capacity of storage segment Q is a1MB, the write method is sequential write, and the storage medium type of the physical storage block mapped to storage segment Q is SLC.
[0090] The file system 122 can determine the characteristics of each storage segment by recording the segment parameters of each storage segment. The file system can receive a storage resource request and determine the request parameters in the received storage request. As described above, the request parameters correspond to the capability parameters in the capability information and can include one or more of whether the current storage capacity meets the data length requirements, the required response latency level, the required data retention time level, the required data writing method, etc. The file system can select one or more storage segments whose segment parameters match the request parameters from the storage resources as the determined at least one storage segment for the storage resource request, such as a pre-allocated storage resource or a storage resource for a write operation. In one embodiment, the file system 122 can select a storage segment whose segment parameters meet the requirements of the request parameters for the storage resource request based on the request parameters in the request. For example, still taking the storage resource request above as an example, the exemplary storage resource request is {the current storage capacity size meets the data length requirements; the response delay is in the order of hundreds of microseconds; the data retention time is in units of "years"; the data writing method is sequential writing}, then the file system can select a storage segment with segment parameters of {a1MB; sequential writing; MLC}.
[0091] It can be understood that the various parameter elements in the segment parameters and request parameters in the above description are merely exemplary. Those skilled in the art may make various settings for the various parameter elements in the segment parameters and request parameters based on the actual hardware conditions and actual needs, etc., and this disclosure does not limit this.
[0092] Returning to FIG. 2 , after determining one or more storage segments from the storage resource that can be used for the storage request, the file system 122 can determine, in step 208 , the physical storage blocks in the storage device 134 that are used for the storage resource request based on the determined one or more storage segments. It will be appreciated that since the storage segments in the file system 122 and the physical storage blocks in the storage device 134 have a mapping relationship, the file system can, based on this mapping relationship, determine the physical storage blocks from the storage device 134 for storage resource pre-allocation or write operations, etc., after determining the one or more storage segments for the storage request. For example, let's take the example of storage segment A in the file system 122 being determined for storage resources. Based on the mapping relationship between the storage segments and the physical storage blocks in the storage device 134, storage segment A is mapped to physical storage block a in the storage device 134. Accordingly, the file system 122 can determine that physical storage block a in the storage device 134 is used for the requested storage resource. For example, data can be written to physical storage block a. By executing the method for managing storage resources according to an embodiment of the present disclosure, and by providing capability information to the requesting application, the file system can quickly and flexibly match storage resources for the requesting application based on the storage resource request generated by the requesting application according to the capability information. This not only meets the different requirements of different applications in different scenarios, but also significantly reduces response latency and improves access efficiency, thereby significantly improving the user's operating experience.
[0093] Below, an example process 300 for setting physical parameters of a storage segment and configuring the storage device through interaction between a file system and a storage device according to an embodiment of the present disclosure will be described in conjunction with FIG3 . FIG3 illustrates an example process for setting physical parameters of a storage segment and configuring the storage device through interaction between a file system 122 and a storage device 134 according to an embodiment of the present disclosure. The process in FIG3 can be performed by the file system 122 and the storage device 134 in FIG1 . For example, when the file system 122 is implemented via software, the operations of the file system 122 can be implemented by the processor 132 executing the software. As shown in FIG3 , the file system 122 can send a physical parameter acquisition request to the storage device 134 at 302 to obtain the physical parameters of the storage device 134. The physical parameters of the storage device 134 may include, but are not limited to, one or more of the storage capacity size, physical page size, physical page identifier, plane size, plane identifier, superblock size, or superblock identifier of the physical blocks of the storage device 134. The physical parameters of the storage device 134 may also include other parameters related to the storage device, which are not limited by the present disclosure.
[0094] After receiving the physical parameter acquisition request from the file system 122, the storage device 134 sends a request response to the file system at 304, indicating that the storage device 134 has received the physical parameter acquisition request. At 306, the storage device 134 may send the physical parameters of the storage device 134 to the file system 122. At 308, the file system 122 may configure the physical parameters of each storage segment in the storage resource based on the received physical parameters. The physical parameters of the storage segment may include, but are not limited to, the storage capacity of the storage segment or the write mode. The write mode includes at least one of sequential write and random write.
[0095] In some embodiments, the storage capacity of the storage segments of the file system 122 can be configured based on the physical parameters of the storage device 134. Furthermore, when configuring the storage capacity of each storage segment, the file system 122 can set the capacity based on the type of storage medium to be used and the storage capacity of the physical storage blocks of the storage device 134, thereby configuring the storage capacity of the storage segment to be equal to or a multiple of the storage capacity of the physical storage block. The storage medium type includes at least one of single-bit cell (SLC), multi-bit cell (MLC), triple-level cell (TLC), or quad-level cell (QLC), which indicates the storage medium type of the physical storage block. The storage medium type can indicate the number of bits stored in a storage cell of the same area. For example, SLC indicates that 1 bit of data is stored in a storage cell, MLC indicates that 2 bits of data are stored in a storage cell, TLC indicates that 3 bits of data are stored in a storage cell, and QLC indicates that 4 bits of data are stored in a storage cell. The smaller the number of bits stored in a memory cell of the same area, the shorter the reading time of the memory cell and the faster the response.
[0096] When the storage medium type to be adopted is only SLC (for example, the file system 122 configures each physical storage block in the storage device 134 as SLC), the file system 122 can configure the storage capacity size of each storage segment to be equal to the storage capacity size of the physical storage block in the storage device 134; when the storage medium type to be adopted is a combination of SLC and TLC (for example, the file system 122 configures a part of the physical storage blocks in the storage device 134 as TLC, and sets another part of the physical storage blocks in the storage device 134 to SLC), the file system can configure the storage capacity size of each storage segment to be equal to three times the storage capacity size of the physical storage block; when the storage medium type to be adopted is a combination of SLC and MLC (for example, the file system 122 configures a part of the physical storage blocks in the storage device 134 as SLC, and sets another part of the physical storage blocks in the storage device 134 to MLC), the file system 122 can The storage capacity of each storage segment is configured to be equal to twice the storage capacity of the physical storage block; when the storage medium type to be used is a combination of SLC and QLC (for example, the file system 122 configures a portion of the physical storage blocks in the storage device 134 as SLC and another portion of the physical storage blocks in the storage device 134 as QLC), the file system 122 can configure the storage capacity of each storage segment to be equal to four times the storage capacity of the physical storage block; and when the storage medium type to be used is a combination of SLC, MLC, and QLC (for example, the file system 122 configures a portion of the physical storage blocks in the storage device 134 as SLC, another portion of the physical storage blocks in the storage device 134 as MLC, and another portion of the physical storage blocks in the storage device 134 as QLC), the file system 122 can configure the storage capacity of each storage segment to be equal to four times the storage capacity of the physical storage block. It will be understood that the configuration of the storage capacity of the above storage segments is only exemplary, and those skilled in the art can configure it in different ways according to needs and hardware performance, and this disclosure is not limited to this.
[0097] The file system 122 may set a write mode for each storage segment. For example, the file system 122 may set the write mode for some storage segments to sequential write and set the write mode for other storage segments to random write.
[0098] After the file system 122 completes the setting of the physical parameters of each storage segment, the file system 122 can configure the storage device 134. As shown in Figure 3, the file system 122 can send a configuration request to the storage device 134 in 312. The configuration request includes configuration information for configuring at least one of the write mode or storage medium type of one or more physically erased storage blocks. The file system 122 can accordingly set the parameters of the physically erased storage blocks in the storage device 134 based on the configured physical parameters. The configuration information sent to the physically erased storage blocks can be generated based on the physical parameters of the storage segment. For example, the write mode in the configuration information can be determined based on the write mode in the physical parameters of the storage segment. The configuration information can include configuration information for configuring the write mode and / or storage medium type of the physically erased storage blocks. The configuration information can indicate how the physically erased storage blocks in the storage device 134 are to be used. The configuration information may include a write mode to indicate whether the physically erased storage blocks in the storage device 134 are written sequentially or randomly; and the storage medium type in the configuration information indicates the number of bits stored in a storage unit of the same area of the physically erased storage blocks in the storage device 134, such as SLC, TLC, QLC or MLC.
[0099] For example, if the configuration information for configuring a physically erased storage block M is {sequential write; TLC}, it indicates that the write mode of the physically erased storage block M is configured as sequential write, and the storage medium type of the physically erased storage block M is configured as TLC. By executing the above operations, the file system 122 can configure each physically erased storage block in the storage device 134.
[0100] At 314, the storage device 134 configures the parameters of the physically erased storage block according to the received configuration request. For example, based on the write mode and storage medium type indicated in the received configuration request, the storage device 134 may configure the write mode and storage medium type of the corresponding physically erased storage block according to the values specified in the configuration request. At 316, the storage device 134 sends a response message to the file system 122, indicating that the storage device 134 has completed the parameter configuration according to the configuration request. Accordingly, in response to receiving the response message, the file system 122 can confirm that the storage device 134 has correctly configured the corresponding physically erased storage block according to the configuration request, as shown in block 318 of FIG. 3 .
[0101] Thus, the file system can configure its own physical parameters based on the physical parameters of the storage device and then configure the storage device using the configured physical parameters. For example, the file system 122 can configure the write mode and storage medium type of the physically erased storage block in the storage device 134 according to the values specified in the configuration request. This enables the file system to manage the storage resources of the storage device.
[0102] The following describes a process for aligning storage segments in the file system 122 with one or more configured physically erased storage blocks in the storage device 134 based on mapping. In some embodiments, the file system 122 can map physically erased storage blocks in the storage device 134 to storage segments in the file system 122. During the mapping process, physically erased storage blocks with the same write mode are mapped to the storage segments. Furthermore, depending on the storage medium type of the physically erased storage blocks, one or more physically erased storage blocks can be mapped to one storage segment. For example, in an embodiment using a combination of TLC and SLC, three physically erased storage blocks of SLC can be mapped to one storage segment, and one physically erased storage block of TLC can be mapped to one storage segment. In an embodiment using a combination of QLC and SLC, four physically erased storage blocks of SLC can be mapped to one storage segment, and one physically erased storage block of QLC can be mapped to one storage segment. In an embodiment using a combination of MLC, QLC, and SLC, four SLC physically erased memory blocks can be mapped to one memory segment, two MLC physically erased memory blocks can be mapped to one memory segment, and one QLC physically erased memory block can be mapped to one memory segment. In an embodiment using only SLC, one SLC is mapped to one memory segment. The specific implementation process of this mapping will be described below with reference to the accompanying figures.
[0103] Based on this mapping, for paired mapped storage segments and one or more physically erased storage blocks, the file system 122 can use the physical parameters of the storage segment to update the corresponding segment parameters, and the updated segment parameters include the storage capacity, write method, and storage medium type of the storage segment. The storage capacity of a storage segment is equal to the total storage capacity of the one or more physically erased storage blocks mapped to it. The write method and storage medium type in the segment parameters are consistent with the write method and storage medium type of the physically erased storage blocks mapped to the storage segment. Furthermore, the storage medium type in the segment parameters of a storage segment indicates the storage medium type of the physically erased storage blocks mapped to the storage segment. Through the above-mentioned mapping and parameter updates, the storage segments in the file system are aligned with the physically erased storage blocks in the storage device, thereby facilitating the file system's management of the storage device.
[0104] Figures 4A and 4B illustrate schematic diagrams of the configuration of physically erased storage blocks in a storage device after alignment with storage segments in a file system according to an embodiment of the present disclosure. Figure 4A illustrates schematic diagram 400 of the configuration of physically erased storage blocks in a storage device 134 after alignment with storage segments in a file system 122, using both SLC and TLC, according to an embodiment of the present disclosure. As shown in Figure 4A, after the aforementioned mapping operation, the storage segments in the file system 122 are aligned with one or more physically erased storage blocks in the storage device 134. Furthermore, the write mode and storage medium type in the segment parameters of each storage segment are consistent with the write mode and storage medium type of the physically erased storage block mapped to that storage segment. Based on the aligned write mode, the file system 122 and the storage device 134 can be divided into a random write storage area and a sequential write storage area, as shown in Figure 4A. The random write storage area may primarily store metadata such as checkpoints and nodes, while the sequential write storage area may primarily store user data.
[0105] In both the random write storage area and the sequential write storage area, the storage segments are aligned with the configured physically erased storage blocks. For example, as shown in FIG4A , in the random write storage area, storage segment 1 is aligned with TLC physically erased storage block 1. The storage capacity of storage segment 1 is equal to the storage capacity of TLC physically erased storage block 1, and the write method of storage segment 1 is consistent with the write method of TLC physically erased storage block 1, both of which are random writes. Furthermore, the storage medium type in the segment parameters of storage segment 1 is consistent with the storage medium type of TLC physically erased storage block 1, indicating that the storage medium type of TLC physically erased storage block 1 mapped to storage segment 1 is TLC. In the sequential write memory area, storage segment (N+1) is aligned with the three SLC physically erased storage blocks (N+1, N+2, and N+3). The storage capacity of storage segment (N+1) is equal to the total storage capacity of the three SLC physically erased storage blocks. The write method of storage segment (N+1) is consistent with the write method of the three SLC physically erased storage blocks (N+1, N+2, and N+3), both of which are sequential writes. Furthermore, the storage medium type in the segment parameters of storage segment (N+1) is consistent with the storage medium type of the three SLC physically erased storage blocks (N+1, N+2, and N+3), indicating that the storage medium type of the three SLC physically erased storage blocks (N+1, N+2, and N+3) mapped to storage segment (N+1) is SLC. The alignment of the remaining storage segments and physically erased storage blocks in FIG. 4A is similar and will not be further described here for the sake of simplicity.
[0106] FIG4B illustrates a schematic diagram 400′ of the configuration of the physically erased storage blocks in the storage device after alignment with the storage segments in the file system in the case of MLC, SLC and QLC according to an embodiment of the present disclosure. As shown in FIG4B , after the above-mentioned mapping operation, the storage segments in the file system 122 are aligned with one or more physically erased storage blocks in the storage device 134. In addition, the write mode and storage medium type in the segment parameters of each storage segment are respectively consistent with the write mode and storage medium type of the physically erased storage blocks mapped to the storage segment. Based on the write mode after alignment, the file system 122 and the storage device 134 can be divided into a random write storage area and a sequential write storage area, as shown in FIG4B . In the random write storage area, metadata such as check points, nodes, etc. may be mainly stored, and in the sequential write storage area, user data may be mainly stored.
[0107] In both the random write and sequential write storage areas, storage segments are aligned with configured physical erase blocks. For example, as shown in FIG4B , in the random write storage area, storage segment (N-1) is aligned with four SLC physical erase blocks (K, (K+1), (K+2), and (K+3). The storage capacity of storage segment (N-1) is equal to the total storage capacity of the four SLC physical erase blocks (K, (K+1), (K+2), and (K+3). The write method of storage segment (N-1) is consistent with the write method of the four SLC physical erase blocks (K, (K+1), (K+2), and (K+3), both of which are random writes. Furthermore, the storage medium type in the segment parameters of storage segment (N-1) is consistent with the storage medium type of the four SLC physically erased storage blocks (K, (K+1), (K+2), and (K+3), indicating that the storage medium type of the four SLC physically erased storage blocks mapped to storage segment (N-1) is SLC. In the sequential write memory area, storage segment (N+2) is aligned with a QLC physically erased storage block (K+9). The storage capacity of storage segment (N+2) is equal to the storage capacity of QLC physically erased storage block (K+9), and the write method of storage segment (N+2) is consistent with the write method of QLC physically erased storage block (K+9), both of which are sequential writes. Furthermore, the storage medium type in the segment parameters of the storage segment (N+2) is consistent with the storage medium type of the QLC physically erased storage block (K+9), indicating that the storage medium type of the QLC physically erased storage block (K+9) mapped to the storage segment (N+2) is QLC. Similarly, in the sequential write storage area, the storage segment M is aligned with the two MLC physically erased storage blocks ((K+q), (K+q+1)), wherein the storage capacity of the storage segment M is equal to the total storage capacity of the two MLC physically erased storage blocks ((K+q), (K+q+1)), and the writing method of the storage segment M is consistent with the writing method of the two MLC physically erased storage blocks ((K+q), (K+q+1)), both of which are sequential writes. Furthermore, the storage medium type in the segment parameters of storage segment M is consistent with the storage medium type of the two MLC physically erased storage blocks ((K+q), (K+q+1)), indicating that the storage medium type of the two MLC physically erased storage blocks ((K+q), (K+q+1)) mapped to storage segment M is MLC. The alignment of the remaining storage segments and physically erased storage blocks in FIG4B is similar and will not be further described here for the sake of simplicity.
[0108] It is understood that the identifiers M, N, K, q, etc. in Figures 4A and 4B are integers and are schematic identifiers, and do not constitute a limitation of the present disclosure. In addition, the number of storage segments and physically erased storage blocks in the file system and storage device can also be set according to hardware performance and specific needs. In addition, the random write storage area and the sequential write storage area can include any number of storage segments and physically erased storage blocks, and the boundary between the random write storage area and the sequential write storage area can be set in any way, and the present disclosure does not limit this.
[0109] The following describes an example process for mapping physical storage blocks in a storage device to storage segments of a file system, in conjunction with FIG. FIG. 5 schematically illustrates an exemplary method 500 for mapping physical storage blocks in a storage device 134 to storage segments of a file system 122, according to an embodiment of the present disclosure. Method 500 in FIG. 5 can be executed by file system 122 in electronic device 100. For example, when file system 122 is implemented via software, operations of file system 122 can be implemented by processor 132 executing the software. Although the steps shown in FIG. 5 perform the corresponding functions of the mapping method in a specific order, it is understood that the order of execution of the steps in FIG. 5 may vary relative to the order shown. For example, two or more steps shown in succession may be executed simultaneously, or some steps may be executed simultaneously. Furthermore, certain steps in method 500 in FIG. 5 may be omitted. Furthermore, other steps may be added to method 500 in FIG. It is understood that all such variations are within the scope of the present disclosure.
[0110] As shown in Figure 5, when mapping one or more physically erased storage blocks to a storage segment, in step 502, the file system maps the identifier of the corresponding storage segment to the identifier of the one or more physically erased storage blocks. Since the storage capacity of a storage segment is configured based on the storage capacity of a physical storage block and the type of storage medium used, and the storage capacity of a storage segment is an integer multiple of the storage capacity of a physical storage block, a storage segment can correspond to one or more physically erased storage blocks. For example, in a storage resource using a combination of TLC and SLC, one storage segment can correspond to three SLC physically erased storage blocks. In a storage resource using a combination of MLC and SLC, one storage segment can correspond to two SLC physically erased storage blocks. In a storage resource using a combination of MLC, QLC, and SLC, one storage segment can correspond to four SLC physically erased storage blocks. In a storage resource using a combination of QLC and SLC, one storage segment can correspond to four SLC physically erased storage blocks. Accordingly, the file system 122 may map the identifier of each segment with the identifier of one or more corresponding physically erased storage blocks. For example, if one storage segment corresponds to one physically erased storage block, the file system may map the identifier of the segment with the identifier of the corresponding physically erased storage block. If one storage segment corresponds to two physically erased storage blocks, the file system may map the identifier of the segment with the identifiers of the two physically erased storage blocks, and so on.
[0111] For the paired mapped storage segments and one or more physical storage blocks, the file system 122 will continue to map the storage units determined based on the storage granularity in the storage segments in the mapping pair with the granularity storage units in the physically erased storage blocks in 504. For example, for the paired mapped storage segments and the corresponding one or more physically erased storage blocks, the file system 122 can map the identifiers of the storage units determined based on the minimum storage granularity in the storage segments with the identifiers of the storage units determined based on the minimum storage granularity in the corresponding one or more physically erased storage blocks. Typically, in a file system, the storage granularity can be a logical block address (LBA), and the storage granularity in a storage device can be a physical page, for example, both of which are 4KB in size. The 4KB example is only illustrative, and those skilled in the art can adopt various appropriate sizes according to actual circumstances, and this disclosure does not limit this. The file system 122 can map the LBA with the identifier of the physical page. Figure 6 schematically shows a schematic diagram of the mapping of storage units in a storage segment and storage units in a physically erased storage block according to an embodiment of the present disclosure. For example, LBA1 may be mapped to physical page 51, LAB2 may be mapped to physical page 52, and so on.
[0112] In some embodiments, as shown in 506 in FIG. 5 , for paired mappings of storage segments and corresponding one or more physically erased storage blocks, the file system 122 may synchronize a write location (write pointer) in the storage segment with a write location in the one or more physically erased storage blocks. Specifically, for a storage unit (e.g., LBA) in the storage segment, the file system may assign a pointer p to the starting storage unit. Pointer p may point to the starting address of the starting storage unit. The file system 122 may generate a write request based on the address pointed to by pointer p and send the write request to the physical storage unit in the storage device 134 that is mapped to the starting storage unit. After receiving the write request, the physical storage unit may respond and send the response information to the file system 122. The response information may include the address of the physical storage unit in the storage device 134 that received the starting address. After receiving the response information, the file system 122 may obtain the address in the response information and synchronize the obtained address with the address pointed to by pointer p (starting address), thereby synchronizing the starting write location of the file system 122 with the starting write location in the storage device 134. Afterwards, the file system 122 increments the pointer p by 1 so that the pointer points to the next write location and continues to perform similar synchronization operations to synchronize the next write location with the corresponding next write location in the storage device 134. The file system 122 performs the synchronization operations multiple times until the synchronization of the entire storage segment with the corresponding write locations in one or more physically erased storage blocks is completed.
[0113] The above, in conjunction with the accompanying drawings, describes the process of aligning the storage segments in the file system 122 with the physical storage blocks in the storage device 134 through configuration and mapping. After the above configuration, the file system can manage the storage device. Advantageously, based on the management of the storage device by the file system, the garbage collection operations of the file system and the storage device can be uniformly performed by the file system, thereby avoiding the situation where the file system and the storage device perform garbage collection operations at the same time. The situation of repeated data movement can be avoided, and the response delay can be significantly reduced, and the writable capacity of the storage device can be increased. The following, in conjunction with the accompanying drawings, describes the process of the file system uniformly performing garbage collection operations on the file system and the storage device in the sequential write area.
[0114] During garbage collection operations performed by file system 122, file system 122 performs garbage collection operations in a storage area comprised of one or more sequentially written storage segments. Based on these garbage collection operations, file system 122 simultaneously completes garbage collection operations in corresponding storage areas within storage device 134, where the corresponding storage areas within storage device 134 are comprised of corresponding physically erased storage blocks aligned with one or more sequentially written storage segments, and the corresponding physically erased storage blocks are written sequentially. In other words, file system 122 performs unified garbage collection operations on storage segments and physically erased storage blocks within the sequentially written areas. When file system 122 performs garbage collection operations in these sequentially written areas, it also simultaneously completes garbage collection operations in sequentially written storage areas within the storage device aligned with these sequentially written areas. Accordingly, storage device 134 does not need to perform garbage collection operations on the sequentially written storage areas within the storage device that correspond to the sequentially written areas of the file system. It will be appreciated that when file system 122 is implemented via software, the operations of file system 122 can be implemented through the execution of the software by processor 132.
[0115] Fig. 7 A and Fig. 7 B schematically illustrate the schematic diagram of performing garbage collection operation in the sequential write area according to an embodiment of the present disclosure. For the purpose of illustration, and for the sake of clarity, only partial storage segments and physical erase storage blocks are shown in Fig. 7 A and Fig. 7 B, and each segment and physical erase storage block only illustrate partial storage units. But it is understandable that the file system 122 and storage device 134 in Fig. 7 A and Fig. 7 B can include more or less storage segments and physical erase storage blocks, and each storage segment and physical erase storage block can also include more or less storage units, and the present disclosure does not limit this. In addition, although storage segments p and q are illustrated in Fig. 7 A and Fig. 7 B respectively to align physical erase storage blocks p and q, it is understandable that, in the process of actual use, the numbering of the aligned storage segments and the numbering of the physical erase storage blocks do not need to be identical.
[0116] As shown in FIG7A , eight storage units are shown in storage segment p of file system 122, where the data in storage units 1 and 3-8 are invalid, and the data in storage unit 2 is valid. When garbage collection is performed on storage segment p, the valid data in storage unit 2 must first be moved, for example, to storage unit 1 in storage segment q. Because storage segments p and q in the file system are aligned with physically erased storage blocks p and q in the storage device, respectively, and each pair of aligned storage segments and storage units in a physically erased storage block is also aligned with each other, when file system 122 moves data in storage unit 2 in the storage segment, storage device 134 also correspondingly moves the data in storage unit 2 in physically erased storage block p, for example, to storage unit 1 in physically erased storage block q.
[0117] After performing the data migration, file system 122 can erase storage segment p. Accordingly, file system 122 also performs an erase operation on physically erased storage block p in storage device 134, thereby erasing both storage segment p and physically erased storage block p, as shown in FIG7B . The valid data in storage segment p in the file system is migrated to storage cell 1 of storage segment q, and storage segment p is erased. Simultaneously, the valid data in physically erased storage block p in storage device 134 is migrated to storage cell 1 of physically erased storage block q, and physically erased storage block p is erased. The aforementioned garbage collection operations are all performed by file system 122. File system 122 can perform the aforementioned data migration and erasure operations on all storage segments in the sequential write area, thereby implementing garbage collection operations within the sequential write area. When the file system 122 performs garbage collection operations in its own sequential write area, it simultaneously completes garbage collection operations in the sequential write storage area in the storage device 134 that is aligned with the sequential write area. Accordingly, the storage device 134 does not need to perform garbage collection operations on the sequential write storage area in the storage device that corresponds to the sequential write area of the file system.
[0118] During the data storage process, a storage segment can have different states depending on the data being written to it. These states can include: free, open, or closed. Accordingly, when using a storage segment for a write operation, the file system can update the state of the storage segment in the storage resource. Specifically, the file system can update the state of a storage segment ready for a write operation to open; update the state of a storage segment fully written to closed; and update the state of a storage segment whose data has been completely moved and can be used again for data storage to free. These states can be transitioned between, as shown in Figure 8.
[0119] FIG8 schematically illustrates a schematic diagram of transitions between various states according to an embodiment of the present disclosure. Initially, there may not be any data in the storage segment, and accordingly, the state may be defined as an idle state 810. The storage segment in the idle state 810 may be configured ready for write operations, at which point the state of the storage segment is an open state 820. The file system 122 may perform write operations on the storage segment in the open state 820. When the data is full, the storage segment is defined as a closed state 830. For the storage segment in the closed state 830, the file system 122 may perform a garbage collection operation 840 similar to that described above. After the garbage collection operation 840, all the data in the storage segment is moved, the storage segment can be used for data storage again, and the state of the storage segment may be updated to the idle state 810, as shown in FIG8 .
[0120] In some embodiments, the file system 122 can also change the usage of the storage segment in the idle state, so as to achieve flexible configuration of the boundary between the random write storage area and the sequential write storage area, and thus more flexibly configure resources according to user needs.
[0121] Specifically, the file system 122 can change the usage mode of a storage segment that is in an idle state. For example, the file system 122 can determine that the write mode of a storage segment whose current write mode is sequential write is to be changed to random write, or the write mode of a storage segment whose current write mode is random write is to be changed to sequential write. Accordingly, the write mode of one or more physical erase blocks corresponding to the storage segment whose write mode is to be modified is also changed. In some embodiments, when the file system 122 is to change the write mode of a storage segment whose current write mode is sequential write to random write or to change the write mode of a storage segment whose current write mode is random write to sequential write, the file system 122 can send a notification to the storage device 134, indicating that the write mode of one or more physical erase blocks mapped to the storage segment whose write mode is to be changed (for example, from random write to sequential write or from sequential write to random write) is also to be changed accordingly. In response to the notification, the storage device 134 may change the write mode of the one or more physically erased storage blocks (for example, change from random write to sequential write or from sequential write to random write). After completing the change of the write mode of the one or more physically erased storage blocks, the storage device 134 may send a response message indicating that the change is successful to the file system 122. After receiving the response message from the storage device 134, the file system 122 may modify the write mode of the storage segment whose write mode is to be changed, for example, change from random write to sequential write or from sequential write to random write.
[0122] For example, for a storage segment h in an idle state, its current write mode is random write. The file system 122 may determine that the write mode of the storage segment h needs to be changed from random write to sequential write. The file system 122 may send a notification to the storage device 134, indicating that the write mode of the physically erased storage block mapped to the storage segment h also needs to be changed from random write to sequential write. In response to the notification, the storage device 134 changes the write mode of the physically erased storage block that forms a mapping pair with the storage segment h from random write to sequential write (for example, the physically erased storage block is selected from the free storage block resource pool and added to the sequential write storage area). After completing the change of the write mode of the physically erased storage block, the storage device 134 may send a response message indicating that the change was successful to the file system 122. After receiving the response message from the storage device 134, the file system 122 may further change the write mode of the storage segment h from random write to sequential write. In some embodiments, when file system 122 determines that the write mode of a storage segment should be changed from sequential write to random write, it may send a notification to storage device 134, indicating that the write mode of one or more physically erased storage blocks mapped in pairs with the storage segment should also be changed from sequential write to random write. In this case, in response to the notification indicating that the write mode of the one or more physically erased storage blocks has been changed from sequential write to random write, storage device 134 adds the one or more physically erased storage blocks to the free storage block resource pool of storage device 134. When storage device 134 adds the one or more physically erased storage blocks to the free storage block resource pool of storage device 134, it completes the change in the write mode of the one or more physically erased storage blocks, thereby changing the write mode of the one or more physically erased storage blocks to random write. Furthermore, storage device 134 may send a response message to file system 122 indicating that the change was successful. After receiving the response message from storage device 134, file system 122 may change the write mode of the storage segment from sequential write to random write.
[0123] Figures 9A and 9B schematically illustrate the operation performed by the storage device in response to changing the write mode of the physically erased storage block from sequential write to random write. As shown in Figure 9A, the physically erased storage blocks (illustrated as "storage blocks" in Figure 9A) 1 to storage block a are sequential write storage blocks in the storage device 134, and are aligned with the corresponding storage segments in the file system 122 respectively. For example, the storage block 3 shown is aligned with the storage segment 3. It will be understood that the alignment of storage block 3 with storage segment 3 is shown here only for illustrative purposes, and the aligned storage blocks and storage segments do not have to be numbered the same. When the state of storage segment 3 is idle and the file system 122 is to change the write mode of storage segment 3 to random write, the file system 122 sends a notification to the storage device 134. The notification indicates that the write mode of storage block 3 also needs to be changed to random write.
[0124] 9B illustrates the operation of the storage device 134 in response to the notification. The storage device 134 receives the notification and determines that the notification indicates that the write mode of the storage block 3 is modified to random write. The storage device 134 can remove the storage block 3 from the sequential write storage area (as shown by the dotted line) and add the storage block 3 to the free storage block resource pool of the storage device 134, thereby modifying the write mode of the storage block 3 to random write. Further, the storage device 134 can send a response message indicating the successful change to the file system 122. After receiving the response message from the storage device 134, the file system 122 can change the write mode of the storage segment 3 from sequential write to random write.
[0125] In some embodiments, when file system 122 changes the write mode of a storage segment from random write to sequential write, file system 122 may send a notification to storage device 134 indicating that the write mode of one or more physically erased storage blocks mapped in pairs with the storage segment is also to be changed from random write to sequential write. In this case, in response to the notification indicating that the write mode of one or more physically erased storage blocks mapped in pairs with the storage segment whose write mode is to be changed is also to be changed from random write to sequential write, storage device 134 selects the one or more physically erased storage blocks from a pool of free storage block resources as newly added physically erased storage blocks for sequential write and sends a request (e.g., a management request) to file system 122 for the one or more newly added physically erased storage blocks. In some embodiments, the request may be included in or correspond to a response message sent by storage device 134 indicating that the change was successful. File system 122 may receive the request (e.g., a management request) from storage device 134. In response to receiving the request, file system 122 may determine that storage device 134 has completed the change of the write mode of the one or more physically erased storage blocks. Furthermore, the file system 122 may change the writing mode of the storage segment from random writing to sequential writing.
[0126] Figures 10A and 10B schematically illustrate the operations performed by the storage device 134 in response to changing the write mode of a physically erased storage block from random write to sequential write. As shown in Figure 10A, physically erased storage blocks (illustrated as "storage blocks" in Figure 10A) 1 to storage block a are sequential write storage blocks in the storage device and are aligned with corresponding storage segments in the file system 122. For example, storage block 3 is shown aligned with storage segment 3. It will be understood that the alignment of storage block 3 with storage segment 3 is shown here only for illustrative purposes, and the aligned storage blocks and storage segments do not need to have the same number. When the status of another storage segment b in the file system 122 is idle and the file system 122 wants to change the write mode of storage segment b to sequential write, the file system 122 sends a notification to the storage device 134. The notification indicates that the write mode of the physically erased storage blocks aligned with storage block b also needs to be changed to sequential write.
[0127] Figure 10B illustrates the operation in response to the notification according to storage device 134. Storage device 134 receives the notification and determines that the notification indicates that the write mode of storage block b needs to be modified to sequential write. Storage device 134 can select the storage block b corresponding to the storage segment b from the free resource block pool and send a request (such as a management request) for the storage block to file system 122. Storage device 134 can add the storage block b to the sequential write area in the storage device 134, such as, adding to the end of the sequential write area, for the management of storage resources by file system 122, thus completing the modification of the write mode of the storage block b. Accordingly, file system 122 can receive the request from storage device 134, and in response to the request, file system 122 can determine that storage device 134 has completed the change of the write mode of the one or more physically erased storage blocks. And then, file system 122 can change the write mode of the storage segment from random write to sequential write.
[0128] Advantageously, by changing how free storage segments are used, the file system can flexibly configure the boundary between random write storage areas and sequential write storage areas, thereby more flexibly configuring resources based on user needs, thereby further improving the user experience.
[0129] FIG11 schematically illustrates a block diagram of an apparatus 1100 for managing storage resources according to an embodiment of the present disclosure. The apparatus 1100 may be implemented via software, hardware, or a combination thereof. In some embodiments, the apparatus 1100 may be implemented as a software device, a hardware device, or a combination of hardware and software. The apparatus 1100 shown in FIG11 can be used to implement the process for managing storage resources described above in conjunction with FIG2 through FIG10 .
[0130] As shown in FIG11 , the apparatus may include a capability information providing module 1102, a request receiving module 1104, a storage segment determination module 1106, and a storage block determination module 1108. In some embodiments, the capability information providing module 1102 is configured to provide capability information related to storage resources. The request receiving module 1104 is configured to receive a storage resource request for a storage resource, which is generated by a requesting application based on requirements and based on the capability information. The storage segment determination module 1106 is configured to determine, based on the storage resource request, at least one storage segment that satisfies the storage resource request from storage resources with different characteristics. The storage block determination module 1108 is configured to determine, based on the at least one determined storage segment, a physical storage block in the storage device to be used for the storage resource request.
[0131] Thus, in the embodiments of the present disclosure, by providing capability information to the requesting application that initiates the access request and receiving the storage resource request generated by the requesting application based on the capability information according to its own needs, the file system 122 can more conveniently, quickly and flexibly match storage resources for the requesting application, thereby not only meeting the different requirements of different applications in different scenarios, but also significantly reducing the response delay and improving the access efficiency, thereby significantly improving the user's operating experience.
[0132] In some embodiments, the capability information may include capability parameters, and the capability parameters may include at least one of the following items: storage capacity, response latency level, data retention time level, or data writing method.
[0133] In some embodiments, the requirements may include one or more of the following: the size of the stored data, the hotness or coldness of the stored data, or the response speed from the requesting application.
[0134] In some embodiments, the capability information providing module may be configured to provide capability information related to storage resources through a middleware interface. Accordingly, in some embodiments, the storage request may be generated by calling the middleware interface.
[0135] In some embodiments, the apparatus 1100 may further include: a recording module configured to record segment parameters of each storage segment in the storage resource, wherein the segment parameters correspond to capability parameters in the capability information.
[0136] In some embodiments, the storage segment determination module 1106 may include a determination submodule and a selection submodule, the determination submodule may be configured to determine a request parameter in a storage request, wherein the request parameter corresponds to a capability parameter in the capability information, and the selection submodule may be configured to select one or more storage segments whose segment parameters match the request parameters from the storage resources as the determined at least one storage segment.
[0137] In this way, by matching the segment parameters with the request parameters, it is possible to conveniently select the appropriate storage segment from the storage resources for the storage resource request, which can further reduce the response delay and improve the access efficiency, thereby significantly improving the user's operating experience.
[0138] In some embodiments, the device 1100 may further include: an acquisition module configured to acquire physical parameters of a storage device; a configuration module configured to configure the physical parameters of each storage segment in the storage resource based on the physical parameters of the storage device, wherein the physical parameters of the storage segment include at least one of the storage capacity size or writing mode of the corresponding storage segment, wherein the storage capacity size is equal to or an integer multiple of the storage capacity size of the physical block of the storage device, and the writing mode includes at least one of sequential writing and random writing.
[0139] In this way, by obtaining the physical parameters of the storage device 134, the file system 122 can configure the physical parameters of the storage segments in the file system 122 according to the physical parameters of the storage device 134, so that it can be adapted to various types of storage devices, and it can also ensure the alignment of the storage segments in the file system 122 with the physical storage blocks in the storage device 134, which is conducive to the smoothness and stability of the file system in the process of managing the physical storage blocks in the storage device.
[0140] In some embodiments, the apparatus 1100 may further include: a sending module configured to send a configuration request to one or more physically erased storage blocks, the configuration request including configuration information for configuring at least one of a writing method or a storage medium type of the one or more physically erased storage blocks; a receiving module configured to receive response information corresponding to the configuration request from the storage device 134; and a confirmation module configured to confirm that the one or more physically erased storage blocks are correctly configured according to the configuration request, wherein the physical storage blocks include the one or more physically erased blocks.
[0141] In some embodiments, the storage medium type may include at least one of single-bit cell (SLC), multi-bit cell (MLC), triple-level cell (TLC), or quad-level cell (QLC).
[0142] In some embodiments, the device 1100 may further include: a mapping module configured to map one or more physically erased storage blocks to corresponding storage segments, wherein the total storage capacity of the one or more physically erased storage blocks is equal to the storage capacity of the corresponding storage segment; and an update module configured to update the segment parameters of the corresponding storage segment with the physical parameters of the corresponding storage segment based on the mapping, the segment parameters including the storage capacity, writing mode and storage medium type of the corresponding storage segment, wherein the writing mode and storage medium type of the corresponding storage segment are respectively consistent with the writing mode and storage medium type of one or more physically erased storage blocks mapped to the storage segment.
[0143] In some embodiments, the mapping module 1100 includes a first mapping submodule, a second mapping submodule and a synchronization submodule, wherein the first mapping submodule can be configured to map the identifier of the corresponding storage segment with the identifier of one or more physically erased storage blocks; the second mapping submodule can be configured to map the identifier of the storage unit determined based on the storage granularity in the corresponding storage segment with the identifier of the storage unit determined based on the storage granularity in the one or more physically erased storage blocks for the corresponding storage segment and the one or more physically erased storage blocks mapped in pairs; and the synchronization submodule can be configured to synchronize the write position in the storage segment with the write position in the one or more physically erased storage blocks for the corresponding storage segment and the one or more physically erased storage blocks mapped in pairs.
[0144] In some embodiments, the device 1100 may also include: a garbage collection operation module, configured to perform a garbage collection operation in a storage area composed of one or more storage segments whose writing method is sequential writing, and based on the garbage collection operation, simultaneously complete the garbage collection operation in the corresponding storage area in the storage device 134, wherein the corresponding storage area in the storage device 134 is composed of corresponding physically erased storage blocks aligned with one or more sequentially written storage segments, and wherein the writing method of the corresponding physically erased storage blocks is sequential writing.
[0145] In this way, by aligning the sequential write storage area of file system 122 with the sequential write storage area of storage device 134, the execution of garbage collection operations in file system 122 and storage device 134 can be merged. Accordingly, by having file system 122 perform garbage collection operations in both file system 122 and storage device 134, the repeated data movement that occurs when file system 122 and storage device 134 perform garbage collection simultaneously can be avoided, thereby significantly reducing response latency and increasing the writable capacity of the storage device.
[0146] In some embodiments, the physical parameters of the storage device 134 include at least one or more of the capacity size, physical page size, physical page identifier, plane size, plane identifier, super block size or super block identifier of the physical storage block of the storage device 134.
[0147] In some embodiments, the apparatus 1100 may further include: an update module configured to update the state of the storage resource during a write operation using the determined at least one storage segment, where the state includes an idle state, an open state, or a closed state.
[0148] In some embodiments, the update module can be configured to: update the status of a storage segment that is ready for a write operation to an open state; update the status of a storage segment that is full of data to a closed state; and update the status of a storage segment that has all its data moved and can be used again for data storage to an idle state.
[0149] In some embodiments, the apparatus 1100 may further include: a determination module configured to determine, for a storage segment in an idle state, that a usage mode of the storage segment is to be changed; a sending module configured to send a notification to the storage device 134 indicating that a writing mode of one or more physically erased storage blocks mapped to the storage segment is to be changed; and a changing module configured to change the writing mode of the storage segment in response to receiving response information indicating that the change is successful from the storage device.
[0150] In some embodiments, in response to the notification, the storage device 134 adds the one or more physically erased storage blocks to a free storage block resource pool of the storage device.
[0151] In some embodiments, the apparatus 110 may further include a receiving module configured to receive a request for the one or more newly added physically erased storage blocks from the storage device 134, wherein the one or more newly added physically erased storage blocks are selected by the storage device 134 from a pool of free storage block resources in the storage device. In some embodiments, the request may be included in the response information indicating that the modification is successful or may correspond to the response information.
[0152] In this way, by switching the writing mode of the storage segment with an idle state between random writing and sequential writing, the boundary change between the random write storage area and the sequential write storage area of the file system 122 can be flexibly changed, thereby facilitating the flexible configuration of storage resources according to user needs.
[0153] FIG12 schematically shows a schematic block diagram of an example device 1200 for implementing embodiments of the present disclosure according to some embodiments of the present disclosure. The device 1200 may be implemented as an electronic device or included in the electronic device shown in FIG1 .
[0154] As shown in the figure, the device 1200 includes a processor 1201, a read-only memory (ROM) 1202, and a random access memory (RAM) 1203. In one implementation, the processor 1201 can be a central processing unit (CPU), which performs various appropriate actions and processes according to computer program instructions stored in the RAM 1202 and / or RAM 1203 or computer program instructions loaded from the storage unit 1208 into the ROM 1202 and / or RAM 1203. Various programs and data required for the operation of the device 1200 can also be stored in the ROM 1202 and / or RAM 1203. The processor 1201 and the ROM 1202 and / or RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.
[0155] Various components in device 1200 are connected to I / O interface 1205, including an input unit 1206, such as a keyboard and mouse; an output unit 1207, such as various types of displays and speakers; a storage unit 1208, such as a magnetic disk and optical disk; and a communication unit 1209, such as a network card, a modem, a wireless communication transceiver, etc. Communication unit 1209 allows device 1200 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0156] In another implementation, the processor 1201 can be various general-purpose and / or specialized processing components with processing and computing capabilities. The processor may include, but is not limited to, a central processing unit (CPU), a graphics processing unit (GPU), a field programmable gate array (FPGA), an application-specific integrated circuit (ASIC), a digital signal processor (DSP), or an artificial intelligence (AI) processor, among any other circuits with processing capabilities, or a combination thereof. In some embodiments, some examples of implementations include, but are not limited to, GPUs, various dedicated AI computing chips, FPGAs, ASICs, CPUs, DSPs, various computing units that run machine learning model algorithms, and any appropriate processors, controllers, microcontrollers, etc., which may be referred to as computing units accordingly. The processor 1201 performs the various methods and processes described above. For example, in some embodiments, the processes described above may be implemented as a computer software program tangibly embodied in a computer-readable medium, such as the storage unit 1208. In some embodiments, part or all of the computer program may be loaded and / or installed onto the device 1200 via the ROM 1202 and / or the RAM 1203 and / or the communication unit 1209. When the computer program is loaded into ROM 1202 and / or RAM 1203 and executed by processor 1201, one or more steps of the process described above may be performed. Alternatively, in other embodiments, processor 1201 may be configured to perform the process described above in any other appropriate manner (e.g., by means of firmware).
[0157] For example, the device 1200 in FIG12 may be implemented as an electronic device having a storage device, etc., or may be implemented as a chip or a chip system, which is not limited in the embodiments of the present disclosure. In some embodiments, the storage device in the device 1200 in FIG12 may include various types of storage devices, and the storage device may also include a storage array, a distributed storage system, etc.
[0158] The present disclosure also provides a chip that may include an input interface, an output interface, and a processing circuit. In the present disclosure, the input interface and the output interface may be used to implement signaling or data interaction, while the processing circuit may be used to implement signaling or data information generation and processing.
[0159] The embodiments of the present disclosure further provide a chip system, including a processor for supporting a user device to implement the functions involved in any of the above embodiments. In one possible design, the chip system may also include a memory for storing necessary program instructions and data. When the processor executes the program instructions, the device in which the chip system is installed implements the method involved in any of the above embodiments. Exemplarily, the chip system may be composed of one or more chips, or may include chips and other discrete devices.
[0160] An embodiment of the present application further provides a processor for coupling with a memory, wherein the memory stores instructions. When the processor executes the instructions, the processor executes the methods and functions involved in any of the above embodiments.
[0161] Embodiments of the present application also provide a computer-readable storage medium having computer instructions or program codes stored thereon, which, when executed by a processor, causes the processor to perform the methods and functions described in any of the above embodiments. A computer-readable medium can be any tangible medium containing or storing a program for or related to an instruction execution system, apparatus, or device. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. Computer-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any suitable combination thereof. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage system such as a server or data center that integrates one or more available media. More detailed examples of computer-readable storage media include an electrical connection with one or more wires, magnetic media (e.g., a magnetic disk, floppy disk, hard disk, tape, magnetic storage device), optical media (e.g., an optical storage device, DVD), semiconductor media (e.g., a solid-state drive), random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), or any suitable combination thereof.
[0162] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The embodiments of the present application also provide at least one computer program product tangibly stored on a non-transitory computer-readable storage medium. The computer program product includes one or more computer-executable instructions, such as instructions included in a program module, which are executed in a device on a real or virtual processor of the target to perform the processes, methods and functions involved in any of the above embodiments. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) method.
[0163] According to the method provided in the embodiments of the present application, the present application also provides a computer program product, which includes: computer program code, which, when executed on a computer, causes the computer to perform the processes, methods, and functions in the above-described embodiments. Generally, program modules include routines, programs, libraries, objects, classes, components, data structures, etc. that perform specific tasks or implement specific abstract data types. In various embodiments, the functions of program modules can be combined or divided between program modules as needed. Machine-executable instructions for program modules can be executed in local or distributed devices. In distributed devices, program modules can be located in local and remote storage media.
[0164] The computer program code for realizing the method of the present disclosure can be written in one or more programming languages. These computer program codes can be provided to the processor of general-purpose computer, special-purpose computer or other programmable data processing device so that the program code, when being executed by computer or other programmable data processing device, causes the function / operation specified in flow chart and / or block diagram to be implemented. The program code can be executed completely on computer, partly on computer, as an independent software package, partly on computer and partly on remote computer or completely on remote computer or server. In the context of the present disclosure, computer program code or related data can be carried by any appropriate carrier so that equipment, device or processor can perform various processing and operation described above. The example of carrier includes signal, computer readable medium, etc. The example of signal can include electric, optical, radio, sound or other form of propagation signal, such as carrier wave, infrared signal etc.
[0165] In general, various embodiments of the present application can be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects can be implemented in hardware, while other aspects can be implemented in firmware or software, which can be executed by a controller, microprocessor, or other user device. Although various aspects of the embodiments of the present disclosure are shown and described as block diagrams, flow charts, or using some other graphical representation, it should be understood that the blocks, devices, systems, techniques, or methods described herein can be implemented as, for example, non-limiting examples, hardware, software, firmware, dedicated circuits or logic, general-purpose hardware or controllers or other user devices, or some combination thereof.
[0166] As used in the above embodiments, the term “when…” may be interpreted to mean “if…” or “after…” or “in response to determining…” or “in response to detecting…”, depending on the context. Similarly, the phrases “upon determining…” or “if (stated condition or event) is detected” may be interpreted to mean “if determining…” or “in response to determining…” or “upon detecting (stated condition or event)” or “in response to detecting (stated condition or event)”, depending on the context.
[0167] The above descriptions of various implementations of the present disclosure are intended to be exemplary, not exhaustive, and not limited to the disclosed implementations. Without departing from the scope and spirit of the various implementations described, many modifications and changes will be apparent to those skilled in the art. The choice of terms used herein is intended to explain the principles of the various implementations, their practical applications, or improvements to the technology in the market, or to enable other persons skilled in the art to understand the various implementations disclosed herein. The specific internal implementation may vary depending on the type of electronic device, the operating system carried, the program used, or the interface called. The present application is not subject to any limitation in its embodiments, and the characteristic functions described in the embodiments of the present application may be implemented. The various embodiments of the present application may be arbitrarily combined to achieve different technical effects.
[0168] The above specific implementation methods further explain in detail the purpose, technical solutions and beneficial effects of the embodiments of the present application. It should be understood that the above are only specific implementation methods of the embodiments of the present application and are not intended to limit the scope of protection of the embodiments of the present application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of the embodiments of the present application should be included in the scope of protection of the embodiments of the present application.
[0169] It should be noted that although the embodiments of the present application are described above in conjunction with the accompanying drawings, the above embodiments are not independent of each other, and they can also be combined to obtain other embodiments. The methods, situations, categories, and divisions of the embodiments in the embodiments of the present application are only for the convenience of description and should not constitute special limitations. The features of the various methods, categories, situations, and embodiments can be combined with each other when they are logical. The various embodiments of the present application can be combined arbitrarily to achieve different technical effects. The embodiments of the present application no longer list various combinations.
[0170] In addition, although the operations of the method of the present disclosure are described in a particular order in the accompanying drawings, this does not require or imply that these operations must be performed in this particular order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flowchart can change the order of execution. Additionally or alternatively, certain steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps. It should also be noted that the features and functions of two or more devices according to the present disclosure can be embodied in one device. Conversely, the features and functions of a device described above can be further divided into being embodied by multiple devices.
[0171] While various implementations of the present disclosure have been described above, the foregoing description is intended to be illustrative, non-exhaustive, and non-limiting to the disclosed implementations. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described implementations. The terminology used herein is selected to facilitate explanation of the principles, practical applications, or improvements to existing technologies, or to enable others skilled in the art to understand the various implementations disclosed herein.
Claims
1. A method for managing storage resources, characterized in that: The method comprises: Provides capability information related to storage resources; receiving a storage resource request for the storage resource, the storage resource request being generated by a requesting application according to demand and based on the capability information; According to the storage resource request, determining at least one storage segment satisfying the storage resource request from the storage resources with different characteristics; and A physical storage block in a storage device for the storage resource request is determined based on the determined at least one storage segment.
2. The method according to claim 1, characterized in that The capability information includes capability parameters, and the capability parameters include at least one of the following items: storage capacity, response delay level, data retention time level, or data writing method.
3. The method according to claim 1, characterized in that The requirement includes one or more of the following items: the size of the storage data from the requesting application, the hotness or coldness of the storage data, or the response speed.
4. The method according to claim 1, characterized in that: The capability information provided about storage resources includes: The capability information related to the storage resource is provided through a middleware interface.
5. The method according to claim 4, characterized in that The storage request is generated by calling the middleware interface.
6. The method according to claim 1, characterized in that The method further comprises: The segment parameters of each storage segment in the storage resource are recorded, wherein the segment parameters correspond to the capability parameters in the capability information.
7. The method according to claim 6, characterized in that Determining at least one storage segment satisfying the storage request from the storage resources having different characteristics comprises: determining a request parameter in the storage request, wherein the request parameter corresponds to a capability parameter in the capability information; and One or more storage segments whose segment parameters match the request parameters are selected from the storage resources as the determined at least one storage segment.
8. The method according to claim 1, characterized in that The method further comprises: Obtaining physical parameters of the storage device; and According to the physical parameters of the storage device, the physical parameters of each storage segment in the storage resource are configured, wherein the physical parameters of the storage segment include one or both of the storage capacity size or the writing mode of the corresponding storage segment, the storage capacity size is equal to or an integer multiple of the storage capacity size of the physical block of the storage device, and the writing mode includes at least one of sequential writing and random writing.
9. The method according to claim 8, characterized in that The method further comprises: Sending a configuration request to one or more physically erased storage blocks, the configuration request including configuration information for configuring at least one of a writing mode or a storage medium type of the one or more physically erased storage blocks; receiving response information to the configuration request from the storage device; and confirming that the one or more physically erased storage blocks are correctly configured according to the configuration request, The physical storage blocks include the one or more physically erased storage blocks.
10. The method according to claim 9, characterized in that The storage medium type includes at least one of a single-bit cell (SLC), a multi-bit cell (MLC), a triple-level cell (TLC), or a quad-level cell (QLC).
11. The method according to claim 9, characterized in that The method further comprises: Mapping the one or more physically erased storage blocks to corresponding storage segments, wherein a total storage capacity of the one or more physically erased storage blocks is equal to a storage capacity of the corresponding storage segment; and Based on the mapping, the physical parameters of the corresponding storage segment are used to update the segment parameters of the corresponding storage segment, wherein the segment parameters include the storage capacity, writing mode and storage medium type of the corresponding storage segment. The writing mode and storage medium type of the corresponding storage segment are respectively consistent with the writing mode and storage medium type of the one or more physically erased storage blocks mapped to the corresponding storage segment.
12. The method according to claim 11, characterized in that Mapping the one or more physically erased storage blocks to corresponding storage segments includes: Mapping the identification of the corresponding storage segment with identifications of the one or more physically erased storage blocks; For the corresponding storage segments and the one or more physically erased storage blocks mapped in pairs, mapping the identification of the storage unit determined based on the storage granularity in the corresponding storage segments with the identification of the storage unit determined based on the storage granularity in the one or more physically erased storage blocks; and For the corresponding storage segment and the one or more physically erased storage blocks mapped in pairs, a write position in the corresponding storage segment is synchronized with a write position in the one or more physically erased storage blocks.
13. The method according to claim 11, characterized in that The method further comprises: Performing garbage collection operations in a storage area consisting of one or more storage segments whose writing mode is sequential writing; and Based on the garbage collection operation, simultaneously completing the garbage collection operation in the corresponding storage area in the storage device, The corresponding storage area in the storage device is composed of corresponding physically erased storage blocks aligned with the one or more sequentially written storage segments, and the writing mode of the corresponding physically erased storage blocks is sequential writing.
14. The method according to claim 8, characterized in that The physical parameters of the storage device include one or more of the storage capacity size, physical page size, physical page identifier, plane size, plane identifier, super block size or super block identifier of the physical storage block of the storage device.
15. The method according to claim 1, characterized in that The method further comprises: In the process of performing a write operation using the determined at least one storage segment, updating the state of the storage resource, The state includes an idle state, an open state or a closed state.
16. The method according to claim 15, characterized in that Updating the state of the storage resource includes: updating the state of the storage segment ready for the write operation to an open state; Updating the state of the storage segment that is full of data to a closed state; and The state of the storage segment from which all data has been moved and which can be used for data storage again is updated to an idle state.
17. The method according to claim 15, characterized in that The method further comprises: For a storage segment in an idle state, determining that a writing mode of the storage segment is to be changed; sending a notification to the storage device, the notification indicating that a write mode of one or more physically erased storage blocks mapped to the storage segment is to be changed; and In response to receiving response information indicating that the change is successful from the storage device, the writing mode of the storage segment is changed.
18. The method according to claim 17, characterized in that In response to the notification, the storage device adds the one or more physically erased storage blocks to a free storage block resource pool of the storage device.
19. The method according to claim 17, characterized in that The method further comprises: A request for the newly added one or more physically erased storage blocks is received from the storage device, wherein the newly added one or more physically erased storage blocks are selected by the storage device from a free storage block resource pool in the storage device.
20. A device for managing storage resources, characterized in that: include: A capability information providing module, configured to provide capability information related to storage resources; a request receiving module, configured to receive a storage resource request for the storage resource, the storage resource request being generated by a requesting application according to demand and based on the capability information; a storage segment determination module, configured to determine, according to the storage resource request, at least one storage segment satisfying the storage resource request from the storage resources with different characteristics; as well as The storage block determination module is configured to determine a physical storage block in the storage device for the storage resource request according to the determined at least one storage segment.
21. The device according to claim 20, characterized in that The capability information includes capability parameters, which include at least one of the following items: storage capacity, response latency level, data retention time level or data writing method, and the requirements include one or more of the following items: the size of the stored data from the requesting application, the hotness or coldness of the stored data, or the response speed.
22. The device according to claim 20, characterized in that The device also includes: The recording module is configured to record the segment parameters of each storage segment in the storage resource, wherein the segment parameters correspond to the capability parameters in the capability information.
23. The device according to claim 22, characterized in that The storage segment determination module includes: a determining submodule configured to determine a request parameter in the storage request, wherein the request parameter corresponds to a capability parameter in the capability information; and The selection submodule is configured to select one or more storage segments whose segment parameters match the request parameters from the storage resource as the determined at least one storage segment.
24. The device according to claim 20, characterized in that The device also includes: an acquisition module, configured to acquire physical parameters of the storage device; and a configuration module, configured to configure the physical parameters of each storage segment in the storage resource according to the physical parameters of the storage device, The physical parameters of the storage segment include one or both of the storage capacity or writing mode of the corresponding storage segment, the storage capacity is equal to or an integer multiple of the storage capacity of the physical block of the storage device, and the writing mode includes at least one of sequential writing and random writing.
25. The device according to claim 24, characterized in that The device also includes: A sending module, configured to send a configuration request to one or more physically erased storage blocks, wherein the configuration request includes configuration information for configuring at least one of a writing mode or a storage medium type of the one or more physically erased storage blocks; a receiving module configured to receive response information to the configuration request from the storage device; and a confirmation module configured to confirm that the one or more physically erased storage blocks are correctly configured according to the configuration request, The physical storage blocks include the one or more physically erased storage blocks.
26. The device according to claim 25, characterized in that The device also includes: a mapping module configured to map the one or more physically erased storage blocks to corresponding storage segments, wherein a total storage capacity of the one or more physically erased storage blocks is equal to a storage capacity of the corresponding storage segment; and an updating module configured to update the segment parameters of the corresponding storage segment with the physical parameters of the corresponding storage segment based on the mapping, wherein the segment parameters include the storage capacity size, writing mode and storage medium type of the corresponding storage segment, The writing mode and storage medium type of the corresponding storage segment are respectively consistent with the writing mode and storage medium type of the one or more physically erased storage blocks mapped to the corresponding storage segment.
27. The device according to claim 26, characterized in that The device also includes: The garbage collection operation module is configured to: perform a garbage collection operation in a storage area composed of one or more storage segments whose writing mode is sequential writing, and based on the garbage collection operation, simultaneously complete the garbage collection operation in the corresponding storage area in the storage device, The corresponding storage area in the storage device is composed of corresponding physically erased storage blocks aligned with the one or more sequentially written storage segments, and the writing mode of the corresponding physically erased storage blocks is sequential writing.
28. The device according to claim 20, characterized in that The device also includes: an updating module, configured to update the state of the storage resource during a write operation using the determined at least one storage segment, The state includes an idle state, an open state or a closed state.
29. The device according to claim 28, characterized in that The device also includes: A determination module is configured to determine, for a storage segment in an idle state, that a writing mode of the storage segment is to be changed; a sending module configured to send a notification to the storage device, the notification indicating that a write mode of one or more physically erased storage blocks mapped to the storage segment is to be changed; and The changing module is configured to change the writing mode of the storage segment in response to receiving response information indicating that the change is successful from the storage device.
30. An electronic device, characterized in that: The electronic device comprises an interface and a processor coupled to the interface, wherein the processor is configured to execute the method according to any one of claims 1 to 19.
31. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the method according to any one of claims 1 to 19 is implemented.
Citation Information
Patent Citations
Data storing method, device and equipment and storage medium
CN108334541A
Data storage method, device and system
CN110968253A
File storage method, device and equipment and storage medium
CN111382123A
Method, device, equipment and medium for accessing data
CN112148418A
Cited By
Resource data processing method and device, storage medium and electronic equipment
CN119847451A
Mapping table reconstruction method and device, electronic equipment and computer readable storage medium
CN120973701A
