File management method and electronic device

CN120540580BActive Publication Date: 2026-08-07GEER TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GEER TECH CO LTD
Filing Date
2025-04-14
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

[0005]本申请实施例的一个目的是提供一种新的文件管理的技术方案,以解决现有的文件管理系统在垃圾清理时存在的耗时较长、效率较低的问题

Benefits of technology

[0031]根据本公开的一个实施例,通过在触发设定事件的情况下,按照所述第一顺序的逆序,依次确定所述多个元数据页面中每一元数据页面的目标索引信息,可以解决现有的垃圾清理方式需要遍历整个存储器来标记无效数据时存在的垃圾清理过程耗时较长,效率较低的技术问题,提高垃圾处理的效率。并且,通过根据所述目标索引信息集,更新所述第二存储区域存储的多个数据,可以清理第二存储区域存储的无效数据,降低第二存储区域的占用。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120540580B_ABST
    Figure CN120540580B_ABST
Patent Text Reader

Abstract

The application discloses a file management method and an electronic device, and relates to the technical field of electronic devices. A memory comprises a first storage area and a second storage area, the second storage area is used for storing a plurality of data, the first storage area comprises a plurality of metadata pages, the plurality of metadata pages are sequentially written with a plurality of index information corresponding to the plurality of data in a first order, one index information corresponds to one data, and the method comprises the following steps: in the case that a set event is triggered, target index information of each metadata page in the plurality of metadata pages is sequentially determined in the reverse order of the first order, wherein the target index information is the index information that is in the latest writing order and in an effective state among the index information belonging to the same category in the plurality of index information; a target index information set is obtained according to the target index information of each metadata page in the plurality of metadata pages; and the plurality of data stored in the second storage area is updated according to the target index information set.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of memory technology, and more specifically, to a file management method and an electronic device. Background Technology

[0002] In file systems, frequent write and delete operations are common. Over time, a large amount of invalid data accumulates in the memory, consuming valuable storage space and reducing the actual usable space of the memory.

[0003] In existing file management systems, invalid data is typically marked by traversing data blocks in the memory, then the pages containing the invalid data are marked as reclaimable, the old pages marked as reclaimable are erased, and space is freed up for new data to be written.

[0004] However, existing file management systems require traversing the entire storage device to mark invalid data, resulting in a time-consuming and inefficient garbage collection process. Summary of the Invention

[0005] One objective of this application is to provide a new technical solution for file management to solve the problems of long processing time and low efficiency in existing file management systems during garbage collection.

[0006] According to a first aspect of this application, a file management method is provided, applied to a memory, the memory including a first storage area and a second storage area, the second storage area being used to store multiple data, the first storage area including multiple metadata pages, the multiple metadata pages being sequentially written with multiple index information corresponding to the multiple data in a first order, one index information corresponding to one data, the method comprising:

[0007] When a set event is triggered, the target index information of each of the plurality of metadata pages is determined in reverse order of the first order; wherein, the target index information is the index information that is written latest and is in a valid state among the index information belonging to the same category among the plurality of index information.

[0008] Based on the target index information of each of the multiple metadata pages, a target index information set is obtained;

[0009] Based on the target index information set, update multiple data stored in the second storage area.

[0010] Prior to this, determining the target index information of each of the plurality of metadata pages in reverse order of the first order includes:

[0011] Obtain multiple index information for each of the multiple metadata pages;

[0012] For each metadata page, the target index information of the metadata page is determined in reverse order of the first sequence, based on multiple index information of the metadata page.

[0013] Preferably, the data is key-value pair data, the index information includes keys and write status information, and determining the target index information of the metadata page based on multiple index information of the metadata page includes:

[0014] Based on multiple keys corresponding to multiple index information on the metadata page, candidate index information is determined from the multiple index information; wherein, the candidate index information is the index information corresponding to the first key appearing in reverse order of the first order;

