WO2020006771A1 - 一种文件***调整方法及设备 - Google Patents
一种文件***调整方法及设备 Download PDFInfo
- Publication number
- WO2020006771A1 WO2020006771A1 PCT/CN2018/094924 CN2018094924W WO2020006771A1 WO 2020006771 A1 WO2020006771 A1 WO 2020006771A1 CN 2018094924 W CN2018094924 W CN 2018094924W WO 2020006771 A1 WO2020006771 A1 WO 2020006771A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- area
- metadata
- file system
- data
- backup
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
Definitions
- the present application relates to the storage field, and in particular, to a file system adjustment method and device.
- the offline and online file system partition adjustment technology directly moves the data and metadata of the file system, and the overlapped data will be temporarily recorded in memory during the move.
- the partition adjustment process cannot be recovered, the data recorded in the memory will be lost and cannot be recovered, and eventually the file system will be directly damaged, resulting in irreparable losses for the user.
- F2FS partition adjustment program provided by the open source community.
- the existing F2FS tail area expansion adjustment technology adjusts and moves each area in the order of main area, SSA, NAT, SIT, CKPT, and SB.
- main area When the main area is modified, it is directly moved and the latest CKPT is modified in place and effective.
- SIT and NAT backup without remote update.
- some data in the area will be read into the memory first, and then new data will be written. The state will be discarded without moving process. After power failure, it cannot be restored to the state before power failure. Continue Relocation, and the latest CKPT is invalid due to the local update of CKPT.
- Embodiments of the present invention provide a file system adjustment method and device, which can avoid data loss of the file system during the process of adjusting the storage space of the file system.
- a file system adjustment method including: first, determining an adjustment range of a storage space of the file system, determining an adjustment range of a data area of the file system according to the adjustment range of the storage space of the file system, The adjustment range performs a data update operation; subsequently, an effective backup area of each first metadata area can be used to construct the adjusted first metadata area and move all metadata areas of the file system.
- the metadata area of the file system includes a first metadata area, and the first metadata area includes two backup areas.
- the second metadata area in the data area of the file system is updated according to the adjusted metadata area of the file system.
- the second metadata area is the metadata area without duplicate backup in the data area of the file system.
- the adjustment range of the storage space of the file system can be determined first, and the adjustment of the data area of the file system can be further determined according to the adjustment range of the file system. Range, performs a data update operation on the adjustment range of the data area. Subsequently, for each first metadata area of the file system, the first metadata area includes two backup areas, and an effective first backup area of the first metadata area is used to construct an adjusted first metadata area.
- a moving order of all metadata areas of the file system may also be determined according to a preset algorithm, and all metadata areas of the file system are moved according to the moving order.
- the second metadata in the data area of the file system may also be updated according to the metadata area adjusted by the file system.
- the so-called second metadata is non-dual backup metadata that exists in the data area. It can be seen that in the method provided by the embodiment of the present invention, when data of the file system is updated (such as moving), a new metadata area is constructed by using the effective backup in the dual backup, and the data is safely migrated through the dual backup file system feature. , To achieve the security adjustment of the file system, in the process of adjusting the storage space of the file system can avoid the data loss of the file system.
- performing the data update operation on the adjustment range of the data area includes: if the data area of the file system is reduced, moving data within the adjustment range of the data area To the free data block; if the data area of the file system is extended, the data area is expanded to include an adjustment range, and the adjustment range in the data area is empty.
- An embodiment of the present invention provides a specific implementation manner for performing a data update operation on a data area of a file system.
- determining an adjustment range of a data region of the file system, and performing data update on the adjustment range of the data region After the operation the method further includes: writing a second version number; the valid version number is changed from the first version number to the second version number.
- an effective backup area of each first metadata area is used to construct an adjusted first metadata area and move all metadata areas of the file system. Including: using the effective backup area of the first metadata area to be reduced to construct the reduced first metadata area; determining a moving order of all metadata areas of the file system according to a preset algorithm, and moving all metadata of the file system according to the moving order. Data area; use the effective backup area of the first metadata area that needs to be expanded to construct the enlarged first metadata area.
- the embodiments of the present invention provide specific implementation methods for reconstructing the metadata area and moving the metadata area, which can ensure that the metadata area of the file system is not affected by each other during the adjustment process.
- the first metadata area includes a first backup area and a second backup area; the first backup area is currently valid Backup area; using the effective backup area of the first metadata area to construct the adjusted first metadata area includes: determining the reduced range of the first metadata area, and copying data other than the reduced range in the first backup area to the second The backup area; or, determining the expanded range of the first metadata area, copying the data in the first backup area to the second backup area, and the second backup area includes the expanded area of the first metadata area.
- the reconstruction of the metadata area may be adjusting the scope of the metadata area, and specifically, the scope of the metadata area may be expanded or reduced.
- the first metadata region includes a first backup region and a second backup region; the first backup region is currently valid Backup area; using the effective backup area of the first metadata area to construct the adjusted first metadata area includes: updating data in the first backup area, and storing the updated data in the second backup area.
- the reconstruction of the metadata area may be adjusting the content of the metadata area, and specifically the data stored in the metadata area may be modified.
- updating the data in the first backup area specifically includes: reading the address of the metadata area from the first backup area , Updating the address of the read-out second metadata area according to the adjustment range of the file system.
- the address stored in the metadata area may be modified.
- an effective backup area of each first metadata area is used to construct an adjusted first metadata area and move it After all the metadata areas of the file system, the method further includes: writing a third version number; the valid version number is unchanged, and is the second version number.
- the method of moving all metadata areas of the file system includes: determining the reduced range of the first metadata area when the first metadata area is moved, and only Move other data outside the reduced range in the first metadata area; or, determine the expanded range of the first metadata area, move the adjusted first metadata area, or move the adjusted first metadata area and clear it Data within the expanded range of the first metadata area; the adjusted first metadata area includes the expanded range of the first metadata area.
- the method further includes: when moving a metadata area, preset along the block unit.
- the direction moves the data in the metadata area in turn; the preset direction points to the adjusted start address of the metadata area or the adjusted end address of the metadata area.
- updating the second metadata area in the data area of the file system according to the adjusted metadata area of the file system includes: traversing each of the file systems A valid data block, looking for the metadata region adjusted by the file system to obtain the second metadata region corresponding to the valid data block and the offset of the valid data block in the second metadata region, and corresponding to the offset in the second metadata region.
- the data block address is updated to the address of a valid data block.
- the method further includes: updating the second metadata in the data area of the file system according to the metadata area adjusted by the file system. After the data area, a fourth version number is written, and the fourth version number is a valid version number.
- a device which includes a processing unit for determining an adjustment range of a storage space of a file system, determining an adjustment range of a data area of the file system according to the adjustment range of the storage space of the file system, and The adjustment range performs a data update operation; the processing unit is further configured to use the effective backup area of each first metadata area to construct the adjusted first metadata area and move all the metadata areas of the file system; the file system's metadata area Including a first metadata area, the first metadata area including two backup areas; the processing unit is further configured to update the second metadata area in the data area of the file system according to the adjusted metadata area of the file system, and the second metadata area
- the data area is the metadata area without dual backup among the data areas of the file system.
- the adjustment range of the storage space of the file system when adjusting the size of the storage space occupied by the file system on the disk, the adjustment range of the storage space of the file system can be determined first, and the adjustment range of the data area of the file system can be further determined according to the adjustment range of the file system. , Perform a data update operation on the adjustment range of the data area. Subsequently, for each first metadata area of the file system, the first metadata area includes two backup areas, and an effective first backup area of the first metadata area is used to construct an adjusted first metadata area.
- a moving order of all metadata areas of the file system may also be determined according to a preset algorithm, and all metadata areas of the file system are moved according to the moving order.
- the second metadata in the data area of the file system may also be updated according to the metadata area adjusted by the file system.
- the so-called second metadata is non-dual backup metadata that exists in the data area. It can be seen that in the method provided by the embodiment of the present invention, when data of the file system is updated (such as moving), a new metadata area is constructed by using the effective backup in the dual backup, and the data is safely migrated through the dual backup file system feature. , To achieve the security adjustment of the file system, in the process of adjusting the storage space of the file system can avoid the data loss of the file system.
- the processing unit is specifically configured to:
- the data area of the file system is reduced, the data within the adjustment range of the data area is moved to a free data block; if the data area of the file system is extended, the data area is expanded to include the adjustment range, and the The adjustment range is empty.
- the processing unit is further configured to determine an adjustment range of a data region of the file system, and After performing the data update operation, the second version number is written; the effective version number is changed from the first version number to the second version number.
- the processing unit is specifically configured to construct a reduced first metadata area by using an effective backup area of the first metadata area that needs to be reduced; Let the algorithm determine the moving order of all metadata areas of the file system, and move all metadata areas of the file system according to the moving order; use the effective backup area of the first metadata area that needs to be expanded to construct the enlarged first metadata area.
- the first metadata area includes a first backup area and a second backup area; the first backup area is currently valid A backup area; the processing unit is specifically configured to determine a reduced range of the first metadata area and copy data other than the reduced range in the first backup area to the second backup area; or determine an enlarged range of the first metadata area, The data in the first backup area is copied to the second backup area, and the second backup area includes an expanded range of the first metadata area.
- the first metadata region includes a first backup region and a second backup region; the first backup region is currently valid Backup area; using the effective backup area of the first metadata area to construct the adjusted first metadata area includes: updating data in the first backup area, and storing the updated data in the second backup area.
- the processing unit is specifically configured to read the address of the metadata area from the first backup area, and according to the file system's The adjustment range updates the address of the read-out second metadata area.
- the processing unit is further configured to use an effective backup area of each first metadata area to construct an adjusted first After the metadata area is moved and all metadata areas of the file system are moved, the third version number is written; the valid version number is unchanged, and it is the second version number.
- the processing unit is specifically configured to determine the first meta data when the first meta data area is moved. Reduce the scope of the data area, and move only other data outside the reduced scope in the first metadata area; or, determine the expanded scope of the first metadata area, move the adjusted first metadata area, or move the adjusted The first metadata area clears data in the expanded range of the first metadata area; the adjusted first metadata area includes the expanded range of the first metadata area.
- the processing unit is further configured to sequentially move a metadata area in a preset direction when moving a metadata area.
- the data in the metadata area; the preset direction points to the adjusted start address of the metadata area or the adjusted end address of the metadata area.
- the processing unit is specifically configured to traverse each valid data block in the file system and find the metadata area adjusted by the file system to obtain a valid data block corresponding The second metadata region and the offset of the valid data block in the second metadata region, and update the address of the data block corresponding to the offset in the second metadata region to the address of the valid data block.
- the processing unit is further configured to update the second metadata in the data area of the file system according to the metadata area adjusted by the file system. After the data area, a fourth version number is written, and the fourth version number is a valid version number.
- FIG. 1 is a schematic diagram of a prior art file system adjustment method
- FIG. 2 is a schematic diagram of F2FS provided by an embodiment of the present invention.
- FIG. 3 is a structural block diagram of a device according to an embodiment of the present invention.
- FIG. 4 is a schematic flowchart of a file system adjustment method according to an embodiment of the present invention.
- FIG. 5 is a schematic diagram of adjusting a file system according to an embodiment of the present invention.
- FIG. 6 is a schematic diagram of updating a metadata area according to an embodiment of the present invention.
- FIG. 7 is another schematic diagram of metadata area update according to an embodiment of the present invention.
- FIG. 8 is another schematic diagram of metadata area update according to an embodiment of the present invention.
- FIG. 9 is another schematic diagram of metadata area update according to an embodiment of the present invention.
- FIG. 10 is a schematic flowchart of determining a moving order of a metadata region according to an embodiment of the present invention.
- FIG. 11 is a schematic diagram of data movement provided by an embodiment of the present invention.
- FIG. 12 is another schematic diagram of moving data according to an embodiment of the present invention.
- FIG. 13 is another schematic diagram of moving data according to an embodiment of the present invention.
- FIG. 14 is a schematic diagram of a metadata area that needs to be moved according to an embodiment of the present invention.
- FIG. 15 is another schematic diagram of metadata area update according to an embodiment of the present invention.
- FIG. 16 is another structural block diagram of a device according to an embodiment of the present invention.
- FIG. 17 is another structural block diagram of a device according to an embodiment of the present invention.
- the file system is an important part of the computer operating system. It is used to organize, manage, and store files on the computer's storage medium (disk or flash memory).
- the file system can be divided into multiple blocks. Typically, for most file systems, each block is the same size, and a block size can be 4096 bytes.
- the file system adjustment method provided by the embodiment of the present invention is applicable to a dual backup file system, a so-called dual backup file system, that is, two backups of metadata can exist in the file system.
- a dual backup file system a so-called dual backup file system, that is, two backups of metadata can exist in the file system.
- F2FS file system Flash-friendly file system, Flash Friendly File System.
- flash-friendly file system Flash Friendly File System
- the following uses F2FS as an example to introduce the distribution of dual backup file systems on disks.
- the file systems adapted by the method provided in the embodiments of the present invention include, but are not limited to, F2FS, and can also be applied to other dual-backup file systems.
- the storage space of the F2FS includes a metadata area and a data area.
- the metadata area includes a super block (SB), a checkpoint (CKPT), a segment information table (SIT), a node address table (node address table, NAT), and a segment summary area (segment summary area (SSA).
- the data area includes a node block and a data block.
- the data block stores user data in the file system.
- the node block is another metadata structure in the file system and holds a file system in the file system. Metadata of the object. It should be noted that each node in the main area has only one backup. In the embodiment of the present invention, it can be referred to as the metadata of the Wushuang backup.
- F2FS has segments (sections), sections (sections), and zones (zones).
- each metadata area including:
- SB is the 0th and 1st block of the file system.
- SB includes two identical backups, respectively SB0 and SB1.
- SB0 corresponds to the 0th block and SB1 corresponds to the 1st block.
- SIT is used to record the allocation of blocks in each segment in the main area.
- SIT includes the SIT0 set and the SIT1 set.
- SIT0 and SIT1 both include SIT blocks.
- the currently valid SIT block constitutes one backup, and the remaining SIT blocks constitute another backup.
- each SIT block contains 55 SIT entries. Among them, SIT entry records the usage of 512 blocks in its corresponding segment.
- NAT is used to record the address of the node.
- NAT includes two sets: the NAT0 set and the NAT1 set. Both NAT0 and NAT1 include NAT blocks.
- the currently valid NAT block constitutes one backup, and the remaining NAT blocks constitute another backup.
- each NAT block contains 455 NAT entries. Each NAT entry records the address of a corresponding node. The position of the nat entry in the NAT area indicates the node's nid (identity of the node).
- CKPT is two segments after SB alignment.
- the starting address of the CKPT is aligned in segments.
- CKPT includes two identical backups, namely CKPT0 and CKPT1.
- only one CKPT backup is valid.
- CKPT0 is currently valid
- CKPT1 can be written next time
- CKPT1 is valid after CKPT1 is reliably written to the device
- CKPT0 can continue to be written next time.
- the currently stable and valid CKPT backup cannot be written, and only another CKPT backup can be written.
- the CKPT includes the version number.
- the newer CKPT is the currently valid CKPT identified by the file system.
- the version number of CKPT0 is 0, the version number of CKPT1 is 1, and CKPT1 is valid. Further, a version number 2 is written in CKPT0, the version number of CKPT1 is still 1, and the version number of CKPT0 is newer, which is the currently valid CKPT.
- CKPT0 and CKPT1 both include NAT version bitmap and SIT version bitmap.
- the NAT version bitmap records the currently valid NAT blocks, such as: NAT version in CKPT0 records which NAT blocks are valid for CKPT0; NAT version map in CKPT1 records which NAT blocks are valid for CKPT1.
- the SIT version bitmap records the currently valid SIT blocks, such as: The SIT version in CKPT1 records which SIT blocks are valid for CKPT1; the SIT version in CKPT0 records which SIT blocks are valid for CKPT0.
- the SSA includes multiple summary blocks, one summary block corresponds to one segment.
- a summary block includes 512 entries, and each entry corresponds to a block, which records which node the block belongs to and its position in the node.
- metadata areas such as SB, SIT, NAT, and CKPT, there is only one backup of the SSA in the F2FS file system.
- the data and metadata of the file system are directly moved to adjust the size of the file system, and the overlapped data is temporarily recorded in the memory during the moving process.
- the partition adjustment process cannot be recovered.
- the data recorded in the memory will be lost and cannot be recovered, which will directly damage the file system and cause irreparable losses to the user.
- An embodiment of the present invention provides a file system adjustment method.
- the adjustment range of the storage space of the file system can be determined first, and the file system data is further determined according to the adjustment range of the file system.
- the adjustment range of the region Perform a data update operation on the adjustment range of the data region.
- the first metadata area includes two backup areas, and an effective first backup area of the first metadata area is used to construct an adjusted first metadata area.
- a moving order of all metadata areas of the file system may also be determined according to a preset algorithm, and all metadata areas of the file system are moved according to the moving order.
- the second metadata in the data area of the file system may also be updated according to the metadata area adjusted by the file system.
- the so-called second metadata is non-dual backup metadata that exists in the data area. It can be seen that in the method provided by the embodiment of the present invention, when data of the file system is updated (such as moving), a new metadata area is constructed by using the effective backup in the dual backup, and the data is safely migrated through the dual backup file system feature. , To achieve the security adjustment of the file system, in the process of adjusting the storage space of the file system can avoid the data loss of the file system.
- the file system adjustment method provided by the embodiment of the present invention may be applied to the device shown in FIG. 3.
- the device includes a processor 20, a memory 21, and a communication interface 22.
- the processor 20, the memory 21, and the communication interface 22 communicate via a bus 23.
- the device can also communicate with other devices through the communication interface 23.
- the processor 20 includes N processor cores (core 1, ..., core k, ..., core N), such as at least one central processing unit (CPU), and each CPU may be a single processor.
- the core processor single-CPU
- the core processor can also be a multi-core processor (multi-CPU).
- the multiple processor cores may share time and may simultaneously read data stored in the memory 21.
- the memory 21 is the foregoing storage medium, and the memory may store data, software programs, modules, and the like.
- the memory 21 may be a hard disk (HDD), a solid-state drive (SSD), a disk storage medium or a flash memory device, or can be used to carry or store a desired program code in the form of an instruction or a data structure and Any other medium that can be accessed by the processor 20, but is not limited thereto.
- the device can use a file system to manage files, and the data of these files is stored in the memory 21 of the device.
- the processor 20 calls the code in the memory 21 to execute the file system adjustment method according to the embodiment of the present invention, and adjusts the size of the storage space of the file system, such as: reducing the storage space of the file system and expanding the file. System storage space.
- An embodiment of the present invention provides a file system adjustment method, which is applicable to a dual backup file system. As shown in Figure 4, the method includes the following steps:
- the device determines an adjustment range of a storage space of a file system, determines an adjustment range of a data region of the file system according to the adjustment range of the file system, and performs a data update operation on the adjustment range of the data region.
- the storage space of the file system includes a metadata area of the file system and a data area of the file system.
- the device may compare the fields of the adjusted metadata area with the fields of the current metadata area to determine the adjustment range of the data area of the file system, such as the range in which the data area of the file system needs to be moved, or the file The data area of the system needs to be extended.
- the data update operation performed on the data area of the file system includes the following two cases:
- reducing the data area of the file system may be reducing the head of the area or reducing the tail of the area.
- the data area of the file system is extended, the data area is extended to an area including the adjustment range.
- the data area of the extended file system may be the head of the extended area, or the tail of the extended area.
- the extended segment data area may be left blank or left unprocessed, but it cannot affect Data area.
- the device writes the second version number, and updates the currently valid version number from the first version number to the second version number.
- a newer CKPT version number can be reliably written, and the effective backup area is changed from the effective backup area of the first version number to the second version.
- Valid backup area For example, before step 401, the version number of CKPT0 in the file system is 0, and the version number of CKPT1 is 1. Before step 401, CKPT1 is valid, and the effective backup area is the effective backup area of CKPT1, that is, the first backup area is the effective backup area of CKPT1. .
- a newer version number can be written in CKPT0, such as: version number 2.
- version number 2 is a valid version number
- CKPT0 is valid
- the valid backup area is a valid backup of CKPT0. Area, that is, the first backup area becomes a valid backup area of CKPT0.
- the device uses an effective backup area of each first metadata area to construct an adjusted first metadata area and moves all metadata areas of the file system; the first metadata area includes two backup areas.
- the metadata area of the file system includes the first metadata area
- the metadata area of the file system may also include other metadata areas without peer backup, such as SSA.
- the construction of the metadata area of the file system includes adjusting the range of the metadata area, or the content of the metadata area may be modified.
- the first backup area may be updated. And store the updated data in the second backup area.
- the reduced first metadata area (the metadata area with dual backups) is reconstructed first, then all metadata areas are moved, and finally the enlarged first metadata area is reconstructed.
- a reduced first metadata area is constructed by using a valid backup area of the first metadata area that needs to be narrowed down; a moving order of all metadata areas of the file system is determined according to a preset algorithm, and the moving order is determined according to the moving order Moving all metadata areas of the file system; constructing an enlarged first metadata area using a valid backup area of the first metadata area that needs to be expanded.
- the content of the metadata area may be modified before moving all the metadata areas of the file system, or The content of the metadata area is modified after all the metadata areas of the file system are moved.
- the first metadata area is a metadata area including two backup areas, such as NAT and SIT.
- NAT, SIT, and SSA can be moved and rebuilt.
- some adjustments of the first metadata area are related to the adjustment size of the storage space of the file system, such as NAT.
- the content of the NAT can be modified according to the adjustment range of the storage space of the file system.
- a new NAT is first constructed by using a backup of the NAT. After the metadata of both backups is rebuilt, all the metadata areas including the NAT are moved. Alternatively, move the metadata area including NAT first, and then use a backup of NAT to build a new NAT.
- Some adjustments of the first metadata area are related to the adjustment of the data area of the file system, such as SIT.
- SIT data area of the file system
- the scope of the SIT needs to be reduced.
- a backup of the SIT is used to build the reduced size.
- SIT after the metadata of both backups has been reconstructed, all metadata areas including SIT are moved.
- the scope of the SIT needs to be expanded.
- all metadata areas including the SIT are moved, and then a backup of the SIT is used to construct the expanded SIT.
- the reconstruction of the first metadata area includes the following two cases:
- the range of the first metadata area is changed, which mainly includes the reduction of the first metadata area or the expansion of the first metadata area. It may be that a change in the data area of the file system causes a change in the range of the first metadata area. For example, the data area of the file system is reduced, and the first metadata area may be reduced, such as: the reduction of the main area may cause the SIT to shrink; the data area of the file system is enlarged, and the first metadata area may be expanded, such as: the expansion of the main area may SIT expanded.
- the adjustment range of the first metadata region may be determined according to the adjustment range of the data region of the file system, and then a valid first backup of the first metadata region is used to construct a new first metadata region.
- the reduced range of the first metadata region is determined according to the reduced range of the data region of the file system, and data other than the reduced range in the first backup of the first metadata region is copied to the second backup. region.
- the first metadata area includes a first backup area and a second backup area.
- the first backup area is a backup area in which the first metadata area is currently valid, that is, the CKPT currently valid when performing step 403.
- the second backup area is a backup area composed of invalid blocks corresponding to the currently valid block.
- the adjustment range of the first metadata region may also be determined by other methods, which is not limited in the embodiment of the present invention. Taking SIT as an example, when the data area of the file system needs to be reduced, the SIT area also needs to be reduced.
- a reduced SIT can be constructed in the second backup area of the SIT.
- the version number of CKPT0 in the file system before step 401 is 0 and the version number of CKPT1 is 1.
- CKPT1 is valid
- the valid backup area is the valid backup area of CKPT1.
- a newer version number 2 may be written in CKPT0.
- the valid backup area is the valid backup area of CKPT0.
- the first backup area may be a backup area composed of a valid SIT block (or NAT block) corresponding to CKPT0;
- the second backup area may be a backup area composed of an invalid SIT block corresponding to a valid SIT block of CKPT0.
- the expanded range of the first metadata area may be determined according to the expanded range of the data area of the file system, and further, the data in the first backup area of the first metadata area is copied to the first metadata area.
- Two backup areas, and the second backup area includes an expanded range of the first metadata area.
- the extended range of the second metadata area in the second backup area may also be set to be empty.
- SIT when the data area of the file system needs to be expanded, the SIT area also needs to be expanded.
- An expanded SIT can be constructed in the second backup area of the SIT, that is, the data in the first backup area is copied to the second backup area.
- the content of the first metadata area changes. It mainly includes the increase or decrease of the addresses stored in the first metadata area. It may be that a change in the storage space of the file system causes the address stored in the first metadata area (such as the address of the second metadata area) to change. For example, the storage space of the file system is reduced or expanded, and the address of the node block stored in the first metadata area (that is, the second metadata area described in the embodiment of the present invention) may be changed.
- the correction amount of the address stored in the first metadata area may be determined according to the adjustment range shrink of the storage space of the file system, and then a valid first backup area of the first metadata area is used to construct a new first metadata area.
- the address is read from the valid backup area of the first metadata area, the read address is modified according to the correction amount, and the modified address is correspondingly stored in the second backup area of the first metadata area.
- the correction amount of the address stored in the first metadata area may be an adjustment range shrink of the storage space of the file system.
- the addresses stored in the currently valid backup area of the first metadata area need to be modified according to the reduced scope of the storage space of the file system, such as the address of the second metadata area, where the first
- the binary data area may be a metadata area without a double backup in the data area of the file system, such as a node block (node block).
- an effective first backup area (first backup area) of the first metadata area is used to construct the adjusted first metadata area, that is, the address of the second metadata area is read out in the first backup area, and then the file can be read based on the file.
- the storage space of the system is reduced to modify the read-out second metadata area address, and then the modified second metadata area address is written into the second backup area.
- shrink may be subtracted from the addresses of the read-out second metadata areas, and shrink is a reduced value of the storage space of the file system.
- the first metadata area includes a first backup area and a second backup area.
- the first backup area is a backup area currently valid among the two backup areas of the first metadata area, and is a block corresponding to the currently valid CKPT ( Such as: NAT block backup area, the second backup area is a backup area made up of invalid blocks corresponding to the currently valid block.
- the address stored in the current valid backup area of the first metadata area needs to be modified according to the expanded range of the storage space of the file system, such as the address of the second metadata area, where the first
- the binary data area can be a metadata area without double backup in the data area of the file system, such as: node block node.
- the node block address is read from the effective backup area (first backup area) of the first metadata area, and the read node block addresses are all increased by -shrink (shrink is less than 0), -shrink is the file system
- the expanded value of the storage space can further write the modified node block address into the second backup area of the first metadata area.
- a moving order of all metadata areas of the file system may be determined first according to a preset algorithm, and then all metadata areas of the file system may be moved according to the determined moving order.
- the preset algorithm may be: pushing the metadata area to be moved into the stack in a certain order, and moving in the order of popping the stack. For example, proceed from left to right. First push the leftmost metadata area onto the stack.
- the data in the metadata area is sequentially moved in a preset direction in units of blocks; the preset direction points to the adjusted start address of the metadata area or the metadata area adjustment After the end address to ensure that the metadata area data is not overwritten.
- the metadata region to be moved has four blocks of ABCD in order from left to right, and the end address of the metadata region is shifted to the right, so the four blocks of ABCD can be moved in order from right to left. First move D to the right, the end address of D after the move is aligned with the end address of the metadata area, then move C to the right, then move B to the right, and finally move A to the right.
- the SSA can be reconstructed when the metadata area of the file system is moved. Specifically, in the scenario of reducing the file system, when the SSA area is moved, the reduction range of the SSA area is determined, and only data other than the reduction range described in the SSA is moved.
- the adjusted SSA area includes the expanded range of the SSA area.
- the device writes the third version number, and the currently valid version number is still the second version number.
- an older CKPT version number can be reliably written.
- the version number of CKPT0 in the file system is 2, and the version number of CKPT1 is 1.
- an older version number can be written in CKPT1, which can be a version number smaller than 0, such as- 1.
- the valid backup area of the older version number can be designated as the currently valid backup area, for example, the valid backup area of CKPT1 is designated as the currently valid backup area.
- step 404 the reconstruction and relocation of the metadata area in the file system are completed. Further, the metadata in the file system's data area without backup can be updated according to the already stable metadata area, and the node blocks in the main area are updated. (node block).
- each valid data block in the file system is traversed, a metadata region adjusted by the file system is searched to obtain a second metadata region corresponding to the valid data block, and the valid data block is in the first
- the offset in the binary data area updates the address of the data block corresponding to the offset in the second metadata area to the address of the valid data block.
- the currently valid backup area in the embodiments of the present invention refers to the latest valid backup area or a designated backup area.
- the current effective backup area in step 401 is the latest effective backup area, that is, the effective backup area of CKPT1.
- a newer version number is written in CKPT0
- the current valid backup area is the latest valid backup area, that is, the valid backup area of CKPT0.
- the current valid backup area is the latest valid backup area and remains the valid backup area of CKPT0.
- an older version number is written in CKPT1
- the valid backup area of the older version number CKPT1 is designated as the previous valid backup area.
- the currently valid backup area is the designated backup area, and it can be considered as a backup area of current concern.
- the valid backup area of the older version number CKPT1 is designated as the current valid backup. region.
- a newer version number may be written after step 405, for example, a version number 4 is written in CKPT0.
- the first stage is to migrate data to adapt to the adjustment of the file system.
- the fields of the adjusted metadata area compare with the fields of the current metadata area to determine how many main areas need to be moved, and find free blocks, and move the effective blocks of the main area that need to be moved to free. Inside the block. Referring to FIG. 5, the dotted line shows the address of the adjusted metadata area. The length of each adjusted area is obtained by calculating the adjusted super_block address. Finally, the adjusted main_blkaddr is compared with the main_blkaddr before adjustment. The main_shrink of this adjustment is obtained.
- the node needs to be moved. In other words, a new node block is allocated, and the data of the currently valid node block is moved to the new node block.
- the NAT needs to be updated offsite, that is, the node address in the NAT is modified offsite.
- CKPT1 when the first stage is performed, CKPT1 is stable and effective.
- the effective NAT block of CKPT1 can be copied to the NAT block of the second backup area, and then stored in the NAT block in the second backup area. Modify the node address and switch to these NAT blocks when writing CKPT0, that is, these NAT blocks are valid after writing CKPT0.
- the nodes (inode, dnode) corresponding to the data need to be updated remotely.
- the data block A is directly indexed by an inode.
- the inode corresponding to the data block A is updated remotely accordingly.
- Data block B is indexed indirectly through dnodes.
- the idnode stores the ID of the dnode, so there is no need to modify the idnode.
- the idnode id is stored in didnode, so there is no need to modify the didnode.
- a valid backup area is designated as a valid backup area of CKPT1.
- the latest version number will be written in CKPT0, such as: version number 2.
- version number 2 is a valid version number
- CKPT0 is valid.
- the effective backup in the dual backup is used to reconstruct the metadata area that needs to be reduced (such as SIT and NAT of F2FS).
- the SIT area needs to be reduced, and the effective SIT backup area of CKPT0 that is stable and effective after the end of the first stage needs to be adjusted.
- the effective NAT backup area of CKPT0 that is stable and effective after the first stage is adjusted.
- each solid rectangle represents a SIT block.
- the white SIT block and the SIT block filled with oblique lines in FIG. 8 are SIT blocks that are valid after writing CKPT0 in the first stage, that is, valid SIT blocks of CKPT0.
- the SIT block filled with diagonal shading is the part that needs to be reduced when the SIT area is adjusted, that is, the SIT block filled with diagonal shading is discarded, and the second backup area of CKPT0 is used to build and adjust the horizontal SIT block in FIG. After the SIT area.
- the specific data copying process may include: copying D2 to A1 ', that is, the adjusted SIT area starts from A1'.
- the above-mentioned data copy process is merely an example, and the embodiment of the present invention does not limit the data copy involved in constructing a new SIT.
- the SIT version_bitmap currently maintained in the CKPT records which SIT blocks are valid in the valid CKPT0 written in the first stage.
- the SIT is constructed in the second backup area composed of the invalid SIT blocks corresponding to the valid SIT blocks of CKPT0. Therefore, the SIT version_bitmap currently maintained needs to be reversed after the SIT is constructed.
- a rectangular block represents a NAT block, and a NID (node ID) is stored in the NAT block.
- the horizontally filled NAT block in FIG. 9 is a currently valid NAT block, that is, a valid NAT block of CKPT0, and a white NAT block is a valid NAT block of CKPT1.
- the NID (node ID) start address can be read from CKPT0, and the NID start address read out can be modified according to shrink, which can reduce the start address of NID by shrink. Finally, the modified NID start address is written into the valid NAT block of CKPT1.
- the NAT version_bitmap currently maintained in the CKPT records which NAT blocks are valid in the valid CKPT0 written in the first stage.
- the NAT is constructed as a backup composed of the invalid NAT block corresponding to the valid NAT block of CKPT0. Therefore, the NAT version_bitmap currently maintained needs to be reversed after the NAT is constructed.
- a valid backup area is designated as a valid backup area of CKPT0.
- an older version number is written in CKPT1, such as: version number -1. After that, version number 2 is still a valid version number, and CKPT0 is valid.
- all metadata areas of the file system are securely migrated, such as SB, CP, SIT, NAT, and SSA of F2FS.
- the bare data is moved.
- the file system cannot be mounted.
- the design scheme guarantees that it can continue after power failure.
- i metadata areas that need to be moved. From left to right, they are recorded as the 0th metadata area, the 1st metadata area ... the i-1th metadata area. Data area.
- the 0th metadata area is popped from the stack; if NEW_BLKADDR ⁇ OLD_BLKADDR (or the last area) is not satisfied, the 0th metadata area is still in the stack until there is The new metadata area is pushed into the stack and satisfies the above inequality, all the metadata areas in the stack are popped out, and they are moved in the popped order. Further, j is also updated to j + 1, that is, the next metadata area is looped.
- the data in the metadata area is moved in units of blocks, and appropriate synchronization operations are added between the blocks to ensure that writes pass the file system cache, and the device cache finally reaches the device reliably.
- the moving direction of the data in the metadata area points to the adjusted start address of the metadata area or the adjusted end address of the metadata area.
- the direction of moving data points to the adjusted end address of the metadata area.
- the data can be moved in the order from right to left. It needs to be moved 7 times in delta units. The amount of each move should be within the allowed range of memory allocation It should be as large as possible and close to the delta. In this way, after the power failure, the state before the power failure can be restored.
- the direction of moving data points to the adjusted starting address of the metadata area. Specifically, the data can be moved from left to right in order. It needs to be moved 7 times in delta units. In this way, it can be restored after power failure. The state of moving before power.
- the SSA area is adjusted. There is only one copy of the SSA in F2FS, and it is not suitable for direct adjustment in the previous stage. Referring to FIG. 13, during the data movement process, only the remaining data outside the narrow range of the SSA area is moved.
- the relocated SSA area includes the expanded range of the SSA area.
- the expanded range of the SSA area in the adjusted SSA area may be empty.
- CP there are five metadata areas: CP, SIT0, SIT1, NAT, and SSA.
- the effective backup in the dual backup is used to reconstruct the metadata area that needs to be expanded.
- the expansion and reconstruction of the metadata area may include the following two possibilities:
- the designated valid backup area at the beginning of the fourth stage is the valid backup area of CKPT0.
- CKPT1 version number -1
- version number 2 is still a valid version number
- CKPT0 is valid.
- an older version number is written in CKPT1 after the end of the second phase, there is no need to write the version number after the end of the fourth phase, and CKPT0 is valid.
- an older version number is not written in CKPT1 after the end of the second phase, an older version number needs to be written after the end of the fourth phase, such as: version number -1, guaranteed to write CKPT0 is valid after the version number.
- the fifth stage the metadata correction stage without the dual backup in the file system
- F2FS In F2FS, some metadata is stored in the data area of the file system, and there is no double backup, mainly dnode and inode.
- the node block in the main area can be updated according to the adjusted metadata areas.
- the SIT, NAT, and SSA updates are ready, so the offsets in the dnode and inode can be corrected according to the SIT, NAT, and SSA.
- the offset in the dnode and inode can be corrected by a stable SSA, which can avoid the problem that the blkaddr fails due to multiple updates to the blkaddr due to power failure.
- the SIT block in the SIT is searched, and all valid data blocks data block in the data area of the file system are determined through the SIT entry in the SIT block.
- each valid data block iterate through each valid data block to find its SSA, find the node corresponding to the data block through SSA, and the offset of the data block in node, and modify the address of the data block corresponding to this offset in node to The address of the data block.
- data block A is directly indexed by an inode, and the inode corresponding to the data block A is found by SSA, and the offset of data block A in the inode.
- the data block address corresponding to the offset is changed to the address of data block A.
- data block B is indirectly indexed by dnode, and the dnode corresponding to data block B and the offset of data block B in dnode are found through SSA. Change the corresponding data block address to the address of data block B.
- the idnode stores the ID of the dnode, so there is no need to modify the idnode.
- the idnode id is stored in didnode, so there is no need to modify the didnode.
- CKPT0 is still valid.
- a valid backup area with an older version number can be designated as the current valid backup area, that is, the current valid backup area can be designated as the valid backup area of CKPT1.
- write a newer version number in CKPT0 such as version number 4.
- the above-mentioned second and fourth stages are not necessarily implemented. If all metadata areas need to be reduced, then there is no need to expand and rebuild the metadata area, and there is no need to perform the fourth stage; if all metadata areas need to be expanded, then no need to reduce and rebuild the metadata area, no need to perform second stage. If the metadata area of the file system has both a metadata area that needs to be reduced and a metadata area that needs to be enlarged, then the second and fourth phases must be performed. In the second stage, the metadata area that needs to be reduced is reconstructed, and in the fourth stage, the metadata area that needs to be enlarged is reconstructed.
- the device in the embodiment of the present invention includes a hardware structure and / or a software module corresponding to each function.
- this application can be implemented in hardware or a combination of hardware and computer software. Whether a certain function is performed by hardware or computer software-driven hardware depends on the specific application and design constraints of the technical solution. A professional technician can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
- the embodiments of the present application may divide the function modules of the device according to the foregoing method examples.
- each function module may be divided corresponding to each function, or two or more functions may be integrated into one processing module.
- the above integrated modules can be implemented in the form of hardware or software functional modules. It should be noted that the division of the modules in the embodiments of the present application is schematic, and is only a logical function division. In actual implementation, there may be another division manner.
- FIG. 16 shows a possible composition diagram of the device involved in the foregoing embodiment.
- the device may include a processing unit 1601 and a communication unit. 1602.
- the processing unit 1601 is configured to support the device to execute all steps of the file system adjustment method shown in FIG. 4.
- the sending unit 1602 is configured to support communication between the device and other devices.
- the device provided in the embodiment of the present application is configured to execute the file system adjustment method of the discovery signal, and thus can achieve the same effect as the above file system adjustment method.
- FIG. 17 shows another possible composition diagram of the device involved in the foregoing embodiment.
- the device includes a processing module 1701 and a communication module 1702.
- the processing module 1701 is configured to control and manage the actions of the server.
- the processing module 1701 is configured to support the device to execute the method shown in FIG. 4 and / or other processes used in the technology described herein.
- the communication module 1702 is configured to support communication between the device and other devices.
- the device may further include a storage module 1703 for storing program code and data of the server.
- the processing module 1701 may be a processor or a controller. It may implement or execute various exemplary logical blocks, modules, and circuits described in connection with the disclosure of this application.
- a processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and so on.
- the communication module 1702 may be a transceiver, a transceiver circuit, or a communication interface.
- the storage module 1703 may be a memory.
- the processing module 1701 is a processor
- the communication module 1702 is a communication interface
- the storage module 1603 is a memory
- the device involved in this embodiment of the present application may be the device shown in FIG. 3.
- the disclosed systems, devices, and methods may be implemented in other ways.
- the device embodiments described above are only schematic.
- the division of the modules or units is only a logical function division.
- multiple units or components may be divided.
- the combination can either be integrated into another system, or some features can be ignored or not implemented.
- the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, which may be electrical, mechanical or other forms.
- the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objective of the solution of this embodiment.
- each functional unit in each embodiment of the present application may be integrated into one processing unit, or each of the units may exist separately physically, or two or more units may be integrated into one unit.
- the above integrated unit may be implemented in the form of hardware or in the form of software functional unit.
- the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium.
- the technical solution of the present application is essentially a part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium , Including a plurality of instructions for causing a device (which may be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in the embodiments of the present application.
- the foregoing storage medium includes: various types of media that can store program codes, such as a flash memory, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk, or an optical disk.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明实施例提供一种文件***调整方法及设备,涉及存储领域,在对文件***的存储空间进行调整的过程中能够避免文件***的数据丢失。包括:确定文件***的存储空间的调整范围,根据文件***的存储空间的调整范围确定文件***的数据区域的调整范围,对数据区域的调整范围执行数据更新操作;利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移文件***的所有元数据区域;文件***的元数据区域包括第一元数据区域,第一元数据区域包括两个备份区域;根据文件***调整后的元数据区域更新文件***的数据区域中的第二元数据区域,第二元数据区域为文件***的数据区域中无双备份的元数据区域。
Description
本申请涉及存储领域,尤其涉及一种文件***调整方法及设备。
随着嵌入式终端功能的增加,操作***占用的空间会越来越大,需要对文件***的分区大小进行调整,来满足更大的ROM需求。
当前无论离线或在线的文件***分区调整技术均是直接搬移文件***的数据和元数据,搬移过程中重叠的数据会临时记录在内存中。当设备或器件掉电时,分区调整过程无法恢复,记录在内存中的数据会丢失无法恢复,最终直接破坏文件***,对用户产生无法挽回的损失。如:开源社区提供的F2FS的分区调整方案。
参考图1,现有F2FS尾部分区扩大调整技术按照main area、SSA、NAT、SIT、CKPT、SB的顺序依次调整搬移各区域,修改main area区域时直接搬移并原地修改最新的CKPT以及有效的SIT和NAT备份,不进行异地更新,调整时会先将区域中部分数据读入内存,然后写入新的数据,没有搬移过程状态落盘,掉电后无法恢复到掉电前的状态继续搬移,且由于CKPT本地更新,导致最新的CKPT失效。
发明内容
本发明的实施例提供一种文件***调整方法及设备,在对文件***的存储空间进行调整的过程中能够避免文件***的数据丢失。
为达到上述目的,本发明的实施例采用如下技术方案:
第一方面,公开了一种文件***调整方法,包括:首先,确定文件***的存储空间的调整范围,根据文件***的存储空间的调整范围确定文件***的数据区域的调整范围,对数据区域的调整范围执行数据更新操作;随后,可以利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移文件***的所有元数据区域。其中,文件***的元数据区域包括第一元数据区域,第一元数据区域包括两个备份区域。最后,根据文件***调整后的元数据区域更新文件***的数据区域中的第二元数据区域,第二元数据区域为文件***的数据区域中无双备份的元数据区域。
本发明实施例提供的方法中,在对文件***在磁盘所占存储空间的大小进行调整时,首先可以确定文件***存储空间的调整范围,进一步根据文件***的调整范围确定文件***数据区域的调整范围,对该数据区域的调整范围执行数据更新操作。随后,针对所述文件***的每一个第一元数据区域,第一元数据区域包括两个备份区域,利用第一元数据区域的有效备份区域构建调整后的第一元数据区域。另外,还可以根据预设算法确定文件***的所有元数据区域的搬移顺序,按照该搬移顺序搬移所述文件***的所有元数据区域。最后,还可以根据所述文件***调整后的元数据区域更新所 述文件***的数据区域中的第二元数据。所谓第二元数据是存在于数据区域的非双备份的元数据。可见,本发明实施例提供的方法中,对文件***的数据进行更新(如:搬移)时,利用双备份中的有效备份构建新的元数据区域,通过双备份文件***特性对数据进行安全搬移,实现了文件***的安全调整,在对文件***的存储空间进行调整的过程中能够避免文件***的数据丢失。
结合第一方面,在第一方面的第一种可能的实现方式中,对数据区域的调整范围执行数据更新操作包括:若缩小文件***的数据区域,则将数据区域的调整范围内的数据搬移至空闲的数据块;若扩展文件***的数据区域,则将数据区域扩展成包括调整范围的区域,且数据区域中的调整范围为空。
本发明实施例提供了对文件***的数据区域进行数据更新操作的具体实现方式。
结合第一方面或第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,确定文件***的数据区域的调整范围,对数据区域的调整范围执行数据更新操作之后,方法还包括:写入第二版本号;有效版本号由第一版本号变为第二版本号。
结合第一方面,在第一方面的第三种可能的实现方式中,利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移文件***的所有元数据区域具体包括:利用需要缩小的第一元数据区域的有效备份区域构建缩小后的第一元数据区域;根据预设算法确定文件***的所有元数据区域的搬移顺序,按照搬移顺序搬移文件***的所有元数据区域;利用需要扩大的第一元数据区域的有效备份区域构建扩大后的第一元数据区域。
本发明实施例提供了重建元数据区域以及搬移元数据区域的具体实现方式,可以保证在调整过程中,文件******的元数据区域互相之间不受影响。
结合第一方面的第三种可能的实现方式,在第一方面的第四种可能的实现方式中,第一元数据区域包括第一备份区域和第二备份区域;第一备份区域是当前有效备份区域;利用第一元数据区域的有效备份区域构建调整后的第一元数据区域包括:确定第一元数据区域的缩小范围,将第一备份区域中除缩小范围外的数据拷贝至第二备份区域;或,确定第一元数据区域的扩大范围,将第一备份区域中的数据拷贝至第二备份区域,第二备份区域包括第一元数据区域的扩大范围。
在本发明实施例中,对元数据区域的重建可以是调整元数据区域的范围,具体可以扩大元数据区域的范围或缩小元数据区域的范围。
结合第一方面的第三种可能的实现方式,在第一方面的第五种可能的实现方式中,第一元数据区域包括第一备份区域和第二备份区域;第一备份区域是当前有效备份区域;利用第一元数据区域的有效备份区域构建调整后的第一元数据区域包括:更新第一备份区域内的数据,并将更新后的数据存储在第二备份区域。
在本发明实施例中,对元数据区域的重建可以是调整元数据区域的内容,具体可以修改元数据区域存储的数据。
结合第一方面的第五种可能的实现方式,在第一方面的第六种可能的实现方式中,更新第一备份区域内的数据具体包括:从第一备份区域读出元数据区域的地址,根据文件***的调整范围更新读出的第二元数据区域的地址。
在本发明实施例中,在调整元数据区域时,可以对元数据区域存储的地址进行修改。
结合第一方面的第二种可能的实现方式,在第一方面的第七种可能的实现方式中,利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移文件***的所有元数据区域之后,方法还包括:写入第三版本号;有效版本号不变,为第二版本号。
结合第一方面,在第一方面的第八种可能的实现方式中,方法搬移文件***的所有元数据区域包括:在搬移第一元数据区域时,确定第一元数据区域的缩小范围,仅搬移第一元数据区域中缩小范围之外的其他数据;或,确定第一元数据区域的扩大范围,搬移调整后的第一元数据区域,或,搬移调整后的第一元数据区域并清除第一元数据区域的扩大范围内的数据;调整后的第一元数据区域包括第一元数据区域的扩大范围。
结合第一方面或第一方面的第三种可能的实现方式中,在第一方面的第九种可能的实现方式中,方法还包括:搬移一个元数据区域时,以块为单位沿预设方向依次搬移该元数据区域内的数据;预设方向指向元数据区域调整后的开始地址或元数据区域调整后的结束地址。
结合第一方面,在第一方面的第十种可能的实现方式中,根据文件***调整后的元数据区域更新文件***的数据区域中的第二元数据区域,包括:遍历文件***中的每一个有效数据块,查找文件***调整后的元数据区域获得有效数据块对应的第二元数据区域以及有效数据块在第二元数据区中的偏移,将第二元数据区域中偏移对应的数据块地址更新为有效数据块的地址。
结合第一方面,在第一方面的第十一种可能的实现方式中,所述方法还包括:根据所述文件***调整后的元数据区域更新所述文件***的数据区域中的第二元数据区域之后,写入第四版本号,所述第四版本号为有效版本号。
第二方面,公开了一种设备,包括:处理单元,用于确定文件***的存储空间的调整范围,根据文件***的存储空间的调整范围确定文件***的数据区域的调整范围,对数据区域的调整范围执行数据更新操作;处理单元还用于,利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移文件***的所有元数据区域;文件***的元数据区域包括第一元数据区域,第一元数据区域包括两个备份区域;处理单元还用于,根据文件***调整后的元数据区域更新文件***的数据区域中的第二元数据区域,第二元数据区域为文件***的数据区域中无双备份的元数据区域。
本发明实施例提供的设备,在对文件***在磁盘所占存储空间的大小进行调整时,首先可以确定文件***存储空间的调整范围,进一步根据文件***的调整范围确定文件***数据区域的调整范围,对该数据区域的调整范围执行数据更新操作。随后,针对所述文件***的每一个第一元数据区域,第一元数据区域包括两个备份区域,利用第一元数据区域的有效备份区域构建调整后的第一元数据区域。另外,还可以根据预设算法确定文件***的所有元数据区域的搬移顺序,按照该搬移顺序搬移所述文件***的所有元数据区域。最后,还可以根据所述文件***调整后的元数据区域更新所述文件***的数据区域中的第二元数据。所谓第二元数据是存在于数据区域的非双备份 的元数据。可见,本发明实施例提供的方法中,对文件***的数据进行更新(如:搬移)时,利用双备份中的有效备份构建新的元数据区域,通过双备份文件***特性对数据进行安全搬移,实现了文件***的安全调整,在对文件***的存储空间进行调整的过程中能够避免文件***的数据丢失。
结合第二方面,在第二方面的第一种可能的实现方式中,处理单元具体用于,
若缩小文件***的数据区域,则将数据区域的调整范围内的数据搬移至空闲的数据块;若扩展文件***的数据区域,则将数据区域扩展成包括调整范围的区域,且数据区域中的调整范围为空。
结合第二方面或第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,处理单元还用于,确定文件***的数据区域的调整范围,对数据区域的调整范围执行数据更新操作之后,写入第二版本号;有效版本号由第一版本号变为第二版本号。
结合第二方面,在第二方面的第三种可能的实现方式中,处理单元具体用于,利用需要缩小的第一元数据区域的有效备份区域构建缩小后的第一元数据区域;根据预设算法确定文件***的所有元数据区域的搬移顺序,按照搬移顺序搬移文件***的所有元数据区域;利用需要扩大的第一元数据区域的有效备份区域构建扩大后的第一元数据区域。
结合第二方面的第三种可能的实现方式,在第二方面的第四种可能的实现方式中,第一元数据区域包括第一备份区域和第二备份区域;第一备份区域是当前有效备份区域;处理单元具体用于,确定第一元数据区域的缩小范围,将第一备份区域中除缩小范围外的数据拷贝至第二备份区域;或,确定第一元数据区域的扩大范围,将第一备份区域中的数据拷贝至第二备份区域,第二备份区域包括第一元数据区域的扩大范围。
结合第二方面的第三种可能的实现方式,在第二方面的第五种可能的实现方式中,第一元数据区域包括第一备份区域和第二备份区域;第一备份区域是当前有效备份区域;利用第一元数据区域的有效备份区域构建调整后的第一元数据区域包括:更新第一备份区域内的数据,并将更新后的数据存储在第二备份区域。
结合第二方面的第五种可能的实现方式,在第二方面的第六种可能的实现方式中,处理单元具体用于,从第一备份区域读出元数据区域的地址,根据文件***的调整范围更新读出的第二元数据区域的地址。
结合第二方面的第二种可能的实现方式,在第二方面的第七种可能的实现方式中,处理单元还用于,利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移文件***的所有元数据区域之后,写入第三版本号;有效版本号不变,为第二版本号。
结合第二方面或第二方面的第三种可能的实现方式,在第二方面的第八种可能的实现方式中,处理单元具体用于,在搬移第一元数据区域时,确定第一元数据区域的缩小范围,仅搬移第一元数据区域中缩小范围之外的其他数据;或,确定第一元数据区域的扩大范围,搬移调整后的第一元数据区域,或,搬移调整后的第一元数据区域并清除第一元数据区域的扩大范围内的数据;调整后的第一元数据区域包括第一元数据区域的扩大范围。
结合第二方面的第八种可能的实现方式,在第二方面的第九种可能的实现方式中,处理单元还用于,搬移一个元数据区域时,以块为单位沿预设方向依次搬移该元数据区域内的数据;预设方向指向元数据区域调整后的开始地址或元数据区域调整后的结束地址。
结合第二方面,在第二方面的第十种可能的实现方式中,处理单元具体用于,遍历文件***中的每一个有效数据块,查找文件***调整后的元数据区域获得有效数据块对应的第二元数据区域以及有效数据块在第二元数据区中的偏移,将第二元数据区域中偏移对应的数据块地址更新为有效数据块的地址。
结合第二方面,在第二方面的第十一种可能的实现方式中,处理单元还用于,根据所述文件***调整后的元数据区域更新所述文件***的数据区域中的第二元数据区域之后,写入第四版本号,所述第四版本号为有效版本号。
图1为现有技术文件***调整方法的示意图;
图2为本发明实施例提供的F2FS的示意图;
图3为本发明实施例提供的设备的结构框图;
图4为本发明实施例提供的文件***调整方法的流程示意图;
图5为本发明实施例提供的文件***调整示意图;
图6为本发明实施例提供的元数据区域更新示意图;
图7为本发明实施例提供的另一元数据区域更新示意图;
图8为本发明实施例提供的另一元数据区域更新示意图;
图9为本发明实施例提供的另一元数据区域更新示意图;
图10为本发明实施例提供的确定元数据区域搬移顺序的流程示意图;
图11为本发明实施例提供的数据搬移示意图;
图12为本发明实施例提供的另一搬移数据示意图;
图13为本发明实施例提供的另一搬移数据示意图;
图14为本发明实施例提供的需要搬移的元数据区域的示意图;
图15为本发明实施例提供的另一元数据区域更新示意图;
图16为本发明实施例提供的设备的另一结构框图;
图17为本发明实施例提供的设备的另一结构框图。
文件***是计算机操作***中的重要组成部分,用于在计算机的存储介质(磁盘或闪存)上组织、管理和存储文件。文件***可以被划分为多个块(block)。典型的,对于多数文件***,每个block大小相同,且一个block大小可以是4096字节。
本发明实施例提供的文件***调整方法适用于双备份文件***,所谓双备份文件***,即元数据在文件***内可以存在两个备份。如:F2FS文件***(闪存友好型文件***,Flash Friendly File System)。以下以F2FS作为示例,介绍双备份文件***在磁盘上的分布。需要说明的是,本发明实施例提供的方法适应的文件***包括但不限于F2FS,还可以应用于其他双备份的文件***。
参考图2,F2FS的存储空间包括元数据区域和数据区域(main area)。其中,元 数据区域包括超级块(super block,SB)、检查点(checkpoint,CKPT)、段信息表(segment information table,SIT)、节点地址表(node address table,NAT)、段摘要区(segment summary area,SSA)。数据区域包括节点块(node block)以及数据块(data block),数据块在文件***中存储用户数据,节点块是文件***中的另一种元数据结构,保存了文件***中的一个文件***对象的元信息数据。需要说明的是,main area中的node均只有一个备份,在本发明实施例中可以称为无双备份的元数据。
另外,文件***的最小单位是块(block),在F2FS中一个block=4096(4k)字节。F2FS存在segment(段)、section(小节)、zone(区),一个segment包含512个连续的block,本发明实施例中1segment=1section=1zone。
以下对各个元数据区域进行解释说明,具体包括:
(1)SB是文件***的第0和第1个block,SB包括两个相同备份,分别为SB0、SB1,SB0对应第0个block,SB1对应第1个block。
(2)SIT用于记录main area中每个segment中的block的分配情况,参考图2,SIT包括SIT 0集合、SIT1集合这两个区域,SIT 0和SIT1均包括SIT block。另外,当前有效的SIT block构成一个备份,其余SIT block构成另外一个备份。具体地,每个SIT block中包含55个SIT entry。其中,SIT entry记录了与其对应的segment中的512个block的使用情况。
(3)NAT用于记录node的地址。NAT包括NAT0集合、NAT1集合这两个集合。NAT0、NAT1均包括NAT block。另外,当前有效的NAT block构成一个备份,其余NAT block构成另外一个备份。其中,每个NAT block中包含455个NAT entry。每个NAT entry记录了与其对应的一个node的地址。而这个nat entry本身在NAT区域中的位置,表示该node的nid(node的标识)。
(4)CKPT是SB对齐之后的两个segment。CKPT的起始地址以segment对齐。CKPT包括两个相同备份,分别为CKPT0、CKPT1,同一时刻,只有一个CKPT备份是有效的。示例的,当前有效的是CKPT0,下一次可以写CKPT1,将CKPT1可靠写入器件之后CKPT1就是有效的,下一次可以继续写CKPT0。也就是说,当前稳定有效的那个CKPT备份不能写操作,只能写另外一个CKPT备份。CKPT中包括版本号,版本号较新的CKPT是当前有效的CKPT被文件***识别。示例的,CKPT0的版本号是0,CKPT1的版本号是1,CKPT1有效。进一步,在CKPT0写入版本号2,CKPT1的版本号仍为1,CKPT0的版本号较新,为当前有效的CKPT。
CKPT0、CKPT1均包括NAT version bitmap和SIT version bitmap。NAT version bitmap记录了当前有效的NAT block,如:CKPT0中的NAT version bitmap记录了哪些NAT block对于CKPT0是有效的;CKPT1中的NAT version bitmap记录了哪些NAT block对于CKPT1是有效的。SIT version bitmap记录了当前有效的SIT block,如:CKPT1中的SIT version bitmap记录了哪些SIT block对于CKPT1是有效的;CKPT0中的SIT version bitmap记录了哪些SIT block对于CKPT0是有效的。
(5)SSA包括多个summary block,一个summary block对应与一个segment。一个summary block包括512个entry,每个entry对应于一个block,记录了该block属于哪个node,以及在node中的位置。与SB、SIT、NAT、CKPT等元数据区域不同的 是,F2FS文件***中SSA仅有一个备份。
现有技术中,直接搬移文件***的数据和元数据对文件***的大小进行调整,搬移过程中重叠的数据会临时记录在内存中。当设备和器件掉电时,分区调整过程无法恢复,记录在内存中的数据会丢失无法恢复,会直接破坏文件***,对用户产生无法挽回的损失。
本发明实施例提供一种文件***调整方法,在对文件***在磁盘所占存储空间的大小进行调整时,首先可以确定文件***存储空间的调整范围,进一步根据文件***的调整范围确定文件***数据区域的调整范围,对该数据区域的调整范围执行数据更新操作。随后,针对所述文件***的每一个第一元数据区域,第一元数据区域包括两个备份区域,利用第一元数据区域的有效备份区域构建调整后的第一元数据区域。另外,还可以根据预设算法确定文件***的所有元数据区域的搬移顺序,按照该搬移顺序搬移所述文件***的所有元数据区域。最后,还可以根据所述文件***调整后的元数据区域更新所述文件***的数据区域中的第二元数据。所谓第二元数据是存在于数据区域的非双备份的元数据。可见,本发明实施例提供的方法中,对文件***的数据进行更新(如:搬移)时,利用双备份中的有效备份构建新的元数据区域,通过双备份文件***特性对数据进行安全搬移,实现了文件***的安全调整,在对文件***的存储空间进行调整的过程中能够避免文件***的数据丢失。
本发明实施例提供的文件***调整方法可以应用于图3所示的设备,如图3所示,该设备包括处理器20、存储器21以及通信接口22。处理器20、存储器21以及通信接口22通过总线23通信。该设备还可以通过通信接口23与其他设备通信。
其中,处理器20包括N个处理器核心(核心1、……、核心k、……、核心N),例如至少一个中央处理器(Central Processing Unit,CPU)等,每一个CPU可以是一个单核处理器(single-CPU),也可以是一个多核处理器(multi-CPU)。多个处理器核心可以分时,也可以同时读取存储器21中存储的数据。
存储器21为上述存储介质,该存储器可以存储数据、软件程序以及模块等。存储器21可以为硬盘(Hard Disk Drive,HDD)、固态硬盘(Solid-State Drive,SSD)、磁盘存储介质或者闪存设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由处理器20存取的任何其他介质,但不限于此。
在实际应用中,设备可以利用文件***对文件进行管理,这些文件的数据存储在设备的存储器21中。本发明实施例中,处理器20调用存储器21中的代码执行本发明实施例所述的文件***调整方法,对文件***的存储空间的大小进行调整,如:缩小文件***的存储空间、扩大文件***的存储空间。
本发明实施例提供一种文件***调整方法,适用于双备份文件***。如图4所示,所述方法包括以下步骤:
401、设备确定文件***的存储空间的调整范围,根据所述文件***的调整范围确定所述文件***的数据区域的调整范围,对所述数据区域的调整范围执行数据更新操作。
需要说明的是,文件***的存储空间包括文件***的元数据区域以及文件***的数据区域。具体实现中,设备可以根据调整后的元数据区域的字段,与当前元数据区 域的字段进行对比,确定文件***的数据区域的调整范围,如:文件***的数据区域需要搬移的范围,或文件***的数据区域需要扩展的范围。
另外,对文件***的数据区域执行的数据更新操作包括以下两种情况:
若缩小文件***的数据区域,则将数据区域的调整范围内的数据搬移至空闲块。本发明实施例中,缩小文件***的数据区域可以是缩小该区域的头部,也可以是缩小该区域的尾部。
若扩展所述文件***的数据区域,则将所述数据区域扩展成包括所述调整范围的区域。本发明实施例中,扩展文件***的数据区域可以是扩展该区域的头部,也可以是扩展该区域的尾部,扩展出的segment数据区域可以选择置为空或不做处理,但不能影响元数据区域。
402、设备写入第二版本号,将当前有效版本号由第一版本号更新为第二版本号。
也就是说,在步骤401完成数据区域调整范围的数据更新操作后,可以可靠写入一笔较新的CKPT版本号,将有效的备份区域由第一版本号的有效备份区域变为第二版本号的有效备份区域。示例的,步骤401之前文件***中CKPT0的版本号是0,CKPT1的版本号是1,步骤401之前CKPT1有效,有效备份区域是CKPT1的有效备份区域,即第一备份区域是CKPT1的有效备份区域。在步骤402中,可以在CKPT0写入一笔较新的版本号,如:版本号2,CKPT0可靠写入器件之后,版本号2为有效版本号,CKPT0有效,有效备份区域是CKPT0的有效备份区域,即第一备份区域变为CKPT0的有效备份区域。
403、设备利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移所述文件***的所有元数据区域;所述第一元数据区域包括两个备份区域。
需要说明的是,所述文件***的元数据区域包括第一元数据区域,当然所述文件***的元数据区域还可以包括其他无双备份的元数据区域,如:SSA。当对文件***的存储空间进行调整时,对文件***的元数据区域的构建包括调整元数据区域的范围,或者,也可以修改元数据区域的内容,具体地,可以更新所述第一备份区域内的数据,并将更新后的数据存储在所述第二备份区域。
具体地,首先重建缩小的第一元数据区域(有双备份的元数据区域),随后搬移所有元数据区域,最后再重建扩大的第一元数据区域。具体地,利用需要缩小范围的第一元数据区域的有效备份区域构建缩小后的第一元数据区域;根据预设算法确定所述文件***的所有元数据区域的搬移顺序,按照所述搬移顺序搬移所述文件***的所有元数据区域;利用需要扩大范围的第一元数据区域的有效备份区域构建扩大后的第一元数据区域。
另外,对于需要修改内容的第一元数据区域,不论扩大文件***的存储空间或缩小文件***的存储空间,可以在搬移所述文件***的所有元数据区域之前修改元数据区域的内容,也可以在搬移所述文件***的所有元数据区域之后修改元数据区域的内容。
需要说明的是,所述第一元数据区域为包括两个备份区域的元数据区域,如:NAT、SIT。在步骤403中可以对NAT、SIT以及SSA进行搬移、重建。具体实现中,有些第一元数据区域的调整与文件***存储空间调整的大小相关,如:NAT,具体地可以 是根据文件***的存储空间的调整范围修改NAT的内容。当文件***的存储空间改变(扩大或缩小)时,首先利用NAT的一个备份构建新的NAT,当双备份的元数据都完成重建后,再搬移包括NAT在内的所有元数据区域。或者,首先搬移包括NAT在内的元数据区域,再利用NAT的一个备份构建新的NAT。
有些第一元数据区域的调整与文件***的数据区域(main area)的调整相关,如:SIT,当文件***的数据区域缩小时,SIT的范围需要缩小,首先利用SIT的一个备份构建缩小后的SIT,当双备份的元数据都完成重建后,再搬移包括SIT在内的所有元数据区域。当文件***的数据区域扩大时,SIT的范围需要扩大,首先搬移包括SIT在内的所有元数据区域,再利用SIT的一个备份构建扩大后的SIT。
对第一元数据区域的重建包括以下两种情况:
(1)第一元数据区域的范围发生变化,主要包括第一元数据区域缩小或第一元数据区域扩大。可能是文件***的数据区域发生变化导致第一元数据区域的范围发生改变。示例的,文件***的数据区域缩小,第一元数据区域可能缩小,如:main area缩小可能导致SIT缩小;文件***的数据区域扩大,第一元数据区域可能扩大,如:main area扩大可能导致SIT扩大。具体实现中,可以根据文件***的数据区域的调整范围确定第一元数据区域的调整范围,再利用第一元数据区域的有效备份来构建新的第一元数据区域。
示例的,根据文件***的数据区域的缩小范围确定所述第一元数据区域的缩小范围,将第一元数据区域的第一备份中除所述缩小范围外的数据拷贝至所述第二备份区域。其中,第一元数据区域包括第一备份区域和第二备份区域,第一备份区域是第一备份区域是第一元数据区域当前有效的一个备份区域,即在执行步骤403时当前有效CKPT的version bitmap对应的block(如:SIT block)构成的备份区域,第二备份区域是当前有效block对应的无效block构成的备份区域。当然,也可以通过其他方式来确定第一元数据区域的调整范围,本发明实施例对此不做限定。以SIT为例,当文件***的数据区域需要缩小,SIT区域也需要缩小,可以在SIT的第二备份区域构建缩小后的SIT。
一种示例,步骤401之前文件***中CKPT0的版本号是0,CKPT1的版本号是1,步骤401之前CKPT1有效,有效备份区域是CKPT1的有效备份区域。在步骤402中,可以在CKPT0写入一笔较新的版本号2,之后,有效备份区域是CKPT0的有效备份区域。本发明实施例中的第一备份区域可以是CKPT0对应的有效SIT block(或NAT block)构成的备份区域;第二备份区域可以是CKPT0的有效SIT block对应的无效SIT block构成的一个备份区域。
或者,还可以根据文件***的数据区域的扩大范围确定所述第一元数据区域的扩大范围,进一步,将第一元数据区域的第一备份区域中的数据拷贝至第一元数据区域的第二备份区域,并且第二备份区域包括所述第一元数据区域的扩大范围。在一些实施例中,还可以将所述第二备份区域中所述第二元数据区域的扩大范围置为空。以SIT为例,当文件***的数据区域需要扩大,SIT区域也需要扩大,可以在SIT的第二备份区域构建扩大后的SIT,即将第一备份区域的数据拷贝至第二备份区域。
(2)第一元数据区域的内容发生变化。主要包括第一元数据区域中存储的地址增 加或减少。可能是文件***的存储空间发生变化导致第一元数据区域中存储的地址(如:第二元数据区域地址)发生改变。示例的,文件***的存储空间缩小或扩大,第一元数据区域中存储的node块(即本发明实施例所述的第二元数据区域)地址可能改变。具体实现中,可以根据文件***的存储空间的调整范围shrink来确定第一元数据区域中存储的地址的修正量,再利用第一元数据区域的有效备份区域来构建新的第一元数据区域,即从第一元数据区域的有效备份区域中读出地址,根据这个修正量来修改读出的地址,再将修改后的地址相应存储在第一元数据区域的第二备份区域中。在一些实施例中,第一元数据区域中存储的地址的修正量可以是文件***的存储空间的调整范围shrink。
示例的,缩小文件***的存储空间:需要根据文件***的存储空间的缩小范围来修正第一元数据区域的当前有效备份区域中存储的地址,如:第二元数据区域的地址,其中,第二元数据区域可以是文件***的数据区域中无双备份的元数据区域,如:节点块(node块)。具体实现中,利用第一元数据区域的有效备份区域(第一备份区域)构建调整后的第一元数据区域,即在第一备份区域中读出第二元数据区域地址,进而可以根据文件***的存储空间的缩小范围来修正读出的第二元数据区域地址,再将修改后的第二元数据区域地址写入第二备份区域。具体地,可以将读出的第二元数据区域地址均减去shrink,shrink为文件***的存储空间的缩小值。其中,第一元数据区域包括第一备份区域和第二备份区域,第一备份区域是第一元数据区域的两个备份区域中当前有效的一个备份区域,是当前有效的CKPT对应的block(如:NAT block)构成的备份区域,第二备份区域是当前有效block对应的无效block构成的备份区域。
示例的,扩大文件***的存储空间:需要根据文件***的存储空间的扩大范围来修正第一元数据区域的当前有效备份区域中存储的地址,如:第二元数据区域的地址,其中,第二元数据区域可以是文件***的数据区域中无双备份的元数据区域,如:节点块node。具体实现中,利用从第一元数据区域的有效备份区域(第一备份区域)中读出node块地址,将读出的node块地址均增加-shrink(shrink小于0),-shrink为文件***的存储空间的扩大值,进而可以把修改后的node块地址写入第一元数据区域的第二备份区域。
在一些实施例中,可以首先根据预设算法确定所述文件***的所有元数据区域的搬移顺序,进而可以按照确定的搬移顺序搬移所述文件***的所有元数据区域。其中,预设算法可以是:按照一定顺序将需要搬移的元数据区域压入堆栈,按照弹出堆栈的顺序来搬移。示例的,按照从左到右的顺序来进行,首先将最左边的元数据区域压入堆栈,如果满足NEW_BLKADDR≤OLD_BLKADDR(或最后一个区域),则将该元数据区域弹出堆栈;如果不满足NEW_BLKADDR≤OLD_BLKADDR(或最后一个区域),则该元数据区域仍在堆栈,直至有新的元数据区域压入堆栈且满足上述不等式,将堆栈中的元数据区域全部弹出。按照弹出堆栈的顺序搬移元数据区域。其中,当有元数据区域满足NEW_BLKADDR=OLD_BLKADDR时,可以将堆栈内的所有元数据区域弹出,但是该满足NEW_BLKADDR=OLD_BLKADDR的元数据区域不搬移。其中,最后一个区域指的是最右边的一个区域。
或者,按照从右到左的顺序来进行,首先将最右边的元数据区域压入堆栈,如果 满足NEW_BLKADDR≥OLD_BLKADDR(或最后一个区域),则将该元数据区域弹出堆栈;如果不满足NEW_BLKADDR≥OLD_BLKADDR(或最后一个区域),则该元数据区域仍在堆栈,直至有新的元数据区域压入堆栈且满足上述不等式,将堆栈中的元数据区域全部弹出,按照弹出堆栈的顺序来搬移。当有元数据区域满足NEW_BLKADDR=OLD_BLKADDR时,可以将堆栈内的所有元数据区域弹出,但是该满足NEW_BLKADDR=OLD_BLKADDR的元数据区域不搬移。其中,最后一个区域指的是最左边的一个区域。
另外,在一个元数据区域内,以块为单位沿预设方向依次搬移该元数据区域内的数据;所述预设方向指向所述元数据区域调整后的开始地址或所述元数据区域调整后的结束地址,保证元数据区域数据不覆盖。示例的,需要搬移的元数据区域从左到右依次有ABCD四个块,该元数据区域搬移后的结束地址右移,因此可以按照从右到左的顺序依次搬移ABCD四个块。首先向右搬移D,搬移后的D的结束地址与该元数据区域搬移后的结束地址对齐,其次向右搬移C,接着向右搬移B,最后向右搬移A。
需要说明的是,可以在搬移文件***的元数据区域时对SSA进行重建。具体地,缩小文件***的场景下,在搬移SSA区域时,确定SSA区域的缩小范围,仅搬移SSA中所述缩小范围之外的其他数据。
或,扩展文件***的场景下,确定SSA区域的扩大范围,搬移调整后的SSA区域;调整后的SSA区域包括SSA区域的扩大范围。
当然,其他文件***类似的元数据区域的搬移也可以按照上述方式进行,包括但不限于F2FS文件***的SSA。
404、设备写入第三版本号,当前有效版本号仍为所述第二版本号。
也就是说,在步骤403完成元数据区域的重建及搬移后,可以可靠写入一笔较旧的CKPT版本号。示例的,步骤403之后文件***中CKPT0的版本号是2,CKPT1的版本号是1,在此可以在CKPT1写入较旧的版本号,该版本号可以是比0小的版本号,如-1。在步骤404写入较旧的版本号之后,可以指定较旧版本号的有效备份区域为当前有效的备份区域,如:指定CKPT1的有效备份区域为当前有效备份区域。
405、根据所述文件***调整后的元数据区域更新所述文件***的数据区域中的第二元数据区域,所述第二元数据区域为所述文件***的数据区域中无双备份的元数据区域。
步骤404之后,完成了文件***中元数据区域的重建及搬移,进一步,还可以根据已经稳定的元数据区域对文件***的数据区域中无双备份的元数据进行更新,更新main area中的节点块(node块)。
具体地,遍历所述文件***中的每一个有效数据块,查找所述文件***调整后的元数据区域获得所述有效数据块对应的第二元数据区域以及所述有效数据块在所述第二元数据区域中的偏移,将所述第二元数据区域中所述偏移对应的数据块地址更新为所述有效数据块的地址。
需要说明的是,本发明实施例中的当前有效备份区域指的是最新的有效备份区域或指定的备份区域。如:步骤401当前有效备份区域就是最新的有效备份区域,即CKPT1的有效备份区域。步骤402中在CKPT0写入一个较新的版本号,当前有效备 份区域是最新的有效备份区域,即CKPT0的有效备份区域。步骤403中,当前有效备份区域是最新的有效备份区域,仍为CKPT0的有效备份区域。步骤404中,在CKPT1写入一个较旧的版本号,在本发明实施例步骤404中指定较旧的版本号CKPT1的有效备份区域为前有效备份区域。在步骤405中,当前有效备份区域是指定的备份区域,可以认为是当前关注的一个备份区域,如:在本发明实施例步骤405中指定较旧的版本号CKPT1的有效备份区域为当前有效备份区域。
在一些实施例中,步骤405之后还可以写入一笔较新的版本号,如:在CKPT0写入版本号4。
以下以F2FS作为示例,介绍本发明实施例提供的文件***调整方法,主要包括以下五个阶段:
第一阶段、为适应文件***的调整进行数据迁移。
具体地,根据调整后的元数据区域的字段,与当前元数据区域的字段进行比较,确定有多少main area区域需要搬移,并寻找空闲块,将需要搬移的main area区域的有效块迁移到空闲块内。参考图5,虚线所示为调整后的元数据区域的地址,通过计算得出调整后的super_block的地址来得到调整后的各区域的长度,最终取得调整后的main_blkaddr,与调整前的main_blkaddr对比即得出该次调整的main_shrink。
当文件***从头部缩小时,文件***的调整范围shrink>0,根据main_blkaddr(main area的地址)调整前后的差值来计算main_shrink即数据区域的调整范围,main_shrink≠(不一定等于)shrink。
当文件***头部扩展时,文件***的存储空间的调整范围shrink<0,可能出现两种结果main_shrink>0或main_shrink<=0。main_shrink>0需要参考上述缩小文件***的方案中的做法,需要将数据区域缩小范围内的数据搬移至空闲块,另外,还可能需要对node以及data进行相应的更新。main_shrink<=0时,在第一阶段不做任何数据搬移。
另外,如果搬移的main area区域中包含node,需要对node进行搬移。也就是说分配新的node块,将当前有效的node块的数据搬移至新的node块中。另外,还需要对NAT进行异地更新,即对NAT中的node地址进行异地修改。具体地,参考图6,执行第一阶段时,稳定有效的是CKPT1,在此可以将CKPT1的有效NAT block拷贝至第二备份区域的NAT block,再对第二备份区域中的NAT block中存储的node地址进行修改,并在写CKPT0时切换到这些NAT block,即写CKPT0后这些NAT block有效。或者,直接修改第二备份区域中NAT block中的node地址。
参考图7,如果搬移的main area区域中包含data,除了搬移data外,还需要对data对应的node(inode、dnode)进行异地更新。具体地,参考图7,data block A是通过inode来直接索引的,在搬移data block A时,相应地异地更新data block A对应的inode。data block B是通过dnode来间接索引的,在搬移data block B时,只需要相应地异地更新data block B对应的dnode。idnode中存储dnode的ID,因此无需修改idnode。didnode中存储idnode的ID,因此无需修改didnode。
需要说明的是,第一阶段开始时指定有效的备份区域为CKPT1的有效备份区域。第一阶段结束时,会在CKPT0写入一笔最新的版本号,如:版本号2,之后,版本号 2为有效版本号,CKPT0是有效的。
第二阶段、利用双备份中的有效备份对需要缩小的元数据区域(如F2FS的SIT、NAT)进行重建。
对于文件***的数据区域缩小的情况,SIT区域需要缩小,需要对第一阶段结束后稳定有效的CKPT0的有效SIT备份区域进行调整。对于文件***的存储空间缩小的情况,需要对第一阶段结束后稳定有效的CKPT0的有效NAT备份区域进行调整。以下分别介绍SIT、NAT的重建:
(1)针对当前SIT修正调整后的SIT。
参考图8,每个实线矩形代表一个SIT块,图8中的白色SIT块以及斜线阴影填充的SIT块为第一阶段写入CKPT0后有效的SIT块,即CKPT0的有效SIT块。其中,斜线阴影填充的SIT块是SIT区域调整时需要缩小的部分,即需要舍弃斜线阴影填充的SIT块,利用CKPT0的第二备份区域——图8中横线填充的SIT块构建调整后的SIT区域。将图8中的A、B、C’、D1去除,D2是调整后的SIT区域的数据源的开头,将CKPT0的有效SIT块拷贝至CKPT0的第二备份区域。具体的数据拷贝过程可以包括:将D2拷贝至A1’,也就是说调整后的SIT区域从A1’开始。另外,将E1’拷贝至A2’,将E2’拷贝至B1’,将F1’拷贝至B2’,将F2’拷贝至C1,将G1拷贝至C2,将G2拷贝至D1’,将H1拷贝至D2’,将H2拷贝至E1,将I1’拷贝至E2,将I2’拷贝至F1,将J1’拷贝至F2,将J2’拷贝至G1’,将K1拷贝至G2’,将K2拷贝至H1’,将L1’拷贝至H2’,将L2’拷贝至I1。需要说明的是,上述数据拷贝过程仅仅作为示例,本发明实施例对构建新的SIT涉及的数据拷贝不做限制。
需要说明的是,CKPT中当前维护的SIT version_bitmap记录了第一阶段写入的有效CKPT0中,哪些SIT块是有效的。另外,第二阶段将SIT构建在了CKPT0的有效SIT块对应的无效SIT块构成的第二备份区域,因此在构建SIT结束后需对当前维护的SIT version_bitmap做翻转处理。
(2)针对当前NAT修正调整后的NAT
参考图9,一个矩形块代表一个NAT块,NAT块中存储有NID(node ID)。图9中横线填充的NAT块是当前有效的NAT块,即CKPT0的有效NAT块,白色NAT块是CKPT1的有效NAT块。可以从CKPT0中读出NID(node ID)起始地址,再根据shrink修正读出的NID起始地址,可以将NID的起始地址减少shrink。最后再将修改后的NID起始地址写入CKPT1的有效NAT块。
需要说明的是,CKPT中当前维护的NAT version_bitmap记录了第一阶段写入的有效CKPT0中,哪些NAT块是有效的。另外,第二阶段将NAT构建在了CKPT0的有效NAT块对应的无效NAT块构成的一个备份,因此在构建NAT结束后需对当前维护的NAT version_bitmap做翻转处理。
需要说明的是,第二阶段开始时指定有效的备份区域为CKPT0的有效备份区域。第二阶段结束时,会在CKPT1写入一笔较旧的版本号,如:版本号-1,之后,版本号2仍为有效版本号,CKPT0是有效的。
第三阶段、安全迁移文件***的所有元数据区域,如F2FS的SB、CP、SIT、NAT以及SSA。
本阶段开始进行裸数据搬移,文件***不可挂载,设计方案保证掉电后仍可继续进行。首先需要确定各个元数据区域的搬移数据,假设有i个需要搬移的元数据区域,从左到右依次记为第0个元数据区域、第1个元数据区域……第i-1个元数据区域。按照从左到右的顺序依次将i个元数据区域压入堆栈。参考图10,首先将第j个元数据区域压入堆栈,第一次循环中j=0。如果满足NEW_BLKADDR≤OLD_BLKADDR(或最后一个区域),则将第0个元数据区域弹出堆栈;如果不满足NEW_BLKADDR≤OLD_BLKADDR(或最后一个区域),则第0个元数据区域仍在堆栈中,直至有新的元数据区域压入堆栈且满足上述不等式,将堆栈中的元数据区域全部弹出,按照弹出的顺序进行搬移。进一步,还将j更新为j+1,即下一个元数据区域进行循环。
其中,当有元数据区域满足NEW_BLKADDR=OLD_BLKADDR时,可以将堆栈内的所有元数据区域弹出,但是该满足NEW_BLKADDR=OLD_BLKADDR的元数据区域不搬移。
进一步,元数据区域内的数据按照块为单位进行搬移,且块间加入适当同步操作来保证写入通过文件***缓存、器件缓存最后可靠达到器件即可。
具体实现中,元数据区域内的数据的搬移方向指向该元数据区域调整后的起始地址,或者指向该元数据区域调整后的结束地址。参考图11,搬移数据的方向指向元数据区域调整后的结束地址,具体可以按照从右到左的顺序搬移数据,需要以delta为单位搬移7次,在内存分配允许的范围内应每次搬移量应尽量大且接近delta。如此,在掉电后可以恢复到掉电前搬移的状态。
参考图12,搬移数据的方向指向元数据区域调整后的起始地址,具体可以按照从左到右的顺序搬移数据,需要以delta为单位搬移7次,如此,在掉电后可以恢复到掉电前搬移的状态。
另外,在本阶段中对SSA区域进行搬移时,对SSA区域进行调整。F2FS中SSA只存在一份,前面阶段不适合直接进行调整,参考图13,在搬移数据过程中,仅搬移SSA区域的缩小范围外的其余数据。当然,如果需要扩展SSA区域,搬移后的SSA区域包括SSA区域扩大的范围,另外,调整后的SSA区域中SSA区域的扩大范围可以为空。
参考图14,实现中搬移的区域有CP、SIT0、SIT1、NAT、SSA这五个元数据区域。
第四阶段、利用双备份中的有效备份对需要扩大的元数据区域进行重建。
具体地,对元数据区域扩大重建可以包括以下两种可能:
(1)根据文件***的存储空间的扩大范围修改元数据区域的内容。具体地,文件***的存储空间的调整范围shrink修改元数据区域存储的node地址。可以从CKPT0中读出NID(node ID)起始地址,再根据shrink修正读出的NID起始地址,可以将NID的起始地址增加shrink。最后再将修改后的NID起始地址写入CKPT1对应的有效NAT块。
(2)根据文件***的数据区域的扩大范围确定元数据区域的扩大范围,利用元数据区域的有效备份构建扩大后的元数据区域。将CKPT0对应的有效块拷贝至CKPT1对应的有效块,并且调整后的元数据区域的头部为空,调整后的元数据区域应该包括 元数据区域的扩大范围。
需要说明的是,第四阶段进行开始时指定有效的备份区域是CKPT0的有效备份区域。
第四阶段结束时,保证在CKPT1写入一笔较旧的版本号,如:版本号-1,之后,版本号2仍为有效版本号,CKPT0是有效的。需要说的是,如果第二阶段结束后在CKPT1写入了一笔较旧的版本号,在第四阶段结束后就不需要在写入版本号,保证CKPT0是有效的即可。当然,如果在第二阶段结束后没有在CKPT1写入了一笔较旧的版本号,在第四阶段结束后就需要在写入一笔较旧版本号,如:版本号-1,保证写版本号之后CKPT0是有效的。
第五阶段、文件***中无双备份的元数据修正阶段
F2FS中,部分元数据存放在文件***的数据区域,且没有双备份,主要是dnode和inode。
在对所有元数据区域进行调整后,可以根据调整后的元数据区域更新main area中的node块。示例的,第四阶段后,SIT、NAT和SSA的更新已经就绪,因此可以根据上述SIT、NAT和SSA来修正dnode和inode中的偏移。示例的,可以通过稳定的SSA来修正dnode和inode中的偏移,可以避免由于掉电对blkaddr多次更新造成blkaddr失效的的问题。参考图15,首先查找SIT中的SIT block,通过SIT block中的SIT entry确定文件***数据区域的所有有效数据块data block。进一步,遍历每个有效的data block,找到其SSA,通过SSA找到该data block对应的node,以及该data block在node中的偏移,将该node中的这个偏移对应的data block地址修改为该data block的地址。参考图15,以data block A为例,data block A是通过inode来直接索引的,通过SSA找到该data block A对应的inode,以及data block A在inode中的偏移,将该inode中的这个偏移对应的data block地址修改为data block A的地址。
参考图15,以data block B为例,data block B是通过dnode来间接索引的,通过SSA找到data block B对应的dnode,以及data block B在dnode中的偏移,将该dnode中的这个偏移对应的data block地址修改为data block B的地址。idnode中存储dnode的ID,因此无需修改idnode。didnode中存储idnode的ID,因此无需修改didnode。
需要说明的是,虽然第四阶段结束后在CKPT1写入了一笔较旧的版本号,CKPT0仍有效。但是可以在第五阶段开始时指定较旧版本号的有效备份区域为当前有效备份区域,即可以指定当前有效备份区域为CKPT1的有效备份区域。另外,在第五阶段结束后,在CKPT0写入一笔较新的版本号,如:版本号4。
另外,上述第二阶段、第四阶段并不是必须要执行的。如果所有的元数据区域均需要缩小,那就不用对元数据区域进行扩大重建,无需执行第四阶段;如果所有的元数据区域均需要扩大,那就不用对元数据区域进行缩小重建,无需执行第二阶段。如果文件***的元数据区域中既有需要缩小的元数据区域,又有需要扩大的元数据区域,那就必须执行第二阶段、第四阶段。在第二阶段对需要缩小的元数据区域进行重建,在第四阶段对需要扩大的元数据区域进行重建。
上述主要从实现流程的角度对本申请实施例提供的方案进行了介绍。可以理解的是,本发明实施例中的设备为了实现上述功能,其包含了执行各个功能相应的硬件结 构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例可以根据上述方法示例对设备进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
在采用对应各个功能划分各个功能模块的情况下,图16示出了上述实施例中涉及的设备的一种可能的组成示意图,如图16所示,该设备可以包括:处理单元1601、通信单元1602。
其中,处理单元1601,用于支持设备执行图4所示的文件***调整方法的所有步骤。
发送单元1602,用于支持设备与其他设备之间的通信。
需要说明的是,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
本申请实施例提供的设备,用于执行上述发现信号的文件***调整方法,因此可以达到与上述文件***调整方法相同的效果。
在采用集成的单元的情况下,图17示出了上述实施例中所涉及的设备的另一种可能的组成示意图。如图17所示,该设备包括:处理模块1701和通信模块1702。
处理模块1701用于对服务器的动作进行控制管理,例如,处理模块1701用于支持设备执行图4所示的方法、和/或用于本文所描述的技术的其它过程。通信模块1702用于支持设备与其他设备之间的通信。设备还可以包括存储模块1703,用于存储服务器的程序代码和数据。
其中,处理模块1701可以是处理器或控制器。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,DSP和微处理器的组合等等。通信模块1702可以是收发器、收发电路或通信接口等。存储模块1703可以是存储器。
当处理模块1701为处理器,通信模块1702为通信接口,存储模块1603为存储器时,本申请实施例所涉及的设备可以为图3所示的设备。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。上述描述的***,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的***,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所 述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个***,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台设备(可以是个人计算机,服务器,或者网络设备等)或处理器执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:快闪存储器、移动硬盘、只读存储器、随机存取存储器、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。
Claims (24)
- 一种文件***调整方法,其特征在于,包括:确定所述文件***的存储空间的调整范围,根据所述文件***的存储空间的调整范围确定所述文件***的数据区域的调整范围,对所述数据区域的调整范围执行数据更新操作;利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移所述文件***的所有元数据区域;所述文件***的元数据区域包括所述第一元数据区域,所述第一元数据区域包括两个备份区域;根据所述文件***调整后的元数据区域更新所述文件***的数据区域中的第二元数据区域,所述第二元数据区域为所述文件***的数据区域中无双备份的元数据区域。
- 根据权利要求1所述的文件***调整方法,其特征在于,所述对所述数据区域的调整范围执行数据更新操作包括:若缩小所述文件***的数据区域,则将所述数据区域的调整范围内的数据搬移至空闲的数据块;若扩展所述文件***的数据区域,则将所述数据区域扩展成包括所述调整范围的区域,且所述数据区域中的所述调整范围为空。
- 根据权利要求1或2所述的文件***调整方法,其特征在于,所述确定所述文件***的数据区域的调整范围,对所述数据区域的调整范围执行数据更新操作之后,所述方法还包括:写入第二版本号;有效版本号由第一版本号变为所述第二版本号。
- 根据权利要求1所述的文件***调整方法,其特征在于,所述利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移所述文件***的所有元数据区域具体包括:利用需要缩小的第一元数据区域的有效备份区域构建缩小后的第一元数据区域;根据预设算法确定所述文件***的所有元数据区域的搬移顺序,按照所述搬移顺序搬移所述文件***的所有元数据区域;利用需要扩大的第一元数据区域的有效备份区域构建扩大后的第一元数据区域。
- 根据权利要求4所述的文件***调整方法,其特征在于,所述第一元数据区域包括第一备份区域和第二备份区域;所述第一备份区域是当前有效备份区域;所述利用所述第一元数据区域的有效备份区域构建调整后的第一元数据区域包括:确定所述第一元数据区域的缩小范围,将所述第一备份区域中除所述缩小范围外的数据拷贝至所述第二备份区域;或,确定所述第一元数据区域的扩大范围,将所述第一备份区域中的数据拷贝至所述第二备份区域,所述第二备份区域包括所述第一元数据区域的扩大范围。
- 根据权利要求4所述的文件***调整方法,其特征在于,所述第一元数据区域包括第一备份区域和第二备份区域;所述第一备份区域是当前有效备份区域;所述利用所述第一元数据区域的有效备份区域构建调整后的第一元数据区域包括:更新所述第一备份区域内的数据,并将更新后的数据存储在所述第二备份区域。
- 根据权利要求6所述的文件***调整方法,其特征在于,所述更新所述第一备 份区域内的数据具体包括:从所述第一备份区域读出所述元数据区域的地址,根据所述文件***的调整范围更新读出的所述第二元数据区域的地址。
- 根据权利要求3所述的文件***调整方法,其特征在于,所述利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移所述文件***的所有元数据区域之后,所述方法还包括:写入第三版本号;有效版本号不变,为所述第二版本号。
- 根据权利要求1所述的文件***调整方法,其特征在于,所述方法搬移所述文件***的所有元数据区域包括:在搬移所述第一元数据区域时,确定所述第一元数据区域的缩小范围,仅搬移所述第一元数据区域中所述缩小范围之外的其他数据;或,确定所述第一元数据区域的扩大范围,搬移调整后的所述第一元数据区域,或,搬移调整后的所述第一元数据区域并清除所述第一元数据区域的扩大范围内的数据;所述调整后的所述第一元数据区域包括所述第一元数据区域的扩大范围。
- 根据权利要求1或4所述的文件***调整方法,其特征在于,所述方法还包括:搬移一个元数据区域时,以块为单位沿预设方向依次搬移该元数据区域内的数据;所述预设方向指向所述元数据区域调整后的开始地址或所述元数据区域调整后的结束地址。
- 根据权利要求1所述的文件***调整方法,其特征在于,所述根据所述文件***调整后的元数据区域更新所述文件***的数据区域中的第二元数据区域,包括:遍历所述文件***中的每一个有效数据块,查找所述文件***调整后的元数据区域获得所述有效数据块对应的第二元数据区域以及所述有效数据块在所述第二元数据区中的偏移,将所述第二元数据区域中所述偏移对应的数据块地址更新为所述有效数据块的地址。
- 根据权利要求1或11所述的文件***调整方法,其特征在于,所述根据所述文件***调整后的元数据区域更新所述文件***的数据区域中的第二元数据区域之后,所述方法还包括:写入第四版本号,所述第四版本号为有效版本号。
- 一种设备,其特征在于,包括:处理单元,用于确定所述文件***的存储空间的调整范围,根据所述文件***的存储空间的调整范围确定所述文件***的数据区域的调整范围,对所述数据区域的调整范围执行数据更新操作;所述处理单元还用于,利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移所述文件***的所有元数据区域;所述文件***的元数据区域包括所述第一元数据区域,所述第一元数据区域包括两个备份区域;所述处理单元还用于,根据所述文件***调整后的元数据区域更新所述文件***的数据区域中的第二元数据区域,所述第二元数据区域为所述文件***的数据区域中无双备份的元数据区域。
- 根据权利要求13所述的设备,其特征在于,所述处理单元具体用于,若缩小所述文件***的数据区域,则将所述数据区域的调整范围内的数据搬移至空闲的数据块;若扩展所述文件***的数据区域,则将所述数据区域扩展成包括所述调整范围的区域,且所述数据区域中的所述调整范围为空。
- 根据权利要求13或14所述的设备,其特征在于,所述处理单元还用于,确定所述文件***的数据区域的调整范围,对所述数据区域的调整范围执行数据更新操作之后,写入第二版本号;有效版本号由第一版本号变为所述第二版本号。
- 根据权利要求13所述的设备,其特征在于,所述处理单元具体用于,利用需要缩小的第一元数据区域的有效备份区域构建缩小后的第一元数据区域;根据预设算法确定所述文件***的所有元数据区域的搬移顺序,按照所述搬移顺序搬移所述文件***的所有元数据区域;利用需要扩大的第一元数据区域的有效备份区域构建扩大后的第一元数据区域。
- 根据权利要求16所述的设备,其特征在于,所述第一元数据区域包括第一备份区域和第二备份区域;所述第一备份区域是当前有效备份区域;所述处理单元具体用于,确定所述第一元数据区域的缩小范围,将所述第一备份区域中除所述缩小范围外的数据拷贝至所述第二备份区域;或,确定所述第一元数据区域的扩大范围,将所述第一备份区域中的数据拷贝至所述第二备份区域,所述第二备份区域包括所述第一元数据区域的扩大范围。
- 根据权利要求16所述的设备,其特征在于,所述第一元数据区域包括第一备份区域和第二备份区域;所述第一备份区域是当前有效备份区域;所述利用所述第一元数据区域的有效备份区域构建调整后的第一元数据区域包括:更新所述第一备份区域内的数据,并将更新后的数据存储在所述第二备份区域。
- 根据权利要求18所述的设备,其特征在于,所述处理单元具体用于,从所述第一备份区域读出所述元数据区域的地址,根据所述文件***的调整范围更新读出的所述第二元数据区域的地址。
- 根据权利要求15所述的设备,其特征在于,所述处理单元还用于,利用每一个第一元数据区域的有效备份区域构建调整后的第一元数据区域并搬移所述文件***的所有元数据区域之后,写入第三版本号;有效版本号不变,为所述第二版本号。
- 根据权利要求13或16所述的设备,其特征在于,所述处理单元具体用于,在搬移所述第一元数据区域时,确定所述第一元数据区域的缩小范围,仅搬移所述第一元数据区域中所述缩小范围之外的其他数据;或,确定所述第一元数据区域的扩大范围,搬移调整后的所述第一元数据区域,或,搬移调整后的所述第一元数据区域并清除所述第一元数据区域的扩大范围内的数据;所述调整后的所述第一元数据区域包括所述第一元数据区域的扩大范围。
- 根据权利要求21所述的设备,其特征在于,所述处理单元还用于,搬移一个元数据区域时,以块为单位沿预设方向依次搬移该元数据区域内的数据;所述预设方向指向所述元数据区域调整后的开始地址或所述元数据区域调整后的结束地址。
- 根据权利要求13所述的设备,其特征在于,所述处理单元具体用于,遍历所 述文件***中的每一个有效数据块,查找所述文件***调整后的元数据区域获得所述有效数据块对应的第二元数据区域以及所述有效数据块在所述第二元数据区中的偏移,将所述第二元数据区域中所述偏移对应的数据块地址更新为所述有效数据块的地址。
- 根据权利要求13或23所述的设备,其特征在于,所述处理单元还用于,根据所述文件***调整后的元数据区域更新所述文件***的数据区域中的第二元数据区域之后,写入第四版本号,所述第四版本号为有效版本号。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201880085585.8A CN111566622B (zh) | 2018-07-06 | 2018-07-06 | 一种文件***调整方法及设备 |
PCT/CN2018/094924 WO2020006771A1 (zh) | 2018-07-06 | 2018-07-06 | 一种文件***调整方法及设备 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2018/094924 WO2020006771A1 (zh) | 2018-07-06 | 2018-07-06 | 一种文件***调整方法及设备 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2020006771A1 true WO2020006771A1 (zh) | 2020-01-09 |
Family
ID=69060560
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/094924 WO2020006771A1 (zh) | 2018-07-06 | 2018-07-06 | 一种文件***调整方法及设备 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN111566622B (zh) |
WO (1) | WO2020006771A1 (zh) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130205071A1 (en) * | 2012-02-08 | 2013-08-08 | Altior Inc. | Compressed cache storage acceleration |
CN103544254A (zh) * | 2013-10-15 | 2014-01-29 | 华为技术有限公司 | 一种数据管理方法及装置 |
US20160092312A1 (en) * | 2014-09-30 | 2016-03-31 | Code 42 Software, Inc. | Deduplicated data distribution techniques |
CN105593804A (zh) * | 2013-07-02 | 2016-05-18 | 日立数据***工程英国有限公司 | 用于文件***虚拟化的方法和设备、用于文件***虚拟化的数据存储***、以及用于数据存储***的文件服务器 |
CN107526546A (zh) * | 2017-08-25 | 2017-12-29 | 深圳大学 | 一种Spark分布式计算数据处理方法及*** |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8868882B2 (en) * | 2011-06-08 | 2014-10-21 | Microsoft Corporation | Storage architecture for backup application |
CN103282899B (zh) * | 2011-12-23 | 2016-06-15 | 华为技术有限公司 | 文件***中数据的存储方法、访问方法及装置 |
KR102033323B1 (ko) * | 2014-03-05 | 2019-10-17 | 한국전자통신연구원 | 플래시 메모리에서 사용하는 로그 구조 파일시스템의 메타데이터 저장 방법 |
-
2018
- 2018-07-06 CN CN201880085585.8A patent/CN111566622B/zh active Active
- 2018-07-06 WO PCT/CN2018/094924 patent/WO2020006771A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130205071A1 (en) * | 2012-02-08 | 2013-08-08 | Altior Inc. | Compressed cache storage acceleration |
CN105593804A (zh) * | 2013-07-02 | 2016-05-18 | 日立数据***工程英国有限公司 | 用于文件***虚拟化的方法和设备、用于文件***虚拟化的数据存储***、以及用于数据存储***的文件服务器 |
CN103544254A (zh) * | 2013-10-15 | 2014-01-29 | 华为技术有限公司 | 一种数据管理方法及装置 |
US20160092312A1 (en) * | 2014-09-30 | 2016-03-31 | Code 42 Software, Inc. | Deduplicated data distribution techniques |
CN107526546A (zh) * | 2017-08-25 | 2017-12-29 | 深圳大学 | 一种Spark分布式计算数据处理方法及*** |
Also Published As
Publication number | Publication date |
---|---|
CN111566622A (zh) | 2020-08-21 |
CN111566622B (zh) | 2023-11-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP6309103B2 (ja) | スナップショットおよびクローンの複製 | |
US10474654B2 (en) | Structural data transfer over a network | |
US8001165B2 (en) | Storage system format for transaction safe file system | |
JP5657550B2 (ja) | 分散ストレージシステムにおけるデータのアトミックな複合変形 | |
US7861049B2 (en) | Methods and apparatus for archiving digital data | |
US20180307602A1 (en) | Access request processing method and apparatus, and computer device | |
US8977802B2 (en) | Access device, information recording device, controller, real time information recording system, access method, and program | |
US9031906B2 (en) | Method of managing data in asymmetric cluster file system | |
WO2010100813A1 (ja) | ストレージシステム | |
US11256720B1 (en) | Hierarchical data structure having tiered probabilistic membership query filters | |
CN111459846A (zh) | 一种基于混合dram-nvm内存的动态哈希表操作方法 | |
JP2014506345A (ja) | データストレージシステムにおける、ファイルのクローニング及びデクローニング | |
US10628298B1 (en) | Resumable garbage collection | |
US11709628B2 (en) | File storage and computer system that creates new chunks after an update | |
KR101623631B1 (ko) | 캐시 메모리 구조 및 방법 | |
WO2020006771A1 (zh) | 一种文件***调整方法及设备 | |
KR101456104B1 (ko) | 비휘발성 메모리를 위한 듀얼 버퍼링 파일 관리 방법, 파일 관리 시스템 및 대용량 저장 장치 | |
US11163642B2 (en) | Methods, devices and computer readable medium for managing a redundant array of independent disks | |
JP6648596B2 (ja) | ファイルシステム制御装置、ストレージシステム、ファイルシステム制御方法、及び、プログラム | |
JP2011159142A (ja) | ストレージシステム | |
KR20190056087A (ko) | 블록 삭제시의 데이터 입출력을 최소화하는 파일 관리 구조 제어 시스템 및 방법 | |
JP6794827B2 (ja) | ストレージ管理装置、ストレージシステム、方法およびプログラム | |
CN117633895A (zh) | 一种分布式文件存储方法、***和装置 | |
KR20200102337A (ko) | 캐시라인 컨시어스 익스텐더블 해싱 방법 및 장치 | |
WO2014010566A1 (ja) | ネットワークブートシステム |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18925123 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18925123 Country of ref document: EP Kind code of ref document: A1 |