File system space adjusting method and device and electronic equipment

文档序号:95874 发布日期:2021-10-12 浏览:18次 中文

阅读说明:本技术 文件系统空间的调整方法、装置和电子设备 (File system space adjusting method and device and electronic equipment ) 是由 缪勰 方炜 郭雪楠 于 2020-03-20 设计创作,主要内容包括:本申请提供一种文件系统空间的调整方法、装置和电子设备。本申请的文件系统空间的调整方法,包括:接收第一输入,所述第一输入用于调整文件系统空间的大小,所述文件系统空间占用物理存储空间;响应于所述第一输入,确定调整区域的大小;根据所述调整区域的大小,对文件系统的虚拟预留区域和文件系统数据进行调整,获取调整后的文件系统空间,所述文件系统管理的逻辑空间包括所述虚拟预留区域和所述文件系统空间对应的逻辑空间,所述虚拟预留区域未占用物理存储空间,所述调整后的文件系统空间所占用的物理存储空间的大小大于或小于调整前的文件系统空间所占用的物理存储空间。本申请可以实现文件系统空间的安全和无损调整,避免由逻辑层所带来文件系统的存储性能损失,降低文件系统空间调整所需时长。(The application provides a file system space adjusting method and device and electronic equipment. The file system space adjusting method comprises the following steps: receiving a first input, the first input being used to adjust a size of a file system space, the file system space occupying a physical storage space; determining a size of an adjustment region in response to the first input; and adjusting the virtual reserved area and the file system data of the file system according to the size of the adjustment area to acquire the adjusted file system space, wherein the logical space managed by the file system comprises the virtual reserved area and the logical space corresponding to the file system space, the virtual reserved area does not occupy the physical storage space, and the physical storage space occupied by the adjusted file system space is larger than or smaller than the physical storage space occupied by the file system space before adjustment. The method and the device can realize safe and lossless adjustment of the space of the file system, avoid the loss of the storage performance of the file system brought by a logic layer, and reduce the time required by the space adjustment of the file system.)

1. A method for adjusting file system space is characterized in that the method is applied to a file system, and a logical space managed by the file system comprises a virtual reserved area and a logical space corresponding to the file system space, wherein the file system space occupies a physical storage space, and the virtual reserved area does not occupy the physical storage space; the method comprises the following steps:

receiving a first input for resizing the file system space;

and adjusting the virtual reserved area and the file system data to acquire an adjusted file system space, wherein the size of a physical storage space occupied by the adjusted file system space is larger than or smaller than that occupied by the file system space before adjustment.

2. The method according to claim 1, characterized in that the starting position of the logical address of the file system is located inside the physical storage space occupied by the file system space.

3. The method according to claim 2, wherein the file system space includes a data area and a metadata area, the data area is used for the file system to perform read-write operations, the metadata area is used for storing metadata of the file system, and the metadata area is located inside a physical storage space occupied by the file system space.

4. The method of any of claims 1 to 3, wherein the first input is used to expand the file system space;

the adjusting the virtual reserved area of the file system and the file system data to obtain the adjusted file system space includes:

mapping an adjustment area in the virtual reserved area to a physical storage space, setting the adjustment area to be in an idle state, and acquiring an adjusted file system space, wherein the adjusted file system space comprises the adjustment area;

determining the position of the adjusted virtual reserved area according to the position of the adjustment area;

and updating the virtual reserved area recording information in the file system data according to the adjusted position of the virtual reserved area.

5. The method of claim 4, wherein the setting the adjustment region to an idle state comprises:

and updating metadata corresponding to the adjustment area in the file system data, wherein the updated metadata corresponding to the adjustment area indicates that the adjustment area is in an idle state.

6. The method of claim 5, further comprising:

judging whether the size of the adjusting area is smaller than or equal to the size of the virtual reserved area;

when the size of the adjustment area is smaller than or equal to the size of the virtual reserved area, executing the step of mapping the adjustment area in the virtual reserved area to a physical storage space and setting the adjustment area in an idle state.

7. The method of any of claims 1 to 3, wherein the first input is used to narrow down the file system space;

the adjusting the virtual reserved area of the file system and the file system data to obtain the adjusted file system space includes:

setting an adjustment area in the file system space to be in a used state, releasing a physical storage space occupied by the adjustment area, and acquiring an adjusted file system space and an adjusted virtual reserved area, wherein the adjusted virtual reserved area comprises the adjustment area;

determining the position of the adjusted virtual reserved area according to the position of the adjustment area;

and updating the virtual reserved area recording information in the file system data according to the adjusted position of the virtual reserved area.

8. The method of claim 7, wherein when the adjustment region overlaps with a used region in the file system space, the method further comprises:

and migrating the valid data of the area which is overlapped with the used area in the space of the file system to the available space of the file system.

9. The method of claim 7 or 8, further comprising:

judging whether the size of the adjusting area is smaller than or equal to the size of the available space of the file system;

and when the size of the adjusting area is smaller than or equal to the size of the available space of the file system, executing the step of setting the adjusting area in the space of the file system to be in a used state and releasing the physical storage space occupied by the adjusting area.

10. An apparatus for adjusting file system space, comprising:

a receiving module, configured to receive a first input, where the first input is used to adjust a size of a file system space, and the file system space occupies a physical storage space;

the processing module is used for adjusting a virtual reserved area and file system data of a file system to acquire an adjusted file system space, the logical space managed by the file system comprises the virtual reserved area and a logical space corresponding to the file system space, the virtual reserved area does not occupy a physical storage space, and the size of the physical storage space occupied by the adjusted file system space is larger than or smaller than that occupied by the file system space before adjustment.

11. The apparatus of claim 10, wherein a starting location of the logical address of the file system is located inside a physical storage space occupied by the file system space.

12. The apparatus according to claim 11, wherein the file system space includes a data area and a metadata area, the data area is used for the file system to perform read/write operations, the metadata area is used for storing metadata of the file system, and the metadata area is located inside a physical storage space occupied by the file system space.

13. The apparatus of any of claims 10 to 12, wherein the first input is used to expand the file system space;

the processing module is used for: mapping an adjustment area in the virtual reserved area to a physical storage space, setting the adjustment area to be in an idle state, and acquiring an adjusted file system space, wherein the adjusted file system space comprises the adjustment area; determining the position of the adjusted virtual reserved area according to the position of the adjustment area; and updating the virtual reserved area recording information in the file system data according to the adjusted position of the virtual reserved area.

14. The apparatus of claim 13, wherein the processing module is configured to: and updating metadata corresponding to the adjustment area in the file system data, wherein the updated metadata corresponding to the adjustment area indicates that the adjustment area is in an idle state.

15. The apparatus of claim 14, wherein the processing module is further configured to:

judging whether the size of the adjusting area is smaller than or equal to the size of the virtual reserved area;

when the size of the adjustment area is smaller than or equal to the size of the virtual reserved area, executing the step of mapping the adjustment area in the virtual reserved area to a physical storage space and setting the adjustment area in an idle state.

16. The apparatus of any of claims 10 to 12, wherein the first input is to narrow the file system space;

the processing module is used for: setting an adjustment area in the file system space to be in a used state, releasing a physical storage space occupied by the adjustment area, and acquiring an adjusted file system space and an adjusted virtual reserved area, wherein the adjusted virtual reserved area comprises the adjustment area;

determining the position of the adjusted virtual reserved area according to the position of the adjustment area;

and updating the virtual reserved area recording information in the file system data according to the adjusted position of the virtual reserved area.