[0015] If the write status information of the candidate index information indicates that the write status is committed, the candidate index information is determined as the target index information, and the target index information of the metadata page is obtained.

[0016] Preferably, the index information includes a data offset, the second storage area includes multiple data pages, the multiple data pages are written with multiple data in a second order, and updating the multiple data stored in the second storage area according to the target index information set includes:

[0017] Based on the multiple data offsets corresponding to the target index information set, the target index information set is divided into multiple target index information subsets corresponding to different data pages; wherein, one target index information subset corresponds to one data page, and the target index information subset includes multiple target index information sets whose data offsets belong to the same data page;

[0018] Based on the sorting of each data page in the second order, multiple target data corresponding to the target index information subset of the data page are written into the next data page of the current data page in the second storage area, and the data of the data page is deleted.

[0019] Preferably, after writing multiple target data corresponding to the target index information subset of the data page into the next data page of the current data page in the second storage area, the method further includes:

[0020] Update the target index information corresponding to the target data according to the write position of each target data among the plurality of target data.

[0021] Preferably, before triggering the set event, the method further includes:

[0022] When the memory is in a write state, the target data page is determined based on the remaining data volume of the current data page and the amount of data to be written.

[0023] If the next data page after the target data page is not empty, the set event is triggered.

[0024] Preferably, the step of determining that the next data page of the target data page is not empty includes:

[0025] If an index corresponding to the next data page of the target data page exists among the multiple index information stored in the first storage area, it is determined that the next data page of the target data page is not empty.

[0026] Preferably, the method further includes:

[0027] If the next data page after the target data page is empty, the data to be written is written to the target data page, and index information corresponding to the data to be written is established in the first storage area according to the writing position of the data to be written.

[0028] Preferably, the index information includes data write status information, and before triggering the set event, the method further includes:

[0029] When the memory is in a state of deleting the first index information, the first index information is rewritten to the current metadata page of the first storage area, and the write status information of the first index information is updated to the deletion status.

[0030] According to a second aspect of this application, an electronic device is provided, the electronic device including a controller and a memory, the memory including a first storage area and a second storage area, the second storage area being used to store a plurality of data, the first storage area being used to store a plurality of index information corresponding to the plurality of data, the controller storing computer instructions, the computer instructions being executed by the controller to perform the method as described in the first aspect.

[0031] According to one embodiment of this disclosure, by determining the target index information of each of the plurality of metadata pages in reverse order of the first sequence upon triggering a set event, the technical problem of long garbage collection time and low efficiency in existing garbage collection methods that require traversing the entire memory to mark invalid data can be solved, thereby improving the efficiency of garbage processing. Furthermore, by updating the plurality of data stored in the second storage area according to the target index information set, invalid data stored in the second storage area can be cleaned up, reducing the occupancy of the second storage area.

[0032] Other features and advantages of this application will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description

[0033] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments of the present application and, together with their description, serve to explain the principles of the present application.

[0034] Figure 1 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this application;

[0035] Figure 2 This is a flowchart illustrating a file management method according to an embodiment of this application;

[0036] Figure 3 This is a schematic diagram of the pages included in a memory according to an example of this application;

[0037] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0038] Various exemplary embodiments of the present application will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values ​​of the components and steps set forth in these embodiments do not limit the scope of the present application.

[0039] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the scope of this application and its application or use.

[0040] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.

[0041] In all the examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.

[0042] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.

[0043] <Hardware Configuration>

[0044] like Figure 1 The diagram shown is a block diagram of the hardware configuration of an electronic device 100 provided in one embodiment of this application.

[0045] See Figure 1 As shown, the electronic device 100 includes a controller 1000 and a memory 2000. The controller 1000 and the memory 2000 are communicatively connected.

[0046] Electronic device 100 can be a desktop computer, laptop computer, tablet computer, mobile phone, etc., and there is no limitation here.

[0047] Electronic device 100 can also be a storage device, such as flash memory, etc., without limitation here.

