Space pre-distribution method and device and electronic equipment
By preallocating storage space configuration information for file directories in the file storage system and writing files according to key values when receiving file write instructions, the performance problems caused by insufficient storage space under the streamlined configuration strategy are solved, and more efficient storage performance and reliability are achieved.
Patent Information
- Application Number
- CN202510231663.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-06-13
AI Technical Summary
In a file storage system, thin configuration policies cause data writing to slow down when the actual physical storage space is close to exhaustion, affecting system performance, and even leading to data storage failure and loss.
A space preallocation method is proposed, by preallocating storage space configuration information for a file directory in a file storage system, representing these information using key values, and when receiving a file writing instruction, a file writing operation is performed according to the key value of the target file directory. In addition, when the storage space configuration information adjustment instruction is received, the pre-allocated storage space configuration information of the file directory is adjusted to improve storage space utilization and ensure storage performance.
By pre-allocating storage space, the storage space of the file directory is avoided from being occupied by files in other directories, the performance and reliability of the file storage system are improved, and data storage failure and loss are prevented.
Smart Images

Figure CN120144547A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of file storage, and particularly to a method, device, and electronic device for space pre-allocation. Background Art
[0002] In a file storage system, a data storage allocation strategy of thin provisioning is usually adopted, that is, a virtual space larger than the actual physical storage space is allocated to an application program or a user. When data is actually written, the corresponding physical storage space is allocated from the actual physical storage space for the application program or the user. This method will cause the data writing speed to slow down when the actual physical storage space is nearly exhausted, affecting the system performance, and even causing data storage failure and data loss. Summary of the Invention
[0003] In view of this, this application provides a method, device, and electronic device for space pre-allocation to avoid the problem of data storage failure.
[0004] The technical solutions provided by this application are as follows:
[0005] According to an embodiment of the first aspect of this application, a space pre-allocation method is proposed. This method is applied to a file storage system and includes:
[0006] Pre-allocate corresponding storage space configuration information for at least one file directory established in the file storage system; the storage space configuration information is represented by a corresponding key value;
[0007] When a file writing instruction is received, based on the target file directory carried in the file writing instruction, determine whether there is a corresponding key value for the target file directory;
[0008] When there is a corresponding key value for the target file directory, perform a corresponding file writing operation based on the key value corresponding to the target file directory;
[0009] When a storage space configuration information adjustment instruction for any file directory is received, based on the storage space configuration information adjustment instruction, adjust the pre-allocated storage space configuration information for the file directory to improve the storage space utilization rate in the file storage system and ensure the storage performance of the file storage system.
[0010] Optionally, the key value is recorded in the form of metadata of a file directory. The key value includes the correspondence between the file directory and the storage space configuration information, and the storage space configuration information includes the address information of the storage space pre-configured for the file directory. Determining whether there is a corresponding key value for the target file directory based on each file directory for which the storage space configuration information has been pre-allocated and the target file directory carried in the file writing instruction includes:
[0011] Determine the target file directory corresponding to the file to be written according to the file writing instruction;
[0012] Search for the metadata of the target file directory, and determine whether the metadata of the target file directory includes the correspondence between the target file directory and the address information of the storage space pre-configured for the target file directory;
[0013] If so, determine that there is a corresponding key value for the target file directory.
[0014] Optionally, when there is a corresponding key value for the target file directory, perform a corresponding file writing operation based on the key value corresponding to the target file directory, including:
[0015] Based on the address information of the storage space pre-configured for the target file directory, write the file to be written into the available space in the storage space, where the available space refers to the space in the storage space pre-configured for the target file directory that has not been written with a file.
[0016] Optionally, when receiving a storage space configuration information adjustment instruction for any file directory, adjust the pre-allocated storage space configuration information of the file directory based on the storage space configuration information adjustment instruction, including:
[0017] When receiving a storage space expansion instruction for any file directory, based on the size of the expanded space carried in the storage space expansion instruction, obtain the expanded space from the unallocated space in the file storage system, and add the expanded space to the storage space corresponding to the file directory to write a file in the storage space corresponding to the file directory;
[0018] Wherein, the size of the expanded space is not greater than the size of the unallocated space, and the unallocated space refers to the space in the file storage system that has not been allocated and has not been written with a file.
[0019] Optionally, when receiving a storage space configuration information adjustment instruction for any file directory, adjust the pre-allocated storage space configuration information of the file directory based on the storage space configuration information adjustment instruction, including:
[0020] When receiving an instruction to reduce the storage space for any file directory, based on the size of the reduced space carried in the storage space reduction instruction, obtain the reduced space from the storage space corresponding to the file directory, and release the reduced space as the unallocated space in the file storage system;
[0021] Wherein, the size of the reduced space is not greater than the available space in the storage space corresponding to the file directory, the available space refers to the space in the storage space corresponding to the file directory where no file is written, and the unallocated space refers to the space in the file storage system that is not allocated and no file is written.
[0022] Optionally, when receiving an instruction to adjust the storage space configuration information for any file directory, based on the storage space configuration information adjustment instruction, adjust the pre-allocated storage space configuration information for the file directory, including:
[0023] When receiving an instruction to delete the storage space for any file directory, detect whether there is available space in the storage space corresponding to the file directory;
[0024] If so, release the available space as the unallocated space in the file storage system;
[0025] Wherein, the available space refers to the space in the storage space corresponding to the file directory where no file is written, and the unallocated space refers to the space in the file storage system that is not allocated and no file is written.
[0026] Optionally, after receiving an instruction to adjust the storage space configuration information for any file directory and adjusting the pre-allocated storage space configuration information for the file directory based on the storage space configuration information adjustment instruction, the method further includes:
[0027] Update the key value of the storage space information corresponding to the file directory according to the adjusted storage space configuration information.
[0028] According to an embodiment of the second aspect of the present application, a space pre-allocation device is proposed. The device is applied to a file storage system, and the device includes:
[0029] A configuration unit for pre-allocating corresponding storage space configuration information for at least one established file directory in the file storage system; the storage space configuration information is represented by a corresponding key value;
[0030] A determination unit for, when receiving a file writing instruction, determining whether there is a corresponding key value for the target file directory based on the target file directory carried in the file writing instruction;
[0031] A writing unit, configured to perform a corresponding file writing operation based on a key value corresponding to the target file directory when the key value exists in the target file directory;
[0032] An adjustment unit, configured to, when receiving an indication for adjusting the storage space configuration information of any file directory, adjust the pre-allocated storage space configuration information of the file directory based on the indication for adjusting the storage space configuration information, so as to improve the utilization rate of the storage space in the file storage system and ensure the storage performance of the file storage system.
[0033] Optionally, the key value is recorded in the form of metadata of the file directory, and the key value includes the correspondence between the file directory and the storage space configuration information, where the storage space configuration information includes the address information of the pre-configured storage space for the file directory; the determining unit is specifically configured to:
[0034] Determine the target file directory corresponding to the file to be written according to the file writing instruction;
[0035] Search for the metadata of the target file directory, and determine whether the metadata of the target file directory includes the correspondence between the target file directory and the address information of the pre-configured storage space for the target file directory;
[0036] If so, determine that the target file directory has a corresponding key value;
[0037] And / or, the writing unit is specifically configured to:
[0038] Based on the address information of the pre-configured storage space for the target file directory, write the file to be written into the available space in the storage space, where the available space refers to the space in the pre-configured storage space for the target file directory that has not been written with a file;
[0039] And / or, the adjustment unit is specifically configured to:
[0040] When receiving an indication for expanding the storage space of any file directory, obtain the expanded space from the unallocated space in the file storage system based on the size of the expanded space carried in the indication for expanding the storage space, and add the expanded space to the storage space corresponding to the file directory, so as to write a file in the storage space corresponding to the file directory;
[0041] Wherein, the size of the expanded space is not greater than the size of the unallocated space, and the unallocated space refers to the space in the file storage system that has not been allocated and has not been written with a file;
[0042] And / or, the adjustment unit is specifically configured to:
[0043] When receiving a storage space reduction indication for any file directory, based on the size of the reduced space carried by the storage space reduction indication, obtain the reduced space from the storage space corresponding to the file directory, and release the reduced space as the unallocated space in the file storage system;
[0044] Wherein, the size of the reduced space is not greater than the available space in the storage space corresponding to the file directory, the available space refers to the space in the storage space corresponding to the file directory where no file is written, and the unallocated space refers to the space in the file storage system that is not allocated and no file is written;
[0045] And / or, the adjustment unit is specifically configured to:
[0046] When receiving a storage space deletion indication for any file directory, detect whether there is available space in the storage space corresponding to the file directory;
[0047] If so, release the available space as the unallocated space in the file storage system;
[0048] Wherein, the available space refers to the space in the storage space corresponding to the file directory where no file is written, and the unallocated space refers to the space in the file storage system that is not allocated and no file is written;
[0049] And / or, the adjustment unit is further configured to:
[0050] Update the key value of the storage space information corresponding to the file directory according to the adjusted storage space configuration information.
[0051] According to an embodiment of the third aspect of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in the first aspect is implemented.
[0052] As can be seen from the above technical solutions, the present application pre-allocates corresponding storage space configuration information for at least one directory in the file storage system, and represents it by a key value. When receiving a file writing indication, if it is determined that there is a corresponding key value for the target file directory carried by the file writing indication, the file is written based on the key value. When receiving an adjustment indication for the storage space configuration information of any file directory, the allocated storage space configuration information of the file directory is adjusted. The above solution pre-allocates a storage space for the file directory, reserves the storage space, avoids the storage space corresponding to the file directory being occupied by files in other directories, and can adjust the storage space configuration information accordingly when receiving an adjustment indication for the storage space configuration information, improving the performance of the file storage system. Description of the Drawings
[0053] The accompanying drawings here are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0054] Figure 1 Schematic flowchart of a spatial pre-allocation method provided for an embodiment of the present application;
[0055] Figure 2 Schematic diagram of a specific spatial pre-allocation method provided for an embodiment of the present application;
[0056] Figure 3 Schematic diagram of a storage space creation method provided for an embodiment of the present application;
[0057] Figure 4 Schematic diagram of a storage space expansion method provided for an embodiment of the present application;
[0058] Figure 5 Schematic diagram of a storage space deletion method provided for an embodiment of the present application;
[0059] Figure 6 Schematic diagram of the structure of an electronic device provided for an embodiment of the present application;
[0060] Figure 7 Structural diagram of a spatial pre-allocation device provided for an embodiment of the present application. Detailed implementation manners
[0061] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application, and to make the above-mentioned objects, features, and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0062] In a file storage system, a data storage allocation strategy of thin provisioning is usually adopted, that is, a virtual space larger than the actual physical storage space is allocated to an application program or a user, and when data is actually written, the corresponding physical storage space will be allocated from the actual physical storage space for the application program or the user.
[0063] Thin provisioning meets the rapidly changing requirements and complex workloads through flexible and efficient storage management. With the continuous development of informatization, users have put forward more stringent requirements for the capacity and reliability of the file storage system. Especially when storing data related to critical services, it becomes particularly important to ensure that the service will not be affected due to insufficient storage space.
[0064] However, thin provisioning can lead to a slowdown in data writing speed when the actual physical storage space is approaching exhaustion, affecting system performance. Since the storage does not reserve enough available space, if the system fails to expand in a timely manner, it may even lead to storage failure.
[0065] Based on this, the present application proposes a space pre-allocation method to avoid the problem of data storage failure.
[0066] Please refer to Figure 1 , Figure 1 which is a schematic flow diagram of a space pre-allocation method provided by an embodiment of the present application.
[0067] In this embodiment, the method can be applied to a file storage system, specifically to a metadata server (MDS: Metadata Server) in the file storage system, and the metadata server is used to manage and store the metadata of the file storage system.
[0068] As Figure 1 shown, the method can specifically include the following steps:
[0069] Step 101, pre-allocate corresponding storage space configuration information for at least one established file directory in the file storage system.
[0070] The file storage system may include multiple file directories, and the file directories provide the organizational structure of the files and help users manage and access the files.
[0071] In this embodiment, corresponding storage space configuration information can be pre-allocated for one or more file directories in the file storage system, that is, the physical storage space occupied by the file directory is pre-allocated for one or more file directories, and the pre-allocated physical storage space cannot be occupied by files in other directories.
[0072] It should be noted that in the thin provisioning scheme, before the file is written, the physical storage space is not really allocated for the file directory, but when the file is written, the physical storage space is allocated from the space to be allocated in the file storage system. Different from the common thin provisioning scheme in the file storage system, the scheme proposed in this embodiment has already pre-allocated the corresponding physical storage space for the file directory in advance. Even if there is no file written in the file directory, the physical storage space allocated to the file directory will not be occupied by files in other directories.
[0073] As an embodiment, corresponding storage space configuration information can be pre-allocated for all file directories, or only for specific file directories, such as the file directory to which important files belong, or the file directory to which the files of important users belong, so as to ensure that the pre-allocated storage space can be immediately used when important files are written, without being affected by the writing of files in other directories and without being occupied by files in other directories.
[0074] It should be noted that when pre-allocating storage space for a file directory, it can be allocated according to the total size of the physical storage space to be allocated included in the file storage system, so as to ensure that the corresponding size of storage space can be successfully allocated.
[0075] In this embodiment, the storage space configuration information can be represented by corresponding key values to reflect the correspondence between the storage space configuration information and the file directory. For example, the identifier of the file directory can be used as the key, and the storage space configuration information can be used as the value, and it is stored in the form of a key-value pair.
[0076] As an embodiment, the storage space configuration information can include the address information of the storage space pre-configured for the file directory. The above key values can be recorded in the form of the metadata of the file directory, that is, the correspondence between the file directory and the storage space configuration information is stored in the form of the metadata of the file directory, so as to facilitate the adjustment of the storage space configuration information.
[0077] As an embodiment, the key-value pair can be stored through a data structure of object mapping (OMAP: Object Map), and the present application does not limit this.
[0078] So far, the description of step 101 is completed, and then step 102 is executed.
[0079] Step 102, when receiving a file writing instruction, based on the target file directory carried in the file writing instruction, determine whether there is a corresponding key value for the target file directory.
[0080] After the pre-allocation of the file directory in step 101 is completed, in the case of receiving a file writing instruction, the target file directory to which the file to be written will be written can be determined based on the file writing instruction.
[0081] In this embodiment, the file writing instruction can be sent by the user through the client, or can be sent by the administrator through the service platform, and the present application does not limit this.
[0082] As an example, the file storage path and file size of the file to be written can be carried in the file write instruction. The file storage path includes the target file directory where the file to be written will be written. After determining the target file directory where the file to be written will be written through the file write instruction, it can be further determined whether there is a corresponding key value for the target file directory.
[0083] Specifically, the metadata of the target file directory can be searched to determine whether the metadata of the target file directory includes the correspondence between the target file directory and the address information of the storage space preconfigured for the target file directory; if so, it is determined that there is a corresponding key value for the target file directory.
[0084] In this embodiment, the metadata of the target file directory can be queried. If the metadata stores the correspondence between the target file directory and the address information of the storage space preconfigured for the target file directory, it is determined that there is a corresponding key value for the target file directory, that is, the target file directory is preconfigured with a physical storage space.
[0085] So far, the description of step 102 is completed, and then step 103 is executed.
[0086] Step 103, when there is a corresponding key value for the target file directory, perform the corresponding file write operation based on the key value corresponding to the target file directory.
[0087] In this embodiment, if it is determined that there is a corresponding key value for the target file directory, it indicates that the target file directory is preconfigured with a physical storage space. At this time, the corresponding file write operation can be performed based on the key value corresponding to the target file directory.
[0088] Specifically, based on the address information of the storage space preconfigured for the target file directory, the file to be written is written to the available space in the storage space. The available space refers to the space in the storage space preconfigured for the target file directory where no file has been written.
[0089] In this embodiment, the location of the storage space can be determined based on the address information of the storage space preconfigured for the target file directory recorded in the key value corresponding to the target file directory, and then the file to be written is further written to the available space in the storage space.
[0090] As an example, before writing a file, it can be detected whether the size of the available space in the storage space corresponding to the target file directory meets the writing requirements of the file to be written. If it meets the requirements, the file to be written can be directly written.
[0091] So far, the description of step 103 is ended, and then step 104 is executed.
[0092] Step 104, when receiving an indication for adjusting the storage space configuration information for any file directory, based on the indication for adjusting the storage space configuration information, adjust the pre-allocated storage space configuration information for this file directory.
[0093] In this embodiment, the pre-allocated storage space configuration information for a file directory can also be adjusted based on actual requirements. When receiving an indication for adjusting the storage space configuration information, the pre-allocated storage space configuration information for this file directory can be adjusted to meet the storage requirements, improve the utilization rate of the storage space in the file storage system, and ensure the storage performance of the file storage system.
[0094] In this embodiment, there can be various types of indications for adjusting the storage space configuration information, and this application does not limit this. Hereinafter, step 104 will be described in detail by taking three specific indications for adjusting the storage space configuration information as examples.
[0095] (1) The indication for adjusting the storage space configuration information can be an indication for expanding the storage space.
[0096] It is easy to understand that the indication for expanding the storage space can be sent when the size of the pre-allocated storage space for a file directory is insufficient, so as to expand the storage space and complete the file writing.
[0097] For example, the management platform can periodically monitor the size of the available space in the storage space. If it detects that the size of the available space in the storage space is less than a preset threshold, it issues an indication for expanding the storage space; or, before writing a file, it can detect whether the size of the available space in the storage space corresponding to the target file directory meets the writing requirements of the file to be written. If not, that is, the size of the available space in the current storage space is less than the size of the file to be written, an indication for expanding the storage space can be issued.
[0098] In this embodiment, the indication for expanding the storage space can carry the size of the expanded space. The size of the expanded space refers to the size of the storage space that needs to be added to the pre-allocated storage space corresponding to this directory file; similarly, the indication for expanding the storage space can also carry the size of the target space after expansion, that is, indicating the size of the storage space of this target directory after expansion. The size of the expanded space or the size of the storage space after expansion can be determined according to the size of the file to be written, ensuring that the storage space after expansion can meet the writing requirements of the file to be written. This application does not limit this.
[0099] Hereinafter, a description will be given by taking the indication for expanding the storage space carrying the size of the expanded space as an example.
[0100] Specifically, when a storage space expansion instruction for any file directory is received, an expansion space is obtained from the unallocated space in the file storage system based on the size of the expansion space carried in the storage space expansion instruction, and the expansion space is added to the storage space corresponding to the file directory to write a file into the storage space corresponding to the file directory;
[0101] Among them, the size of the expansion space is not greater than the size of the unallocated space, and the unallocated space refers to the space in the file storage system that has not been allocated and has not been written with files.
[0102] In this embodiment, when a storage space expansion instruction for any file directory is received, an expansion space can be obtained from the unallocated space in the file storage system and added to the storage space corresponding to the file directory to complete the writing process of the file to be written.
[0103] It should be noted that the unallocated space in the file storage system refers to the storage space included in the entire physical storage space of the file storage system, except for the storage space that has been pre-allocated to each file directory (occupied by the file directory) and the storage space that has not been pre-allocated to each file directory but has been written with other files (occupied by the written files), that is, the unoccupied storage space.
[0104] (2) The storage space configuration information adjustment instruction can be a storage space reduction instruction.
[0105] It is easy to understand that the storage space reduction instruction can be sent by the management platform to some file directories with relatively large available space in the storage space when it detects that the unallocated space is insufficient, instructing the storage space corresponding to the file directory to release a part of the available space.
[0106] For example, if File Directory 1 needs to be expanded and the unallocated space in the current file storage system does not meet the expansion requirements of File Directory 1, at this time, other file directories with relatively large available space can be requested to reduce their capacity and release a part of the available space so that the size of the unallocated space meets the expansion requirements of File Directory 1; or, when the data to be written is written to a non-pre-allocated directory, if it is found that the unallocated space in the file storage system cannot accommodate the data to be written, at this time, other file directories with relatively large available space can also be requested to reduce their capacity and release a part of the available space.
[0107] In this embodiment, the storage space reduction instruction can carry the size of the reduced space, and the size of the reduced space refers to the size of the storage space that needs to be released to the unallocated space; similarly, the storage space reduction instruction can also carry the size of the target space after reduction, that is, it instructs the remaining storage space size of the target directory after reduction. The size of the reduced space or the size of the target space after reduction can be adjusted according to the actual situation, and this application does not limit this.
[0108] The following describes an example where the size of the reduced storage space is carried in the storage space reduction indication.
[0109] Specifically, when receiving a storage space reduction indication for any file directory, based on the size of the reduced storage space carried in the storage space reduction indication, obtain the reduced storage space from the storage space corresponding to the file directory, and release the reduced storage space as the space to be allocated in the file storage system;
[0110] Among them, the size of the reduced storage space is not greater than the available space in the storage space corresponding to the file directory. The available space refers to the space in the storage space corresponding to the file directory where no file has been written, and the space to be allocated refers to the space in the file storage system that has not been allocated and no file has been written.
[0111] In this embodiment, when receiving a storage space reduction indication for any file directory, the reduced storage space can be obtained from the available space in the storage space corresponding to the file directory and released as the space to be allocated.
[0112] (3) The storage space configuration information adjustment indication can be a storage space deletion indication.
[0113] In this embodiment, if a storage space is no longer needed for a certain file directory, the management platform can issue a storage space deletion indication for the file directory.
[0114] Specifically, when receiving a storage space deletion indication for any file directory, detect whether there is available space in the storage space corresponding to the file directory;
[0115] If so, release the available space as the space to be allocated in the file storage system.
[0116] In this embodiment, when receiving a storage space deletion indication for any file directory, the available space in the storage space corresponding to the file directory can be released to the space to be allocated. Since files have been stored in the non-available space in the storage space corresponding to the file directory, these storage spaces cannot be released currently. After the stored files are deleted, these storage spaces can also be released to the space to be allocated.
[0117] It should be noted that even if there is no available space in the storage space corresponding to the file directory that receives the storage space deletion indication, the space deletion indication will delete the key values included in the metadata of the file directory. Although the files in the directory still occupy these storage spaces, these storage spaces are no longer pre-allocated storage spaces.
[0118] So far, the description of the three storage space configuration information adjustment indications is completed.
[0119] As an example, when receiving an indication to adjust the storage space configuration information for any file directory, after adjusting the pre-allocated storage space configuration information for the file directory based on the indication to adjust the storage space configuration information, the method proposed by the embodiments of the present application may further include:
[0120] According to the adjusted storage space configuration information, update the key value of the storage space information corresponding to the file directory.
[0121] After adjusting the storage space configuration information (expanding, shrinking, or deleting), the key value of the storage space information corresponding to the file directory can be further updated. For example, after expanding, update the address information corresponding to the storage space recorded in the key value to the address information after expansion; after shrinking, update the address information corresponding to the storage space recorded in the key value to the address information after shrinking; after deleting, the key value relationship pair can be directly deleted.
[0122] Thus, the description of step 104 ends.
[0123] In this embodiment, only pre-allocation for empty directories is involved and nested directory creation pre-allocation is not supported. That is, only when there is no pre-allocation setting for the file directory and its parent and sub-directories can storage space be pre-allocated for the file directory.
[0124] In this embodiment, it should be noted that for each directory pre-allocation space, only the lower limit capacity value of the pre-allocated storage space corresponding to the directory can be set. When the amount of data written to the file exceeds the pre-allocated storage space corresponding to the directory, the expansion operation may not be immediately executed, and the part exceeding the pre-allocated capacity range of the directory is directly stored in the unallocated space of the file storage space.
[0125] For example, if 10GB of space is pre-allocated for a certain file directory and 11GB of data is actually written, the remaining 1GB will occupy a part of the unallocated space in the file storage system.
[0126] On this basis, when the storage space corresponding to the file directory is expanded subsequently, the part of the space occupying the unallocated space will be divided into the storage space allocated for the file directory.
[0127] For example, taking the above example, if 10GB of space is pre-allocated for the file directory and 11GB of data is actually written, the remaining 1GB will occupy a part of the unallocated space in the file storage system. When the pre-allocated storage space corresponding to the file directory is expanded to 20GB, the above remaining 1GB file can also be divided into the expanded storage space. That is, the expanded storage space corresponding to the file directory is 20GB, the occupied space is 11GB, and the remaining available space is 9GB.
[0128] So far, the description of Figure 1 ends.
[0129] In this application, storage space configuration information corresponding to at least one directory in the file storage system is pre-allocated and represented by key values. When a file write instruction is received, if it is determined that there is a corresponding key value for the target file directory carried in the file write instruction, the file is written based on this key value. When a storage space configuration information adjustment instruction for any file directory is received, the allocated storage space configuration information for this file directory is adjusted. The above solution pre-allocates storage space for the file directory, reserves this storage space, avoids the storage space corresponding to this file directory being occupied by files in other directories, and can correspondingly adjust the storage space configuration information when a storage space configuration information adjustment instruction is received, improving the performance of the file storage system.
[0130] Next, in combination with Figures 2 to 5 , a specific embodiment is used to describe the space pre-allocation method proposed in this application.
[0131] Please refer to Figure 2 , Figure 2 , which is a schematic diagram of a specific space pre-allocation method provided by an embodiment of this application.
[0132] As shown in Figure 2 , when a file write instruction is received, the MDS can query the metadata of the target file directory according to the target file directory carried in the file write instruction. If the metadata of the target file directory includes a key value, it indicates that the target file directory is pre-configured with storage space, and the queried pre-allocation information (i.e., the total capacity, remaining capacity, address information, etc. of the pre-allocated storage space) is obtained.
[0133] After determining that the target file directory is pre-configured with storage space, it can be further detected whether the available space in the pre-allocated storage space meets the write requirements of the file to be written.
[0134] If it meets, that is, the available space capacity in the storage space is sufficient, the file to be written can be directly written into the available space;
[0135] If it does not meet, the part of the file size that exceeds the storage space corresponding to this file directory can be stored in the space to be allocated in the file storage system.
[0136] As another optional implementation, the storage space can be adjusted (expanded) so that the adjusted storage space can complete the file write.
[0137] So far, the description of Figure 2 ends.
[0138] Please refer to Figure 3 , Figure 3 , which is a schematic diagram of a method for creating a storage space provided by an embodiment of the present application.
[0139] In this embodiment, the total capacity of the storage space of the file storage system can be denoted as S, and the actually occupied storage space can be denoted as C, where C = C1 + C2;
[0140] Among them, C1 refers to the sum of the sizes of the actually occupied storage spaces of all pre-allocated file directories. The following explains the size of the actually occupied storage space of the pre-allocated file directories:
[0141] Denote the pre-allocated space size set for the file directory as X, and the actually written data volume of this file directory as Y. If X ≥ Y, that is, the pre-allocated storage space of the file directory is not less than the actually written data volume under this file directory (that is, all the files under this file directory are written into the pre-allocated storage space of this file directory), then the size of the actually occupied storage space of this file directory is X (that is, the pre-allocated storage space size); otherwise, if X < Y, that is, the pre-allocated storage space of the file directory is less than the actually written data volume under this file directory (that is, part of the files under this file directory are written into the pre-allocated storage space of this file directory, and the part exceeding the pre-allocated storage space of this file directory is written into the unallocated space of the file storage system), then the size of the actually occupied storage space of this file directory is Y (that is, the sum of the pre-allocated storage space size and the size of the part exceeding the pre-allocated storage space of this file directory).
[0142] For example, storage spaces are pre-allocated for two file directories. The pre-allocated storage space size for file directory 1 is 1G, and the pre-allocated storage space size for file directory 2 is 2G. Among them, the written data volume in file directory 1 is 0.8G, then the actually occupied storage space size of file directory 1 is 1G; the written data volume in file directory 2 is 2.2G, then the actually occupied storage space size of file directory 2 is 2.2G (2G pre-allocated space + 0.2G occupied by the exceeding part of the unallocated space), and the size of C1 in this file storage system is 1G + 2.2G = 3.2G).
[0143] C2 refers to the actually written data volume of non-pre-allocated file directories, that is, the actually written data volume under file directories without pre-allocated storage spaces. This part of the data is all stored in the unallocated space of the file storage system and can be counted according to the actually written data volume under the actual directory. The capacity of the unallocated space of the file storage system is (S - C).
[0144] The following introduces the process of pre-allocating a storage space for a file directory in the current file storage system:
[0145] As Figure 3 shown, the method specifically includes:
[0146] The management platform issues a task for pre - allocating a file directory. The pre - allocation instruction carries the size of the pre - allocated storage space, denoted as A.
[0147] If A is greater than the capacity of the space to be allocated in the file storage system (S - C), it indicates that the capacity of the space to be allocated in the file storage system is not enough to allocate a space of size A for this file directory, and an error prompt message (such as "Insufficient space") is returned.
[0148] If A is less than or equal to the capacity of the space to be allocated in the storage system (S - C), and this file directory and its parent and sub - directories have no pre - allocation settings (no nested creation), and this file directory also does not have a pre - configured storage space, then a pre - creation request is sent to the MDS, so that the MDS stores the pre - allocation information (i.e., key - value pairs) in the form of OMAP as the metadata of this file directory and updates it to the metadata stored in the MDS.
[0149] Meanwhile, after updating the metadata of this file directory stored in the current MDS, all MDSs can be broadcast (other MDSs are used as backup MDSs for the current MDS to replace the function of the current MDS in case of a failure of the current MDS) to synchronously update the metadata of this file directory.
[0150] Thus, the process of pre - allocating this file directory is completed.
[0151] Please refer to Figure 4 , Figure 4 a schematic diagram of a method for expanding storage space provided by an embodiment of this application.
[0152] As Figure 4 shown, the method may include:
[0153] During the use of a file storage system, if the pre-allocated space for a certain file directory is insufficient, and there is enough space to be allocated, the capacity of the pre-allocated space can be freely increased. For example, if the original pre-allocated space size for the file directory is A, and now the size of the expanded space for this file directory needs to be set as A1, that is, the pre-allocated storage space size for this file directory needs to be expanded from A to (A + A1). At this time, it is necessary to compare the size of A1 with the space capacity to be allocated (S - C). If the pre-allocated space size A1 is greater than (S - C), creation cannot be performed, and an error is returned. If the pre-allocated space size A1 is not greater than (S - C), then update the metadata of this file directory stored in the current MDS, update the pre-allocated storage space corresponding to this file directory to the size of (A + A1), and at the same time update the address information of the storage space corresponding to this file directory in the key value, that is, update the pre-allocation information corresponding to this file directory, so as to update the metadata managed by the MDS, and broadcast all MDSs to synchronously update the metadata of this file directory.
[0154] So far, the description of Figure 4 ends.
[0155] In this embodiment, when the space capacity to be allocated is insufficient and there is still a lot of available space in the pre-allocated file directory, the capacity that has been allocated can be reduced in the pre-allocation to release some space. For example, the pre-allocated capacity size of the directory is set as A, and now the target space size after reducing the capacity of this file directory is set as A2, that is, the pre-allocated storage space size for this file directory needs to be reduced from A to A2. The management interface issues a capacity reduction request. If the actually written data capacity Y in this pre-allocated directory is greater than or equal to the pre-allocated setting capacity size A of the directory, the capacity reduction operation cannot be performed, and a prompt message that the pre-allocated space of the directory is full and cannot be reduced is returned; if the actually written data volume Y in this pre-allocated directory is less than A, then the value range of the target space size A2 after reducing the capacity of this file directory is [Y, A). After the capacity reduction, the space capacity to be allocated in the file storage system is S - C + (A - A2), where (A - A2) is the storage space in the available space of the pre-allocated storage space corresponding to this file directory that is released to the space to be allocated.
[0156] Please refer to Figure 5 , Figure 5 which is a schematic diagram of a method for deleting storage space provided by an embodiment of this application.
[0157] As Figure 5 shown, this method may include:
[0158] Upon receiving a deletion instruction, the space pre-allocation information corresponding to the file directory recorded in the MDS can be deleted first, that is, the key value corresponding to the file directory and the underlying system pre-allocation flag bit information are deleted from the metadata information managed by the MDS. The underlying system pre-allocation flag bit information is used to indicate whether the storage space has been pre-allocated for the file directory, and all MDSs are broadcast to synchronously update the metadata.
[0159] Further detect the amount of data Y that has been written to this file directory at this time.
[0160] If the actually written data volume Y < A, that is, the actually written data volume Y is less than the pre-allocated space size A, after issuing the deletion directory space pre-allocation instruction, the available space (A - Y) in the pre-allocated space corresponding to this file directory will be directly released as unallocated space. At this time, the remaining total storage space size is S - C + (A - Y). If the actually written data volume Y >= A in this file directory, that is, the actually written data volume Y is greater than or equal to the pre-allocated space size A, after deleting the space pre-allocation setting of this file directory, since there is no available space in the pre-allocated space corresponding to this file directory, the available space cannot be released as unallocated space. At this time, the remaining total storage space size of the storage cluster is still S - C, without change, but the storage space occupied by this file directory is no longer the pre-allocated storage space at this time, but the unallocated space in the file storage system.
[0161] So far, the description of Figure 5 ends.
[0162] Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of an electronic device proposed in an embodiment of this application. At the hardware level, this electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a terminal interaction device at the logical level. Of course, in addition to the software implementation method, this application does not exclude other implementation methods, such as logical devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logical unit, but can also be hardware or logical devices.
[0163] Please refer to Figure 7 , Figure 7 which is a structural diagram of a space pre-allocation device proposed in an embodiment of this application. As shown in Figure 7 , this device may include a configuration unit 701, a determination unit 702, a writing unit 703, and an adjustment unit 704. Specifically, this device includes:
[0164] The configuration unit 701 is used to pre-allocate corresponding storage space configuration information for at least one established file directory in the file storage system; the storage space configuration information is represented by a corresponding key value;
[0165] The determination unit 702 is used to, when receiving a file writing instruction, determine whether there is a corresponding key value for the target file directory based on the target file directory carried in the file writing instruction;
[0166] The writing unit 703 is used to, when there is a corresponding key value for the target file directory, perform a corresponding file writing operation based on the key value corresponding to the target file directory;
[0167] The adjustment unit 704 is used to, when receiving a storage space configuration information adjustment instruction for any file directory, adjust the pre-allocated storage space configuration information of this file directory based on the storage space configuration information adjustment instruction.
[0168] Optionally, the key value is recorded in the form of the metadata of the file directory, the key value includes the correspondence between the file directory and the storage space configuration information, and the storage space configuration information includes the address information of the pre-configured storage space for this file directory; the determination unit 702 is specifically used for:
[0169] Determine the target file directory corresponding to the file to be written according to the file writing instruction;
[0170] Search for the metadata of the target file directory and determine whether the metadata of the target file directory includes the correspondence between the target file directory and the address information of the pre-configured storage space for this target file directory;
[0171] If so, determine that there is a corresponding key value for the target file directory;
[0172] And / or, the writing unit 703 is specifically used for:
[0173] Based on the address information of the pre-configured storage space for this target file directory, write the file to be written into the available space in the storage space, where the available space refers to the space in the storage space corresponding to this file directory that has not been written with files;
[0174] And / or, the adjustment unit 704 is specifically used for:
[0175] When receiving a storage space expansion instruction for any file directory, obtain an expansion space from the unallocated space in the file storage system based on the size of the expansion space carried in the storage space expansion instruction, and add the expansion space to the storage space corresponding to this file directory to write files in the storage space corresponding to this file directory;
[0176] Among them, the size of the expanded space is not greater than the size of the space to be allocated. The space to be allocated refers to the space in the file storage system that has not been allocated and has no file written to it;
[0177] And / or, the adjustment unit 704 is specifically configured to:
[0178] When receiving a storage space reduction instruction for any file directory, based on the size of the reduced space carried in the storage space reduction instruction, obtain the reduced space from the storage space corresponding to the file directory, and release the reduced space as the space to be allocated in the file storage system;
[0179] Among them, the size of the reduced space is not greater than the size of the available space in the storage space corresponding to the file directory. The available space refers to the space in the storage space corresponding to the file directory that has no file written to it. The space to be allocated refers to the space in the file storage system that has not been allocated and has no file written to it;
[0180] And / or, the adjustment unit 704 is specifically configured to:
[0181] When receiving a storage space deletion instruction for any file directory, detect whether there is available space in the storage space corresponding to the file directory;
[0182] If so, release the available space as the space to be allocated in the file storage system;
[0183] Among them, the available space refers to the space in the storage space corresponding to the file directory that has no file written to it. The space to be allocated refers to the space in the file storage system that has not been allocated and has no file written to it;
[0184] And / or, the adjustment unit 704 is further configured to:
[0185] According to the adjusted storage space configuration information, update the key value of the storage space information corresponding to the file directory.
[0186] Thus, the description of the space pre-allocation device in Figure 7 is completed.
[0187] Correspondingly, an embodiment of the present application further provides a computer-readable storage medium. A number of computer instructions are stored on the computer-readable storage medium. When the computer instructions are executed, the method disclosed in the above examples of the present application can be implemented.
[0188] Exemplarily, the above computer-readable storage medium can be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, and so on. For example, the computer-readable storage medium can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), solid-state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or a combination thereof.
[0189] The above are only the preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of protection of the present application.
Claims
1. A space pre-allocation method, characterized in that: The method is applied to a file storage system, and the method comprises: Pre-allocating corresponding storage space configuration information for at least one file directory established in the file storage system; the storage space configuration information is represented by a corresponding key value; When receiving a file write instruction, determining whether a corresponding key value exists in the target file directory based on the target file directory carried in the file write instruction; If a corresponding key value exists in the target file directory, a corresponding file write operation is performed based on the key value corresponding to the target file directory; When a storage space configuration information adjustment indication is received for any file directory, the pre-allocated storage space configuration information of the file directory is adjusted based on the storage space configuration information adjustment indication to improve the storage space utilization in the file storage system and ensure the storage performance of the file storage system.
2. The method according to claim 1, characterized in that The key value is recorded in the form of metadata of the file directory, the key value includes a correspondence between the file directory and the storage space configuration information, and the storage space configuration information includes address information of the storage space preconfigured for the file directory; The determining, based on the target file directory carried by the file write instruction, whether the target file directory has a corresponding key value includes: Determine the target file directory corresponding to the file to be written according to the file writing instruction; Searching for metadata of the target file directory to determine whether the metadata of the target file directory includes a correspondence between the target file directory and address information of a storage space preconfigured for the target file directory; If so, it is determined that the target file directory has a corresponding key value.
3. The method according to claim 2, characterized in that In the case that the target file directory has a corresponding key value, performing a corresponding file write operation based on the key value corresponding to the target file directory includes: Based on the address information of the storage space preconfigured for the target file directory, the file to be written is written into the available space in the storage space, where the available space refers to the space in the storage space preconfigured for the target file directory where no file is written.
4. The method according to claim 1, characterized in that When receiving a storage space configuration information adjustment instruction for any file directory, adjusting the pre-allocated storage space configuration information of the file directory based on the storage space configuration information adjustment instruction includes: When receiving a storage space expansion indication for any file directory, based on the size of the expansion space carried in the storage space expansion indication, the expansion space is obtained from the to-be-allocated space in the file storage system, and the expansion space is added to the storage space corresponding to the file directory, so as to write files into the storage space corresponding to the file directory; The size of the expanded space is not greater than the size of the to-be-allocated space, and the to-be-allocated space refers to a space in the file storage system that is not allocated and has no files written to it.
5. The method according to claim 1, characterized in that When receiving a storage space configuration information adjustment instruction for any file directory, adjusting the pre-allocated storage space configuration information of the file directory based on the storage space configuration information adjustment instruction includes: When a storage space shrinkage indication for any file directory is received, based on the shrinkage space size carried in the storage space shrinkage indication, the shrinkage space is obtained from the storage space corresponding to the file directory, and the shrinkage space is released as a to-be-allocated space in the file storage system; Among them, the size of the reduced space is not greater than the size of the available space in the storage space corresponding to the file directory, the available space refers to the space in the storage space corresponding to the file directory where no files are written, and the space to be allocated refers to the space in the file storage system that is not allocated and has no files written.
6. The method according to claim 1, characterized in that When receiving a storage space configuration information adjustment instruction for any file directory, adjusting the pre-allocated storage space configuration information of the file directory based on the storage space configuration information adjustment instruction includes: When receiving a storage space deletion instruction for any file directory, detecting whether there is available space in the storage space corresponding to the file directory; If yes, releasing the available space as the space to be allocated in the file storage system; The available space refers to a space in the storage space corresponding to the file directory where no files are written, and the to-be-allocated space refers to a space in the file storage system that is not allocated and has no files written thereto.
7. The method according to any one of claims 4 to 6, characterized in that When receiving a storage space configuration information adjustment instruction for any file directory, after adjusting the pre-allocated storage space configuration information of the file directory based on the storage space configuration information adjustment instruction, the method further comprises: According to the adjusted storage space configuration information, the key value of the storage space information corresponding to the file directory is updated.
8. A space pre-allocation device, characterized in that: The device is applied to a file storage system and comprises: A configuration unit, used to pre-allocate corresponding storage space configuration information for at least one file directory established in the file storage system; the storage space configuration information is represented by a corresponding key value; A determination unit, configured to, upon receiving a file write instruction, determine, based on a target file directory carried in the file write instruction, whether a corresponding key value exists in the target file directory; A writing unit, configured to, if a corresponding key value exists in the target file directory, perform a corresponding file writing operation based on the key value corresponding to the target file directory; An adjustment unit is used to adjust the pre-allocated storage space configuration information of any file directory based on the storage space configuration information adjustment indication when receiving the storage space configuration information adjustment indication for the file directory, so as to improve the storage space utilization rate in the file storage system and ensure the storage performance of the file storage system.
9. The device according to claim 8, characterized in that The key value is recorded in the form of metadata of the file directory, the key value includes a correspondence between the file directory and the storage space configuration information, and the storage space configuration information includes address information of the storage space preconfigured for the file directory; the determining unit is specifically used to: Determine the target file directory corresponding to the file to be written according to the file writing instruction; Searching for metadata of the target file directory to determine whether the metadata of the target file directory includes a correspondence between the target file directory and address information of a storage space preconfigured for the target file directory; If yes, then determine that the target file directory has a corresponding key value; And / or, the writing unit is specifically used for: Based on the address information of the storage space preconfigured for the target file directory, writing the file to be written into the available space in the storage space, where the available space refers to the space in the storage space preconfigured for the target file directory where no file is written; And / or, the adjustment unit is specifically used for: When receiving a storage space expansion indication for any file directory, based on the size of the expansion space carried in the storage space expansion indication, the expansion space is obtained from the to-be-allocated space in the file storage system, and the expansion space is added to the storage space corresponding to the file directory, so as to write files into the storage space corresponding to the file directory; The size of the expansion space is not greater than the size of the to-be-allocated space, and the to-be-allocated space refers to the space in the file storage system that is not allocated and has no files written to it; And / or, the adjustment unit is specifically used for: When a storage space shrinkage indication for any file directory is received, based on the shrinkage space size carried in the storage space shrinkage indication, the shrinkage space is obtained from the storage space corresponding to the file directory, and the shrinkage space is released as a to-be-allocated space in the file storage system; The size of the shrinking space is not greater than the size of the available space in the storage space corresponding to the file directory, the available space refers to the space in the storage space corresponding to the file directory where no files are written, and the to-be-allocated space refers to the space in the file storage system that is not allocated and has no files written therein; And / or, the adjustment unit is specifically used for: When receiving a storage space deletion instruction for any file directory, detecting whether there is available space in the storage space corresponding to the file directory; If yes, releasing the available space as the space to be allocated in the file storage system; The available space refers to the space in the storage space corresponding to the file directory where no files are written, and the to-be-allocated space refers to the space in the file storage system that is not allocated and has no files written therein; And / or, the adjustment unit is further used for: According to the adjusted storage space configuration information, the key value of the storage space information corresponding to the file directory is updated.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.