17. The apparatus of claim 16, wherein when the adjustment region overlaps with a used region in the file system space, the processing module is further configured to: and migrating the valid data of the area which is overlapped with the used area in the file system space to the available space in the file system space.

18. The apparatus of claim 16 or 17, wherein the processing module is further configured to:

judging whether the size of the adjusting area is smaller than or equal to the size of the available space of the file system;

and when the size of the adjusting area is smaller than or equal to the size of the available space of the file system, executing the step of setting the adjusting area in the space of the file system to be in a used state and releasing the physical storage space occupied by the adjusting area.

19. An electronic device, comprising:

one or more processors;

a memory for storing one or more programs;

when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-9.

20. A computer-readable storage medium, comprising a computer program which, when executed on a computer, causes the computer to perform the method of any one of claims 1-9.

21. A computer program product, characterized in that the computer program product comprises a computer program for performing the method of any of claims 1-9 when the computer program is executed by a computer.

22. A chip comprising a processor and a memory, the memory for storing a computer program, the processor for calling and running the computer program stored in the memory to perform the method of any one of claims 1-9.

Technical Field

The present application relates to computer technologies, and in particular, to a method and an apparatus for adjusting a file system space, and an electronic device.

Background

The operating system is located between the bottom hardware and the user, and is a bridge for communication between the bottom hardware and the user. The user may enter commands through a user interface of the operating system. And the operating system analyzes the instruction, drives the hardware equipment and realizes the user requirement. The operating system may provide the following functions: process management, memory management, file systems, network communications, security mechanisms, user interfaces, drivers, and the like. Among them, the file system is a method and a data structure for specifying files on a storage device (disk, solid state disk, etc.) or a partition in an operating system, i.e., a method of organizing files on a storage device.

For reasons of ease of management and use, etc., a storage device (e.g., a hard disk) may be partitioned into multiple partitions and multiple file systems created for data storage and organization. With the use of storage devices, the initial space partitioning may have a problem of not meeting the use requirements. For example, the available space of a partition covered by a file system is about to run out, but the file system still needs to be used continuously to run the operating system. In order to meet the use requirement, a lossless space resizing method is usually adopted to adjust the partition and the content of the storage device. In order to achieve lossless partition adjustment, it is critical to complete file system space adjustment. One commonly used method for adjusting the storage space and the file system is to use Logical Volume Manager (LVM), that is, to add a logical layer between the hard disk partition and the file system to expand or contract the partition. The logical layer may mask the physical space limitations of the hard disk partitions to present to the outside in logical volume space. The file system is created on the logical volume, and when the file system space needs to be enlarged or reduced, the size of the logical volume space can be adjusted as required, and then the file system space is adjusted by using a file system space adjusting tool (e.g., a resize2fs or other tool) to further achieve file system space adjustment.

Although the adjustment mode of the file system can flexibly adjust the hard disk space, the logical layer may cause the storage performance loss of the file system, and cannot meet the use requirement of the embedded device with higher performance requirement. In addition, the file system space adjustment tools are usually complex and time-consuming to adjust, and have a high risk of data corruption.

Disclosure of Invention

The application provides a method and a device for adjusting a file system space and electronic equipment, which can realize safe and lossless adjustment of the file system space, avoid the loss of storage performance of a file system brought by a logic layer to a certain extent, and reduce the time required by the adjustment of the file system space.

The present application is described below in several aspects, and the implementations and advantages of the following aspects are mutually referenced.

In a first aspect, the present application provides a method for adjusting a file system space, where the method may include: a first input is received, the first input to resize file system space that occupies physical storage space. Determining a size of an adjustment region in response to the first input; adjustment may also be initiated in direct response to the first input; or may also begin adjusting when other conditions and the first input are both satisfied, as described herein. And adjusting the virtual reserved area of the file system to obtain an adjusted file system space, wherein the logical space managed by the file system comprises the virtual reserved area and a logical space corresponding to the file system space, the virtual reserved area does not occupy a physical storage space, and the size of the physical storage space occupied by the adjusted file system space is larger than or smaller than the physical storage space occupied by the file system space before adjustment.

In a possible design, in the adjusting, the adjusting further includes adjusting the file system data, where the file system data includes metadata of the file system, and the metadata of the file system includes virtual reserved area record information indicating a start position and a length, or a start position and an end position, or a length and an end position of the virtual reserved area.

In this implementation, the file system manages at least two portions of logical space: and the virtual reserved area and the logical space corresponding to the file system space, wherein only the file system space occupies the physical storage space. Taking increasing the file system space as an example, when the original file system space needs to be increased, the virtual reserved area is reduced, the reduced part in the virtual reserved area is added into the logic space corresponding to the file system space, and the logic space can be mapped to the physical storage space to form the increased file system space. Thus, the logical address of the original file system space can still be unchanged, and the increased file system space contains the logical address of the original file system space and the logical address of the newly added original virtual reserved area. And then, updating the virtual reserved area recording information, wherein the updated virtual reserved area recording information represents the position of the adjusted virtual reserved area. Therefore, the adjusting method provided by the application can ensure that the logical address of the non-adjusting area is unchanged, so that the flow of adjusting the space of the file system is greatly simplified, and the adjusting process is simpler, safer and more efficient.

For a scenario in which the file system space is increased, the virtual reserved area recording information in the file system data may be updated after the virtual reserved area is adjusted.

For a scene with a reduced file system space, the virtual reserved area recording information in the file system data may be updated after the virtual reserved area is adjusted. When the reduced file system space involves the moving of valid data, the file system data also includes the valid data, i.e. the data stored in the physical storage space of the file system space. Before the virtual reserved area is adjusted, the valid data in the adjustment area needs to be moved. Namely, the valid data in the file system data is moved.

According to the file system space adjusting method, the file system space can be adjusted, partition adjustment of the storage device can be completed, the space adjusting process is simplified, and space adjusting timeliness is improved.

In one possible design, the starting location of the logical address of the file system is located inside the physical storage space occupied by the file system space.

The internal part of the physical storage space in the embodiment of the present application means that the distance between the non-start position and the non-end position of the physical storage space, that is, the distance between the non-start position and the non-end position of the physical storage space, and the distance between the non-start position and the non-end position of the physical storage space, is greater than 0, and the distance between the non-start position and the end position of the physical storage space is greater than 0.

The starting position of the logical address of the file system is located inside the physical storage space occupied by the file system space, which means that the starting position of the logical address of the file system is located at the non-starting position and the non-ending position of the physical storage space occupied by the file system space. For example, if the physical storage space occupied by the file system space is (100, 200), 100 is the starting physical address, and 200 is the ending physical address, the starting position of the logical address of the file system is located at 150, that is, located inside the physical storage space occupied by the file system space.

In the implementation mode, the starting position of the logical address of the file system is set inside the physical storage space occupied by the space of the file system, so that the adjustment can be carried out from two ends of the space of the file system, and the flexibility of adjusting the space of the file system is improved.

The initial position of the logical address can not move in the process of adjusting the space of the file system, and the relative address of the data area can be ensured to be unchanged, thereby reducing the complexity of adjusting the space of the file system.

In an implementation manner, the file system space includes a data area and a metadata area, the data area is used for performing read-write operation on the file system, the metadata area is used for storing metadata of the file system, and the metadata area is located inside a physical storage space occupied by the file system space.

The metadata area is located in the physical storage space occupied by the file system space, and means that the metadata area is located at a non-start position and a non-end position of the physical storage space occupied by the file system space. For example, if the physical storage space occupied by the file system space is (100, 200), 100 is the starting physical address, and 200 is the ending physical address, the metadata area is located at (150, 160), that is, located inside the physical storage space occupied by the file system space.