[0048] In other examples, memory 2000 may be, for example, flash memory, and controller 1000 may be a device set up independently of memory 2000. In this case, the electronic device may also be called a file management system.

[0049] In one embodiment, the controller 1000 can be as follows: Figure 1 As shown, it includes a processing unit 1100, a storage unit 1200, an interface device 1300, a communication device 1400, a display device 1500, an input device 1600, a speaker 1700, a microphone 1800, etc.

[0050] The storage unit 1200 stores instructions that control the processing unit 1100 to execute one or more steps of the method described in this embodiment, thereby providing relevant support for the file management method of this embodiment. This embodiment does not limit the specific steps executed by the processing unit 1100.

[0051] The processing unit 1100 may be, for example, a central processing unit (CPU), a microprocessor (MCU), etc. The storage unit 1200 may include, for example, ROM (Read-Only Memory), RAM (Random Access Memory), or non-volatile memory such as a hard disk. The interface device 1300 may include, for example, a serial bus interface (including a USB interface), a parallel bus interface, or an HDMI interface. The communication device 1400 may be capable of wired or wireless communication. The display device 1500 may be, for example, an LCD screen, an LED screen, or a touch screen. The input device 1600 may include, for example, a touch screen or motion input. The user can input / output voice information via a speaker 1700 and a microphone 1800.

[0052] Despite Figure 1 The controller 1000 is shown with multiple devices, but this application may only involve some of the devices, for example, only the processing unit 1100 and the storage unit 1200.

[0053] The memory 2000 can be communicatively connected to the controller 1000. The memory 2000 includes a first storage area and a second storage area. The second storage area is used to store multiple data. The first storage area includes multiple metadata pages. The multiple metadata pages are written sequentially in a first order to multiple index information corresponding to the multiple data. One index information corresponds to one data.

[0054] When a set event is triggered, the controller 1000 performs a garbage cleanup operation to update multiple data stored in the second storage area.

[0055] It should be understood that, despite Figure 1 Only one controller 1000 and one memory 2000 are shown, but this does not mean that the number of each is limited. The electronic device 100 may contain multiple controllers 1000 and multiple memories 2000.

[0056] In the above description, those skilled in the art can design instructions based on the solutions provided in this disclosure. How the instructions control the processor to operate is well known in the art, and therefore will not be described in detail here.

[0057] Figure 1 The electronic devices shown are for illustrative purposes only and are not intended to limit this disclosure, its application, or its use.

[0058] <Method Implementation>

[0059] Figure 2 This is a flowchart illustrating a file management method according to an embodiment of this application, applied to a memory, and specifically can be... Figure 1 The controller 1000 shown is implemented.

[0060] like Figure 3 The diagram illustrates the structure of an example memory. The memory includes a first storage area and a second storage area, the second storage area being used to store multiple data items. These multiple data items can be values ​​from key-value pairs or other types of data; no limitation is made here.

[0061] The first storage area includes multiple metadata pages, such as... Figure 3 As shown, the first storage area includes three metadata pages.

[0062] Multiple metadata pages sequentially write the corresponding index information for each piece of data in a first-order sequence. Each index corresponds to one piece of data.

[0063] An index can be metadata associated with a piece of data, used to quickly locate and access the specific location of that data in a second storage area.

[0064] For example, such as Figure 3 As shown, when storing key-value pairs with the key "Name" and the value "John" and the key "age" and the value "27" in memory, the index information such as the keys ("Name" and "age") can be stored in the first storage area, and the values ​​("John" and "27") can be stored in the second storage area. The index information includes not only the keys but also key-value pair write status information (i.e.,...). Figure 3 In the context of Flag: Commit, where "Commit" indicates that the write status of the key-value pair is committed, and the position of the value (i.e., ... Figure 3 Offset: 12288, Offset: 12292), and the number of bytes of the value (i.e. Figure 3 Size: 4, Size: 1). The key-value pair write status information indicates the write status of the key-value pair, which can be either committed or deleted. The key can be a unique identifier used to uniquely identify a piece of data. The value's position can be the starting position of the value in the second storage area. The number of bytes in the value indicates its size.

