WO2021185094A1 - 文件系统空间的调整方法、装置和电子设备 - Google Patents

文件系统空间的调整方法、装置和电子设备 Download PDF

Info

Publication number
WO2021185094A1
WO2021185094A1 PCT/CN2021/079146 CN2021079146W WO2021185094A1 WO 2021185094 A1 WO2021185094 A1 WO 2021185094A1 CN 2021079146 W CN2021079146 W CN 2021079146W WO 2021185094 A1 WO2021185094 A1 WO 2021185094A1
Authority
WO
WIPO (PCT)
Prior art keywords
file system
space
area
adjustment
adjusted
Prior art date
Application number
PCT/CN2021/079146
Other languages
English (en)
French (fr)
Inventor
缪勰
方炜
郭雪楠
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2021185094A1 publication Critical patent/WO2021185094A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/119Details of migration of file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1727Details of free space management performed by the file system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/188Virtual file systems

Definitions

  • This application relates to computer technology, and in particular to a method, device and electronic equipment for adjusting the space of a file system.
  • the operating system is located between the underlying hardware and the user, and is the bridge between the two.
  • the user can input instructions through the user interface of the operating system.
  • the operating system parses the instructions and drives the hardware devices to meet user requirements.
  • the operating system can provide the following functions: process management, memory management, file system, network communication, security mechanism, user interface, and driver programs.
  • the file system is a method and data structure used to specify files on storage devices (disks, solid state drives, etc.) or partitions in an operating system, that is, a method for organizing files on a storage device.
  • storage devices for example, hard disks
  • multiple file systems are created for data storage and organization.
  • the initial space division may not meet the use requirements.
  • 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 for the operating system to run.
  • the partition and content of the storage device are usually adjusted by the method of non-destructive space size adjustment.
  • the key is to complete the file system space adjustment.
  • a commonly used method is to adopt logical volume manager (LVM), that is, adding a logical layer between the hard disk partition and the file system to realize the expansion or reduction of the partition.
  • LVM logical volume manager
  • This logical layer can shield the physical space limitation of hard disk partitions and present it to the outside with logical volume space.
  • the file system is created on the logical volume.
  • the file system space adjustment tool for example, resize2fs, etc.
  • This application provides a method, device and electronic device for adjusting the space of a file system, which can realize the safe and non-destructive adjustment of the file system space, avoid the storage performance loss of the file system caused by the logic layer to a certain extent, and reduce the space adjustment of the file system.
  • the present application provides a method for adjusting file system space.
  • the method may include: receiving a first input, the first input being used to adjust the size of the file system space, and the file system space occupies physical storage space.
  • the size of the adjustment area is determined; the adjustment can also be started directly in response to the first input; or the adjustment can also be started when other conditions and the first input are all satisfied, this application.
  • Adjust the virtual reserved area of the file system to obtain the adjusted file system space.
  • the logical space managed by the file system includes the virtual reserved area and the logical space corresponding to the file system space.
  • the virtual reserved area does not occupy physical space. Storage space, the size of the physical storage space occupied by the adjusted file system space is larger or smaller than the physical storage space occupied by the file system space before the adjustment.
  • the adjustment process further includes the adjustment of the file system data, where the file system data includes the metadata of the file system, and the metadata of the file system includes the record information of the virtual reserved area.
  • the reserved area record information is used to indicate the start position and length, or start position and end position, or length and end position of the virtual reserved area.
  • the file system manages at least two parts of the logical space: the virtual reserved area and the logical space corresponding to the file system space, of which only the file system space occupies the physical storage space.
  • the virtual reserved area is reduced, and the reduced part of the virtual reserved area is added to the logical space corresponding to the file system space.
  • This logical space can be mapped to The physical storage space forms an enlarged file system space. In this way, the logical address of the original file system space can still remain unchanged, and the increased file system space includes the logical address of the original file system space and the newly added logical address of the original virtual reserved area.
  • the virtual reserved area record information is updated, and the updated virtual reserved area record information indicates the position of the adjusted virtual reserved area. It can be seen that the adjustment method provided by the present application can ensure that the logical address of the non-adjustment area remains unchanged, so that the process of file system space adjustment is greatly simplified, and the adjustment process is simpler, safer, and more efficient.
  • the record information of the virtual reserved area in the file system data can be updated.
  • the record information of the virtual reserved area in the file system data may be updated.
  • the aforementioned file system data also includes the valid data, that is, data stored in the physical storage space of the file system space. Before adjusting the virtual reserved area, it is necessary to move the valid data in the adjusted area. That is, the effective data in the file system data is moved.
  • the file system space adjustment can be completed, and then the partition adjustment of the storage device can be completed, which simplifies the space adjustment process and improves the space adjustment timeliness.
  • the starting position of the logical address of the file system is located inside the physical storage space occupied by the file system space.
  • the inside of the physical storage space in the embodiment of the present application refers to the non-starting position and the non-ending position of the physical storage space, that is, the distance from the starting position of the physical storage space is greater than 0, and the distance from the ending 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 a non-starting position of the physical storage space occupied by the file system space And non-terminal positions.
  • 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, then the starting position of the logical address of the file system is at 150, that is, in the file system space The internal physical storage space occupied.
  • the starting position of the logical address will not move during the file system space adjustment process, which can ensure that the relative address of the data area remains unchanged, thereby reducing the complexity of the file system space adjustment.
  • the file system space includes a data area and a metadata area
  • the data area is used for read and write operations of the file system
  • the metadata area is used to store metadata of the file system
  • the metadata area is located in Inside the physical storage space occupied by the file system space.
  • the metadata area is located inside the physical storage space occupied by the file system space, which means that the metadata area is located at a non-starting position and a 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 metadata area is located at (150, 160), that is, it is located in the file system space The interior of the physical storage space.
  • the first input is used to expand the file system space
  • the adjustment area is located in the virtual reserved area.
  • adjusting the virtual reserved area of the file system to obtain the adjusted file system space includes: mapping the adjustment area in the virtual reserved area to the physical storage space, and the adjustment area Set to an idle state to obtain the adjusted file system space, and the adjusted file system space includes the adjustment area.
  • the position of the adjusted virtual reserved area is determined according to the position of the adjusted area; the virtual reserved area record information in the file system data is updated according to the position of the adjusted virtual reserved area.
  • setting the adjustment area to an idle state includes: in the file system data, updating the metadata corresponding to the adjustment area, and the metadata corresponding to the updated adjustment area indicates that the adjustment area is Idle state.
  • the method may further include: determining whether the size of the adjustment area is less than or equal to the size of the virtual reserved area. When the size of the adjustment area is less than or equal to the size of the virtual reserved area, the steps of mapping the adjustment area in the virtual reserved area to the physical storage space and setting the adjustment area to an idle state are performed.
  • the first input is used to reduce the file system space
  • the adjustment area is located in a data area of the file system space.
  • adjusting the virtual reserved area of the file system to obtain the adjusted file system space includes: setting the adjustment area in the file system space to a used state, and releasing the adjustment area occupied Obtain the adjusted file system space and the adjusted virtual reserved area, and the adjusted virtual reserved area includes the adjusted area. Further, the position of the adjusted virtual reserved area is determined according to the position of the adjusted area; the virtual reserved area record information in the file system data is updated according to the position of the adjusted virtual reserved area.
  • the method may further include: determining whether the size of the adjustment area is less than or equal to the size of the available space of the file system. When the size of the adjustment area is less than or equal to the size of the available space of the file system, the step of setting the adjustment area in the file system space to a used state and releasing the physical storage space occupied by the adjustment area is performed.
  • the adjustment device may include: a receiving module, configured to receive a first input, the first input being used to adjust the size of the file system space, the file system space occupies physical storage space; a processing module, used to respond to The first input determines the size of the adjustment area; the processing module is also used to adjust the virtual reserved area and file system data of the file system according to the size of the adjustment area to obtain the adjusted file system space.
  • the logical space managed by the system includes the virtual reserved area and the logical space corresponding to the file system space.
  • the virtual reserved area does not occupy physical storage space.
  • the size of the physical storage space occupied by the adjusted file system space is greater than or less than Physical storage space occupied by the file system space before adjustment.
  • the starting position of the logical address of the file system is located inside the physical storage space occupied by the file system space.
  • the file system space includes a data area and a metadata area
  • the data area is used for read and write operations of the file system
  • the metadata area is used to store metadata of the file system
  • the metadata area Located inside the physical storage space occupied by the file system space.
  • the processing module is used to update metadata corresponding to the adjustment area in the file system data, and the updated metadata corresponding to the adjustment area indicates that the adjustment area is in an idle state.
  • the processing module is further used to determine whether the size of the adjustment area is less than or equal to the size of the virtual reserved area; when the size of the adjustment area is less than or equal to the size of the virtual reserved area, Perform the steps of mapping the adjustment area in the virtual reserved area to the physical storage space, and setting the adjustment area to an idle state.
  • the first input is used to reduce the file system space
  • the adjustment area is located in a data area of the file system space.
  • the processing module is used to: set the adjustment area in the file system space to a used state, release the physical storage space occupied by the adjustment area, and obtain the adjusted file system space and the adjusted virtual reserved area.
  • the adjusted virtual reserved area includes the adjusted area; the position of the adjusted virtual reserved area is determined according to the position of the adjusted area; the file system data is updated according to the position of the adjusted virtual reserved area
  • the virtual reserved area records information.
  • the processing module when the adjustment area overlaps the used area in the file system space, the processing module is also used to: transfer the effective data of the area overlapping with the used area in the file system space Available space to the file system space.
  • the processing module is further used to determine whether the size of the adjustment area is less than or equal to the size of the available space of the file system.
  • the step of setting the adjustment area in the file system space to a used state and releasing the physical storage space occupied by the adjustment area is performed.
  • the receiving module mentioned in the above second aspect may be a receiving interface, a receiving circuit or a receiver, etc.; the processing module may be one or more processors.
  • this application provides an electronic device, including: one or more processors; a memory, used to store one or more programs; when the one or more programs are executed by the one or more processors , Enabling the one or more processors to implement the method according to any one of the foregoing first aspects.
  • the present application provides a computer-readable storage medium, including a computer program, which when executed on a computer, causes the computer to execute the method described in any one of the above-mentioned first aspects.
  • the present application provides a computer program or a computer program product containing a computer program, when the computer program is executed by a computer, it is used to execute the method described in any one of the above-mentioned first aspects.
  • the present application provides a chip including a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the above-mentioned first aspect The method of any one of.
  • the method, apparatus and electronic device for adjusting the file system space of the embodiments of the present application receive a first input, the first input is used to adjust the size of the file system space, the file system space occupies the physical storage space, and responds to the first input. Input, determine the size of the adjustment area, adjust the virtual reserved area and file system data of the file system according to the size of the adjustment area, and obtain the adjusted file system space.
  • the logical space managed by the file system includes the virtual reserved area The logical space corresponding to the file system space, the virtual reserved area does not occupy physical storage space, and the size of the physical storage space occupied by the adjusted file system space is larger or smaller than the physical storage occupied by the file system space before adjustment space.
  • the embodiments of the present application can avoid the storage performance loss of the file system caused by LVM, and reduce the time required for file system space adjustment.
  • FIG. 2 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the application.
  • FIG. 3 is a schematic diagram of the software structure of an electronic device according to an embodiment of the application.
  • FIG. 4 is a schematic diagram of the software structure of an electronic device according to an embodiment of the application.
  • 5A is a schematic diagram of the physical layout of the file system space according to an embodiment of the application.
  • 5B is a schematic diagram of the logical layout of the file system space according to an embodiment of the application.
  • FIG. 6 is a flowchart of a method for adjusting the space of a file system according to an embodiment of the application
  • FIG. 7 is a flowchart of a method for adjusting the space of a file system according to an embodiment of the application.
  • FIG. 8 is a schematic diagram of a process of shrinking file system space according to an embodiment of the application.
  • FIG. 9 is a schematic diagram of a process of shrinking file system space according to an embodiment of the application.
  • FIG. 10 is a flowchart of a method for adjusting the space of a file system according to an embodiment of the application.
  • FIG. 11 is a schematic diagram of an expansion process of a file system space according to an embodiment of the application.
  • FIG. 12 is a schematic diagram of an expansion process of a file system space according to an embodiment of the application.
  • FIG. 13 is a schematic diagram of an adjustment method of a file system space according to an embodiment of the application.
  • FIG. 14 is a schematic structural diagram of another electronic device according to an embodiment of the application.
  • At least one (item) refers to one or more, and “multiple” refers to two or more.
  • “And/or” is used to describe the association relationship of associated objects, indicating that there can be three types of relationships, for example, “A and/or B” can mean: only A, only B, and both A and B , Where A and B can be singular or plural.
  • the character “/” generally indicates that the associated objects before and after are in an “or” relationship.
  • the following at least one item (a) or similar expressions refers to any combination of these items, including any combination of a single item (a) or a plurality of items (a).
  • At least one of a, b, or c can mean: a, b, c, "a and b", “a and c", “b and c", or "a and b and c" ", where a, b, and c can be single or multiple.
  • Storage device a device used to store information, usually digitizes the information and then stores it in electric, magnetic or optical media.
  • the storage devices involved in the embodiments of the present application refer to external storage, which may include hard disks, magnetic disks, floppy disks, optical disks, or U disks.
  • the storage device provides physical storage space.
  • Hard disk partitioning refers to dividing the overall storage space of the hard disk into multiple independent areas.
  • the multiple independent areas can be used to install the operating system, install applications, and store data.
  • Files, etc. Generally, starting from the convenience, ease, and speed of file storage and management, the physical hard disk is divided into multiple partitions to store different types of files, such as storing operating systems, applications, and data files.
  • File system space refers to the physical storage space managed by the file system, and the file system can perform read and write operations on the physical storage space.
  • a file system corresponds to a partition
  • the file system space may be a storage area where the partition is located.
  • the file system space may also be referred to as: the physical storage space actually covered by the file system, the readable and writable space of the file system, etc., and its name is not limited by this.
  • the physical storage space may also be referred to as the physical storage space corresponding to the file system space or the managed physical storage space, etc.
  • the virtual reserved area is different from the file system space.
  • the file system cannot read and write to the virtual reserved area, and the virtual reserved area does not occupy actual physical storage space.
  • the virtual reserved area can be used as a part of the logical coverage of the file system, that is, a part of the logical space managed by the file system, and the file system also manages the logical space corresponding to the aforementioned file system space. That is, the space logically covered by the file system includes the logical space and the virtual reserved area corresponding to the above-mentioned file system space.
  • the virtual reserved area can be understood as a part of the logical space managed by the file system. This part of the space does not occupy the actual physical storage space. Occupy a space in the space.
  • the reduced space can be included in the virtual reserved area.
  • the virtual reserved area can be reduced, and a part of the virtual reserved area can be set to be readable and writable. Realize the reduction or expansion of the file system's read and write space, and the physical storage space actually covered by the file system changes during this process, but the total logical space covered by it has not changed, so the file system space adjustment process will not cause adjustment
  • the relative address of data outside the area changes, so data in other areas does not need to be migrated, making the process of file system space adjustment simple. That is, the logical space managed by the file system is divided into the logical space corresponding to the file system space and the 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 can also have other names, and its names are not restricted by this.
  • the method for adjusting the file system space provided by the embodiments of this application can be applied to mobile phones, tablet computers, notebook computers, ultra-mobile personal computers (UMPC), handheld computers, netbooks, and personal digital assistants (personal digital assistants).
  • the file system space adjustment method in the embodiment of the present application mainly involves the file system module in the operating system kernel and the file system space adjustment tool.
  • 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 used to receive a first input input by a user, and the first input is used to adjust the size of the file system space.
  • 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.
  • the file system module 2000 of the embodiment of the present application adds a support module 2001 of a virtual reserved area and a kernel state space adjustment interface 2002.
  • the support module 2001 of the virtual reserved area is used to manage the storage device 1000.
  • the kernel state space adjustment interface 2002 is used to complete the adjustment of the file system space.
  • the user can use the file system space adjustment tool 3001 in the user mode, through the kernel state space adjustment interface 2002 and the support module of the virtual reserved area In 2001, the file system space adjustment was completed.
  • the user mode can also set a virtual reserved area support module 3002 for creating a file system (mkfs), which is used to set a virtual reserved area when creating a file system.
  • the file system space adjustment tool 3001 can be used to adjust the file system space online or offline in a user mode.
  • the file system space adjustment tool 3001 can be an application program, a user-mode execution program/command, an application program interface (Application Programming Interface, API), and the like.
  • FIG. 2 shows a schematic structural diagram of the terminal device 100.
  • the terminal device 100 may include: an application processor 101, a microcontroller unit (microcontroller unit, MCU) 103, a memory 105, a modem (modem) 107, a radio frequency (RF) module 109, and a wireless fidelity (Wireless-Fidelity, (Referred to as Wi-Fi) module 111, Bluetooth module 113, sensor 114, positioning module 150, input/output (I/O) device 115 and other components. These components can communicate through one or more communication buses or signal lines.
  • the terminal device 100 may include more or less components than shown in the figure, or a combination of certain components, or different components. Layout.
  • the application processor 101 is the control center of the terminal device 100, and uses various interfaces and buses to connect various components of the terminal device 100.
  • the application processor 101 may include one or more processing units.
  • the memory 105 stores computer programs, such as the 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 functions defined by the computer program.
  • the application processor 101 executes an operating system 161 to implement various functions of the operating system on the terminal device 100.
  • the memory 105 also stores other data besides computer programs, such as data generated during the operation of the operating system 161 and the application program 163.
  • the memory 105 may include internal memory and external memory.
  • the memory includes but is not limited to random access memory (Random Access Memory, RAM), read-only memory (Read-Only Memory, ROM), or cache (cache).
  • External storage includes but is not limited to flash memory (flash memory), hard disks, optical disks, universal serial bus (USB) disks, etc.
  • Computer programs are usually stored in external memory, and the processor loads the program from external memory to memory before executing the computer program.
  • the memory 105 may be independent and connected to the application processor 101 through a bus; the memory 105 and the application processor 101 may also be integrated into a chip subsystem.
  • MCU 103 is a co-processor used to acquire and process data from the sensor 114.
  • the processing power and power consumption of MCU 103 are less than that of the application processor 101, but it has the feature of "always on” and can be used in the application processor.
  • 101 continuously collects and processes sensor data when it is in sleep mode to ensure the normal operation of the sensor with extremely low power consumption.
  • the sensor 114 may include a light sensor, a motion sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
  • 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 radio frequency module 109 constitute the communication subsystem of the terminal device 100, which is used to implement the main functions of the wireless communication standard protocols such as 3GPP and ETSI. Among them, Modem 107 is used for encoding and decoding, signal modulation and demodulation, and equalization.
  • the radio frequency module 109 is used for receiving and transmitting wireless signals.
  • the radio frequency 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 cooperates with the Modem 107 to realize the wireless communication function.
  • the terminal device 100 may also use the Wi-Fi module 111, the Bluetooth module 113, etc. to perform wireless communication.
  • the Wi-Fi module 111 is used to provide the terminal device 100 with network access that complies with Wi-Fi related standard protocols.
  • the terminal device 100 can access a Wi-Fi access point through the Wi-Fi module 111, and then access the Internet.
  • the Wi-Fi module 111 can also be used as a Wi-Fi wireless access point, which can provide Wi-Fi network access for other terminal devices.
  • the Bluetooth module 113 is used to implement short-distance communication between the terminal device 100 and other terminal devices (such as mobile phones, smart watches, etc.).
  • the Wi-Fi module 111 in the embodiment of the present application may be an integrated circuit or a Wi-Fi chip or the like, and the Bluetooth module 113 may be an integrated circuit or a Bluetooth chip or the like.
  • the positioning module 150 is used to determine the geographic location of the terminal device 100. It is understandable that the positioning module 150 may specifically be a positioning system such as a global positioning system (GPS), a global navigation satellite system (GLONASS), or a Beidou satellite navigation system (BDS). Receiver.
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou satellite navigation system
  • the Wi-Fi module 111, the Bluetooth module 113, and the positioning module 150 may be separate chips or integrated circuits, respectively, or they may be integrated together.
  • the Wi-Fi module 111, the Bluetooth module 113 and the positioning module 150 may be integrated on the same chip.
  • the Wi-Fi module 111, the Bluetooth module 113, the positioning module 150, and the MCU 103 may also be integrated into the same chip.
  • the input/output device 115 includes, but is not limited to: a display 151, a touch screen 153, an audio circuit 155, and so on.
  • the touch screen 153 can collect touch events on or near the user of the terminal device 100 (for example, the user uses a finger, a stylus, or any other suitable object to operate on the touch screen 153 or near the touch screen 153), and Send the collected touch events to other devices (for example, the application processor 101).
  • the display (also called a display screen) 151 is used to display information input by the user or information presented to the user.
  • the display can be configured in the form of liquid crystal display, organic light emitting diode, etc.
  • the audio circuit 1155, the speaker 116, and the microphone 117 may provide an audio interface between the user and the terminal device 100.
  • the audio circuit 109 can transmit the electric signal after the conversion of the received audio data to the speaker 113, which is converted 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 audio circuit 109 After being received, the audio data is converted into audio data, and then the audio data is sent 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.
  • the terminal device 100 may also have a fingerprint recognition function.
  • a fingerprint collection device may be configured on the back of the terminal device 100 (for example, below the rear camera), or a fingerprint collection device may be configured on the front of the terminal device 100 (for example, below the touch screen 153).
  • the operating system 161 carried by the terminal device 100 may be Or other operating systems, this embodiment of the present application does not impose any restriction on this.
  • the terminal device 100 of the operating system is taken as an example.
  • 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 hardware resources such as the application processor 101, the microcontroller unit 103, the memory 105, the Modem 107, the Wi-Fi module 111, the sensor 114, and the positioning module 150 as described above.
  • the application layer 31 includes one or more applications, such as an application 163.
  • the application 163 may be any type of application such as a social application, an e-commerce application, or a browser.
  • the operating system 161, as a software middleware between the hardware layer 21 and the application layer 31, is a computer program that manages and controls hardware and software resources.
  • the application program 163 may be an application program for file system adjustment.
  • the operating system 161 includes a kernel 23, a hardware abstraction layer (HAL) 25, a library and runtime (libraries and runtime) 27, and a framework 29.
  • the kernel 23 is used to provide underlying system components and services, such as: power management, memory management, file system management, thread management, hardware drivers, etc.; hardware drivers include Wi-Fi drivers, sensor drivers, positioning module drivers, etc.
  • the hardware abstraction layer 25 encapsulates the kernel driver, provides an interface to the framework 29, and shields low-level implementation details.
  • the hardware abstraction layer 25 runs in the user space, and the kernel driver runs in the kernel space.
  • the library and runtime 27 is also called the runtime library, which provides the required library files and execution environment for the executable program at runtime.
  • the framework 29 is used to provide various basic common components and services for applications in the application layer 31, such as window management, location management, and so on.
  • the functions of the various components of the operating system 161 described above can all be implemented by the application processor 101 executing a program stored in the memory 105.
  • the hardware layer 21 may include the external memory 1051, and the kernel 23 may include files.
  • the file system management 231 may correspond to the above-mentioned file system module 2000.
  • the application processor 101 of the embodiment of the present application may be configured to execute the computer program in the memory 105, thereby realizing the file system space of the embodiment of the present application.
  • the adjustment method allows the file system management 231 to adjust the file system space in the external storage 1051, realize the safe and lossless adjustment of the file system space, avoid the storage performance loss of the file system caused by the logic layer, and reduce the space adjustment of the file system. It takes a long time.
  • external memory may also be referred to as an external memory.
  • the terminal 100 may include fewer or more components than those shown in FIG. 2, and the terminal device shown in FIG. part.
  • the "data” mentioned in this application refers to a collection of information stored on an electronic device using a memory as a carrier.
  • the data can be text documents, pictures, audio and video, executable programs, and so on. This data can also be called a file.
  • FIG. 5A is a schematic diagram of the physical layout of the file system space according to an embodiment of this application
  • FIG. 5B is a schematic diagram of the logical layout of the file system space according to an embodiment of this application.
  • FIG. 5A shows the distribution of the file system space in the physical storage space.
  • the vertical pattern area is the used area, and the blank area is the free area).
  • the metadata (META) area of the file system is placed inside the file system space, and both ends of the file system space are data areas.
  • the metadata (META) area of the file system is located inside the physical storage space occupied by the file system space. It can be anywhere inside.
  • This layout method can ensure that the file system avoids metadata migration as much as possible during the process of expanding or shrinking the head or tail of the physical storage space, and ensures data security during the file system space adjustment process.
  • the non-migration of metadata can also ensure that the relative address changes of the data area are reduced, and the complexity of file system space adjustment can be greatly reduced.
  • this layout makes it easy to expand and shrink both ends of the coverage area of the file system, which can avoid the performance loss caused by adding an intermediate layer for flexibility.
  • N in FIG. 5A represents the length of the virtual reserved area.
  • the position of the virtual reserved area is (30, N+30) as an example for illustration, where (30, N+30] is the logical address, because The virtual reserved area does not occupy physical storage space, so as shown in Figure 5A, the physical layout of the file system space does not include the virtual reserved area.
  • the virtual reserved area is located in the logical space corresponding to the file system space. Between the areas where it is located, for example, between the two used areas shown in Figure 5A, one of the two used areas has an end address of 30, and the other has a start address of N+31, that is The virtual reserved area occupies a place in the logical space managed by the file system.
  • 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 as As shown in Figure 5A.
  • the metadata area of the file system also includes virtual reserved area record information, the virtual reserved area record information includes related records of the space range where the virtual reserved area is located, for example, the start address of the virtual reserved area At least two of the end address or length.
  • the position and size of the aforementioned virtual reserved area can be set when the file system is initialized, and can also be adjusted according to usage requirements later.
  • the size of the virtual reserved area is set to a value of any size, but since the virtual reserved area is a part of the logical space managed by the file system, the size of the virtual reserved area is smaller than the size of the logical space managed by the file system. That is, the foregoing N is an arbitrary integer greater than or equal to 0 and less than L, and L represents the length of the logical space managed by the file system. For example, when the file system space adjustment only involves the reduction of the file system space, the N can be set to 0.
  • the above-mentioned layout method of the embodiment of the present application can not only improve the security of metadata in the file system space adjustment process, but also enable the file system space adjustment to be adjusted from both ends of the physical storage space, which is more flexible and safe. Setting the virtual reserved area can avoid the change of the logical address of the non-changing area caused by the file system space adjustment process.
  • FIGS. 5A and 5B are only an example of the embodiment of the present application.
  • the two ends of the file system space may not be the data area as shown in FIG. 5A, but may also be the metadata area.
  • 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 present application is located inside the physical storage space occupied by the file system space. That is, the address of the first block shown in FIG. 5A may not be a metadata area, but may also be a data area.
  • Fig. 6 is a flowchart of a method for adjusting the space of a file system according to an embodiment of this application.
  • the execution subject of this embodiment may be the above-mentioned electronic device or the internal chip of the electronic device.
  • the method of this embodiment may include:
  • Step 101 Receive a first input, where the first input is used to adjust the size of a file system space, and the file system space occupies a physical storage space.
  • the user inputs the first input to the electronic device or the 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, that is, adjust the size of the physical storage space occupied by the file system space.
  • Step 102 In response to the first input, determine the size of the adjustment area.
  • the size of the adjustment area may be the size of the physical storage space that needs to be expanded or reduced. In an achievable manner, the size of the adjustment area can be determined according to the size of the available physical storage space.
  • the usable physical storage space may be a usable part of the newly added physical storage space, or may be a usable part of the physical storage space occupied by other file system spaces.
  • the first input is also used to indicate the size of the adjustment demand, and the size of the adjustment area can be determined according to the size of the adjustment demand.
  • Step 103 According to the size of the adjustment area, adjust the virtual reserved area and file system data of the file system to obtain the adjusted file system space.
  • the logical space managed by the file system includes the virtual reserved area and the file system space Corresponding to the logical space, the virtual reserved area does not occupy physical storage space, and the size of the physical storage space occupied by the adjusted file system space is larger or smaller than the physical storage space occupied by the file system space before the adjustment.
  • the file system data may include metadata of the file system and data managed by the file system, and the metadata of the file system includes virtual reserved area record information.
  • the virtual reserved area of the file system is reduced or enlarged correspondingly, so as to expand or shrink the logical space corresponding to the file system space in the logical space managed by the file system, thereby expanding or reducing the file system space
  • the occupied physical storage space can expand or shrink the file system space.
  • the size of the logical space managed by the file system in the embodiment of the present application has not changed before and after the file system space is adjusted.
  • the virtual reserved area is reduced to expand the logical space corresponding to the file system space, and then the expanded area is mapped to the physical storage space, thereby realizing the expansion of the file system space, that is, file Expansion of the physical storage space actually covered by the system.
  • the logical space corresponding to the file system space is reduced, and the physical storage area occupied by the reduced area is released, thereby expanding the virtual reserved area and realizing the reduction of the file system space, that is, the physical storage area actually covered by the file system. Reduction of storage space.
  • the file system space adjustment process Since the size of the logical space managed by the file system has not changed before and after the file system space adjustment, the file system space adjustment process will not cause the relative address of the data outside the adjustment area to change, and other area data does not need to be migrated, making the file system
  • the process of space adjustment becomes simple.
  • the embodiments of the present application can avoid the storage performance loss of the file system caused by LVM, and reduce the time required for file system space adjustment.
  • FIG. 7 is a flowchart of a method for adjusting file system space according to an embodiment of this application.
  • the execution subject of this embodiment may be the above-mentioned electronic device or the internal chip of the electronic device.
  • the file system space includes a data area and a metadata area.
  • This embodiment To reduce the space of the file system, as shown in FIG. 7, the method of this embodiment may include:
  • Step 201 Receive 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, determine the size of the adjustment area.
  • step 201 and step 202 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 Determine whether the size of the adjustment area is less than or equal to the size of the available space of the file system, if yes, execute step 204, if not, end.
  • the available space of the file system may be the available space of the data area or the available space of the metadata area, which is not limited in the embodiment of the present application.
  • Step 204 Determine whether there is valid data of the file system in the adjustment area, if yes, execute step 205, if not, execute step 206.
  • step 205 migrate the valid data to the available space of the file system.
  • the location of the adjustment area can be flexibly selected according to requirements, for example, located at the front end of the file system space or the end of the file system space.
  • the adjustment area is located on the leftmost side as shown in FIG. 8. If there is valid data in the adjustment area, the following step 205 is required to migrate the valid data as shown in FIG. In the free space of the file system.
  • Step 205 According to the data organization mode of the file system, the effective data in the adjustment area is migrated to the available space of the file system.
  • the valid data is 5 data blocks, and the 5 data blocks are moved block by block.
  • the file system space after the move can be seen in the figure Shown in the third row of 8.
  • Step 206 Set the adjustment area in the data area to a used state, release the physical space occupied by the adjustment area, and obtain the adjusted file system space.
  • the physical space occupied by the adjusted file system space becomes smaller.
  • the adjustment area in the data area is set to a used state, that is, the adjustment area is included in the virtual reserved area of the file system, that is, the virtual reserved area of the file system is expanded.
  • Step 207 Determine the position of the adjusted virtual reserved area according to the position of the adjusted area, and update the virtual reserved area record information according to the adjusted position of the virtual reserved area.
  • the first input is used to reduce the size of the file system space
  • the file system space occupies the physical storage space
  • the size of the adjustment area is determined, and the adjustment area is located In the data area of the file system space, set the adjustment area in the data area to the used state, release the physical storage space occupied by the adjustment area, and obtain the adjusted file system space and the adjusted virtual reserved area.
  • the virtual reserved area of 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 the adjustment.
  • the file system space shrinking process will not cause the relative address of the data outside the reduced area to change, and data in other areas does not need to be migrated, making the file system
  • the process of space adjustment becomes simple.
  • the embodiments of the present application can avoid the storage performance loss of the file system caused by LVM, and reduce the time required for file system space adjustment.
  • the execution subject of this embodiment may be the above-mentioned electronic device or the internal chip of the electronic device.
  • the file system space includes a data area and a metadata area.
  • This embodiment To expand the space of the file system, as shown in FIG. 10, the method of this embodiment may include:
  • Step 301 Receive 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, determine the size of the adjustment area.
  • step 301 and step 302 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 Determine whether the size of the adjustment area is less than or equal to the size of the virtual reserved area, if yes, execute step 304, if not, end.
  • the following steps are used to expand the file system space.
  • the size of the adjustment area is greater than the size of the virtual reserved area, the file system space expansion fails.
  • the location of the adjustment area can be flexibly selected according to requirements, for example, located at the front end of the file system space or the end of the file system space.
  • Step 304 Map the adjustment area in the virtual reserved area to the physical storage space, set the adjustment area to an idle state, and obtain an adjusted file system space, where the adjusted file system space includes the adjustment area.
  • the physical storage space in this embodiment may be a newly-added physical storage space, or may be a physical storage space of another file system released through the example shown in FIG. 7 above.
  • the physical space occupied by the adjusted file system space becomes larger.
  • the adjustment area in the virtual reserved area is mapped to the physical storage space, and the adjustment area is set to an idle state, so that the file system can access it. That is, the adjustment area is classified into the file system space, that is, the virtual reserved area is reduced and the file system space is expanded.
  • Step 305 Determine the position of the adjusted virtual reserved area according to the position of the adjusted area, and update the virtual reserved area record information according to the adjusted position of the virtual reserved area.
  • the first input is used to expand the size of the file system space, the file system space occupies physical storage space, and in response to the first input, the size of the adjustment area is determined, and the adjustment area is located In the virtual reserved area, the adjustment area in the virtual reserved area is mapped to the physical storage space, the adjustment area is set to an idle state, and the 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 greater than the physical storage space occupied by the file system space before the adjustment.
  • the file system space shrinking process will not cause the relative address of the data outside the expanded area to change, and data in other areas does not need to be migrated, making the file system
  • the process of space adjustment becomes simple.
  • the embodiments of the present application can avoid the storage performance loss of the file system caused by LVM, and reduce the time required for file system space adjustment.
  • the address change needs to be updated block by block. This process is dangerous and complicated and time-consuming.
  • the virtual reserved area can be expanded or reduced, thereby avoiding the change of the relative address of the data block.
  • the space adjustment process is further simplified, the relative address of the file data block is prevented from changing, the space adjustment speed is improved, and it is safer.
  • each file system in the multiple file systems may adopt the above-mentioned metadata setting method in the embodiment of the present application.
  • some of the file systems of the multiple file systems may adopt the above-mentioned metadata setting method and the setting of the virtual reserved area in the embodiment of the present application, and the remaining file systems may be set in the file system space by using metadata
  • the way of the head, its specific implementation can be flexibly set according to requirements.
  • file system 1 takes three file systems on the storage device as an example, namely file system 1, file system 2, and file system 3.
  • file system 2 and file system 3 adopt the above-mentioned metadata setting method in the embodiment of this application.
  • the method for adjusting the space of the file system in the embodiment of the present application will be illustrated by an example.
  • the physical storage space of file system 2 is about to be exhausted, and the physical storage space of file system 2 needs to be expanded. Because the physical storage space of the storage device is limited and there is no The newly added storage device provides physical storage space, so it needs to be borrowed from other adjacent areas. In this embodiment, borrowing from the file system 3 is taken as an example for illustration. Before expanding the file system 2, the file system 3 needs to be reduced.
  • Combining the file system space adjustment method of the foregoing embodiment first determine the size of the adjustment space, determine whether the size of the adjustment space is less than the available space of the data area of the file system 3, and if so, determine the size of the adjustment space according to the size of the adjustment space From the start position and the end position, it is judged whether there is valid data of the file system 3 in the adjustment space. If so, the valid data in the adjustment area is migrated to the available space of the data area, 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 a used state, the physical storage space occupied by the adjustment area is released, and the adjusted file system space is obtained. That is, as shown in the third row of Figure 13. According to the location of the adjustment area, the virtual reserved area of the file system 3 is updated, that is, the adjustment area is added to the virtual reserved area of the file system 3, and the shrinking process of the file system 3 is completed.
  • the file system 2 is enlarged.
  • the enlarged area of the file system 2 is the reduced area of the file system 3.
  • Adjust the virtual reserved area of file system 2 that is, reduce the virtual reserved area of file system 2, and map the part of the virtual reserved area of file system 2 with the same size as the adjusted area to the physical storage released by file system 3.
  • Space set this part to an idle state, and then the file system 2 can access this part.
  • the virtual reserved area of the file system 2 is updated, that is, the virtual reserved area of the file system 3 is reduced. At this point, the expansion process of the file system 2 is completed.
  • the space of the file system when the space of the file system is exhausted, it can be easily borrowed and borrowed through the space of the adjacent area to perform the space expansion operation, so that the space adjustment is more flexible and safe, and there is no additional performance overhead.
  • the virtual reserved area makes the file system The relative address of the middle data block remains stable, and at the same time, by adjusting the start or end position of the virtual reserved area, the file system can flexibly adjust the read and write range, which greatly simplifies the file system space adjustment.
  • an electronic device in order to implement the above-mentioned functions, includes hardware and/or software modules corresponding to each function.
  • the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software-driven hardware depends on the specific application and design constraint conditions of the technical solution. Those skilled in the art can use different methods for each specific application in combination with the embodiments to implement the described functions, but such implementation should not be considered as going beyond the scope of the present application.
  • the electronic device may be divided into functional modules according to the foregoing method examples.
  • each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module.
  • the above-mentioned integrated modules can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
  • FIG. 14 shows a schematic diagram of a possible composition of the electronic device 1400 involved in the foregoing embodiment.
  • the electronic device 1400 may include: a receiving module 1401 and processing module 1402.
  • the processing module may be a processor or a controller. It can implement or execute various exemplary logical blocks, modules, and circuits described in conjunction with the disclosure of this application.
  • the processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, and so on.
  • the storage module may be a memory.
  • the communication module may specifically be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, and other devices that interact with other devices.
  • the electronic device involved in this embodiment may be a device having the structure shown in FIG. 2.
  • This embodiment also provides a computer storage medium.
  • the computer storage medium stores computer instructions.
  • the terminal device is caused to execute the above-mentioned related method steps to implement the file system space in the above-mentioned embodiment. Adjustment method.
  • This embodiment also provides a computer program product, which when the computer program product runs on a computer, causes the computer to execute the above-mentioned related steps, so as to implement the method for adjusting the file system space in the above-mentioned embodiment.
  • the embodiments of the present application also provide a device.
  • the device may specifically be a chip, component or module.
  • the device may include a processor and a memory connected to each other.
  • the memory is used to store computer execution instructions.
  • the processor can execute the computer-executable instructions stored in the memory, so that the chip executes the file system space adjustment method in the foregoing method embodiments.
  • the electronic device, computer storage medium, computer program product, or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the corresponding method provided above. The beneficial effects of the method will not be repeated here.
  • the virtual reserved area in the embodiment of the present application can also be defined as an area in which the file system can flexibly change the read and write attributes, and the file system can set the virtual reserved area to be readable and writable and non-readable When it is not readable and writable, it is equivalent to the virtual reserved area in the foregoing embodiment.
  • the core idea of the method of realizing file system space adjustment for differently defined virtual reserved areas is the same, and the specific implementation methods are slightly different.
  • the method for adjusting the space of the file system in the embodiment of the present application is not limited by the above definition of the virtual reserved area.
  • the disclosed device and method may be implemented in other ways.
  • the device embodiments described above are merely illustrative, for example, the division of modules or units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components may be combined or It can be integrated into another device, 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, and may be in electrical, mechanical or other forms.
  • the units described as separate parts may or may not be physically separate, and the parts displayed as units may be one physical unit or multiple physical units, that is, they may be located in one place, or they may be distributed to multiple different places. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or 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 can be stored in a readable storage medium.
  • the technical solutions of the embodiments of the present application are essentially or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of a software product, and the software product is stored in a storage medium. It includes several instructions to make a device (which may be a single-chip microcomputer, a chip, etc.) or a processor (processor) execute all or part of the steps of the methods of the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read only memory (read only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种文件系统空间的调整方法、装置和电子设备。文件系统空间的调整方法,包括:接收第一输入,所述第一输入用于调整文件系统空间的大小(步骤101),所述文件系统空间占用物理存储空间;响应于所述第一输入,确定调整区域的大小(步骤102);根据所述调整区域的大小,对文件系统的虚拟预留区域和文件系统数据进行调整,获取调整后的文件系统空间(步骤103),所述文件系统管理的逻辑空间包括所述虚拟预留区域和所述文件系统空间对应的逻辑空间,所述虚拟预留区域未占用物理存储空间,所述调整后的文件系统空间所占用的物理存储空间的大小大于或小于调整前的文件系统空间所占用的物理存储空间。本方法可以实现文件系统空间的安全和无损调整,避免由逻辑层所带来文件系统的存储性能损失,降低文件系统空间调整所需时长。

Description

文件系统空间的调整方法、装置和电子设备
本申请要求于2020年3月20日提交中国专利局、申请号为202010203172.4、申请名称为“文件系统空间的调整方法、装置和电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术,尤其涉及一种文件系统空间的调整方法、装置和电子设备。
背景技术
操作系统位于底层硬件与用户之间,是两者沟通的桥梁。用户可以通过操作系统的用户界面,输入指令。操作系统对指令进行解析,驱动硬件设备,实现用户要求。操作系统可以提供如下的功能:进程管理、内存管理、文件系统、网络通信、安全机制、用户界面、以及驱动程序等。其中,文件系统是操作系统中用于明确存储设备(磁盘、固态硬盘等)或分区上的文件的方法和数据结构,即在存储设备上组织文件的方法。
为了管理和使用的便捷性等原因,存储设备(例如,硬盘)会被划分为多个分区,并创建多个文件系统用于数据存储和组织。随着存储设备的使用,初始的空间划分会存在不能满足使用需求的问题。例如,一个文件系统覆盖的分区的可用空间即将耗尽,但是操作系统要运行,该文件系统仍然需要继续被使用。为了满足使用需求,通常采用无损空间大小调整的方法对存储设备的分区及内容进行调整。为了实现无损分区调整,关键在于完成文件系统空间调整。针对存储空间和文件系统的调整,通常使用的一种方式是采用逻辑卷管理(logical volume manager,LVM),即在硬盘分区和文件系统中间增加逻辑层,实现分区的扩大或缩小。该逻辑层可以屏蔽硬盘分区的物理空间限制,以逻辑卷空间来对外呈现。文件系统创建在逻辑卷上,当文件系统空间需要进行扩大或缩小时,可以按照需要调整逻辑卷空间大小,然后再利用文件系统空间调整工具(例如,resize2fs等工具)进行调整进而实现文件系统空间调整。
上述文件系统的调整方式虽然能够灵活的调整硬盘空间,但是该逻辑层会造成文件系统的存储性能损失,不能满足性能要求较高的嵌入式设备的使用需求。另外,上述文件系统空间调整工具通常都比较复杂而且调整比较耗时,数据损坏的风险较大。
发明内容
本申请提供一种文件系统空间的调整方法、装置和电子设备,可以实现文件系统空间的安全和无损调整,一定程度上避免由逻辑层所带来文件系统的存储性能损失,降低文件系统空间调整所需时长。
下面通过多个方面介绍本申请,以下多个方面的实现方式和有益效果可互相参考。
第一方面,本申请提供一种文件系统空间的调整方法,该方法可以包括:接收第一输入,该第一输入用于调整文件系统空间的大小,该文件系统空间占用物理存储空间。响应 于该第一输入,确定调整区域的大小;也可以直接响应于该第一输入开始调整;或者还可以在其他条件和该第一输入均满足下开始调整,本申请。对文件系统的虚拟预留区域进行调整,获取调整后的文件系统空间,该文件系统管理的逻辑空间包括该虚拟预留区域和该文件系统空间对应的逻辑空间,该虚拟预留区域未占用物理存储空间,该调整后的文件系统空间所占用的物理存储空间的大小大于或小于调整前的文件系统空间所占用的物理存储空间。
一种可能的设计中,在这个调整过程中,还进一步包括对文件系统数据的调整,这里的文件系统数据包括文件系统的元数据,文件系统的元数据包括虚拟预留区域记录信息,该虚拟预留区域记录信息用于指示虚拟预留区域的起始位置和长度、或者起始位置和结束位置、或者长度和结束位置。
本实现方式中,文件系统管理着至少两部分逻辑空间:虚拟预留区域和文件系统空间对应的逻辑空间,其中只有文件系统空间占用物理存储空间。以增大文件系统空间为例,当需要增大原文件系统空间时,减小虚拟预留区域,虚拟预留区域中被减小的部分加入文件系统空间对应的逻辑空间,该逻辑空间可以映射至物理存储空间,形成增大后的文件系统空间。这样,原文件系统空间的逻辑地址仍可以不变,增大后的文件系统空间包含原文件系统空间的逻辑地址和新加入的原虚拟预留区域的逻辑地址。之后,对虚拟预留区域记录信息进行更新,更新后的虚拟预留区域记录信息表示调整后的虚拟预留区域的位置。可见,本申请提供的调整方法可以保证非调整区域的逻辑地址不变,使得文件系统空间调整的流程大大简化,调整过程更加简单、安全且高效。
对于增大文件系统空间的场景,可以在调整虚拟预留区域之后,对文件系统数据中的虚拟预留区域记录信息进行更新。
对于缩小文件系统空间的场景,可以在调整虚拟预留区域之后,对文件系统数据中的虚拟预留区域记录信息进行更新。在缩小文件系统空间中涉及有效数据搬移时,上述文件系统数据还包括该有效数据,即存储在文件系统空间的物理存储空间中的数据。在调整虚拟预留区域之前,需要对调整区域内的有效数据进行搬移。也即对文件系统数据中的有效数据进行搬移。
基于本申请实施例的文件系统空间的调整方法,可以完成文件系统空间的调整,之后可以完成存储设备的分区调整,简化了空间调整流程,提升了空间调整时效。
一种可能的设计中,文件系统的逻辑地址的起始位置位于该文件系统空间所占用的物理存储空间的内部。
本申请实施例物理存储空间的内部指,物理存储空间的非起始位置和非结束位置,即与物理存储空间的起始位置的距离大于0,与物理存储空间的结束位置的距离大于0。
该文件系统的逻辑地址的起始位置位于该文件系统空间所占用的物理存储空间的内部,是指文件系统的逻辑地址的起始位置位于文件系统空间所占用的物理存储空间的非起始位置和非终止位置。例如,文件系统空间所占用的物理存储空间为(100,200),100为起始物理地址,200为结束物理地址,则该文件系统的逻辑地址的起始位置位于150,即位于文件系统空间所占用的物理存储空间的内部。
本实现方式,通过将文件系统的逻辑地址的起始位置设置到该文件系统空间所占用的物理存储空间的内部,可以从文件系统空间的两端进行调整,从而提升文件系统空间调整 的灵活性。
逻辑地址的起始位置不会在文件系统空间调整过程中移动,可以保证数据区域相对地址不变,从而降低文件系统空间调整的复杂性。
一种可实现方式,该文件系统空间包括数据区域和元数据区域,该数据区域用于该文件系统进行读写操作,该元数据区域用于存储该文件系统的元数据,该元数据区域位于该文件系统空间所占用的物理存储空间内部。
该元数据区域位于该文件系统空间所占用的物理存储空间内部,是指元数据区域位于文件系统空间所占用的物理存储空间的非起始位置和非终止位置。例如,文件系统空间所占用的物理存储空间为(100,200),100为起始物理地址,200为结束物理地址,则该元数据区域位于(150,160),即位于文件系统空间所占用的物理存储空间的内部。
本实现方式,通过将元数据区域设置在文件系统空间所占用的物理存储空间内部,可以避免元数据迁移,保证文件系统空间调整的数据安全。
一种可能的设计中,该第一输入用于扩大所述文件系统空间,该调整区域位于该虚拟预留区域中。根据该调整区域的大小,对该文件系统的虚拟预留区域进行调整,获取调整后的文件系统空间,包括:将该虚拟预留区域中的该调整区域映射至物理存储空间,将该调整区域设置为空闲状态,获取调整后的文件系统空间,该调整后的文件系统空间包括该调整区域。进一步的,根据调整区域的位置,确定调整后的虚拟预留区域的位置;根据调整后的虚拟预留区域的位置更新文件系统数据中的虚拟预留区域记录信息。
一种可能的设计中,将该调整区域设置为空闲状态,包括:在该文件系统数据中,更新所述调整区域对应的元数据,更新后的调整区域对应的元数据表示所述调整区域为空闲状态。
一种可能的设计中,该方法还可以包括:判断该调整区域的大小是否小于或等于该虚拟预留区域的大小。当该调整区域的大小小于或等于该虚拟预留区域的大小时,执行该将该虚拟预留区域中的该调整区域映射至物理存储空间,将该调整区域设置为空闲状态的步骤。
一种可能的设计中,该第一输入用于缩小该文件系统空间,该调整区域位于该文件系统空间的数据区域中。根据该调整区域的大小,对该文件系统的虚拟预留区域进行调整,获取调整后的文件系统空间,包括:将文件系统空间中的该调整区域设置为已用状态,释放该调整区域所占用的物理存储空间,获取调整后的文件系统空间和调整后的虚拟预留区域,该调整后的虚拟预留区域包括该调整区域。进一步的,根据调整区域的位置,确定调整后的虚拟预留区域的位置;根据调整后的虚拟预留区域的位置更新文件系统数据中的虚拟预留区域记录信息。
一种可能的设计中,当该调整区域与该文件系统空间中的已用区域重叠时,该方法还可以包括:将与该文件系统空间中的已用区域重叠的区域的有效数据,迁移至该数据区域中的可用空间。
一种可能的设计中,该方法还可以包括:判断该调整区域的大小是否小于或等于该文件系统的可用空间的大小。当该调整区域的大小小于或等于该文件系统的可用空间的大小时,执行该将该文件系统空间中的该调整区域设置为已用状态,释放该调整区域所占用的物理存储空间的步骤。
第二方面,本申请提供一种文件系统空间的调整装置,该调整装置可以为电子设备或者电子设备中的芯片或者片上系统,还可以为电子设备中用于实现第一方面或第一方面的任一可能的设计该的方法的功能模块。该调整装置可以实现上述第一方面或者第一方面的各可能的设计的功能,该功能可以通过硬件执行相应的软件实现。该硬件或软件包括一个或多个上述功能相应的模块。举例来说,该调整装置,可以包括:接收模块,用于接收第一输入,该第一输入用于调整文件系统空间的大小,该文件系统空间占用物理存储空间;处理模块,用于响应于该第一输入,确定调整区域的大小;该处理模块,还用于根据该调整区域的大小,对文件系统的虚拟预留区域和文件系统数据进行调整,获取调整后的文件系统空间,该文件系统管理的逻辑空间包括该虚拟预留区域和该文件系统空间对应的逻辑空间,该虚拟预留区域未占用物理存储空间,该调整后的文件系统空间所占用的物理存储空间的大小大于或小于调整前的文件系统空间所占用的物理存储空间。
一种可能的设计中,文件系统的逻辑地址的起始位置位于该文件系统空间所占用的物理存储空间的内部。
一种可能的设计中,该文件系统空间包括数据区域和元数据区域,该数据区域用于该文件系统进行读写操作,该元数据区域用于存储该文件系统的元数据,该元数据区域位于该文件系统空间所占用的物理存储空间内部。
一种可能的设计中,该第一输入用于扩大该文件系统空间,该调整区域位于该虚拟预留区域中。该处理模块用于:将该虚拟预留区域中的该调整区域映射至物理存储空间,将该调整区域设置为空闲状态,获取调整后的文件系统空间,该调整后的文件系统空间包括该调整区域;根据所述调整区域的位置,确定调整后的虚拟预留区域的位置;根据所述调整后的虚拟预留区域的位置更新所述文件系统数据中的虚拟预留区域记录信息。
一种可能的设计中,该处理模块用于:在该文件系统数据中,更新该调整区域对应的元数据,更新后的该调整区域对应的元数据表示该调整区域为空闲状态。
一种可能的设计中,该处理模块还用于:判断该调整区域的大小是否小于或等于该虚拟预留区域的大小;当该调整区域的大小小于或等于该虚拟预留区域的大小时,执行该将该虚拟预留区域中的该调整区域映射至物理存储空间,将该调整区域设置为空闲状态的步骤。
一种可能的设计中,该第一输入用于缩小该文件系统空间,该调整区域位于该文件系统空间的数据区域中。该处理模块用于:将该文件系统空间中的该调整区域设置为已用状态,释放该调整区域所占用的物理存储空间,获取调整后的文件系统空间和调整后的虚拟预留区域,该调整后的虚拟预留区域包括该调整区域;根据所述调整区域的位置,确定调整后的虚拟预留区域的位置;根据所述调整后的虚拟预留区域的位置更新所述文件系统数据中的虚拟预留区域记录信息。
一种可能的设计中,当该调整区域与该文件系统空间中的已用区域重叠时,该处理模块还用于:将与该文件系统空间中的已用区域重叠的区域的有效数据,迁移至该文件系统空间的可用空间。
一种可能的设计中,该处理模块还用于:判断该调整区域的大小是否小于或等于该文件系统的可用空间的大小。当该调整区域的大小小于或等于该文件系统的可用空间的大小时,执行该将该文件系统空间中的该调整区域设置为已用状态,释放该调整区域所占用的 物理存储空间的步骤。
上述第二方面中提到的接收模块可以为接收接口、接收电路或者接收器等;处理模块可以为一个或者多个处理器。
第三方面,本申请提供一种电子设备,包括:一个或多个处理器;存储器,用于存储一个或多个程序;当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如上述第一方面中任一项所述的方法。
第四方面,本申请提供一种计算机可读存储介质,包括计算机程序,所述计算机程序在计算机上被执行时,使得所述计算机执行上述第一方面中任一项所述的方法。
第五方面,本申请提供一种计算机程序或包含计算机程序的计算机程序产品,当所述计算机程序被计算机执行时,用于执行上述第一方面中任一项所述的方法。
第六方面,本申请提供一种芯片,包括处理器和存储器,所述存储器用于存储计算机程序,所述处理器用于调用并运行所述存储器中存储的计算机程序,以执行如上述第一方面中任一项所述的方法。
本申请实施例的文件系统空间的调整方法、装置和电子设备,通过接收第一输入,该第一输入用于调整文件系统空间的大小,该文件系统空间占用物理存储空间,响应于该第一输入,确定调整区域的大小,根据调整区域的大小,对文件系统的虚拟预留区域和文件系统数据进行调整,获取调整后的文件系统空间,该文件系统管理的逻辑空间包括该虚拟预留区域和该文件系统空间对应的逻辑空间,该虚拟预留区域未占用物理存储空间,该调整后的文件系统空间所占用的物理存储空间的大小大于或小于调整前的文件系统空间所占用的物理存储空间。本申请实施例在实现文件系统空间的安全和无损调整过程中,可以避免由LVM所带来文件系统的存储性能损失,降低文件系统空间调整所需时长。
附图说明
图1为本申请实施例的一种电子设备的示意图;
图2为本申请实施例的一种电子设备的硬件结构示意图;
图3为本申请实施例的一种电子设备的软件结构示意图;
图4为本申请实施例的一种电子设备的软件结构示意图;
图5A为本申请实施例的文件系统空间的物理布局的示意图;
图5B为本申请实施例的文件系统空间的逻辑布局的示意图;
图6为本申请实施例的文件系统空间的调整方法的流程图;
图7为本申请实施例的文件系统空间的调整方法的流程图;
图8为本申请实施例的文件系统空间的缩小过程的示意图;
图9为本申请实施例的文件系统空间的缩小过程的示意图;
图10为本申请实施例的文件系统空间的调整方法的流程图;
图11为本申请实施例的文件系统空间的扩大过程的示意图;
图12为本申请实施例的文件系统空间的扩大过程的示意图;
图13为本申请实施例的文件系统空间的调整方式的示意图;
图14为本申请实施例的另一种电子设备的结构示意图。
具体实施方式
本申请的说明书实施例和权利要求书及附图中的术语“第一”、“第二”等仅用于区分描述的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元。方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
应当理解,在本申请中,“至少一个(项)”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系,例如,“A和/或B”可以表示:只存在A,只存在B以及同时存在A和B三种情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b或c中的至少一项(个),可以表示:a,b,c,“a和b”,“a和c”,“b和c”,或“a和b和c”,其中a,b,c可以是单个,也可以是多个。
首先对本申请实施例所涉及的几个技术术语进行解释说明。
存储设备,用于储存信息的设备,通常是将信息数字化后再以利用电、磁或光学等方式的媒体加以存储。本申请实施例所涉及的存储设备指外部存储器,可以包括硬盘、磁盘、软盘、光盘或U盘等。存储设备提供物理存储空间。
以存储设备为硬盘,对分区进行解释说明,硬盘分区是指将硬盘的整体存储空间划分成多个独立的区域,该多个独立的区域可以分别用来安装操作系统、安装应用程序以及存储数据文件等。通常,从文件存放和管理的方便、容易、快捷性出发,将物理硬盘划分为多个分区,用以存放不同类型的文件,如存放操作系统、应用程序、数据文件等。
文件系统空间,指文件系统管理的物理存储空间,文件系统可以对该物理存储空间进行读写操作。例如,文件系统与分区对应,文件系统空间可以是该分区所在的存储区域。该文件系统空间,也可以称为:文件系统实际覆盖的物理存储空间、文件系统的可读写空间等,其名称不以此作为限制。在本说明书中提到“文件系统空间占用物理存储空间”或类似表述,这里所说的占用的物理存储空间就是该物理存储空间。该物理存储空间也可以称为文件系统空间所对应的物理存储空间或所管理的物理存储空间等。
文件系统空间对应的逻辑空间
虚拟预留区域,与文件系统空间不同,文件系统不能对虚拟预留区域进行读写,虚拟预留区域不占用实际的物理存储空间。该虚拟预留区域可以作为文件系统逻辑覆盖的一部分,即文件系统管理的逻辑空间的一部分,该文件系统还管理上述文件系统空间对应的逻辑空间。也即文件系统逻辑覆盖的空间包括上述文件系统空间对应的逻辑空间和虚拟预留区域。换言之,虚拟预留区域可以理解为文件系统管理的逻辑空间中的一部分空间,该部分空间不占用实际的物理存储空间,该部分空间为不可读写的空间,其用于在文件系统管理的逻辑空间中占位。当文件系储空间进行缩小时,可以通过将缩小的空间纳入虚拟预留区域,当文件系统空间扩大时可以缩小虚拟预留区域,将虚拟预留区域中的一部分空间设置为可读写,从而实现文件系统读写空间的缩小或扩大,而在此过程中文件系统实际覆盖的物理存储空间发生变化,但是其覆盖的总的逻辑空间未发生变化,因此在文件系统空间调整过程不会引起调整区域外的数据的相对地址变化,因此其他区域数据不用发生迁移, 使得文件系统空间调整的流程变得简单。也即,文件系统管理的逻辑空间被划分为文件系统空间对应的逻辑空间和虚拟预留区域。在文件系统空间进行调整过程中,该文件系统管理的逻辑空间保持不变。该虚拟预留区域也可以是其他名称,其名称不以此作为限制。
本申请实施例提供的一种文件系统空间的调整方法可应用于手机、平板电脑、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、手持计算机、上网本、个人数字助理(personal digital assistant,PDA)、可穿戴电子设备、虚拟现实设备等终端设备中,或者服务器或服务集群中,本申请实施例对此不做任何限制。
本申请实施例的文件系统空间的调整方法主要涉及操作系统内核中的文件系统模块以及文件系统空间调整工具。以图1所示的应用场景为例,本申请实施例涉及操作系统的文件系统模块2000,以及文件系统空间调整工具3001。该文件系统空间调整工具3001用于接收用户输入的第一输入,该第一输入用于调整文件系统空间的大小,该文件系统用户态3001向文件系统模块2000发送调整指令,以调整文件系统空间。文件系统模块2000可以基于调整指令对其管理的存储设备1000的文件系统进行调整。如图1所示,本申请实施例的文件系统模块2000内部增加了虚拟预留区域的支持模块2001和内核态空间调整接口2002,该虚拟预留区域的支持模块2001用于管理存储设备1000中的虚拟预留区域,该内核态空间调整接口2002用于完成文件系统空间的调整,用户可以在用户态使用文件系统空间调整工具3001,通过内核态空间调整接口2002和虚拟预留区域的支持模块2001完成文件系统空间调整。该调整方法的具体实施方式可以参见下述实施例的解释说明。用户态还可以设置创建文件系统(mkfs)的虚拟预留区域支持模块3002,用于在创建文件系统时设置虚拟预留区域。该文件系统空间调整工具3001可以用于用户态在线或离线调整文件系统空间。该文件系统空间调整工具3001可以应用程序、用户态执行程序/命令、应用程序接口(Application Programming Interface,API)等。
示例性的,图2示出了终端设备100的结构示意图。
终端设备100可以包括:应用处理器101、微控制器单元(microcontroller unit,MCU)103、存储器105、调制解调器(modem)107、射频(radio frequency,RF)模块109、无线保真(Wireless-Fidelity,简称Wi-Fi)模块111、蓝牙模块113、传感器114、定位模块150、输入/输出(input/output,I/O)设备115等部件。这些部件可通过一根或多根通信总线或信号线进行通信。本领域技术人员可以理解,图2中示出的硬件结构并不构成对终端设备的限定,终端设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
下面结合图2对终端设备100的各个部件进行具体的介绍:
应用处理器101是终端设备100的控制中心,利用各种接口和总线连接终端设备100的各个部件。在一些实施例中,应用处理器101可包括一个或多个处理单元。
存储器105中存储有计算机程序,诸如图2所示的操作系统161和应用程序163。应用处理器101被配置用于执行存储器105中的计算机程序,从而实现该计算机程序定义的功能,例如应用处理器101执行操作系统161从而在终端设备100上实现操作系统的各种功能。存储器105还存储有除计算机程序之外的其他数据,诸如操作系统161和应用程序 163运行过程中产生的数据。存储器105为可以包括内存和外存。内存包括但不限于随机存取存储器(Random Access Memory,RAM),只读存储器(Read-Only Memory,ROM),或高速缓存(cache)等。外存包括但不限于闪存(flash memory)、硬盘、光盘、通用串行总线(universal serial bus,USB)盘等。计算机程序通常被存储在外存上,处理器在执行计算机程序前会将该程序从外存加载到内存。
存储器105可以是独立的,通过总线与应用处理器101相连接;存储器105也可以和应用处理器101集成到一个芯片子系统。
MCU 103是用于获取并处理来自传感器114的数据的协处理器,MCU 103的处理能力和功耗小于应用处理器101,但具有“永久开启(always on)”的特点,可以在应用处理器101处于休眠模式时持续收集以及处理传感器数据,以极低的功耗保障传感器的正常运行。传感器114可以包括光传感器、运动传感器、陀螺仪、气压计、湿度计、温度计、红外线传感器等,在此不再赘述。MCU 103和传感器114可以集成到同一块芯片上,也可以是分离的元件,通过总线连接。
Modem 107以及射频模块109构成了终端设备100通信子系统,用于实现3GPP、ETSI等无线通信标准协议的主要功能。其中,Modem 107用于编解码、信号的调制解调、均衡等。射频模块109用于无线信号的接收和发送,射频模块109包括但不限于天线、至少一个放大器、耦合器、双工器等。射频模块109配合Modem 107实现无线通信功能。
终端设备100还可以使用Wi-Fi模块111,蓝牙模块113等来进行无线通信。Wi-Fi模块111用于为终端设备100提供遵循Wi-Fi相关标准协议的网络接入,终端设备100可以通过Wi-Fi模块111接入到Wi-Fi接入点,进而访问互联网。在其他一些实施例中,Wi-Fi模块111也可以作为Wi-Fi无线接入点,可以为其他终端设备提供Wi-Fi网络接入。蓝牙模块113用于实现终端设备100与其他终端设备(例如手机、智能手表等)之间的短距离通信。本申请实施例中的Wi-Fi模块111可以是集成电路或Wi-Fi芯片等,蓝牙模块113可以是集成电路或者蓝牙芯片等。
定位模块150用于确定终端设备100的地理位置。可以理解的是,定位模块150具体可以是全球定位系统(global position system,GPS)、全球导航卫星系统(global navigation satellite system,GLONASS)、或北斗卫星导航系统(beidounavigation satellite system,BDS)等定位系统的接收器。
Wi-Fi模块111,蓝牙模块113和定位模块150分别可以是单独的芯片或集成电路,也可以集成到一起。例如,在一个实施例中,Wi-Fi模块111,蓝牙模块113和定位模块150可以集成到同一芯片上。在另一个实施例中,Wi-Fi模块111,蓝牙模块113、定位模块150以及MCU 103也可以集成到同一芯片中。
输入/输出设备115包括但不限于:显示器151、触摸屏153,以及音频电路155等等。
其中,触摸屏153可采集终端设备100的用户在其上或附近的触摸事件(比如用户使用手指、触控笔等任何适合的物体在触摸屏153上或在触控屏触摸屏153附近的操作),并将采集到的触摸事件发送给其他器件(例如应用处理器101)。
显示器(也称为显示屏)151用于显示用户输入的信息或展示给用户的信息。可以采用液晶显示屏、有机发光二极管等形式来配置显示器。
音频电路1155、扬声器116、麦克风117可提供用户与终端设备100之间的音频接口。 音频电路109可将接收到的音频数据转换后的电信号,传输到扬声器113,由扬声器113转换为声音信号输出;另一方面,麦克风114将收集的声音信号转换为电信号,由音频电路109接收后转换为音频数据,再通过Modem 107和射频模块109将音频数据发送给比如另一终端设备,或者将音频数据输出至存储器105以便进一步处理。
另外,终端设备100还可以具有指纹识别功能。例如,可以在终端设备100的背面(例如后置摄像头的下方)配置指纹采集器件,或者在终端设备100的正面(例如触摸屏153的下方)配置指纹采集器件。
进一步地,终端设备100搭载的操作系统161可以为
Figure PCTCN2021079146-appb-000001
或者其它操作系统,本申请实施例对此不作任何限制。
以搭载
Figure PCTCN2021079146-appb-000002
操作系统的终端设备100为例,如图3所示,终端设备100从逻辑上可划分为硬件层21、操作系统161,以及应用层31。硬件层21包括如上所述的应用处理器101、微控制器单元103、存储器105、Modem 107、Wi-Fi模块111、传感器114、定位模块150等硬件资源。应用层31包括一个或多个应用程序,比如应用程序163,应用程序163可以为社交类应用、电子商务类应用、浏览器等任意类型的应用程序。操作系统161作为硬件层21和应用层31之间的软件中间件,是管理和控制硬件与软件资源的计算机程序。本实施例中该应用程序163可以是用于文件系统调整的应用程序。
在一个实施例中,操作系统161包括内核23,硬件抽象层(hardware abstraction layer,HAL)25、库和运行时(libraries and runtime)27以及框架(framework)29。其中,内核23用于提供底层系统组件和服务,例如:电源管理、内存管理、文件系统管理、线程管理、硬件驱动程序等;硬件驱动程序包括Wi-Fi驱动、传感器驱动、定位模块驱动等。硬件抽象层25是对内核驱动程序的封装,向框架29提供接口,屏蔽低层的实现细节。硬件抽象层25运行在用户空间,而内核驱动程序运行在内核空间。
库和运行时27也叫做运行时库,它为可执行程序在运行时提供所需要的库文件和执行环境。
框架29用于为应用层31中的应用程序提供各种基础的公共组件和服务,比如窗口管理、位置管理等等。
以上描述的操作系统161的各个组件的功能均可以由应用处理器101执行存储器105中存储的程序来实现。
以存储器105包括内存和外存为例,对上述操作系统161中的内核23所具有的文件系统管理进行解释说明,如图4所示,硬件层21可以包括外存1051,内核23可以包括文件系统管理231,该文件系统管理231可以对应上述文件系统模块2000,本申请实施例的应用处理器101可以被配置用于执行存储器105中的计算机程序,从而实现本申请实施例的文件系统空间的调整方法,以使得文件系统管理231对外存1051中的文件系统空间进行调整,实现文件系统空间的安全和无损调整,避免由逻辑层所带来文件系统的存储性能损失,降低文件系统空间调整所需时长。
需要说明的是,上述外存也可以称之为外部存储器。
所属领域的技术人员可以理解终端100可包括比图2所示的更少或更多的部件,图2所示的该终端设备仅包括与本申请实施例所公开的多个实现方式更加相关的部件。
本申请所述涉及的“数据”,指以存储器为载体存储在电子设备上的信息集合。数据可 以是文本文档、图片、音视频、可执行程序等等。该数据也可以称之为文件。
图5A为本申请实施例的文件系统空间的物理布局的示意图,图5B为本申请实施例的文件系统空间的逻辑布局的示意图。作为一种示例,图5A示出了文件系统空间在物理存储空间中的分布,如图5A所示,本申请实施例的文件系统空间包括文件系统的元数据(META)区域和数据区域(其中,竖纹区域为已用区域,空白区域为空闲区域)。本申请实施例将文件系统的元数据(META)区域放置于文件系统空间的内部,文件系统空间的两端均为数据区域。换言之,文件系统的元数据(META)区域位于文件系统空间所占用的物理存储空间的内部。其可以是内部的任意位置。这种布局方式能够保证文件系统在物理存储空间的头部或尾部进行扩大或缩小调整过程中,尽可能避免元数据迁移,保证文件系统空间调整过程中的数据安全。元数据不迁移还能够保证数据区域相对地址变动减少,能够很大程度上降低文件系统空间调整的复杂性。另外,这种布局方式使得文件系统覆盖区域两端均可以方便地完成扩大缩小,可以避免为了灵活性增加中间层进而带来的性能损失。图5A中的N表示虚拟预留区域的长度,本实施例以虚拟预留区域的位置为(30,N+30]为例进行举例说明,其中(30,N+30]为逻辑地址,由于该虚拟预留区域不占用物理存储空间,所以如图5A所示,该文件系统空间的物理布局中不包括该虚拟预留区域,结合图5B,虚拟预留区域位于文件系统空间对应的逻辑空间所在区域的之间,例如,如图5A所示的两部分已用区域之间,该两部分已用区域中的一个部分的结束地址为30,另一个部分的开始地址为N+31,即该虚拟预留区域在文件系统管理的逻辑空间中占位。如图5B所示,文件系统管理的逻辑空间包括文件系统空间对应的逻辑空间和虚拟预留区域,该文件系统空间的物理布局如图5A所示。该文件系统的元数据区域还包括虚拟预留区域记录信息,该虚拟预留区域记录信息包括虚拟预留区域所在空间范围的相关记录,例如,虚拟预留区域的起始地址、结束地址或长度中至少两项。在需要对文件系统空间进行扩大或缩小时,可以根据需求灵活调整该虚拟预留区域的大小,以实现文件系统空间的安全和无损调整。
上述虚拟预留区域的位置和大小可以在文件系统初始化时进行设置,后续也可以根据使用需求进行调整。虚拟预留区域的大小设置为任意大小的值,但是由于虚拟预留区属于文件系统管理的逻辑空间的一部分,因此该虚拟预留区域的大小小于文件系统管理的逻辑空间的大小。即上述N取大于等于0,且小于L的任意整数,L表示文件系统管理的逻辑空间的长度,例如,文件系统空间调整仅涉及文件系统空间缩小时,该N可以取0。
本申请实施例的上述布局方式,既可以提高文件系统空间调整过程中元数据的安全性,又能够使得文件系统空间调整可以从物理存储空间的两端调整,更加灵活安全。设置虚拟预留区域,可以避免文件系统空间调整过程引起非变动区域的逻辑地址变化。
需要说明的是,上述图5A和图5B仅为本申请实施例的一种示例,在一些示例中,该文件系统空间的两端可以不是如图5A的数据区域,其也可以是元数据区域,本申请实施例不以图5A作为限制。本申请实施例的文件系统的逻辑地址的起始位置(首块)位于文件系统空间所占用的物理存储空间的内部。即如图5A所示的首块地址处可以不是元数据区域,也可以是数据区域。
图6为本申请实施例的文件系统空间的调整方法的流程图,本实施例的执行主体可以 是上述电子设备或电子设备的内部芯片,如图6所示,本实施例的方法可以包括:
步骤101、接收第一输入,该第一输入用于调整文件系统空间的大小,该文件系统空间占用物理存储空间。
例如,用户通过文件系统空间调整工具3001向电子设备或电子设备的内部芯片输入该第一输入。该第一输入用于扩大或缩小文件系统空间,即调整文件系统空间所占用的物理存储空间的大小。
步骤102、响应于该第一输入,确定调整区域的大小。
该调整区域的大小可以是需要扩大或缩小的物理存储空间的大小。一种可实现方式,可以根据可使用的物理存储空间的大小确定该调整区域的大小。该可使用的物理存储空间可以是新增的物理存储空间中的可使用的部分,也可以是其他文件系统空间所占用的物理存储空间中的可使用的部分。另一种可实现方式,该第一输入还用于指示调整需求大小,可以根据该调整需求大小确定该调整区域的大小。
步骤103、根据调整区域的大小,对文件系统的虚拟预留区域和文件系统数据进行调整,获取调整后的文件系统空间,该文件系统管理的逻辑空间包括该虚拟预留区域和该文件系统空间对应的逻辑空间,该虚拟预留区域未占用物理存储空间,该调整后的文件系统空间所占用的物理存储空间的大小大于或小于调整前的文件系统空间所占用的物理存储空间。
该文件系统数据可以包括文件系统的元数据和文件系统管理的数据,该文件系统的元数据包括虚拟预留区域记录信息。
根据调整区域的大小,对文件系统的虚拟预留区域进行相应大小的缩小或扩大,以在文件系统管理的逻辑空间中扩大或缩小文件系统空间对应的逻辑空间,进而扩大或缩小该文件系统空间所占用的物理存储空间,从而实现扩大或缩小文件系统空间。
本申请实施例的文件系统管理的逻辑空间的大小在文件系统空间调整前后均未发生变化。本申请实施例,在需要扩大文件系统空间时,通过缩小虚拟预留区域,扩大文件系统空间对应的逻辑空间,进而将扩大的区域映射到物理存储空间,从而实现文件系统空间的扩大,即文件系统实际覆盖的物理存储空间的扩大。在需要缩小文件系统空间时,通过缩小文件系统空间对应的逻辑空间,释放缩小的区域所占用的物理存储区域,从而扩大虚拟预留区域,实现文件系统空间的缩小,即文件系统实际覆盖的物理存储空间的缩小。
本申请实施例,通过接收第一输入,该第一输入用于调整文件系统空间的大小,该文件系统空间占用物理存储空间,响应于该第一输入,确定调整区域的大小,根据调整区域的大小,对文件系统的虚拟预留区域进行调整,获取调整后的文件系统空间,该文件系统管理的逻辑空间包括该虚拟预留区域和该文件系统空间对应的逻辑空间,该虚拟预留区域未占用物理存储空间,该调整后的文件系统空间所占用的物理存储空间的大小大于或小于调整前的文件系统空间所占用的物理存储空间。由于文件系统管理的逻辑空间的大小在文件系统空间调整前后均未发生变化,所以在文件系统空间调整过程不会引起调整区域外的数据的相对地址变化,其他区域数据不用发生迁移,使得文件系统空间调整的流程变得简单。本申请实施例在实现文件系统空间的安全和无损调整过程中,可以避免由LVM所带来文件系统的存储性能损失,降低文件系统空间调整所需时长。
下面以两个实施例分别对缩小文件系统空间和扩大文件系统空间,进行解释说明。
图7为本申请实施例的文件系统空间的调整方法的流程图,本实施例的执行主体可以是上述电子设备或电子设备的内部芯片,文件系统空间包括数据区域和元数据区域,本实施例为缩小文件系统空间的实施例,如图7所示,本实施例的方法可以包括:
步骤201、接收第一输入,该第一输入用于缩小文件系统空间,该文件系统空间占用物理存储空间。
步骤202、响应于该第一输入,确定调整区域的大小。
其中,步骤201和步骤202的解释说明可以参见图6所示实施例的步骤101和步骤102。
步骤203、判断调整区域的大小是否小于或等于文件系统的可用空间的大小,若是,则执行步骤204,若否,则结束。
当调整区域的大小小于或等于文件系统的可用空间的大小时,则通过下述步骤,缩小文件系统空间。当调整区域的大小大于文件系统的可用空间的大小时,则文件系统空间缩小失败。该文件系统的可用空间可以是数据区域的可用空间,也可以是元数据区域的可用空间,本申请实施例对此不作限定。
步骤204、判断调整区域是否有文件系统的有效数据,若是,则执行步骤205,若否,则执行步骤206。
具体的,通过判断调整区域与文件系统空间中的已用区域是否有重叠,若调整区域与文件系统空间中的已用区域有重叠,则确定重叠的区域内是否有文件系统的有效数据,如果有有效数据,则执行通过下述步骤205将该有效数据迁移至文件系统的可用空间中。
该调整区域的位置可以根据需求进行灵活选取,例如,位于文件系统空间的前端或文件系统空间的尾端。
结合图8的第一行视图进行举例说明,调整区域位于如图8所示的最左侧,该调整区域有有效数据,则需要通过下述步骤205,将有效数据迁移至如图8所示的文件系统的可用空间中。
步骤205、按照文件系统的数据组织方式,将调整区域内的有效数据迁移至文件系统的可用空间。
参见图8的第二行,将有效数据迁移至文件系统的可用空间,例如,该有效数据为5个数据块,对该5个数据块进行逐块搬移,搬移后的文件系统空间可以参见图8的第三行所示。
步骤206、将数据区域中的该调整区域设置为已用状态,释放该调整区域所占用的物理空间,获取调整后的文件系统空间。
参见图8的第四行,该调整后的文件系统空间所占用的物理空间变小。
将数据区域中的该调整区域设置为已用状态,即将该调整区域归入文件系统的虚拟预留区域,也即文件系统的虚拟预留区域扩大。
步骤207、根据调整区域的位置,确定调整后的虚拟预留区域的位置,根据调整后的虚拟预留区域的位置更新虚拟预留区域记录信息。
参照图9的文件系统所管理的逻辑空间进行解释说明,上述图8的第一行至第三行对应的文件系统的逻辑布局为图9的第一行所示。将该调整区域归入文件系统的虚拟预留区 域之后,该文件系统的逻辑布局为图9的第二行所示,即虚拟预留区域扩大。
本申请实施例,通过接收第一输入,该第一输入用于缩小文件系统空间的大小,该文件系统空间占用物理存储空间,响应于该第一输入,确定调整区域的大小,该调整区域位于文件系统空间的数据区域中,将数据区域中的调整区域设置为已用状态,释放调整区域所占用的物理存储空间,获取调整后的文件系统空间和调整后的虚拟预留区域,该调整后的虚拟预留区域包括该调整区域,该调整后的文件系统空间所占用的物理存储空间的大小小于调整前的文件系统空间所占用的物理存储空间。由于文件系统管理的逻辑空间的大小在文件系统空间缩小前后均未发生变化,所以在文件系统空间缩小过程不会引起缩小区域外的数据的相对地址变化,其他区域数据不用发生迁移,使得文件系统空间调整的流程变得简单。本申请实施例在实现文件系统空间的安全和无损调整过程中,可以避免由LVM所带来文件系统的存储性能损失,降低文件系统空间调整所需时长。
图10为本申请实施例的文件系统空间的调整方法的流程图,本实施例的执行主体可以是上述电子设备或电子设备的内部芯片,文件系统空间包括数据区域和元数据区域,本实施例为扩大文件系统空间的实施例,如图10所示,本实施例的方法可以包括:
步骤301、接收第一输入,该第一输入用于扩大文件系统空间,该文件系统空间占用物理存储空间。
步骤302、响应于该第一输入,确定调整区域的大小。
其中,步骤301和步骤302的解释说明可以参见图6所示实施例的步骤101和步骤102。
步骤303、判断调整区域的大小是否小于或等于虚拟预留区域的大小,若是,则执行步骤304,若否,则结束。
当调整区域的大小小于或等于虚拟预留区域的大小时,则通过下述步骤,扩大文件系统空间。当调整区域的大小大于虚拟预留区域的大小时,则文件系统空间扩大失败。
该调整区域的位置可以根据需求进行灵活选取,例如,位于文件系统空间的前端或文件系统空间的尾端。
步骤304、将虚拟预留区域中的调整区域映射至物理存储空间,将调整区域设置为空闲状态,获取调整后的文件系统空间,该调整后的文件系统空间包括该调整区域。
本实施例的物理存储空间可以是新增的物理存储空间,也可以是通过上述图7所示示例释放的另一个文件系统的物理存储空间。
参见图11的所示,该调整后的文件系统空间所占用的物理空间变大。
将虚拟预留区域中的该调整区域映射至物理存储空间,将调整区域设置为空闲状态,从而使得文件系统可以对其进行访问。即将该调整区域归入文件系统空间,也即缩小虚拟预留区域,扩大文件系统空间。
步骤305、根据调整区域的位置,确定调整后的虚拟预留区域的位置,根据调整后的虚拟预留区域的位置更新虚拟预留区域记录信息。
参照图12的文件系统所管理的逻辑空间进行解释说明,上述图11的第一行对应的文件系统的逻辑布局为图12的第一行所示。将虚拟预留区域中的该调整区域归入文件系统空间之后,该文件系统的逻辑布局为图12的第二行所示,即文件系统空间扩大。
本申请实施例,通过接收第一输入,该第一输入用于扩大文件系统空间的大小,该文件系统空间占用物理存储空间,响应于该第一输入,确定调整区域的大小,该调整区域位于虚拟预留区域中,将虚拟预留区域中的调整区域映射至物理存储空间,将调整区域设置为空闲状态,获取调整后的文件系统空间,该调整后的文件系统空间包括该调整区域,该调整后的文件系统空间所占用的物理存储空间的大小大于调整前的文件系统空间所占用的物理存储空间。由于文件系统管理的逻辑空间的大小在文件系统空间扩大前后均未发生变化,所以在文件系统空间缩小过程不会引起扩大区域外的数据的相对地址变化,其他区域数据不用发生迁移,使得文件系统空间调整的流程变得简单。本申请实施例在实现文件系统空间的安全和无损调整过程中,可以避免由LVM所带来文件系统的存储性能损失,降低文件系统空间调整所需时长。
现有的文件系统布局方式在文件系统空间耗尽的情况下很难实现空间扩大,要么需要中间层带来性能开销,要么非常复杂。本申请实施例通过设计新的布局方式,改变关键元数据区域的位置,从前部改放置内部,从而实现文件系统空间两端的灵活调整方式。使得空间调整更加灵活、安全,并且没有额外性能开销,当文件系统空间耗尽时可以很方便的通过相邻区域空间进行拆借,进行空间扩大操作。
当进行空间调整时如果出现文件系统的数据块相对地址发生变动,为了保证数据一致性需要逐块更新地址变动情况,此过程比较危险并且复杂耗时。本申请实施例通过新增虚拟预留区,当发生空间大小调整时候,可以通过扩大或者缩小虚拟预留区来实现,从而避免了,数据块相对地址变化。使得空间调整过程进一步简化,避免文件数据块相对地址发生变化,空间调整速度提高,并且更加安全。
需要说明的是,存储设备上可以有多个文件系统,每个文件系统覆盖一部分物理存储空间,该多个文件系统中的每个文件系统均可以采用本申请实施例的上述元数据的设置方式以及虚拟预留区域的设置,也可以多个文件系统中部分文件系统采用本申请实施例的上述元数据的设置方式以及虚拟预留区域的设置,其余文件系统可以采用元数据设置于文件系统空间的头部的方式,其具体实现方式可以根据需求进行灵活设置。
下面一个实施例以存储设备上有三个文件系统为例,分别为文件系统1、文件系统2和文件系统3,其中,文件系统2和文件系统3采用本申请实施例的上述元数据的设置方式以及虚拟预留区域的设置,对本申请实施例的文件系统空间的调整方法进行举例说明。
参照图13所示,如图13的第一行所示,文件系统2的物理存储空间即将被耗尽,需要扩大文件系统2的物理存储空间,由于存储设备的物理存储空间有限,且并没有新增的存储设备提供物理存储空间,所以需要从其他相邻区域进行拆借,本实施例以从文件系统3进行拆借为例进行举例说明。在对文件系统2进行扩大之前,需要对文件系统3进行缩小。
结合上述实施例的文件系统空间的调整方法,首先确定调整空间的大小,判断调整空间的大小是否小于文件系统3的数据区域的可用空间的大小,若是,则根据调整空间的大小确定调整空间的起始位置和结束位置,判断调整空间中是否有文件系统3的有效数据,若是,则将调整区域内的有效数据迁移至数据区域的可用空间,即如图13的第二行所示。 迁移完成后,将文件系统3的该调整区域设置为已用状态,释放该调整区域所占用的物理存储空间,获取调整后的文件系统空间。即如图13的第三行所示。根据调整区域的位置,更新文件系统3的虚拟预留区域,即将该调整区域添加至文件系统3的虚拟预留区域中,至此,完成文件系统3的缩小过程。
之后,对文件系统2进行扩大。文件系统2扩大的区域即为文件系统3缩小的区域。调整文件系统2的虚拟预留区域,即缩小文件系统2的虚拟预留区域,将文件系统2的虚拟预留区域中的与该调整区域相同大小的部分,映射至文件系统3释放的物理存储空间,将该部分设置为空闲状态,之后文件系统2可以对该部分进行访问。更新文件系统2的虚拟预留区域,即将文件系统3的虚拟预留区域缩小,至此,完成文件系统2的扩大过程。
参照图13第四行,在文件系统2和文件系统3调整过程中,二者管理的逻辑空间的总长度并没有发生变化,通过通过调整虚拟预留区域的起始或结束位置,使得文件系统能够灵活调整可读写的范围,进而大大简化文件系统空间调整,并且文件系统中数据块相对地址保持稳定,使得文件系统空间调整更加安全。
本实施例,当文件系统空间耗尽时可以很方便的通过相邻区域空间进行拆借,进行空间扩大操作,使得空间调整更加灵活、安全,并且没有额外性能开销,通过虚拟预留区域使得文件系统中数据块相对地址保持稳定,同时通过调整虚拟预留区域的起始或结束位置,使得文件系统能够灵活调整可读写的范围,进而大大简化文件系统空间调整。
可以理解的是,电子设备为了实现上述功能,其包含了执行各个功能相应的硬件和/或软件模块。结合本文中所公开的实施例描述的各示例的算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。本领域技术人员可以结合实施例对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本实施例可以根据上述方法示例对电子设备进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块可以采用硬件的形式实现。需要说明的是,本实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
在采用对应各个功能划分各个功能模块的情况下,图14示出了上述实施例中涉及的电子设备1400的一种可能的组成示意图,如图14所示,该电子设备1400可以包括:接收模块1401和处理模块1402。
其中,接收模块1401可以用于支持电子设备1400执行上述步骤101、步骤201或步骤301等,和/或用于本文所描述的技术的其他过程。
处理模块1402可以用于支持电子设备1400执行上述步骤102和步骤103、或步骤202至步骤207、或步骤302至步骤305等,和/或用于本文所描述的技术的其他过程。
需要说明的是,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
本实施例提供的电子设备,用于执行上述文件系统空间的调整方法,因此可以达到与上述实现方法相同的效果。
在采用集成的单元的情况下,电子设备可以包括处理模块、存储模块和通信模块。其中,处理模块可以用于对电子设备的动作进行控制管理,例如,可以用于支持电子设备执行上述接收模块1401和处理模块1402执行的步骤。存储模块可以用于支持电子设备执行存储程序代码和数据等。通信模块,可以用于支持电子设备与其他设备的通信。
其中,处理模块可以是处理器或控制器。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,数字信号处理(digital signal processing,DSP)和微处理器的组合等等。存储模块可以是存储器。通信模块具体可以为射频电路、蓝牙芯片、Wi-Fi芯片等与其他设备交互的设备。
在一个实施例中,当处理模块为处理器,存储模块为存储器时,本实施例所涉及的电子设备可以为具有图2所示结构的设备。
本实施例还提供一种计算机存储介质,该计算机存储介质中存储有计算机指令,当该计算机指令在电子设备上运行时,使得终端设备执行上述相关方法步骤实现上述实施例中的文件系统空间的调整方法。
本实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,以实现上述实施例中的文件系统空间的调整方法。
另外,本申请的实施例还提供一种装置,这个装置具体可以是芯片,组件或模块,该装置可包括相连的处理器和存储器;其中,存储器用于存储计算机执行指令,当装置运行时,处理器可执行存储器存储的计算机执行指令,以使芯片执行上述各方法实施例中的文件系统空间的调整方法。
其中,本实施例提供的电子设备、计算机存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。
通过以上实施方式的描述,所属领域的技术人员可以了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
还需要说明的是,本申请实施例的虚拟预留区域还可以定义为,文件系统可灵活更改读写属性的区域,文件系统可以设置虚拟预留区域为可读写和不可读写,当其为不可读写时,即等价于上述实施例中的虚拟预留区域。不同定义的虚拟预留区域,其实现文件系统空间调整的方法的核心思想相同,具体实现方式略有不同。本申请实施例的文件系统空间的调整方法不以上述虚拟预留区域的定义作为限制。
通过以上实施方式的描述,所属领域的技术人员可以了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,模块或单元的划分, 仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。

Claims (22)

  1. 一种文件系统空间的调整方法,其特征在于,应用于文件系统,所述文件系统管理的逻辑空间包括虚拟预留区域和文件系统空间对应的逻辑空间,其中,所述文件系统空间占用物理存储空间,而所述虚拟预留区域不占用物理存储空间;所述方法包括:
    接收第一输入,所述第一输入用于调整所述文件系统空间的大小;
    对所述虚拟预留区域和文件系统数据进行调整,以获取调整后的文件系统空间,所述调整后的文件系统空间所占用的物理存储空间的大小大于或小于调整前的文件系统空间所占用的物理存储空间。
  2. 根据权利要求1所述的方法,其特征在于,所述文件系统的逻辑地址的起始位置位于所述文件系统空间所占用的物理存储空间的内部。
  3. 根据权利要求2所述的方法,其特征在于,所述文件系统空间包括数据区域和元数据区域,所述数据区域用于所述文件系统进行读写操作,所述元数据区域用于存储所述文件系统的元数据,所述元数据区域位于所述文件系统空间所占用的物理存储空间内部。
  4. 根据权利要求1至3任一项所述的方法,其特征在于,所述第一输入用于扩大所述文件系统空间;
    所述对所述文件系统的虚拟预留区域和文件系统数据进行调整,获取调整后的文件系统空间,包括:
    将所述虚拟预留区域中的调整区域映射至物理存储空间,将所述调整区域设置为空闲状态,获取调整后的文件系统空间,所述调整后的文件系统空间包括所述调整区域;
    根据所述调整区域的位置,确定调整后的虚拟预留区域的位置;
    根据所述调整后的虚拟预留区域的位置更新所述文件系统数据中的虚拟预留区域记录信息。
  5. 根据权利要求4所述的方法,其特征在于,所述将所述调整区域设置为空闲状态,包括:
    在所述文件系统数据中,更新所述调整区域对应的元数据,更新后的所述调整区域对应的元数据表示所述调整区域为空闲状态。
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    判断所述调整区域的大小是否小于或等于所述虚拟预留区域的大小;
    当所述调整区域的大小小于或等于所述虚拟预留区域的大小时,执行所述将所述虚拟预留区域中的所述调整区域映射至物理存储空间,将所述调整区域设置为空闲状态的步骤。
  7. 根据权利要求1至3任一项所述的方法,其特征在于,所述第一输入用于缩小所述文件系统空间;
    所述对所述文件系统的虚拟预留区域和文件系统数据进行调整,获取调整后的文件系统空间,包括:
    将所述文件系统空间中的调整区域设置为已用状态,释放所述调整区域所占用的物理存储空间,获取调整后的文件系统空间和调整后的虚拟预留区域,所述调整后的虚拟预留区域包括所述调整区域;
    根据所述调整区域的位置,确定调整后的虚拟预留区域的位置;
    根据所述调整后的虚拟预留区域的位置更新所述文件系统数据中的虚拟预留区域记 录信息。
  8. 根据权利要求7所述的方法,其特征在于,当所述调整区域与所述文件系统空间中的已用区域重叠时,所述方法还包括:
    将与所述文件系统空间中的已用区域重叠的区域的有效数据,迁移至所述文件系统的可用空间。
  9. 根据权利要求7或8所述的方法,其特征在于,其特征在于,所述方法还包括:
    判断所述调整区域的大小是否小于或等于所述文件系统的可用空间的大小;
    当所述调整区域的大小小于或等于所述文件系统的可用空间的大小时,执行所述将所述文件系统空间中的所述调整区域设置为已用状态,释放所述调整区域所占用的物理存储空间的步骤。
  10. 一种文件系统空间的调整装置,其特征在于,包括:
    接收模块,用于接收第一输入,所述第一输入用于调整文件系统空间的大小,所述文件系统空间占用物理存储空间;
    处理模块,用于对文件系统的虚拟预留区域和文件系统数据进行调整,获取调整后的文件系统空间,所述文件系统管理的逻辑空间包括所述虚拟预留区域和所述文件系统空间对应的逻辑空间,所述虚拟预留区域未占用物理存储空间,所述调整后的文件系统空间所占用的物理存储空间的大小大于或小于调整前的文件系统空间所占用的物理存储空间。
  11. 根据权利要求10所述的装置,其特征在于,所述文件系统的逻辑地址的起始位置位于所述文件系统空间所占用的物理存储空间的内部。
  12. 根据权利要求11所述的装置,其特征在于,所述文件系统空间包括数据区域和元数据区域,所述数据区域用于所述文件系统进行读写操作,所述元数据区域用于存储所述文件系统的元数据,所述元数据区域位于所述文件系统空间所占用的物理存储空间内部。
  13. 根据权利要求10至12任一项所述的装置,其特征在于,所述第一输入用于扩大所述文件系统空间;
    所述处理模块用于:将所述虚拟预留区域中的调整区域映射至物理存储空间,将所述调整区域设置为空闲状态,获取调整后的文件系统空间,所述调整后的文件系统空间包括所述调整区域;根据所述调整区域的位置,确定调整后的虚拟预留区域的位置;根据所述调整后的虚拟预留区域的位置更新所述文件系统数据中的虚拟预留区域记录信息。
  14. 根据权利要求13所述的装置,其特征在于,所述处理模块用于:在所述文件系统数据中,更新所述调整区域对应的元数据,更新后的所述调整区域对应的元数据表示所述调整区域为空闲状态。
  15. 根据权利要求14所述的装置,其特征在于,所述处理模块还用于:
    判断所述调整区域的大小是否小于或等于所述虚拟预留区域的大小;
    当所述调整区域的大小小于或等于所述虚拟预留区域的大小时,执行所述将所述虚拟预留区域中的所述调整区域映射至物理存储空间,将所述调整区域设置为空闲状态的步骤。
  16. 根据权利要求10至12任一项所述的装置,其特征在于,所述第一输入用于缩小所述文件系统空间;
    所述处理模块用于:将所述文件系统空间中的调整区域设置为已用状态,释放所述调整区域所占用的物理存储空间,获取调整后的文件系统空间和调整后的虚拟预留区域,所 述调整后的虚拟预留区域包括所述调整区域;
    根据所述调整区域的位置,确定调整后的虚拟预留区域的位置;
    根据所述调整后的虚拟预留区域的位置更新所述文件系统数据中的虚拟预留区域记录信息。
  17. 根据权利要求16所述的装置,其特征在于,当所述调整区域与所述文件系统空间中的已用区域重叠时,所述处理模块还用于:将与所述文件系统空间中的已用区域重叠的区域的有效数据,迁移至所述文件系统空间的可用空间。
  18. 根据权利要求16或17所述的装置,其特征在于,其特征在于,所述处理模块还用于:
    判断所述调整区域的大小是否小于或等于所述文件系统的可用空间的大小;
    当所述调整区域的大小小于或等于所述文件系统的可用空间的大小时,执行所述将所述文件系统空间中的所述调整区域设置为已用状态,释放所述调整区域所占用的物理存储空间的步骤。
  19. 一种电子设备,其特征在于,包括:
    一个或多个处理器;
    存储器,用于存储一个或多个程序;
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-9中任一项所述的方法。
  20. 一种计算机可读存储介质,其特征在于,包括计算机程序,所述计算机程序在计算机上被执行时,使得所述计算机执行权利要求1-9中任一项所述的方法。
  21. 一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机程序,当所述计算机程序被计算机执行时,用于执行权利要求1-9中任一项所述的方法。
  22. 一种芯片,其特征在于,包括处理器和存储器,所述存储器用于存储计算机程序,所述处理器用于调用并运行所述存储器中存储的计算机程序,以执行如权利要求1-9中任一项所述的方法。
PCT/CN2021/079146 2020-03-20 2021-03-04 文件系统空间的调整方法、装置和电子设备 WO2021185094A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010203172.4A CN113495869B (zh) 2020-03-20 2020-03-20 文件系统空间的调整方法、装置和电子设备
CN202010203172.4 2020-03-20

Publications (1)

Publication Number Publication Date
WO2021185094A1 true WO2021185094A1 (zh) 2021-09-23

Family

ID=77768335

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/079146 WO2021185094A1 (zh) 2020-03-20 2021-03-04 文件系统空间的调整方法、装置和电子设备

Country Status (2)

Country Link
CN (1) CN113495869B (zh)
WO (1) WO2021185094A1 (zh)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101620569A (zh) * 2008-07-03 2010-01-06 英业达股份有限公司 一种逻辑卷存储空间的扩展方法
CN104731517A (zh) * 2013-12-19 2015-06-24 中国移动通信集团四川有限公司 一种存储池容量分配方法和装置
US20150278243A1 (en) * 2014-03-31 2015-10-01 Amazon Technologies, Inc. Scalable file storage service
CN106656631A (zh) * 2017-01-19 2017-05-10 武汉噢易云计算股份有限公司 在共享存储上实现逻辑卷动态分配的方法及系统
US20190129862A1 (en) * 2017-10-27 2019-05-02 Toshiba Memory Corporation Memory system and method for controlling nonvolatile memory
CN110222019A (zh) * 2019-05-08 2019-09-10 安克创新科技股份有限公司 文件系统所占空间的调整方法及装置

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7107385B2 (en) * 2002-08-09 2006-09-12 Network Appliance, Inc. Storage virtualization by layering virtual disk objects on a file system
CN104239235A (zh) * 2014-10-21 2014-12-24 浪潮电子信息产业股份有限公司 一种基于二次分配管理磁盘扩展空间的方法
WO2016181528A1 (ja) * 2015-05-13 2016-11-17 株式会社日立製作所 ストレージ装置
CN107203329B (zh) * 2016-03-17 2020-12-01 伊姆西Ip控股有限责任公司 存储管理方法及设备
CN107306201A (zh) * 2016-04-22 2017-10-31 华为技术有限公司 虚拟化网络的部署方法和部署系统
CN107220008B (zh) * 2017-06-27 2020-08-07 北京小米移动软件有限公司 存储空间预留方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101620569A (zh) * 2008-07-03 2010-01-06 英业达股份有限公司 一种逻辑卷存储空间的扩展方法
CN104731517A (zh) * 2013-12-19 2015-06-24 中国移动通信集团四川有限公司 一种存储池容量分配方法和装置
US20150278243A1 (en) * 2014-03-31 2015-10-01 Amazon Technologies, Inc. Scalable file storage service
CN106656631A (zh) * 2017-01-19 2017-05-10 武汉噢易云计算股份有限公司 在共享存储上实现逻辑卷动态分配的方法及系统
US20190129862A1 (en) * 2017-10-27 2019-05-02 Toshiba Memory Corporation Memory system and method for controlling nonvolatile memory
CN110222019A (zh) * 2019-05-08 2019-09-10 安克创新科技股份有限公司 文件系统所占空间的调整方法及装置

Also Published As

Publication number Publication date
CN113495869A (zh) 2021-10-12
CN113495869B (zh) 2024-04-26

Similar Documents

Publication Publication Date Title
US9606747B2 (en) Importing pre-existing data of a prior storage solution into a storage pool for use with a new storage solution
US20070005661A1 (en) Shared file system management between independent operating systems
CN112035410B (zh) 日志存储方法、装置、节点设备及存储介质
EP3186728B1 (en) File system with data block sharing
US20080229046A1 (en) Unified support for solid state storage
WO2021036370A1 (zh) 预读取文件页的方法、装置和终端设备
US10241718B2 (en) Electronic device and method of analyzing fragmentation of electronic device
CN104580399A (zh) 一种基于OpenStack和Spice的云桌面实现方法
WO2020192667A1 (zh) 一种跨语言编译方法及设备
US9870232B2 (en) Extensible method and system for storage metadata
WO2012127590A1 (ja) エンディアン変換方法、およびシステム
CN115309511B (zh) 基于Xen的数据交互方法、装置、存储介质以及电子设备
CN105653539A (zh) 索引分布式存储的实现方法和装置
US7979601B2 (en) External direct memory access of embedded controller memory
WO2021185094A1 (zh) 文件系统空间的调整方法、装置和电子设备
US9940338B2 (en) Efficiency of file synchronization in a linear tape file system
CN109614089B (zh) 数据访问代码的自动生成方法、装置、设备及存储介质
US20220261489A1 (en) Capability management method and computer device
CN110383255A (zh) 管理对物理设备的客户分区访问
WO2021203591A1 (zh) 异构云存储系统的数据处理方法及其可读介质和系统
TWI696068B (zh) 用於提供高效功率檔案系統操作至一非揮發性區塊記憶體之系統及方法
CN117112044B (zh) 基于网卡的指令处理方法、装置、设备和介质
US9251100B2 (en) Bitmap locking using a nodal lock
US20230024420A1 (en) Methods and devices for file read latency reduction
EP4216052A1 (en) Method for developing mvvm architecture-based application, and terminal

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: 21772189

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: 21772189

Country of ref document: EP

Kind code of ref document: A1