According to the implementation mode, the metadata area is arranged in the physical storage space occupied by the file system space, so that metadata migration can be avoided, and the data security of file system space adjustment is ensured.

In one possible design, the first input is for expanding the file system space, and the adjustment region is located in the virtual reserved region. Adjusting the virtual reserved area of the file system according to the size of the adjustment area to obtain an adjusted file system space, including: and mapping the adjustment area in the virtual reserved area to a physical storage space, setting the adjustment area to be in an idle state, and acquiring an adjusted file system space, wherein the adjusted file system space comprises the adjustment area. Further, determining the position of the adjusted virtual reserved area according to the position of the adjusted area; and updating the virtual reserved area recording information in the file system data according to the adjusted position of the virtual reserved area.

In one possible design, setting the adjustment region to an idle state includes: in the file system data, the metadata corresponding to the adjustment area is updated, and the updated metadata corresponding to the adjustment area indicates that the adjustment area is in an idle state.

In one possible design, the method may further include: and judging whether the size of the adjusting area is smaller than or equal to the size of the virtual reserved area. And when the size of the adjustment area is smaller than or equal to the size of the virtual reserved area, executing the step of mapping the adjustment area in the virtual reserved area to a physical storage space and setting the adjustment area in an idle state.

In one possible design, the first input is used to reduce the file system space, and the adjustment region is located in a data region of the file system space. Adjusting the virtual reserved area of the file system according to the size of the adjustment area to obtain an adjusted file system space, including: setting the adjustment area in the file system space to be in a used state, releasing the physical storage space occupied by the adjustment area, and acquiring the adjusted file system space and the adjusted virtual reserved area, wherein the adjusted virtual reserved area comprises the adjustment area. Further, determining the position of the adjusted virtual reserved area according to the position of the adjusted area; and updating the virtual reserved area recording information in the file system data according to the adjusted position of the virtual reserved area.

In one possible design, when the adjustment region overlaps with a used region in the file system space, the method may further include: valid data for a region that overlaps with a used region in the file system space is migrated to available space in the data region.

In one possible design, the method may further include: and judging whether the size of the adjusting area is smaller than or equal to the size of the available space of the file system. When the size of the adjustment area is smaller than or equal to the size of the available space of the file system, the step of setting the adjustment area in the space of the file system to be in a used state and releasing the physical storage space occupied by the adjustment area is executed.

In a second aspect, the present application provides an apparatus for adjusting a file system space, where the apparatus may be an electronic device or a chip or a system on a chip in the electronic device, and may also be a functional module in the electronic device for implementing the first aspect or any possible design of the first aspect. The adjusting means may implement the functions of the first aspect or of each possible design of the first aspect, which functions may be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. For example, the adjusting device may include: a receiving module, configured to receive a first input, where the first input is used to adjust a size of a file system space, and the file system space occupies a physical storage space; a processing module for determining a size of the adjustment region in response to the first input; the processing module is further configured to adjust a virtual reserved area of the file system and file system data according to the size of the adjustment area, and obtain an adjusted file system space, where a logical space managed by the file system includes the virtual reserved area and a logical space corresponding to the file system space, the virtual reserved area does not occupy a physical storage space, and the size of a physical storage space occupied by the adjusted file system space is greater than or less than the physical storage space occupied by the file system space before adjustment.

In one possible design, the starting location of the logical address of the file system is located inside the physical storage space occupied by the file system space.

In one possible design, the file system space includes a data area and a metadata area, the data area is used for the file system to perform read-write operations, the metadata area is used for storing metadata of the file system, and the metadata area is located inside a physical storage space occupied by the file system space.

In one possible design, the first input is used to expand the file system space, and the adjustment region is located in the virtual reserved region. The processing module is used for: mapping the adjustment area in the virtual reserved area to a physical storage space, setting the adjustment area to be in an idle state, and acquiring an adjusted file system space, wherein the adjusted file system space comprises the adjustment area; determining the position of the adjusted virtual reserved area according to the position of the adjustment area; and updating the virtual reserved area recording information in the file system data according to the adjusted position of the virtual reserved area.

In one possible design, the processing module is configured to: and updating metadata corresponding to the adjustment area in the file system data, wherein the updated metadata corresponding to the adjustment area indicates that the adjustment area is in an idle state.

In one possible design, the processing module is further configured to: judging whether the size of the adjusting area is smaller than or equal to the size of the virtual reserved area; and when the size of the adjustment area is smaller than or equal to the size of the virtual reserved area, executing the step of mapping the adjustment area in the virtual reserved area to a physical storage space and setting the adjustment area in an idle state.

In one possible design, the first input is used to reduce the file system space, and the adjustment region is located in a data region of the file system space. The processing module is used for: setting the adjustment area in the file system space to be in a used state, releasing the physical storage space occupied by the adjustment area, and acquiring the adjusted file system space and an adjusted virtual reserved area, wherein the adjusted virtual reserved area comprises the adjustment area; determining the position of the adjusted virtual reserved area according to the position of the adjustment area; and updating the virtual reserved area recording information in the file system data according to the adjusted position of the virtual reserved area.

In one possible design, when the adjustment region overlaps with a used region in the file system space, the processing module is further configured to: and migrating the valid data of the area which is overlapped with the used area in the file system space to the available space in the file system space.

In one possible design, the processing module is further configured to: and judging whether the size of the adjusting area is smaller than or equal to the size of the available space of the file system. When the size of the adjustment area is smaller than or equal to the size of the available space of the file system, the step of setting the adjustment area in the space of the file system to be in a used state and releasing the physical storage space occupied by the adjustment area is executed.

The receiving module mentioned in the second aspect may be a receiving interface, a receiving circuit, a receiver, or the like; the processing module may be one or more processors.

In a third aspect, the present application provides an electronic device, comprising: one or more processors; a memory for storing one or more programs; when executed by the one or more processors, cause the one or more processors to implement the method of any one of the first aspects as described above.

In a fourth aspect, the present application provides a computer readable storage medium comprising a computer program which, when executed on a computer, causes the computer to perform the method of any of the first aspects above.

In a fifth aspect, the present application provides a computer program or a computer program product comprising a computer program for performing the method of any of the first aspects above when the computer program is executed by a computer.

In a sixth aspect, the present application provides a chip comprising a processor and a memory, the memory being configured to store a computer program, and the processor being configured to call and run the computer program stored in the memory to perform the method according to any one of the first aspect.

The method, the device and the electronic device for adjusting the file system space according to the embodiment of the application receive a first input, wherein the first input is used for adjusting the size of the file system space, the file system space occupies a physical storage space, the size of an adjustment area is determined in response to the first input, a virtual reserved area and file system data of a file system are adjusted according to the size of the adjustment area, the adjusted file system space is obtained, a logical space managed by the file system comprises the virtual reserved area and a logical space corresponding to the file system space, the virtual reserved area does not occupy the physical storage space, and the size of the physical storage space occupied by the adjusted file system space is larger than or smaller than the physical storage space occupied by the file system space before adjustment. According to the embodiment of the application, in the process of realizing the safe and lossless adjustment of the space of the file system, the loss of the storage performance of the file system caused by the LVM can be avoided, and the time required by the space adjustment of the file system is reduced.

Drawings

Fig. 1 is a schematic diagram of an electronic device according to an embodiment of the present application;

fig. 2 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application;

fig. 3 is a schematic diagram of a software structure of an electronic device according to an embodiment of the present application;