[0065] The first order can be page number order.

[0066] For example, the first order can be either page numbers in ascending order or page numbers in descending order; there is no limitation here.

[0067] according to Figure 2 As shown, the file management method of this embodiment may include the following steps S2100 to S2200:

[0068] Step S2100: When a set event is triggered, the target index information of each metadata page in the plurality of metadata pages is determined in reverse order of the first sequence.

[0069] In this embodiment, the event to be set can be a garbage collection event.

[0070] The garbage cleanup event can be triggered by user actions or when there is insufficient storage space in the second storage area; there are no restrictions here.

[0071] In one embodiment, before triggering the setting event in step S2100, the method further includes steps S3100 and S3200.

[0072] Step S3100: When the memory is in a write state, determine the target data page based on the remaining data volume of the current data page and the amount of data to be written.

[0073] In this embodiment, the memory is in a write state when the user performs a write operation.

[0074] The remaining amount of data on the current data page can be obtained from the random access memory, or it can be calculated and determined by the controller based on the amount of data used on the current data page and the total amount of data. No limitation is made here.

[0075] In one example, to improve processing efficiency, the remaining data on the current data page is retrieved from random access memory.

[0076] For example, if the total data size of the current data page is 4096 (i.e., 4KB), the used data size is 4000, the remaining data size of the current data page is 96, and the amount of data to be written is 32, then the target data page is the current data page. If the amount of data to be written is 100, then the target data page is the next data page after the current data page.

[0077] Step S3200: If the next data page of the target data page is not empty, determine to trigger the setting event.

[0078] In this embodiment, to avoid insufficient data space in the second storage area affecting the writing of data to be written, before writing the data to be written, it is first determined whether the next data page of the target data page is empty. If the next data page of the target data page is not empty, it means that the second storage area has been fully occupied, and a garbage collection event is triggered at this time.

[0079] There are several ways to determine whether the next data page of the target data page is empty.

[0080] For example, one can determine whether the next data page is empty by checking the data content of the next data page of the target data page, or by checking whether the index information corresponding to the next data page of the target data page exists in the first storage area.

[0081] In one embodiment, the step of determining that the next data page of the target data page is not empty includes:

[0082] If an index corresponding to the next data page of the target data page exists among the multiple index information stored in the first storage area, it is determined that the next data page of the target data page is not empty.

[0083] In this embodiment, the index information includes a data offset. First, the starting position of the next data page after the target data page can be determined, i.e., the data offset of the next data page after the target data page. For ease of description, this data offset is referred to as the target data offset. Then, it is checked whether there is any index information in the multiple index information stored in the first storage area that is greater than or equal to the target data offset. If there is index information greater than or equal to the target data offset, it is determined that the next data page after the target data page is not empty; otherwise, it is determined that the next data page after the target data page is empty.

[0084] According to the embodiments of this application, by determining that the next data page of the target data page is not empty when there is index information corresponding to the next data page of the target data page among the multiple index information stored in the first storage area, compared with the method of determining whether the next data page of the target data page is empty by obtaining the page content, it can quickly and conveniently determine whether the page is empty, thus improving the response efficiency of the file system.

[0085] In one embodiment, the method further includes step S3300.

[0086] Step S3300: If the next data page after the target data page is empty, write the data to be written to the target data page, and establish index information corresponding to the data to be written in the first storage area according to the writing position of the data to be written.

[0087] In this embodiment, after writing the data to be written to the target data page, an index information corresponding to the data to be written is established in the first storage area according to the writing position of the data to be written, which can facilitate the quick retrieval of the data to be written according to the index information in the future.

[0088] The index information corresponding to the data to be written can include the data name of the data to be written (in the case that the data to be written is key-value pair data, the data name of the data to be written is the key of the data to be written), the writing position of the data to be written, the number of bytes of the data to be written, and the writing status information of the data to be written.