fig. 4 is a schematic diagram of a software structure of an electronic device according to an embodiment of the present application;

FIG. 5A is a diagram illustrating a physical layout of a file system space according to an embodiment of the present application;

FIG. 5B is a schematic diagram of a logical layout of a file system space according to an embodiment of the present application;

FIG. 6 is a flowchart illustrating a method for adjusting a file system space according to an embodiment of the present disclosure;

FIG. 7 is a flowchart illustrating a method for adjusting file system space according to an embodiment of the present disclosure;

FIG. 8 is a diagram illustrating a process of narrowing a file system space according to an embodiment of the present application;

FIG. 9 is a diagram illustrating a process of narrowing a file system space according to an embodiment of the present application;

FIG. 10 is a flowchart illustrating a method for adjusting file system space according to an embodiment of the present application;

FIG. 11 is a diagram illustrating an expanding process of a file system space according to an embodiment of the present application;

FIG. 12 is a diagram illustrating an expanding process of a file system space according to an embodiment of the present application;

FIG. 13 is a diagram illustrating an adjustment of a file system space according to an embodiment of the present application;

fig. 14 is a schematic structural diagram of another electronic device according to an embodiment of the present application.

Detailed Description

The terms "first," "second," and the like in the description examples and claims of this application and in the drawings are used for descriptive purposes only and are not to be construed as indicating or implying relative importance, nor order. Furthermore, the terms "comprises" and "comprising," as well as any variations thereof, are intended to cover a non-exclusive inclusion, such as a list of steps or elements. A method, system, article, or apparatus is not necessarily limited to those steps or elements explicitly listed, but may include other steps or elements not explicitly listed or inherent to such process, system, article, or apparatus.

It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.

First, several technical terms related to the embodiments of the present application will be explained.

A storage device is a device for storing information, and generally, information is digitized and then stored in a medium using an electric, magnetic, optical, or other means. The storage device referred to in the embodiments of the present application refers to an external storage, and may include a hard disk, a magnetic disk, a floppy disk, an optical disk, or a usb disk. The storage device provides physical storage space.

The hard disk partition is to divide the whole storage space of the hard disk into a plurality of independent areas, and the independent areas can be used for installing an operating system, installing an application program, storing a data file and the like. Generally, from the viewpoint of convenience, easiness and rapidness in storing and managing files, a physical hard disk is divided into a plurality of partitions for storing different types of files, such as an operating system, an application program, a data file and the like.

The file system space refers to a physical storage space managed by the file system, and the file system can perform read-write operation on the physical storage space. For example, a file system corresponds to a partition, and the file system space may be the storage area where the partition is located. This file system space, which may also be referred to as: the name of physical storage space actually covered by the file system, readable and writable space of the file system, etc. is not intended to be limiting. In this specification, reference is made to "file system space occupying physical storage space" or the like, where the physical storage space occupied is the physical storage space. The physical storage space may also be referred to as a physical storage space corresponding to the file system space or a managed physical storage space.

Logical space corresponding to file system space

And the virtual reserved area is different from the space of the file system, the file system cannot read and write the virtual reserved area, and the virtual reserved area does not occupy the actual physical storage space. The virtual reserved area may be a part of a logical overlay of a file system, that is, a part of a logical space managed by the file system, and the file system also manages a logical space corresponding to the file system space. That is, the space covered by the file system logic includes the logic space and the virtual reserved area corresponding to the file system space. In other words, the virtual reserved area can be understood as a part of space in the logical space managed by the file system, the part of space does not occupy the actual physical storage space, and the part of space is an unreadable space which is used for occupying space in the logical space managed by the file system. When the file system storage space is reduced, the reduced space can be brought into the virtual reserved area, when the file system space is expanded, the virtual reserved area can be reduced, and a part of space in the virtual reserved area is set to be readable and writable, so that the reduction or expansion of the read-write space of the file system is realized, and in the process, the physical storage space actually covered by the file system is changed, but the total logic space covered by the file system is not changed, so that the relative address change of data outside an adjusting area is not caused in the file system space adjusting process, the data of other areas do not need to be migrated, and the file system space adjusting process is simplified. That is, the logical space of the file system management is divided into a logical space corresponding to the file system space and a virtual reserved area. During the adjustment of the file system space, the logical space managed by the file system remains unchanged. The virtual reserved area may also be other names, and the names are not limited thereto.

The method for adjusting the file system space provided in the embodiment of the present application may be applied to a mobile phone, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a handheld computer, a netbook, a Personal Digital Assistant (PDA), a wearable electronic device, a virtual reality device, or a server or a service cluster, and the embodiment of the present application does not limit the method.

The method for adjusting the file system space in the embodiment of the application mainly relates to a file system module and a file system space adjusting tool in an operating system kernel. Taking the application scenario shown in fig. 1 as an example, the embodiment of the present application relates to a file system module 2000 of an operating system and a file system space adjustment tool 3001. The file system space adjustment tool 3001 is configured to receive a first input from a user, where the first input is used to adjust the size of the file system space, and the file system user state 3001 sends an adjustment instruction to the file system module 2000 to adjust the file system space. The file system module 2000 may adjust the file system of the storage device 1000 it manages based on the adjustment instruction. As shown in fig. 1, a virtual reserved area support module 2001 and a kernel-mode space adjustment interface 2002 are added in a file system module 2000 according to an embodiment of the present invention, where the virtual reserved area support module 2001 is used to manage a virtual reserved area in a storage device 1000, the kernel-mode space adjustment interface 2002 is used to complete adjustment of a file system space, and a user can use a file system space adjustment tool 3001 in a user mode to complete adjustment of the file system space through the kernel-mode space adjustment interface 2002 and the virtual reserved area support module 2001. The specific embodiments of the adjustment method can be seen in the following explanation of examples. The user mode may further set a virtual reserved area support module 3002 of a create file system (mkfs) for setting a virtual reserved area when the file system is created. The file system space adjustment tool 3001 may be used for user-mode online or offline adjustment of file system space. The file system space adjustment tool 3001 may be an Application program, a user mode execution program/command, an Application Programming Interface (API), or the like.

Illustratively, fig. 2 shows a schematic structural diagram of the terminal device 100.

The terminal device 100 may include: an application processor 101, a Micro Controller Unit (MCU) 103, a memory 105, a modem (modem)107, a Radio Frequency (RF) module 109, a Wireless-Fidelity (Wi-Fi) module 111, a bluetooth module 113, a sensor 114, a positioning module 150, and an input/output (I/O) device 115. These components may communicate over one or more communication buses or signal lines. Those skilled in the art will appreciate that the hardware configuration shown in fig. 2 does not constitute a limitation of the terminal device, and that the terminal device 100 may include more or less components than those shown, or combine certain components, or a different arrangement of components.

The following describes each component of the terminal device 100 in detail with reference to fig. 2:

the application processor 101 is a control center of the terminal device 100, and various components of the terminal device 100 are connected by various interfaces and buses. In some embodiments, the application processor 101 may include one or more processing units.

The memory 105 has stored therein computer programs such as an operating system 161 and application programs 163 shown in fig. 2. The application processor 101 is configured to execute a computer program in the memory 105 to implement the functions defined by the computer program, for example, the application processor 101 executes the operating system 161 to implement various functions of the operating system on the terminal device 100. The memory 105 also stores data other than computer programs, such as data generated during operation of the operating system 161 and application programs 163. The memory 105 may include both internal and external memory. The Memory includes, but is not limited to, Random Access Memory (RAM), Read-Only Memory (ROM), or cache. External memory includes, but is not limited to, flash memory (flash memory), hard disks, optical disks, Universal Serial Bus (USB) disks, and the like. The computer program is typically stored on an external memory, from which the processor loads the program into the internal memory before executing the computer program.