[0089] In one embodiment, the index information includes data write status information.

[0090] In this embodiment, the data write status information is used to characterize the data write status. The data write status can be either a commit status or a delete status.

[0091] In these embodiments, before triggering the setting event in step S2100, the method further includes step S2000.

[0092] Step S2000: When the memory is in the state of deleting the first index information, the first index information is rewritten in the current metadata page of the first storage area, and the write status information of the first index information is updated to the deletion status.

[0093] In this embodiment, when a user deletes the first index information (e.g., the index information with the key "Name"), the memory is in the state of deleting the first index information. The current metadata page can be the metadata page of the current operation.

[0094] By rewriting the first index information (e.g., the index information with the key "Name") to the current metadata page and updating the write status information in the first index information to the delete status (i.e., Flag: Delete), the first index information can be deleted with a simple operation. Furthermore, when determining the target index information for each metadata page in reverse order of the first sequence, when the first index information in the delete status is encountered for the first time, all first index information stored in the first storage area is directly deleted. In other words, if the write status of the last written first index information (i.e., the first index information rewritten in step S2000 above) is in the delete status, it indicates that the first index information written before step S2000 also needs to be deleted, thus facilitating the rapid deletion of all first index information and improving the deletion efficiency of the file management system.

[0095] The reverse order of the first order in step S2100 can refer to the reverse order of the first order.

[0096] The page number refers to the page number, that is, the page number of a page refers to the page number of that page in memory.

[0097] For example, if the first order is the page number in ascending order, then the reverse of the first order can be the page number in descending order. The first storage area includes metadata page 1, metadata page 2, and metadata page 3, where 1, 2, and 3 are page numbers. In this case, the target index information for metadata page 3 is determined first, then the target index information for metadata page 2 is determined, and finally the target index information for metadata page 1 is determined.

[0098] The target index information is the index information that was written latest and is in a valid state among multiple index information that belongs to the same category of index information.

[0099] Due to deletion or update operations on the index information stored in the first storage area, multiple indexes belonging to the same category (i.e., the same key) may exist within the first storage area. To improve the efficiency of finding the target index information, for multiple indexes of the same category, we only need to focus on the index information with the latest write order, and disregard the index information with the earliest write order.

[0100] For example, if the first storage area has two indexes with the key "Device Name", it means that the second storage area has two values ​​corresponding to the key "Device Name". In this case, we only need to focus on the index with the key "Device Name" that was written latest in the first storage area. If the write status information included in the index with the key "Device Name" that was written latest in the first storage area indicates that the write status of the index with the key "Device Name" is committed (i.e., valid), then the index with the key "Device Name" that was written latest in the first storage area is a target index.

[0101] In one embodiment, to facilitate quick reading of target index information and improve garbage collection efficiency, the target index information can be stored in random access memory.

[0102] In one embodiment, step S2100, which involves determining the target index information of each metadata page in the plurality of metadata pages in reverse order of the first order, includes steps S2100.1 and S2100.2.

[0103] Step S2100.1: Obtain multiple index information for each of the multiple metadata pages.

[0104] In the example where target index information is stored in random access memory, the controller retrieves multiple index information for each of multiple metadata pages from the random access memory.

[0105] Step S2100.2: For each metadata page, determine the target index information of the metadata page according to the multiple index information of the metadata page in the reverse order of the first order.

[0106] In one embodiment, the data is key-value pair data, and the index information includes the key and write status information.

[0107] The write status information is used to characterize the write status of key-value pair data. The write status of key-value pair data can be either delete or commit.

[0108] In these embodiments, the step S2100.2, which involves determining the target index information of the metadata page based on multiple index information of the metadata page, includes steps S2100.21 and S2100.22.

[0109] Step S2100.21: Determine candidate index information from the multiple index information based on the multiple keys corresponding to the multiple index information of the metadata page.

[0110] In this embodiment, the candidate index information is the index information corresponding to the first key that appears in reverse order of the first sequence.

[0111] For example, the first storage area includes metadata page 1, metadata page 2, and metadata page 3, where 1, 2, and 3 are page numbers. If the index information with the key "Device ID" appears in metadata page 1, metadata page 2, and metadata page 3 respectively, the first order is the ascending order of page numbers, and the reverse order is the descending order of page numbers. In this case, the index information with the key "Device ID" in metadata page 3 is the first index information to appear in the reverse order of the first order, and therefore, the index information with the key "Device ID" in metadata page 3 is a candidate index information. The index information with the key "Device ID" in metadata page 2 and the index information with the key "Device ID" in metadata page 1 are not the first index information to appear in the reverse order of the first order, so they cannot be used as candidate index information.

[0112] It should be noted that a metadata page may include multiple alternative index information. The example of a metadata page including one alternative index information is merely an example and should not be taken as a limitation of this application.

[0113] Step S2100.22: If the write status information of the candidate index information indicates that the write status is committed, the candidate index information is determined as the target index information, and the target index information of the metadata page is obtained.

[0114] Continuing with the example above, one candidate index is the index with the key "Device ID" in metadata page 3. If its write status information indicates that the write status is deleted, it will not be used as the target index. If its write status information indicates that the write status is committed, it will be used as the target index.

[0115] Step S2200: Obtain the target index information set based on the target index information of each metadata page in the plurality of metadata pages.

[0116] In this embodiment, a metadata page may include multiple target index information, or it may include one target index information, or it may not include target index information; no limitation is made here.

[0117] Step S2300: Update multiple data stored in the second storage area according to the target index information set.

[0118] In one embodiment, the index information includes a data offset, which is used to characterize the location of the data in a second storage area.

[0119] For example, if a certain data is stored at the beginning of data page 2 in the second storage area, and the total data volume of each data page is 4096, then the data offset of that data is 4096.

[0120] The second storage area includes multiple data pages, and multiple data are written to the multiple data pages in a second order.

[0121] In this embodiment, the second order can be either from page number in ascending order or from page number in descending order; no limitation is made here.

[0122] The second order can be the same as the first order, or it can be different from the first order.

[0123] For example, the second storage area includes data page 4, data page 5, and data page 6. The second order can be the order of page numbers from smallest to largest, in which case data is written first on data page 4, then on data page 5, and finally on data page 6.

[0124] In this embodiment, step S2300 updates multiple data stored in the second storage area according to the target index information set, including steps S2300.1 to S2300.2.

[0125] Step S2300.1: Based on the multiple data offsets corresponding to the target index information set, divide the target index information set into multiple target index information subsets corresponding to different data pages.

[0126] In this embodiment, a subset of target index information corresponds to a data page, and the subset of target index information includes multiple target index information in the target index information set whose data offsets belong to the same data page.

[0127] For example, the second storage area includes three data pages: data page 4, data page 5, and data page 6. The total data volume of each data page is 4096. The target index information set includes seven target index information sets with data offsets of 0, 2034, 3000, 5000, 5020, 6000, and 7000. The index information sets with offsets of 0, 2034, and 3000 all correspond to data page 4, while the index information sets with offsets of 5000, 5020, 6000, and 7000 correspond to data page 5. Therefore, the target index information set can be divided into two subsets: one corresponding to data page 4 and another corresponding to data page 5. Data page 6 does not have a corresponding subset of target index information. The subset of target index information corresponding to data page 4 includes the index information sets with offsets of 0, 2034, and 3000. A subset of target index information corresponding to data page 5 includes index information with data offsets of 5000, 5020, 6000, and 7000.

[0128] Step S2300.2: Based on the sorting of each data page in the second order, write multiple target data corresponding to the target index information subset of the data page into the next data page of the current data page in the second storage area, and delete the data of the data page.

[0129] In this embodiment, the current data page can be the page where data is currently being written. One target index piece of information in the target index information subset corresponds to one target data item.