The memory 105 may be independent and connected to the application processor 101 through a bus; memory 105 may also be integrated with application processor 101 into a chip subsystem.

The MCU 103 is a co-processor for acquiring and processing data from the sensor 114, the processing power and power consumption of the MCU 103 are smaller than those of the application processor 101, but the MCU 103 has a feature of "always on", which can continuously collect and process sensor data when the application processor 101 is in sleep mode, and thus ensure normal operation of the sensor with extremely low power consumption. The sensors 114 may include optical sensors, motion sensors, gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., which are not described in detail herein. The MCU 103 and the sensor 114 may be integrated on the same chip or may be separate components connected by a bus.

The Modem 107 and the rf module 109 constitute a communication subsystem of the terminal device 100, and are used for implementing main functions of wireless communication standard protocols such as 3GPP and ETSI. The Modem 107 is used for encoding and decoding, modulation and demodulation of signals, equalization, and the like. The rf module 109 is used for receiving and transmitting wireless signals, and the rf module 109 includes, but is not limited to, an antenna, at least one amplifier, a coupler, a duplexer, and the like. The radio frequency module 109 is matched with the Modem 107 to realize a wireless communication function.

The terminal device 100 may also perform wireless communication using the Wi-Fi module 111, the bluetooth module 113, and the like. The Wi-Fi module 111 is configured to provide network access complying with a Wi-Fi related standard protocol for the terminal device 100, and the terminal device 100 may access a Wi-Fi access point through the Wi-Fi module 111 to further access the internet. In other embodiments, the Wi-Fi module 111 may also serve as a Wi-Fi wireless access point, which may provide Wi-Fi network access for other terminal devices. The bluetooth module 113 is used to implement short-range communication between the terminal device 100 and other terminal devices (e.g., a mobile phone, a smart watch, etc.). The Wi-Fi module 111 in the embodiment of the present application may be an integrated circuit or a Wi-Fi chip, and the bluetooth module 113 may be an integrated circuit or a bluetooth chip.

The location module 150 is used to determine the geographical location of the terminal device 100. It can be understood that the positioning module 150 may specifically be a receiver of a positioning system such as a Global Positioning System (GPS), a global navigation satellite system (GLONASS), or a beidou satellite navigation system (BDS).

Wi-Fi module 111, bluetooth module 113, and location module 150 may each be separate chips or integrated circuits, or may be integrated together. For example, in one embodiment, Wi-Fi module 111, Bluetooth module 113, and location module 150 can be integrated onto the same chip. In another embodiment, the Wi-Fi module 111, the Bluetooth module 113, the positioning module 150 and the MCU 103 can also be integrated into the same chip.

Input/output devices 115 include, but are not limited to: a display 151, a touch screen 153, and an audio circuit 155, among others.

Among other things, the touch screen 153 may capture touch events on or near the terminal device 100 by a user (e.g., operations of the user on the touch screen 153 or near the touch screen 153 using any suitable object such as a finger, a stylus, etc.) and transmit the captured touch events to other devices (e.g., the application processor 101).

The display 151 (also referred to as a display screen) is used to display information input by a user or information presented to the user. The display may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like.

The audio circuitry 1155, speaker 116, microphone 117 may provide an audio interface between the user and the terminal device 100. The audio circuit 109 may transmit the electrical signal converted from the received audio data to the speaker 113, and convert the electrical signal into a sound signal by the speaker 113 for output; on the other hand, the microphone 114 converts the collected sound signal into an electric signal, and the electric signal is received by the audio circuit 109 and then converted into audio data, and the audio data is transmitted to, for example, another terminal device through the Modem 107 and the radio frequency module 109, or the audio data is output to the memory 105 for further processing.

In addition, the terminal device 100 may also have a fingerprint recognition function. For example, the fingerprint acquisition device may be disposed on the back side of the terminal device 100 (e.g., below the rear camera), or disposed on the front side of the terminal device 100 (e.g., below the touch screen 153).

Further, the operating system 161 carried by the terminal device 100 may beOr other operating system, to which the embodiments of the present application do not impose any limitations.

To be carried withThe terminal device 100 of the operating system is taken as an example, and as shown in fig. 3, the terminal device 100 can be logically divided into a hardware layer 21, an operating system 161, and an application layer 31. The hardware layer 21 includes the application processor 101, the microcontroller unit 103, the memory 105, the Modem 107, the Wi-Fi module 111, the sensor 114, the positioning module 150, and other hardware resources as described above. The application layer 31 includes one or more applications, such as an application 163, and the application 163 may be any type of application, such as a social-type application, an e-commerce-type application, a browser, and so on. The operating system 161 is a computer program that manages and controls hardware and software resources as software middleware between the hardware layer 21 and the application layer 31. The application program 163 in this embodiment may be an application program for file system adjustment.

In one embodiment, the operating system 161 includes a kernel 23, Hardware Abstraction Layer (HAL) 25, libraries and runtimes (libraries and runtimes) 27, and framework (framework) 29. The kernel 23 is used to provide, among other things, the underlying system components and services, such as: power management, memory management, file system management, thread management, hardware drivers, etc.; the hardware driving program comprises a Wi-Fi driving program, a sensor driving program, a positioning module driving program and the like. The hardware abstraction layer 25 is an encapsulation of the kernel driver, providing an interface to the framework 29, shielding the implementation details of the lower layers. The hardware abstraction layer 25 runs in user space and the kernel driver runs in kernel space.

Libraries and runtimes 27, also called runtime libraries, provide the required library files and execution environment for the executable program at runtime.

The framework 29 is used to provide various underlying common components and services for applications in the application layer 31, such as window management, location management, and the like.

The functions of the various components of the operating system 161 described above may be implemented by the application processor 101 executing programs stored in the memory 105.

Taking the memory 105 including an internal memory and an external memory as an example, the file system management of the kernel 23 in the operating system 161 is explained, as shown in fig. 4, the hardware layer 21 may include an external memory 1051, the kernel 23 may include a file system management 231, the file system management 231 may correspond to the file system module 2000, and the application processor 101 in the embodiment of the present application may be configured to execute a computer program in the memory 105, so as to implement the method for adjusting the file system space in the embodiment of the present application, so that the file system management 231 adjusts the file system space in the external memory 1051, implement the secure and lossless adjustment of the file system space, avoid the storage performance loss of the file system brought by the logic layer, and reduce the time required by the file system space adjustment.

The external memory may be referred to as an external memory.

Those skilled in the art will appreciate that terminal 100 may include fewer or more components than those shown in fig. 2, and that the terminal device shown in fig. 2 includes only those components more pertinent to the various implementations disclosed in the embodiments of the present application.

The term "data" as referred to in this application refers to a collection of information stored on an electronic device using a memory as a carrier. The data may be text documents, pictures, audio-video, executable programs, and the like. This data may also be referred to as a file.

Fig. 5A is a schematic diagram of a physical layout of a file system space according to an embodiment of the present application, and fig. 5B is a schematic diagram of a logical layout of the file system space according to the embodiment of the present application. As an example, fig. 5A illustrates a distribution of a file system space in a physical storage space, and as shown in fig. 5A, the file system space of the embodiment of the present application includes a Metadata (META) area and a data area of a file system (where a vertically-striped area is a used area and a blank area is a free area). In the embodiment of the application, a Metadata (META) area of a file system is placed in a file system space, and two ends of the file system space are both data areas. In other words, the Metadata (META) area of the file system is located inside the physical storage space occupied by the file system space. It may be anywhere inside. The layout mode can ensure that the file system avoids metadata migration as much as possible in the process of expanding or reducing the head or tail of the physical storage space and ensures the data security in the process of adjusting the space of the file system. The non-migration of the metadata can also ensure that the relative address change of the data area is reduced, and the complexity of the file system space adjustment can be reduced to a great extent. In addition, the layout mode enables the two ends of the coverage area of the file system to be conveniently enlarged and reduced, and performance loss caused by adding an intermediate layer for flexibility can be avoided. N in fig. 5A represents the length of the virtual reserved area, this embodiment is exemplified by taking the position of the virtual reserved area as (30, N + 30), where (30, N + 30) is a logical address, and since the virtual reserved area does not occupy the physical storage space, as shown in fig. 5A, the virtual reserved area is not included in the physical layout of the file system space, and with reference to fig. 5B, the virtual reserved area is located between areas where the logical space corresponding to the file system space is located, for example, between two used areas as shown in fig. 5A, the end address of one of the two used areas is 30, and the start address of the other part is N +31, that is, the virtual reserved area occupies the logical space managed by the file system, as shown in fig. 5B, the logical space managed by the file system includes the logical space corresponding to the file system space and the virtual reserved area, the physical layout of the file system space is shown in FIG. 5A. The metadata area of the file system further includes virtual reserved area recording information, which includes related records of the space range in which the virtual reserved area is located, for example, at least two of the start address, the end address or the length of the virtual reserved area. When the file system space needs to be enlarged or reduced, the size of the virtual reserved area can be flexibly adjusted according to the requirement, so that the safe and lossless adjustment of the file system space is realized.

The position and the size of the virtual reserved area can be set when the file system is initialized, and can be adjusted subsequently according to the use requirement. The size of the virtual reserved area is set to a value of an arbitrary size, but since the virtual reserved area belongs to a part of a logical space managed by the file system, the size of the virtual reserved area is smaller than that of the logical space managed by the file system. That is, N may be 0 or more and may be an integer smaller than L, where L represents the length of the logical space managed by the file system, and for example, when the file system space adjustment involves only the reduction of the file system space.

The layout mode of the embodiment of the application can improve the security of the metadata in the file system space adjustment process, and can enable the file system space adjustment to be adjusted from two ends of the physical storage space, so that the file system space adjustment is more flexible and safer. The virtual reserved area is set, so that the change of the logical address of the non-change area caused by the space adjustment process of the file system can be avoided.

It should be noted that fig. 5A and fig. 5B are only an example of the embodiment of the present application, in some examples, two ends of the file system space may not be a data area as in fig. 5A, but may also be a metadata area, and the embodiment of the present application is not limited to fig. 5A. The starting position (first block) of the logical address of the file system in the embodiment of the application is located inside the physical storage space occupied by the file system space. That is, the first block address shown in fig. 5A may be not a metadata area but a data area.

Fig. 6 is a flowchart of a method for adjusting a file system space according to an embodiment of the present disclosure, where an execution main body of the embodiment may be the electronic device or an internal chip of the electronic device, and as shown in fig. 6, the method according to the embodiment may include:

step 101, receiving a first input, where the first input is used to adjust a size of a file system space, and the file system space occupies a physical storage space.

For example, the user inputs the first input to the electronic device or an internal chip of the electronic device through the file system space adjustment tool 3001. The first input is used to expand or reduce the file system space, i.e. to adjust the size of the physical storage space occupied by the file system space.

Step 102, in response to the first input, determining a size of the adjustment region.

The size of the adjustment region may be the size of the physical storage space that needs to be enlarged or reduced. In one implementation, the size of the adjustment region may be determined according to the size of the available physical storage space. The usable physical storage space may be a usable portion of the newly added physical storage space, or a usable portion of the physical storage space occupied by other file system spaces. In another implementation, the first input is further used to indicate a size of the adjustment requirement, and the size of the adjustment area may be determined according to the size of the adjustment requirement.

Step 103, adjusting the virtual reserved area of the file system and the file system data according to the size of the adjustment area, and obtaining an adjusted file system space, where the logical space managed by the file system includes the virtual reserved area and a logical space corresponding to the file system space, the virtual reserved area does not occupy a physical storage space, and the size of the physical storage space occupied by the adjusted file system space is larger than or smaller than the physical storage space occupied by the file system space before adjustment.

The file system data may include metadata of a file system including virtual reserved area recording information and data of file system management.

And according to the size of the adjustment area, correspondingly reducing or expanding the virtual reserved area of the file system so as to expand or reduce the logic space corresponding to the file system space in the logic space managed by the file system, and further expand or reduce the physical storage space occupied by the file system space, thereby realizing the expansion or reduction of the file system space.

The size of the logical space managed by the file system in the embodiment of the application is not changed before and after the adjustment of the file system space. According to the embodiment of the application, when the file system space needs to be expanded, the logic space corresponding to the file system space is expanded by reducing the virtual reserved area, and the expanded area is mapped to the physical storage space, so that the expansion of the file system space is realized, namely the expansion of the physical storage space actually covered by the file system. When the file system space needs to be reduced, the logical space corresponding to the file system space is reduced, and the physical storage area occupied by the reduced area is released, so that the virtual reserved area is expanded, and the reduction of the file system space is realized, namely the reduction of the physical storage space actually covered by the file system.

In the embodiment of the application, a first input is received, where the first input is used to adjust a size of a file system space, the file system space occupies a physical storage space, a size of an adjustment area is determined in response to the first input, a virtual reserved area of the file system is adjusted according to the size of the adjustment area, and an adjusted file system space is obtained. Because the size of the logical space managed by the file system is not changed before and after the file system space is adjusted, the relative address change of data outside the adjustment area can not be caused in the file system space adjustment process, and data in other areas do not need to be migrated, so that the file system space adjustment process is simple. According to the embodiment of the application, in the process of realizing the safe and lossless adjustment of the space of the file system, the loss of the storage performance of the file system caused by the LVM can be avoided, and the time required by the space adjustment of the file system is reduced.

The following explains the reduction of the file system space and the expansion of the file system space in two embodiments, respectively.

Fig. 7 is a flowchart of a method for adjusting a file system space according to an embodiment of the present disclosure, where an execution main body of the embodiment may be the electronic device or an internal chip of the electronic device, and the file system space includes a data area and a metadata area, and the embodiment is an embodiment for reducing the file system space, and as shown in fig. 7, the method according to the embodiment may include:

step 201, receiving a first input, where the first input is used to reduce a file system space, and the file system space occupies a physical storage space.

Step 202, in response to the first input, determining a size of the adjustment region.

For the explanation of step 201 and step 202, reference may be made to step 101 and step 102 in the embodiment shown in fig. 6.

Step 203, determining whether the size of the adjustment area is smaller than or equal to the size of the available space of the file system, if so, executing step 204, and if not, ending.

When the size of the adjustment area is smaller than or equal to the size of the available space of the file system, the file system space is reduced through the following steps. When the size of the adjustment region is larger than the size of the available space of the file system, the file system space reduction fails. The available space of the file system may be an available space of a data area or an available space of a metadata area, which is not limited in this embodiment of the present application.

Step 204, determining whether the adjustment area has valid data of the file system, if yes, executing step 205, and if not, executing step 206.