[0130] Continuing the example above, a subset of target index information corresponding to data page 4 includes index information with data offsets of 0, 2034, and 3000. A subset of target index information corresponding to data page 5 includes index information with data offsets of 5000, 5020, 6000, and 7000. If the second order is page number from smallest to largest, then first, based on the index information with data offsets of 0, 2034, and 3000 corresponding to data page 4, write multiple target data corresponding to the index information with data offsets of 0, 2034, and 3000 corresponding to data page 4 into the next data page of the current data page. After writing multiple data corresponding to the index information with data offsets of 0, 2034, and 3000 into the next data page of the current data page, delete the data on data page 4. This completes the garbage collection or update of data page 4. Based on the index information of data page 5 with data offsets of 5000, 5020, 6000, and 7000, write multiple data items corresponding to the index information of data page 5 with data offsets of 5000, 5020, 6000, and 7000 into the next data page of the current data page. After writing multiple data items corresponding to the index information of 5000, 5020, 6000, and 7000 into the next data page of the current data page, delete the data of data page 5, thereby completing the update of data page 5 (i.e., garbage collection).

[0131] By writing multiple target data sets corresponding to multiple target index subsets to the next data page in ascending order (i.e., second order), the logical order of data can be maintained, data management logic can be simplified, clutter can be reduced, data fragmentation can be minimized, and the overall utilization of memory can be improved. Furthermore, the garbage collection process can be made simpler and more direct, reducing potential errors and complexities during data migration.

[0132] By writing multiple target data corresponding to a subset of target index information of the data page into the next data page of the current data page in the second storage area, and then deleting the data of the data page, data loss after power failure can be avoided, thus improving the security of stored data.

[0133] In one embodiment, after writing the multiple target data corresponding to the target index information subset of the data page into the next data page of the current data page in the second storage area in step S2300.2, the method further includes:

[0134] Update the target index information corresponding to the target data according to the write position of each target data among the plurality of target data.

[0135] In this embodiment, the data offset in the target index information corresponding to the target data is updated according to the writing position of the target data, so as to find the written target data in the future.

[0136] According to the embodiments of this application, by determining the target index information of each metadata page in the plurality of metadata pages in reverse order of the first sequence when a set event is triggered, the technical problem of long garbage collection time and low efficiency in existing garbage collection methods that require traversing the entire memory to mark invalid data can be solved, thereby improving the efficiency of garbage processing. Furthermore, by updating the plurality of data stored in the second storage area according to the target index information set, invalid data stored in the second storage area can be cleaned up, reducing the occupancy of the second storage area.

[0137] <Equipment Example>

[0138] Figure 4 This is a schematic block diagram of an electronic device 400 according to an embodiment of the present application.

[0139] In this embodiment, as Figure 4 As shown, the electronic device 400 includes a controller 410 and a memory 420. The memory 420 includes a first storage area and a second storage area. The second storage area is used to store multiple data, and the first storage area is used to store multiple index information corresponding to the multiple data. The controller stores computer instructions. When the computer instructions are executed by the controller, they perform the method described in any of the above method embodiments.

[0140] In one embodiment, the electronic device 400 may be a mobile phone, tablet computer, etc.

[0141] In another embodiment, the electronic device 400 may be a storage device, such as a FLASH memory.

[0142] In one example, the electronic device could also be as follows: Figure 1 The electronic device shown.

[0143] This application may be a system, method, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of this application.

[0144] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electroelectronic devices, magnetoelectronic devices, optoelectronic devices, electromagnetic devices, semiconductor electronic devices, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination thereof. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.

[0145] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external electronic device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to computer-readable storage media within the respective computing / processing device.

[0146] The computer program instructions used to perform the operations of this application may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In one embodiment, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), can execute computer-readable program instructions to implement various aspects of this application by utilizing state information from the computer-readable program instructions.