Specifically, by determining whether the adjustment region overlaps with a used region in the file system space, if so, determining whether valid data of the file system exists in the overlapped region, and if so, executing the following step 205 to migrate the valid data into the available space of the file system.

The position of the adjustment region can be flexibly selected according to requirements, for example, the adjustment region is located at the front end of the file system space or at the tail end of the file system space.

As illustrated in the first row view of fig. 8, if the adjustment region is located at the leftmost position in fig. 8 and the adjustment region has valid data, the valid data needs to be migrated to the available space of the file system as shown in fig. 8 through the following step 205.

Step 205, according to the data organization mode of the file system, migrating the valid data in the adjustment area to the available space of the file system.

Referring to the second row of fig. 8, valid data is migrated to the available space of the file system, for example, the valid data is 5 data blocks, the 5 data blocks are migrated block by block, and the migrated file system space may be shown in the third row of fig. 8.

Step 206, setting the adjustment area in the data area to a used state, releasing the physical space occupied by the adjustment area, and acquiring the adjusted file system space.

Referring to the fourth row of FIG. 8, the physical space occupied by the adjusted file system space becomes smaller.

And setting the adjustment area in the data area to be in a used state, namely, classifying the adjustment area into a virtual reserved area of the file system, namely, expanding the virtual reserved area of the file system.

And step 207, determining the position of the adjusted virtual reserved area according to the position of the adjusted area, and updating the recording information of the virtual reserved area according to the position of the adjusted virtual reserved area.

To explain with reference to the logical space managed by the file system of fig. 9, the logical layout of the file system corresponding to the first to third rows of fig. 8 is shown in the first row of fig. 9. After the adjustment area is included in the virtual reserved area of the file system, the logical layout of the file system is shown in the second row of fig. 9, i.e. the virtual reserved area is enlarged.

In the embodiment of the application, a first input is received, where the first input is used to reduce the size of a file system space, the file system space occupies a physical storage space, a size of an adjustment area is determined in response to the first input, the adjustment area is located in a data area of the file system space, the adjustment area in the data area is set to a used state, the physical storage space occupied by the adjustment area is released, an adjusted file system space and an adjusted virtual reserved area are obtained, the adjusted virtual reserved area includes the adjustment area, and the size of the physical storage space occupied by the adjusted file system space is smaller than the physical storage space occupied by the file system space before adjustment. Because the size of the logical space managed by the file system is not changed before and after the file system space is reduced, the relative address change of data outside the reduced area is not caused in the process of reducing the file system space, and data in other areas do not need to be migrated, so that the flow of adjusting the file system space is simplified. According to the embodiment of the application, in the process of realizing the safe and lossless adjustment of the space of the file system, the loss of the storage performance of the file system caused by the LVM can be avoided, and the time required by the space adjustment of the file system is reduced.

Fig. 10 is a flowchart of a method for adjusting a file system space according to an embodiment of the present application, where an execution main body of the embodiment may be the electronic device or an internal chip of the electronic device, and the file system space includes a data area and a metadata area, and the embodiment is an embodiment for expanding the file system space, and as shown in fig. 10, the method according to the embodiment may include:

step 301, receiving a first input, where the first input is used to expand a file system space, and the file system space occupies a physical storage space.

Step 302, in response to the first input, determining a size of the adjustment region.

For the explanation of step 301 and step 302, reference may be made to step 101 and step 102 in the embodiment shown in fig. 6.

Step 303, determining whether the size of the adjustment region is smaller than or equal to the size of the virtual reserved region, if so, executing step 304, and if not, ending.

And when the size of the adjustment area is smaller than or equal to the size of the virtual reserved area, expanding the file system space through the following steps. And when the size of the adjusting area is larger than that of the virtual reserved area, the expansion of the file system space fails.

The position of the adjustment region can be flexibly selected according to requirements, for example, the adjustment region is located at the front end of the file system space or at the tail end of the file system space.

Step 304, mapping the adjustment area in the virtual reserved area to a physical storage space, setting the adjustment area to be in an idle state, and acquiring an adjusted file system space, wherein the adjusted file system space includes the adjustment area.

The physical storage space of this embodiment may be a newly added physical storage space, or may be a physical storage space of another file system released by the example shown in fig. 7.

As shown in fig. 11, the physical space occupied by the adjusted file system space becomes large.

And mapping the adjustment area in the virtual reserved area to a physical storage space, and setting the adjustment area to be in an idle state, so that the file system can access the adjustment area. That is, the adjusted area is classified into the file system space, that is, the virtual reserved area is reduced, and the file system space is expanded.

And 305, determining the position of the adjusted virtual reserved area according to the position of the adjusted area, and updating the recording information of the virtual reserved area according to the position of the adjusted virtual reserved area.

To explain with reference to the logical space managed by the file system of fig. 12, the logical layout of the file system corresponding to the first row of fig. 11 described above is shown in the first row of fig. 12. After the adjustment area in the virtual reserved area is classified into the file system space, the logical layout of the file system is shown in the second row of fig. 12, i.e., the file system space is expanded.

In the embodiment of the application, a first input is received, where the first input is used to enlarge a size of a file system space, the file system space occupies a physical storage space, a size of an adjustment area is determined in response to the first input, the adjustment area is located in a virtual reserved area, the adjustment area in the virtual reserved area is mapped to the physical storage space, the adjustment area is set to a free state, an adjusted file system space is obtained, the adjusted file system space includes the adjustment area, and the size of the physical storage space occupied by the adjusted file system space is larger than the physical storage space occupied by the file system space before adjustment. Because the size of the logical space managed by the file system is not changed before and after the file system space is expanded, the relative address change of data outside the expanded area can not be caused in the process of reducing the file system space, and data in other areas do not need to be migrated, so that the flow of adjusting the file system space is simplified. According to the embodiment of the application, in the process of realizing the safe and lossless adjustment of the space of the file system, the loss of the storage performance of the file system caused by the LVM can be avoided, and the time required by the space adjustment of the file system is reduced.

The existing file system layout mode is difficult to realize space expansion under the condition that the file system space is exhausted, or performance overhead is caused by the need of an intermediate layer, or the layout mode is very complex. According to the embodiment of the application, the position of the key metadata area is changed by designing a new layout mode, and the inside of the key metadata area is changed from the front part, so that flexible adjustment modes at two ends of a file system space are realized. The space adjustment is more flexible and safer, no additional performance overhead exists, and the file system can be detached and borrowed conveniently through the space of the adjacent area when the space of the file system is exhausted, so that the space expansion operation is performed.

When the space is adjusted, if the relative address of the data block of the file system changes, the address change situation needs to be updated block by block in order to ensure the data consistency, and the process is dangerous, complex and time-consuming. According to the embodiment of the application, the virtual reserved area is newly added, and when the space size is adjusted, the virtual reserved area can be enlarged or reduced, so that the change of the relative address of the data block is avoided. The space adjusting process is further simplified, the relative address of the file data block is prevented from changing, the space adjusting speed is improved, and the space adjusting method is safer.

It should be noted that, a storage device may have multiple file systems, each file system covers a part of a physical storage space, each file system in the multiple file systems may adopt the setting mode of the metadata and the setting of the virtual reserved area in the embodiment of the present application, or some file systems in the multiple file systems may adopt the setting mode of the metadata and the setting of the virtual reserved area in the embodiment of the present application, and the rest of the file systems may adopt the mode in which the metadata is set at the head of the file system space, and a specific implementation manner of the file systems may be flexibly set according to needs.

In the following embodiment, three file systems are taken as an example on a storage device, which are a file system 1, a file system 2, and a file system 3, where the file system 2 and the file system 3 adopt the above-mentioned setting mode of metadata and the setting of a virtual reserved area in the embodiment of the present application, and an example of the method for adjusting a file system space in the embodiment of the present application is described.

Referring to fig. 13, as shown in the first row of fig. 13, the physical storage space of the file system 2 is about to be exhausted, the physical storage space of the file system 2 needs to be expanded, and since the physical storage space of the storage device is limited and no additional storage device provides the physical storage space, the physical storage space needs to be borrowed from other adjacent areas, which is exemplified by borrowing from the file system 3 in this embodiment. Before the file system 2 is enlarged, the file system 3 needs to be reduced.

With reference to the method for adjusting the file system space in the foregoing embodiment, first, the size of the adjustment space is determined, and it is determined whether the size of the adjustment space is smaller than the size of the available space of the data area of the file system 3, if so, a start position and an end position of the adjustment space are determined according to the size of the adjustment space, and it is determined whether valid data of the file system 3 exists in the adjustment space, and if so, the valid data in the adjustment space is migrated to the available space of the data area, that is, as shown in the second row of fig. 13. After the migration is completed, the adjustment area of the file system 3 is set to be in a used state, the physical storage space occupied by the adjustment area is released, and the adjusted file system space is obtained. I.e. as shown in the third row of fig. 13. And updating the virtual reserved area of the file system 3 according to the position of the adjustment area, namely adding the adjustment area into the virtual reserved area of the file system 3, and thus finishing the reduction process of the file system 3.

After that, the file system 2 is enlarged. The area in which the file system 2 is expanded is the area in which the file system 3 is reduced. Adjusting the virtual reserved area of the file system 2, namely reducing the virtual reserved area of the file system 2, mapping a part of the virtual reserved area of the file system 2, which has the same size as the adjusted area, to the physical storage space released by the file system 3, setting the part to be in an idle state, and then enabling the file system 2 to access the part. And updating the virtual reserved area of the file system 2, namely reducing the virtual reserved area of the file system 3, and thus finishing the expansion process of the file system 2.

Referring to the fourth row of fig. 13, in the process of adjusting the file system 2 and the file system 3, the total length of the logical space managed by the two is not changed, and the starting or ending position of the virtual reserved area is adjusted, so that the file system can flexibly adjust the readable and writable range, thereby greatly simplifying the adjustment of the file system space, and the relative address of the data block in the file system is kept stable, so that the adjustment of the file system space is safer.

According to the embodiment, when the space of the file system is exhausted, the file system can be detached through the space of the adjacent region conveniently, space expansion operation is carried out, space adjustment is more flexible and safer, additional performance overhead is avoided, the relative address of the data block in the file system is kept stable through the virtual reserved region, meanwhile, the starting position or the ending position of the virtual reserved region is adjusted, the read-write range of the file system can be adjusted flexibly, and the space adjustment of the file system is simplified greatly.

It will be appreciated that the electronic device, in order to implement the above-described functions, comprises corresponding hardware and/or software modules for performing the respective functions. The present application is capable of being implemented in hardware or a combination of hardware and computer software in conjunction with the exemplary algorithm steps described in connection with the embodiments disclosed herein. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, with the embodiment described in connection with the particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.

In this embodiment, the electronic device may be divided into functional modules according to the above method example, for example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated module may be implemented in the form of hardware. It should be noted that the division of the modules in this embodiment is schematic, and is only a logic function division, and there may be another division manner in actual implementation.

In the case of dividing the functional modules by corresponding functions, fig. 14 shows a possible composition diagram of the electronic device 1400 in the above embodiment, as shown in fig. 14, the electronic device 1400 may include: a receiving module 1401 and a processing module 1402.

Among other things, the receiving module 1401 may be used to support the electronic device 1400 in performing the above-described steps 101, 201, or 301, etc., and/or other processes for the techniques described herein.

Processing module 1402 may be used to enable electronic device 1400 to perform steps 102 and 103, or steps 202-207, or steps 302-305, etc., described above, and/or other processes for the techniques described herein.

It should be noted that all relevant contents of each step related to the above method embodiment may be referred to the functional description of the corresponding functional module, and are not described herein again.

The electronic device provided by the embodiment is used for executing the method for adjusting the file system space, so that the same effect as the effect of the implementation method can be achieved.

In case an integrated unit is employed, the electronic device may comprise a processing module, a storage module and a communication module. The processing module may be configured to control and manage actions of the electronic device, for example, may be configured to support the electronic device to execute steps executed by the receiving module 1401 and the processing module 1402. The memory module may be used to support the electronic device in executing stored program codes and data, etc. The communication module can be used for supporting the communication between the electronic equipment and other equipment.

The processing module may be a processor or a controller. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. A processor may also be a combination of computing functions, e.g., a combination of one or more microprocessors, a Digital Signal Processing (DSP) and a microprocessor, or the like. The storage module may be a memory. The communication module may specifically be a radio frequency circuit, a bluetooth chip, a Wi-Fi chip, or other devices that interact with other devices.

In an embodiment, when the processing module is a processor and the storage module is a memory, the electronic device according to this embodiment may be a device having the structure shown in fig. 2.

The present embodiment further provides a computer storage medium, where a computer instruction is stored in the computer storage medium, and when the computer instruction runs on an electronic device, the terminal device executes the above related method steps to implement the method for adjusting the file system space in the above embodiment.

The embodiment also provides a computer program product, which, when running on a computer, causes the computer to execute the above related steps to implement the method for adjusting the file system space in the above embodiment.

In addition, embodiments of the present application also provide an apparatus, which may be specifically a chip, a component or a module, and may include a processor and a memory connected to each other; when the device runs, the processor can execute the computer execution instructions stored in the memory, so that the chip can execute the method for adjusting the file system space in the above method embodiments.

The electronic device, the computer storage medium, the computer program product, or the chip provided in this embodiment are all configured to execute the corresponding method provided above, so that the beneficial effects achieved by the electronic device, the computer storage medium, the computer program product, or the chip may refer to the beneficial effects in the corresponding method provided above, and are not described herein again.

Through the description of the above embodiments, those skilled in the art will understand that, for convenience and simplicity of description, only the division of the above functional modules is used as an example, and in practical applications, the above function distribution may be completed by different functional modules as needed, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions.

It should be further noted that the virtual reserved area in the embodiment of the present application may also be defined as an area where the file system can flexibly change the read-write attribute, and the file system may set the virtual reserved area as readable-writable and non-readable-writable, where the virtual reserved area is equivalent to the virtual reserved area in the foregoing embodiment when the virtual reserved area is not readable-writable. The core ideas of the method for realizing the space adjustment of the file system are the same, and the specific implementation modes are slightly different. The method for adjusting the file system space according to the embodiment of the present application is not limited to the definition of the virtual reserved area.

Through the description of the above embodiments, those skilled in the art will understand that, for convenience and simplicity of description, only the division of the above functional modules is used as an example, and in practical applications, the above function distribution may be completed by different functional modules as needed, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions.

In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, a module or a unit may be divided into only one logic function, and may be implemented in other ways, for example, a plurality of units or components may be combined or integrated into another apparatus, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.

Units described as separate parts may or may not be physically separate, and parts displayed as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed to a plurality of different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.

The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially or partially contributed to by the prior art, or all or part of the technical solutions may be embodied in the form of a software product, where the software product is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, or the like) or a processor (processor) to execute all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.

30页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:镜像构建的方法、装置、电子设备和存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!