[0147] Various aspects of this application are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0148] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0149] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0150] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions. It will be well known to those skilled in the art that implementation in hardware, implementation in software, and implementation using a combination of software and hardware are equivalent.

[0151] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical applications, or technological improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein. The scope of this application is defined by the appended claims.

Claims

1. A file management method, characterized in that, Applied to a memory, the memory includes a first storage area and a second storage area, the second storage area being used to store multiple data, and the first storage area including multiple metadata pages, wherein the multiple metadata pages are sequentially written with multiple index information corresponding to the multiple data in a first order, and one index information corresponds to one data, the method including: When a set event is triggered, the target index information of each of the plurality of metadata pages is determined in reverse order of the first order; wherein, the target index information is the index information that is written latest and is in a valid state among the index information belonging to the same category among the plurality of index information. Based on the target index information of each of the multiple metadata pages, a target index information set is obtained; Based on the target index information set, update multiple data stored in the second storage area; The index information includes a data offset, the second storage area includes multiple data pages, the multiple data pages are written with multiple data in a second order, and updating the multiple data stored in the second storage area according to the target index information set includes: Based on the multiple data offsets corresponding to the target index information set, the target index information set is divided into multiple target index information subsets corresponding to different data pages; wherein, one target index information subset corresponds to one data page, and the target index information subset includes multiple target index information sets whose data offsets belong to the same data page; Based on the sorting of each data page in the second order, multiple target data corresponding to the target index information subset of the data page are written into the next data page of the current data page in the second storage area, and the data of the data page is deleted.

2. The method according to claim 1, characterized in that, The step of determining the target index information of each metadata page in the plurality of metadata pages in reverse order of the first order includes: Obtain multiple index information for each of the multiple metadata pages; For each metadata page, the target index information of the metadata page is determined in reverse order of the first sequence, based on multiple index information of the metadata page.

3. The method according to claim 2, characterized in that, The data is key-value pair data, and the index information includes keys and write status information. Determining the target index information of the metadata page based on multiple index information items of the metadata page includes: Based on multiple keys corresponding to multiple index information on the metadata page, candidate index information is determined from the multiple index information; wherein, the candidate index information is the index information corresponding to the first key appearing in reverse order of the first order; If the write status information of the candidate index information indicates that the write status is committed, the candidate index information is determined as the target index information, and the target index information of the metadata page is obtained.

4. The method according to claim 1, characterized in that, After writing multiple target data corresponding to the target index information subset of the data page into the next data page of the current data page in the second storage area, the method further includes: Update the target index information corresponding to the target data according to the write position of each target data among the plurality of target data.

5. The method according to claim 1, characterized in that, Prior to triggering the set event, the method further includes: When the memory is in a write state, the target data page is determined based on the remaining data volume of the current data page and the amount of data to be written. If the next data page after the target data page is not empty, the set event is triggered.

6. The method according to claim 5, characterized in that, The steps to determine that the next data page of the target data page is not empty include: If an index corresponding to the next data page of the target data page exists among the multiple index information stored in the first storage area, it is determined that the next data page of the target data page is not empty.

7. The method according to claim 5, characterized in that, The method further includes: If the next data page after the target data page is empty, the data to be written is written to the target data page, and index information corresponding to the data to be written is established in the first storage area according to the writing position of the data to be written.

8. The method according to claim 1, characterized in that, The index information includes data write status information. Before triggering the set event, the method further includes: When the memory is in a state of deleting the first index information, the first index information is rewritten to the current metadata page of the first storage area, and the write status information of the first index information is updated to the deletion status.

9. An electronic device, characterized in that, The electronic device includes a controller and a memory. The memory includes a first storage area and a second storage area. The second storage area is used to store multiple data items, and the first storage area is used to store multiple index information corresponding to the multiple data items. The controller stores computer instructions, which, when executed by the controller, perform the method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Cache data processing method and device

    CN106294206A

  • Data processing method and device based on nonvolatile storage space and related equipment

    CN119718191A