WO2016191964A1 - Management method and device of file system - Google Patents

Management method and device of file system Download PDF

Info

Publication number
WO2016191964A1
WO2016191964A1 PCT/CN2015/080371 CN2015080371W WO2016191964A1 WO 2016191964 A1 WO2016191964 A1 WO 2016191964A1 CN 2015080371 W CN2015080371 W CN 2015080371W WO 2016191964 A1 WO2016191964 A1 WO 2016191964A1
Authority
WO
WIPO (PCT)
Prior art keywords
area
file
data block
index node
partition
Prior art date
Application number
PCT/CN2015/080371
Other languages
French (fr)
Chinese (zh)
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 华为技术有限公司
Priority to PCT/CN2015/080371 priority Critical patent/WO2016191964A1/en
Priority to CN201580064360.0A priority patent/CN107111549B/en
Publication of WO2016191964A1 publication Critical patent/WO2016191964A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation

Definitions

  • the present application relates to the field of electronic technologies, and in particular, to a file system management method and apparatus.
  • FIG. 1a it is a schematic diagram of a file system in a storage device.
  • the storage space in the storage device is divided into system storage space and user storage space.
  • the system storage space typically contains a plurality of fixed partitions, such as partition 1, partition 2 to partition N in Figure 1a.
  • the size of each fixed partition has been designed by the designer at the time of shipment from the factory, and the possibility of being able to be changed after leaving the factory is minimal.
  • FIG. 1b is a schematic diagram of further layout of the partition 1 in FIG. 1a.
  • the partition 1 After the file system is formatted for the system storage space, the partition 1 includes a super block area, a data block bitmap area, an inode bitmap area, an inode area, and a data block area. After formatting, not only the size of partition 1 is fixed, but the location of each zone is also fixed.
  • the super block area is used to record the system information of the file system of the partition 1, such as the type and size of the file system.
  • the data block bitmap area is defined by the data structure of the bitmap, and each bit represents the use of a data block. For example, a value of 0 indicates that the data block corresponding to the bit is not used, and a value of 1 indicates that the data block corresponding to the bit has been used.
  • the index node bitmap area is also defined by the data structure of the bitmap, and each bit represents the use of an index node. Each index node of the inode area corresponds to a file. The index node records the attributes of the file and the storage address of the file in the data block. The file can be found in the data block by the index node.
  • the data block is used to store files.
  • Partition 2 to partition N are laid out in the same way as partition 1.
  • each fixed partition is allocated a storage space larger than the space required by the partition, so that the storage space is wasted.
  • partition 1 has been used up, but partition 2 has free space, or partition 1 has free space and partition 2 has run out.
  • Designers will continue to expand the size of partition 1 or partition 2 in the new product, then the system storage space will increase, so the user storage space will be compressed, so there is a problem of low storage space utilization.
  • the embodiment of the present invention provides a file system management method and device, which are used to solve the technical problem of low storage space utilization in the prior art.
  • the first aspect of the present application provides a file system management method, including:
  • N Allocating N partitions to the file system on a second consecutive address segment of the storage device, each partition of the N partitions respectively for storing system metadata of each partition; N is greater than 1 Integer
  • the shared data block area is for storing a file;
  • the data block bitmap area is used for Storing a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first usage identifiers; wherein the first The contiguous address segment, the second contiguous address segment, and the third contiguous address segment form a contiguous address segment.
  • each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing a storage address of a file in the shared data block area; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to One of the second usage identifiers;
  • the method further includes:
  • the request includes The size of the file
  • the first usage identifier of the data block corresponding to the storage address is changed in the data block bitmap to a value indicating that the data block has been used.
  • each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes Corresponding to one of the second use identifiers,
  • the method further includes:
  • the second aspect of the present application provides a file system management method, including:
  • the data block bitmap area is configured to store a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first Using an identifier; the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a contiguous address segment, the fourth consecutive The address segment is located between the second consecutive address segment and the third consecutive address segment.
  • the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes Corresponding to one of the second use identifiers;
  • the method further includes:
  • the request includes a size of the file
  • the first usage identifier of the data block corresponding to the storage address is changed in the data block bitmap to a value indicating that the data block has been used.
  • the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes Corresponding to one of the second use identifiers,
  • the method further includes:
  • the third aspect of the present application provides a file system management method, including:
  • the system information includes a type and size of the file system ;
  • the shared area is configured to store a file and an index node; and the index node is configured to record a file stored in the shared area a storage address;
  • the bitmap area is configured to store a usage identifier, where the usage identifier is used to indicate whether a data block in the shared area is used, and each of the data blocks corresponds to one of the usage identifiers;
  • a contiguous address segment, the second contiguous address segment, and the third contiguous address segment form a contiguous address segment.
  • the method further includes:
  • the first address end of the shared area is allocated to the second address end
  • the second address end of the shared area is allocated to the first address end.
  • the file system is allocated on a third consecutive address segment of the storage device After the shared area, the method further includes:
  • the request includes a size of the file
  • the method further includes:
  • the index node further records an attribute of the file
  • the method further includes:
  • a fourth aspect of the present application provides a file system management method, including:
  • a data block bitmap allocation module configured to allocate a data block bitmap area to the file system on a first consecutive address segment of the storage device
  • a metadata partition allocation module configured to allocate N partitions to the file system on a second consecutive address segment of the storage device, where each partition of the N partitions is used to store each partition System metadata; N is an integer greater than one;
  • a data block allocation module configured to allocate a common data block area of the N partitions to the file system on a third consecutive address segment of the storage device, where the shared data block area is used to store a file;
  • the data block bitmap area is configured to store a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first An identifier is used; wherein the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
  • each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing a storage address of a file in the shared data block area; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to a second use identifier; the device further comprises:
  • a receiving module configured to receive a request for creating a file in an i-th partition of the N partitions; the request includes a size of the file;
  • a processing module configured to determine, by using the first usage identifier, an unused data block in the shared data block region; determining a remaining portion in the shared data block region according to the number and size of the unused data blocks a size of the capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be stored in the Determining a storage address in the shared data block area, and searching whether there is an unused index node in the index node bitmap area of the i-th partition; when there is an unused index node, selecting the unused An index node in the index node, writing an attribute of the file and the storage address; changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to indicate the a value that has been used by an index node; storing the file in a data block corresponding to the storage address in the shared data block area;
  • each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is enabled
  • the device further includes:
  • a receiving module configured to receive a request for deleting a file in the partition j in the N partitions
  • a processing module configured to search, according to an attribute of the file, a corresponding index node in an index node area of the partition j: determining, according to a storage address recorded by the index node, data corresponding to the storage address in the shared data block a block; changing, in the data block bitmap area, the first usage identifier of a data block corresponding to the storage address to a value indicating that the data block is not used; and an index node bit of the partition j The second usage identifier of the corresponding index node is changed in the map area to a value indicating that the corresponding index node is not used.
  • the fifth aspect of the present application provides a file system management apparatus, including:
  • a data block bitmap allocation module configured to allocate a data block bitmap area to the file system on a first consecutive address segment of the storage device
  • a metadata partition allocation module configured to allocate a first partition to the file system on a second consecutive address segment of the storage device, where the first partition is configured to store system metadata of the first partition; Assigning a second partition to the file system on a third consecutive address segment of the storage device, where the second partition is configured to store system metadata of the second partition;
  • a data block allocation module configured to allocate a common data block area of the first partition and the second partition to the file system on a fourth consecutive address segment of the storage device; wherein the shared data The block area is configured to store a file; the data block bitmap area is configured to store a first use identifier, and the first use identifier is used to indicate whether a data block in the shared data block area is used, each of the data The block corresponds to one of the first usage identifiers; the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a continuous address segment The fourth consecutive address segment is located between the second consecutive address segment and the third consecutive address segment.
  • the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is enabled Each of the index nodes corresponds to one of the second usage identifiers; the device further includes:
  • a receiving module configured to receive a request for creating a file in the first partition; the request includes a size of the file;
  • a processing module configured to determine, by using the first usage identifier, an unused data block in the shared data block region; determining a remaining portion in the shared data block region according to the number and size of the unused data blocks a size of the capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be stored in the Determining a storage address in the shared data block area, and searching whether there is an unused index node in the index node bitmap area of the first partition; when there is an unused index node, selecting the unused one An index node in the index node, writing an attribute of the file and the storage address; changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to represent the one a value at which an index node has been used; storing the file in a data block corresponding to the storage address in the shared data block area; The data block corresponding to
  • the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes Corresponding to one of the second use identifiers,
  • the device also includes:
  • a receiving module configured to receive a request to delete a file in the first partition
  • a processing module configured to search, according to an attribute of the file, a corresponding index node in an index node area of the first partition: determining, according to a storage address recorded by the index node, a corresponding to the storage address in the shared data block a data block; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; and indexing the first partition The second usage identifier change of the corresponding index node in the bitmap area A value indicating that the corresponding index node is not used.
  • the sixth aspect of the present application provides a file system management apparatus, including:
  • a super block allocation module configured to allocate a super block area for the file system on a first consecutive address segment of the storage device, where the super block area is used to record system information of the file system; The type and size of the file system;
  • bitmap allocation module configured to allocate a bitmap area to the file system on a second consecutive address segment of the storage device
  • a shared area allocation module configured to allocate a shared area to the file system on a third consecutive address segment of the storage device, where the shared area is used for storing files and an index node; and the index node is used for recording and storing a storage address of the file in the shared area;
  • the bitmap area is configured to store a usage identifier, where the usage identifier is used to indicate whether a data block in the shared area is used, and each of the data blocks corresponds to a The usage identifier is used; the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
  • the device further includes a processing module, when the space is allocated to the index node in the shared area, from the shared area The first address end is allocated to the second address end direction; when the shared area allocates space for the file, the second address end of the shared area is allocated to the first address end direction.
  • the device further includes:
  • a receiving module configured to receive a request for creating a file; the request includes a size of the file;
  • a processing module configured to determine, according to the usage identifier, an unused data block in the shared area; determining a size of a remaining capacity in the shared area according to the number and size of the unused data blocks; Determining a size of the file and a size of the remaining capacity to determine whether the remaining capacity is sufficient to create the file and storing an index node corresponding to the file; when the remaining capacity is sufficient to store the file and store an index corresponding to the file a node, creating the file on the unused data block and recording a storage address of the file in the corresponding index node; The usage identifier of the data block corresponding to the storage address and the index node in the bitmap area is changed to a value indicating that the data block has been used.
  • the processing module is further configured to: update the storage in the shared area recorded in the super block a value of the size of the space occupied by all of the index nodes and a value of the size of the space occupied by all of the files stored in the shared area.
  • the device further includes:
  • a receiving module configured to receive a request for querying a file, where the request includes an attribute of the file
  • a processing module configured to query an index node corresponding to the attribute in the shared area; and search for a file corresponding to the storage address in the shared area according to the storage address recorded in the corresponding index node.
  • a seventh aspect of the present application provides an electronic device, including:
  • a processor for allocating a data block bitmap area to the file system on a first consecutive address segment of the memory; assigning N to the file system on a second consecutive address segment of the memory a partition, each partition of the N partitions being used to store system metadata of each partition; N is an integer greater than 1; and the file system is allocated on a third consecutive address segment of the memory a shared data block area of the N partitions, where the shared data block area is used to store a file; the data block bitmap area is used to store a first use identifier, and the first use identifier is used to represent the shared data Whether the data blocks in the block area are used, each of the data blocks corresponding to one of the first usage identifiers; wherein the first consecutive address segment, the second consecutive address segment, and the third continuous The address segments form a contiguous address segment.
  • each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing a storage address of a file in the shared data block area; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; The index node corresponds to one of the second usage identifiers, and the electronic device further includes an input device.
  • the input device is configured to receive a request for creating a file in an i th partition of the N partitions; the request includes a size of the file;
  • the processor is further configured to: determine, by using the first usage identifier, an unused data block in the shared data block area; determine the shared data block area according to the number and size of the unused data blocks. a size of the remaining capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be Storing a storage address in the shared data block area, and searching for an unused index node in an index node bitmap area of the i-th partition; when there is an unused index node, selecting the An index node of an unused index node, writes an attribute of the file and the storage address; and changes the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been used; storing the file in a data block corresponding to the storage address in the shared data block area; The first usage identifier of the data block corresponding to
  • each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes Corresponding to one of the second usage identifiers, the electronic device further includes an input device,
  • the input device is configured to receive a request for deleting a file by a partition j in the N partitions;
  • the processor is further configured to: search, according to an attribute of the file, a corresponding index node in an index node area of the partition j: determining, in the shared data block, the storage address according to a storage address recorded by the index node Corresponding data block; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; indexing the partition j Changing the second usage identifier of the corresponding index node in the node bitmap area to A value indicating that the corresponding index node is not used.
  • An eighth aspect of the present application provides an electronic device, including:
  • a processor for allocating a data block bitmap area to the file system on a first consecutive address segment of the memory; assigning a first to the file system on a second consecutive address segment of the memory a partition, the first partition is configured to store system metadata of the first partition; a second partition is allocated to the file system on a third consecutive address segment of the memory, the second partition is configured to store System metadata of the second partition; a shared data block region of the first partition and the second partition is allocated to the file system on a fourth consecutive address segment of the memory; wherein a shared data block area for storing a file; the data block bitmap area is for storing a first use identifier, and the first use identifier is used to indicate whether a data block in the shared data block area is used, each of the The data block corresponds to one of the first usage identifiers; the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment are consecutive Address segment, Said fourth consecutive addresses between the second consecutive addresses and consecutive addresses of said third segment
  • the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes Corresponding to one of the second usage identifiers; the electronic device further includes an input device,
  • the input device is configured to receive a request for creating a file in the first partition; the request includes a size of the file;
  • the processor is further configured to: determine, by using the first usage identifier, an unused data block in the shared data block area; determine the shared data block area according to the number and size of the unused data blocks. The size of the remaining capacity; determining whether the remaining capacity is sufficient to create the file according to the size of the file and the size of the remaining capacity; when the remaining capacity is sufficient to create the file Determining, that the file is to be stored in the shared data block area, and searching for an unused index node in the index node bitmap area of the first partition; when there is an unused When the node is indexed, one of the unused index nodes is selected, the attribute of the file and the storage address are written; and the corresponding location of the index node in the bitmap area corresponding to the one index node is The second usage identifier is changed to a value indicating that the one index node has been used; the file is stored in a data block corresponding to the storage address in the shared data block area; the data block bitmap is The first usage identifier of the
  • the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes Corresponding to one of the second usage identifiers, the electronic device further includes an input device,
  • the input device is configured to receive a request to delete a file in the first partition
  • the processor is further configured to: search, according to an attribute of the file, a corresponding index node in an index node area of the first partition: determining, in the shared data block, the storage according to a storage address recorded by the index node a data block corresponding to the address; changing the first usage identifier of the data block corresponding to the storage address in the bitmap area of the data block to a value indicating that the data block is not used; The second usage identifier of the corresponding index node in the index node bitmap area is changed to a value indicating that the corresponding index node is not used.
  • the ninth aspect of the present application provides an electronic device, including:
  • a processor configured to allocate a super block area for the file system on a first consecutive address segment of the memory, the super block area for recording system information of the file system; a type, a size of a file system; a bitmap area is allocated to the file system on a second consecutive address segment of the memory; and the file system is on a third consecutive address segment of the memory Allocating a shared area for storing a file and an index node; the index node is configured to record a storage address of a file stored in the shared area; and the bitmap area is configured to store a use identifier, Using an identifier for indicating whether a data block in the shared area is used, each of the data blocks corresponding to one of the usage identifiers; the first consecutive address segment, the second consecutive address segment, and the The third consecutive address segment constitutes a contiguous address segment.
  • the processor is further configured to: when the space is allocated to the index node in the shared area, the first from the shared area The address end is allocated to the second address end direction; when the shared area allocates space for the file, the second address end of the shared area is allocated to the first address end direction.
  • the electronic device further includes an input device
  • the input device is configured to receive a request for creating a file; the request includes a size of the file;
  • the processor is further configured to: determine, according to the usage identifier, an unused data block in the shared area; determine a size of a remaining capacity in the shared area according to the number and size of the unused data blocks. Determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file and storing an index node corresponding to the file; when the remaining capacity is sufficient to store the file and store the file And corresponding to the index node, creating the file on the unused data block and recording a storage address of the file in the corresponding index node; and the bitmap address and the storage address The usage identifier of the data block corresponding to the index node is changed to a value indicating that the data block has been used.
  • the processor is further configured to: update the storage in the shared area recorded in the super block area The size of the space occupied by all of the index nodes and the size of the space occupied by all of the files stored in the shared area.
  • the electronic device further includes an input device
  • the input device is configured to receive a request for querying a file, where the request includes an attribute of the file;
  • the processor is further configured to: query an index node corresponding to the attribute in the shared area; and search for a storage address corresponding to the storage address in the shared area according to a storage address recorded in the corresponding index node. file.
  • the data block area of each partition is shared, and then all the partitions also share the same data block bitmap.
  • the data block bitmap shows that the data block area has enough remaining capacity
  • the data cannot be stored in the data block area.
  • the file system management method of the embodiment of the present application enables the storage space to be fully utilized, thereby reducing the wasted space.
  • 1a-1b are schematic diagrams showing a layout of a file system in a prior art on a storage device
  • FIG. 2 is a flowchart of a method for managing a file system according to an embodiment of the present application
  • 3a-3b are schematic diagrams of layouts of multiple file systems provided on a storage device according to an embodiment of the present application
  • FIG. 4 is a flowchart of a method for creating a file in a file system according to an embodiment of the present application
  • FIG. 5 is a flowchart of a method for deleting a file in a file system according to an embodiment of the present disclosure
  • FIG. 6 is a flowchart of another method for managing a file system according to an embodiment of the present application.
  • FIGS. 7a-7b are schematic diagrams of layout of another file system on a storage device according to an embodiment of the present application.
  • FIG. 8 is a flowchart of still another method for managing a file system according to an embodiment of the present application.
  • FIG. 9 is a schematic diagram of a layout of another system on a storage device according to an embodiment of the present disclosure.
  • FIG. 10 is a flowchart of another method for creating a file in a file system according to an embodiment of the present disclosure.
  • FIG. 11 is a flowchart of a method for searching for a file in a file system according to an embodiment of the present application
  • FIG. 12 is a functional block diagram of a file system management apparatus according to an embodiment of the present application.
  • FIG. 13 is a structural diagram of an electronic device according to an embodiment of the present application.
  • FIG. 14 is a functional block diagram of another file system management apparatus according to an embodiment of the present application.
  • FIG. 15 is a structural diagram of another electronic device according to an embodiment of the present disclosure.
  • FIG. 16 is a functional block diagram of still another file system management apparatus according to an embodiment of the present application.
  • FIG. 17 is a structural diagram of still another electronic device according to an embodiment of the present application.
  • the embodiment of the present invention provides a file system management method and device, which are used to solve the technical problem of low storage space utilization in the prior art.
  • FIG. 2 is a flowchart of a method for managing a file system according to an embodiment of the present application.
  • the method includes:
  • Step 101 Allocating a data block bitmap area to the file system on a first consecutive address segment of the storage device;
  • Step 102 Allocate N partitions to the file system on a second consecutive address segment of the storage device. Each partition of the N partitions is used to store system metadata of each partition respectively; N is greater than 1 Integer
  • Step 103 Allocate a shared data block area of N partitions for the file system on a third consecutive address segment of the storage device, where the shared data block area is used for storing files.
  • the data block bitmap area is used to store the first usage identifier, and the first usage identifier is used to indicate whether the data block in the shared data block area is used, and each data block corresponds to a first usage identifier.
  • the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a continuous address segment.
  • the data block bitmap area is defined by the data structure of the bitmap, and each bit represents the use of a data block. That is, the size of a first use identifier is one bit.
  • the first usage identifier is, for example, 0 and 1, with 0 indicating that the data block is not used. Use 1 to indicate that the data block has been used.
  • the first usage identifier may be other data as long as it can indicate whether a certain data block is used.
  • N partitions are allocated to the system on the storage device.
  • the number of Ns may be determined according to the purpose, that is, the role of each partition is different.
  • the type of file corresponding to each partition is different.
  • partitioning can be performed according to the partitioning method in the prior art, that is, the file system in the prior art has several partitions, and several partitions are allocated in step 102.
  • the size of each partition may be the same or different. Since the type and number of metadata stored in each partition are different, the size of N partitions can be specifically allocated according to the type and number of stored metadata.
  • step 101 the order between step 101, step 102, and step 103 may be arbitrarily changed, or three steps may be performed simultaneously.
  • the storage device in this embodiment and the following embodiments may be a physical storage space of a single hard disk or a USB disk, or may be a partial storage space on a hard disk or a USB disk.
  • the storage device in the embodiment of the present application may be the entire 500G storage space or 200G storage space.
  • the storage device when a user triggers an operation of formatting a storage device, the storage device is installed.
  • the electronic device can perform steps 101 to 103.
  • consecutive address segments in the embodiment of the present application indicate that the logical addresses are consecutive. Therefore, in steps 101 to 103, the respective areas are allocated in accordance with consecutive logical addresses.
  • a case where the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a continuous address segment is, for example, a logical tail address of the data block bitmap area and a first of the N partitions
  • the logical first address of the partitions is contiguous, and the logical tail address of the last partition of the N partitions and the logical first address of the shared data block area are consecutive.
  • step 102 specifically includes allocating N partitions to the file system on a second consecutive address segment starting from a next address of a logical tail address of the data block bitmap region.
  • Step 103 specifically includes allocating N partition shared data block regions to the file system on a third consecutive address segment starting from a next address of a logical tail address of a last partition of the N partitions.
  • the allocation may be performed in a direction from a low address end to a high address end, or may be allocated in a direction from a high address end to a low address end.
  • the address of the second consecutive address segment is higher than the first consecutive address segment
  • the address of the third consecutive address segment is higher than the second consecutive address segment.
  • FIG. 3a is a schematic diagram of a layout structure after the file system is laid out on the storage device according to the file system management method shown in FIG. 2.
  • the data block bitmap area is at the low address end.
  • N partitions are immediately followed by a data block bitmap area layout, and N partitions are located on the high and low side of the data block bitmap area.
  • the shared data block area is then followed by the last partition layout of the N partitions.
  • the address between the first address of the data block bitmap area and the tail address of the shared data block area is continuous.
  • each area when storing data to each area, it may be stored in a direction from a low address end to a high address end.
  • FIG. 3b is a schematic diagram of a layout structure after the file system is laid out on the storage device according to the file system management method shown in FIG. 2.
  • the second example is different from the first example in that the shared data block area is allocated in the data block bitmap area and N blocks. Between partitions.
  • the file system management method of the embodiment of the present application extracts the data blocks of the N partitions to form a continuous storage space, and the data block bitmap area of each area is also separated from the prior art. Going out to form a continuous bitmap area for storing a first usage identifier indicating whether the data block of the shared data block area is used. Therefore, in the embodiment of the present application, as long as the data block bitmap shows that the data block area has sufficient remaining capacity, the data can be stored in the data block area. In the prior art, when data needs to be stored in a certain partition, if the data block bitmap of a certain partition shows that the data block area does not have enough remaining capacity, the data cannot be stored.
  • the adjacent partition of a partition has space, but due to the limitation of the layout, data cannot be stored in the data block area of the adjacent partition. Therefore, compared with the prior art, the file system management method of the embodiment of the present application enables the storage space to be fully utilized, thereby reducing the wasted space. At the same time, the file system management method in the embodiment of the present application avoids the problem that each partition design is larger than the required size, thereby compressing the user storage space, thereby avoiding waste of the storage space.
  • the file system management method in the embodiment of the present application only needs to know how much space the entire file system requires, and does not need to know the size of each specific partition, thereby improving the research and development efficiency of the designer.
  • the method described in FIG. 2 and its embodiment is applied in the user storage space, it is also possible to realize the technical effect that the file can be stored in any one partition as long as there is sufficient storage space in the shared data block area.
  • the storage operation can be responded, thereby storing the movie data in the D-disc.
  • the method in the embodiment of the present application is more convenient for the user to use than the prior art.
  • each partition of the N partitions includes a super block area, an index node bitmap area, and an index node area.
  • the super block area is used to record system information of the file system of each partition, such as the type and size of the file system. Further, the super block area is also used to record the remaining area of the shared data block area. Remaining capacity.
  • the index node of the inode area is used to record the storage address of the file stored in the shared block area. Further, the inode also records the properties of the file. Attributes include information that uniquely identifies a file, such as the name of a file. The file can be found in the shared data block area by the index node. An index node corresponds to the storage address of a file. Further, the attribute also includes information such as the size of the file.
  • the index node bitmap area is used to store the second usage identifier, and the second usage identifier is used to indicate whether the index node is used. Each index node corresponds to a second usage identifier.
  • the index node bitmap area can also be defined by the data structure of the bitmap. Each bit represents the use of an index node or not.
  • the index node bitmap and the index node area are also Large points can be allocated appropriately.
  • partition 1 has 10000 data blocks, and 2500 index node spaces may be allocated. It is now possible to allocate 5000 index node spaces to partition 1 because each index node and index node The bitmap space is small and the space used is negligible. This ensures that the index node of each partition is sufficient when there are free data blocks, so that as long as the free data block is large enough to store the file, the file can be stored in any partition.
  • the number of inodes is specifically related to the type of data stored in the partition. For example, if the partition is primarily used to store big data, the number of index nodes can be less. If the partition is mainly used to store small data, but the amount of data is large, the number of index nodes can be a little more.
  • a request to add a file to the partition i is received, the request including the size of the file.
  • the unused data blocks in the shared data block area are then determined by the first usage identification. For example: 0 means that the data block is not used, and 1 means that the data block has been used. Then all the data blocks corresponding to 0 are unused data blocks.
  • the size of the remaining capacity in the shared data block area is then determined based on the number and size of unused data blocks. Because the size of each data block is known, so according to The amount and size of the data blocks used can be used to calculate the size of the remaining capacity. This part of the content is well known to those skilled in the art, so it will not be described here.
  • the remaining capacity size in the shared data block area After determining the remaining capacity size in the shared data block area, it is determined whether the remaining capacity is sufficient to create the file according to the size of the file and the size of the remaining capacity. For example, the remaining capacity is 10MB. If the size of the newly added file is 8MB, the result of the determination is that the remaining capacity is sufficient. If the size of the newly added file is 15MB, then the result of the determination is that the remaining capacity is not enough.
  • the user interface can be used to prompt the user for insufficient disk space.
  • determining that the file is to be stored in a storage address in the shared data block area specifically, determining a data block to be stored in an unused data block, and then the address of the data block is The storage address where the file will be stored. This part of the content is well known to those skilled in the art, so it will not be described here.
  • the number of inodes is set to be sufficient.
  • the index node area can be allocated slightly larger, which ensures that when there is enough remaining capacity in the shared data block area to create a file, the inode area has An inode that is not being used.
  • the UI can also prompt the user that the index node of partition 1 has been allocated.
  • the file When an unused index node is found, the file is assigned an index node, and the attributes of the file and the storage address are populated in the index node.
  • the second usage identifier corresponding to the one index node is then changed in the index node bitmap area to a value indicating that the one index node has been used.
  • the file is written to a data block in the shared data block area corresponding to the storage address.
  • the first usage identification of the data block corresponding to the storage address is then changed in the data block bitmap area to a value indicating that the data block has been used. For example, in the data block bitmap area, the first use identifier of the occupied data block is set to 1, indicating that the data block has been used.
  • the shared data block is a resource pool, and the data can be performed by querying the data block bitmap to find that there is sufficient remaining capacity in the shared data block area. storage.
  • the file system management method in the embodiment of the present application can save storage space.
  • a request to delete a file in partition j is received. Specifically, for example, the user selects a file on the partition j, such as the D disk, and then right clicks, and selects the “delete” option in the right-click menu, then the electronic device receives the request to delete the file.
  • the corresponding index node is searched in the index node area of the partition j according to the attributes of the file.
  • the metadata includes the storage address of the file.
  • the metadata may further include an attribute of the file, the attribute including an attribute value that can uniquely identify a file, such as a name of the file.
  • the attribute may also include the size of the file, and the like. Therefore, the attributes in the metadata can be matched with the metadata recorded by each index node in the inode area. When the matching is successful, the index node that successfully matches is the index node corresponding to the file.
  • the index node corresponding to the file After finding the index node corresponding to the file, determining a data block corresponding to the storage address in the shared data block according to the storage address recorded by the index node.
  • the first usage identification of the data block corresponding to the storage address is then changed in the data block bitmap area to a value indicating that the data block is not used. This step means that the data blocks occupied by the deleted files are recycled. In actual use, the files in the data block may be erased after determining the data blocks occupied by the file.
  • the erasing operation may not be performed because the first usage identifier corresponding to the data block has been changed to a value indicating that the data block is not used in the data block bitmap, so if there is a file created later
  • the state of the data block is unused, that is, new data can be stored. Therefore, if new data is stored on the data block, it is only necessary to overwrite the original data in the data block.
  • the second usage identifier of the corresponding index node is changed to a value indicating that the corresponding index node is not used, and the index node corresponding to the file is recovered.
  • the attributes of the file and the storage address in the corresponding index node may also be deleted, or may not be deleted, but the attributes of the file and the storage address may be directly overwritten at the next storage.
  • the embodiment of the present application further provides a file system, where the file system includes: a data block bitmap area, N partitions, and a shared data block area.
  • the file system includes: a data block bitmap area, N partitions, and a shared data block area.
  • FIG. 6 is a flowchart of another method for managing a file system according to an embodiment of the present application. As shown in FIG. 6, the method includes:
  • Step 201 Allocating a data block bitmap area to the file system on a first consecutive address segment of the storage device;
  • Step 202 Allocating a first partition to the file system on a second consecutive address segment of the storage device, where the first partition is used to store system metadata of the first partition;
  • Step 203 Allocating a second partition to the file system on a third consecutive address segment of the storage device, where the second partition is configured to store system metadata of the second partition.
  • Step 204 Allocating a shared data block area of the first partition and the second partition to the file system on a fourth consecutive address segment of the storage device; wherein, the shared data block area is used for storing a file; and the data block bitmap area is And configured to store a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block region is used, and each data block corresponds to a first usage identifier.
  • the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a contiguous address segment.
  • the fourth consecutive address segment is located between the second consecutive address segment and the third consecutive address segment.
  • the file system is laid out according to the file system management method shown in FIG. After the layout diagram.
  • the data block bitmap area is located at the lower address end, and the partition 1 is immediately followed by the data block bitmap area and is located at the high address side of the data block bitmap area.
  • the shared data block area is next to the partition 1 and is located on the high address side of the partition 1.
  • the partition 2 is next to the shared data block area and is located on the high address side of the shared data block area.
  • the positional relationship between the zones can be other situations, for example, the reverse of the sequence of FIG. 7a, the data block bitmap area is located at the high address end, and the partition 2 is located at the low address end.
  • the first partition and the second partition also include a super block area, an index node area, and an index node bitmap area.
  • the meanings of the super block area, the inode area, and the index node bitmap area are similar to those described above, and therefore will not be described herein.
  • the order and location of the super block area, the index node bitmap area, and the index node area included in the partition located at the lower address end of the shared data block area may be reversed.
  • the partition 1 and the partition 2 are respectively located at the lower address end and the upper address end of the shared data block area.
  • the order of the three sub-partitions of the partition 1 in the direction from the low address end to the high address end is the super block area, the index node bitmap area, and the index node area.
  • the three sub-partitions of partition 2 are in the direction from the low address end to the high address end, and are respectively in the order of the index node area, the index node bitmap area, and the super block area. Therefore, the file system of partition 2 is "reverse growth".
  • the process of creating a file in the first partition or the second partition is the same as the process of creating a file described above, that is, the foregoing partition i may be replaced with the first partition or the second partition.
  • the process of deleting a file in the first partition or the second partition is the same as the process of deleting the file described above, that is, the aforementioned partition j may be replaced with the first partition or the second partition.
  • the aforementioned partition j may be replaced with the first partition or the second partition.
  • the embodiment of the present application provides a file system, where the file system includes: a data block bitmap area, a first partition, a shared data block area, and a second partition.
  • the meaning and layout of each zone are the same as those described in the foregoing method and its embodiment shown in FIG. So I won't go into details here.
  • FIG. 8 is a flowchart of still another method for managing a file system according to an embodiment of the present application. As shown in Figure 8, the method includes:
  • Step 301 Allocating a super block area to the file system on a first consecutive address segment of the storage device, where the super block area is used to record system information of the file system; the system information includes a type and a size of the file system;
  • Step 302 Allocating a bitmap area to the file system on a second consecutive address segment of the storage device
  • Step 303 Allocate a shared area to the file system on a third consecutive address segment of the storage device, where the shared area is used to store files and index nodes.
  • the index node is used to record the storage address of the file stored in the shared area.
  • the bitmap area is used to store the usage identifier, and the usage identifier is used to indicate whether the data block in the shared area is used. Each data block corresponds to a usage identifier.
  • the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
  • the super block area is also used to record the size of the space occupied by all the index nodes in the shared area and the space occupied by all the files in the shared area. Further, the super block area is also used to record the total size of the shared area. The size of the remaining space in the shared area can be obtained according to the total size of the shared area, the size of the space occupied by all the index nodes, and the size of the space occupied by all the files. The information described above recorded in the super block area facilitates subsequent management of the partition corresponding to the super block area.
  • the index node of the inode area is also used to record the attributes of the file stored in the data block area.
  • Properties include information that uniquely identifies a file, such as a file name.
  • the attribute also includes information such as file size.
  • the storage address is, for example, information indicating an address such as an address pointer, an address itself, or an address offset.
  • the index node area often has a lot of space to use, thus causing waste of storage space.
  • the remaining area of the index node is also used as the storage space of the storage file, so the storage is reduced. The waste of storage space increases the utilization of storage space.
  • FIG. 9 is a schematic diagram of the layout of the file system on the storage device after the file system is laid out according to the method shown in FIG. 8 .
  • the storage space is conveniently utilized, so the method further includes: when the index node is allocated space for the index node, the first address end of the shared area is allocated to the second address end; when in the shared area When space is allocated for a file, allocation is made from the second address end of the shared area to the first address end.
  • the first address end is, for example, a low address end
  • the second address end is, for example, a high address end.
  • the embodiment of the present application provides a file system, where the file system includes: a super block area, a bitmap area, and a shared area.
  • the meaning and layout of each area are the same as those described in the foregoing method shown in FIG. 8 and its embodiments, and therefore are not described herein again.
  • FIG. 10 is a flowchart of a method for creating a file in a file system according to an embodiment of the present application.
  • the layout of the file system on the storage device is performed, for example, in accordance with the layout shown in FIG.
  • the method includes:
  • Step 401 Receive a request for creating a file, where the request includes a size of the file.
  • Step 402 Determine, according to the usage identifier in the bitmap area, an unused data block in the shared area.
  • Step 403 Determine the size of the remaining capacity in the shared area according to the number and size of the unused data blocks.
  • Step 404 Determine, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file and store an index node corresponding to the file.
  • Step 405 When the remaining capacity is sufficient to store the file and store the index node corresponding to the file, create the file on the unused data block and record the storage address of the file in the corresponding index node;
  • Step 406 Change the usage identifier of the data block corresponding to the storage address and the index node in the bitmap area to a value indicating that the data block has been used.
  • the storage address is, for example, an address pointer, and may of course be the address itself or an address.
  • a bias or the like is used to indicate information of an address.
  • the storage area when the storage area is allocated to the index node in the shared area, it is allocated from the low address end to the high address end.
  • the storage space When creating a file, the storage space is allocated from the high address side to the low address side.
  • the space occupied by the index node and the space occupied by the file is a complete continuous storage space, which is convenient for storing various sizes of data, and avoids the need to randomly allocate space, and the shared area has several discontinuities.
  • the storage space, such that the size of the file that can be stored is easily limited, so the method in this embodiment can further improve the utilization of the storage space.
  • the method further includes: updating a space size value occupied by all index nodes stored in the shared area recorded in the super block area and a space size value occupied by all files stored in the shared area. Since the space occupied by the index node in the shared area and the space occupied by the file have changed through steps 401 to 406, the update is performed after step 406. This allows the superblock to keep track of the latest situation and facilitate subsequent management of the entire partition.
  • FIG. 11 is a flowchart of a method for searching for a file in a file system according to an embodiment of the present application.
  • the method includes:
  • Step 501 Receive a request for querying a file, where the request includes an attribute of the file;
  • Step 502 Query an index node corresponding to the attribute in the shared area.
  • Step 503 Search for a file corresponding to the storage address in the shared area according to the storage address recorded in the corresponding index node.
  • the request for receiving the query file may be a request triggered by the query operation itself, or may be a request triggered by another operation request, for example, deleting the file, and The process of triggering a file search first.
  • the file may be subjected to a desired operation, such as deletion.
  • the method further includes: modifying the usage identifier corresponding to the storage address and the index node in the bitmap area to a value indicating that the storage address and the data block corresponding to the index node have been used.
  • FIG. 12 is a functional block diagram of a file system management apparatus according to an embodiment of the present application, which is used to implement the file system management method shown in FIG. 2 to FIG. 5 of the present invention.
  • a file system management apparatus according to an embodiment of the present application, which is used to implement the file system management method shown in FIG. 2 to FIG. 5 of the present invention.
  • the file system management device includes: a data block bitmap allocation module 601, configured to allocate a data block bitmap area for the file system on a first consecutive address segment of the storage device; the metadata partition allocation module 602 ⁇ / RTI> for allocating N partitions to the file system on a second consecutive address segment of the storage device, each partition of the N partitions respectively for storing system metadata of each partition; N is greater than An integer of 1; a data block allocating module 603, configured to allocate, for the file system, a shared data block area of the N partitions on a third consecutive address segment of the storage device, where the shared data block area is used to store a file;
  • the data block bitmap area is configured to store a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first An identifier is used; wherein the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
  • each partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record a storage address of a file stored in the shared data block area; the index node bitmap The device is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second usage identifiers;
  • a receiving module configured to receive a request for creating a file in an i-th partition of the N partitions; the request includes a size of the file;
  • a processing module configured to determine, by using the first usage identifier, that the shared data block area is not enabled a data block; determining a size of the remaining capacity in the shared data block area according to the number and size of the unused data blocks; determining the remaining according to the size of the file and the size of the remaining capacity Whether the capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determine a storage address to be stored in the shared data block area, and an index node bit in the i-th partition The map area is searched for whether there is an unused index node; when there is an unused index node, one of the unused index nodes is selected, and the attribute of the file and the storage address are written; Changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been used; storing the file in the shared data block area a data block corresponding to the storage address; changing the first usage identifier of the data block corresponding to the
  • each partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The device area is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second usage identifiers, and the device further includes:
  • a receiving module configured to receive a request for deleting a file in the partition j in the N partitions
  • a processing module configured to search, according to an attribute of the file, a corresponding index node in an index node area of the partition j: determining, according to a storage address recorded by the index node, data corresponding to the storage address in the shared data block Blocking; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; and using an index node bitmap of the partition j The second usage identifier of the corresponding index node in the zone is changed to a value indicating that the corresponding index node is not used.
  • the electronic device includes a processor 701, a transmitter 702, a receiver 703, a memory 704, and an input device 705.
  • the processor 701 may be a general-purpose central processing unit (CPU), may be an application specific integrated circuit (ASIC), and may be one or more integrated circuits for controlling program execution.
  • the number of memories 704 can be one or more.
  • the memory 704 is, for example, a hard disk or a USB disk.
  • the memories 704, receiver 703 and transmitter 702 are connected to the processor 701 via a bus.
  • the receiver 703 and the transmitter 702 are configured to perform network communication with an external device, and specifically communicate with an external device through a network such as an Ethernet, a wireless access network, or a wireless local area network.
  • Receiver 703 and transmitter 702 may be physically separate components or may be physically identical components.
  • the input device 705 can be, for example, a keyboard, a mouse, or a touch pad.
  • the processor 701 is configured to allocate a data block bitmap area to the file system on a first consecutive address segment of the memory 704; and to the file system on a second consecutive address segment of the memory 704.
  • N partitions are allocated, each of the N partitions being used to store system metadata for each partition; N is an integer greater than 1; the file is on a third consecutive address segment of memory 704
  • the system allocates a shared data block area of the N partitions, the shared data block area is used to store a file; the data block bitmap area is used to store a first use identifier, and the first use identifier is used to indicate the Whether the data blocks in the shared data block area are used, each of the data blocks corresponding to one of the first use identifiers; wherein the first consecutive address segment, the second consecutive address segment, and the first Three consecutive address segments form a contiguous address segment.
  • each partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record a storage address of a file stored in the shared data block area; the index node bitmap The area is used to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second usage identifiers.
  • the input device 705 is configured to receive a request for creating a file in an i-th partition of the N partitions; the request Included in the size of the file; the processor 701 is further configured to: determine, by using the first usage identifier, an unused data block in the shared data block area; according to the number and size of the unused data blocks Determining a size of the remaining capacity in the shared data block area; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file Determining whether the file is to be stored in a storage address in the shared data block area, and searching for an unused index node in an index node bitmap area of the i-th partition; when there is an unused When the node is indexed, one of the unused index nodes is selected, the attribute of the file and the storage address are written; and the corresponding location of the index node in the bitmap area corresponding to the one index node is Changing the second usage
  • each partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit
  • the map area is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second usage identifiers.
  • the input device 705 is configured to receive a request for deleting a file by the partition j in the N partitions.
  • the processor 701 is further configured to: search, according to an attribute of the file, a corresponding index node in an index node area of the partition j: determining, according to a storage address recorded by the index node, that the shared data block corresponds to the storage address Data block; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; and indexing the partition j The second usage identifier of the corresponding index node in the bitmap area is changed to a value indicating that the corresponding index node is not used.
  • FIG. 14 a functional block diagram of another file system management apparatus provided by an embodiment of the present application is used to implement the file system management method shown in FIG. 6 to FIG. 7 b of the present invention.
  • FIG. 14 a functional block diagram of another file system management apparatus provided by an embodiment of the present application is used to implement the file system management method shown in FIG. 6 to FIG. 7 b of the present invention.
  • the management device includes: a data block bitmap allocation module 801, configured to allocate a data block bitmap area for the file system on a first consecutive address segment of the storage device; and a metadata partition allocation module 802 for Assigning, to the file system, a first partition on a second consecutive address segment of the storage device, the first partition for storing system metadata of the first partition; and a third consecutive address of the storage device Assigning a second partition to the file system, the second partition is configured to store system metadata of the second partition, and the data block allocating module 803 is configured to be in a fourth consecutive address segment of the storage device.
  • a data block bitmap allocation module 801 configured to allocate a data block bitmap area for the file system on a first consecutive address segment of the storage device
  • a metadata partition allocation module 802 for Assigning, to the file system, a first partition on a second consecutive address segment of the storage device, the first partition for storing system metadata of the first partition
  • a third consecutive address of the storage device Assigning a second partition to
  • the shared data block area of the first partition and the second partition allocating, for the file system, the shared data block area of the first partition and the second partition; wherein the shared data block area is used for storing a file; and the data block bitmap area is used for storing the first
  • the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first usage identifiers; the first consecutive address segment, The second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a contiguous address segment, and the fourth consecutive address segment is located at the second consecutive address segment and Between the third consecutive address segments.
  • the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The mapping area is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second usage identifiers;
  • a receiving module configured to receive a request for creating a file in the first partition; the request includes a size of the file;
  • a processing module configured to determine, by using the first usage identifier, an unused data block in the shared data block region; determining a remaining portion in the shared data block region according to the number and size of the unused data blocks a size of the capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file Determining whether the file is to be stored in a storage address in the shared data block area, and searching for an unused index node in an index node bitmap area of the first partition; when there is an unused index a node, selecting one of the unused index nodes, writing an attribute of the file and the storage address; and referring to the index node in the index node corresponding to the one index node
  • the second usage identifier is changed to a value indicating that the one index node has been used; the file is stored in a data block corresponding to the storage address in the shared data block area; and the data block bitmap is The first
  • the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The map area is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second usage identifiers.
  • the device also includes:
  • a receiving module configured to receive a request to delete a file in the first partition
  • a processing module configured to search, according to an attribute of the file, a corresponding index node in an index node area of the first partition: determining, according to a storage address recorded by the index node, a corresponding to the storage address in the shared data block a data block; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; and indexing the first partition The second usage identifier of the corresponding index node in the bitmap area is changed to a value indicating that the corresponding index node is not used.
  • the electronic device The processor 901, the transmitter 902, the receiver 903, the memory 904, and the input device 905 are included.
  • the processor 901 may be a general-purpose central processing unit (CPU), may be an application specific integrated circuit (ASIC), and may be one or more integrated circuits for controlling program execution.
  • the number of memories 904 can be one or more.
  • the memory 904 is, for example, a hard disk as a USB flash drive.
  • the memories 904, receiver 903 and transmitter 902 are connected to the processor 901 via a bus.
  • the receiver 903 and the transmitter 902 are configured to perform network communication with an external device, and specifically communicate with an external device through a network such as an Ethernet, a wireless access network, or a wireless local area network.
  • the receiver 903 and the transmitter 902 may be physically separate components or may be physically the same component.
  • the input device 905 is, for example, a mouse, a keyboard, or a touch panel.
  • the processor 901 is configured to allocate a data block bitmap area to the file system on a first consecutive address segment of the memory 904; and to the file system on a second consecutive address segment of the memory 904. Allocating a first partition for storing system metadata of the first partition; assigning a second partition to the file system on a third consecutive address segment of the memory 904, the second partition And storing the system metadata of the second partition; and sharing, on the fourth consecutive address segment of the memory 904, the shared data block area of the first partition and the second partition for the file system;
  • the shared data block area is configured to store a file;
  • the data block bitmap area is configured to store a first use identifier, and the first use identifier is used to indicate whether a data block in the shared data block area is used, and each The data block corresponds to one of the first usage identifiers; the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a continuous the address of Between the fourth consecutive addresses in the second consecutive addresses and the
  • the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The map area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second usage identifiers.
  • the input device 905 is configured to receive a request for creating a file in the first partition, where the request includes a size of the file, and the processor 901 is further configured to: determine, by using the first usage identifier, the shared number Determining an unused data block in the block area; determining a size of the remaining capacity in the shared data block area according to the number and size of the unused data blocks; according to the size of the file and the remaining capacity a size, determining whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be stored in a storage address in the shared data block area, and at the first
  • the indexed index node of the partition finds whether there is an unused index node; when there is an unused index node, selects one of the unused index nodes, writes the attributes of the file and The storage address; changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been
  • the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The map area is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second usage identifiers.
  • the input device 905 is configured to receive a request for deleting a file in the first partition; the processor 901 is further configured to: search, according to an attribute of the file, a corresponding index node in an index node area of the first partition: record according to the index node
  • the storage address determines a data block corresponding to the storage address in the shared data block; changing the first use identifier of the data block corresponding to the storage address in the data block bitmap area to indicate the a value that the data block is not used; changing the second usage identifier of the corresponding index node in the index node bitmap area of the first partition to a value indicating that the corresponding index node is not used.
  • FIG. 16 a file system provided by an embodiment of the present application is provided.
  • the functional block diagram of the management device is used to implement the file system management method shown in FIG. 8 to FIG. 11 of the present invention.
  • the meanings of the terms involved in this embodiment refer to the content described in the foregoing embodiments.
  • the management device includes: a super block allocation module 1001, configured to allocate a super block area for the file system on a first consecutive address segment of the storage device, where the super block area is used to record system information of the file system;
  • the system information includes a type and a size of the file system;
  • the bitmap allocation module 1002 is configured to allocate a bitmap area to the file system on a second consecutive address segment of the storage device;
  • the shared area allocation module 1003 And a shared area for the file system on a third consecutive address segment of the storage device, where the shared area is used for storing files and an index node; and the index node is used for recording and storing in the shared area.
  • the bitmap area is configured to store a usage identifier, where the usage identifier is used to indicate whether a data block in the shared area is used, and each of the data blocks corresponds to one of the usage identifiers;
  • the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
  • the device further includes: a processing module, configured to allocate from the first address end to the second address end of the shared area when the shared area allocates space for the index node; When the shared area allocates space for the file, the shared area is allocated from the second address end of the shared area to the first address end.
  • a processing module configured to allocate from the first address end to the second address end of the shared area when the shared area allocates space for the index node; When the shared area allocates space for the file, the shared area is allocated from the second address end of the shared area to the first address end.
  • the device further includes:
  • a receiving module configured to receive a request for creating a file; the request includes a size of the file;
  • a processing module configured to determine, according to the usage identifier, an unused data block in the shared area; determining a size of a remaining capacity in the shared area according to the number and size of the unused data blocks; Determining a size of the file and a size of the remaining capacity to determine whether the remaining capacity is sufficient to create the file and storing an index node corresponding to the file; when the remaining capacity is sufficient to store the file and store an index corresponding to the file a node, creating the file on the unused data block and recording a storage address of the file in the corresponding index node; storing the bitmap area with the storage address and the The usage identifier of the data block corresponding to the index node is changed to a value indicating that the data block has been used.
  • the processing module is further configured to: update a space size value occupied by all the index nodes stored in the shared area recorded in the super block, and a space occupied by all the files stored in the shared area Size value.
  • the device further includes:
  • a receiving module configured to receive a request for querying a file, where the request includes an attribute of the file
  • a processing module configured to query an index node corresponding to the attribute in the shared area; and search for a file corresponding to the storage address in the shared area according to the storage address recorded in the corresponding index node.
  • the electronic device includes a processor 1201, a transmitter 1202, a receiver 1203, a memory 1204, and an input device 1205.
  • the processor 1201 may be a general-purpose central processing unit (CPU), may be an application specific integrated circuit (ASIC), and may be one or more integrated circuits for controlling program execution.
  • the number of memories 1204 can be one or more.
  • the memory 1204 is, for example, a hard disk as a USB flash drive.
  • the memories 1204, receivers 1203, and transmitters 1202 are coupled to the processor 1201 via a bus.
  • the receiver 1203 and the transmitter 1202 are configured to perform network communication with an external device, and specifically communicate with an external device through a network such as an Ethernet, a wireless access network, or a wireless local area network.
  • Receiver 1203 and transmitter 1202 may be physically separate components or may be physically identical components.
  • the input device 1205 can be a mouse, a keyboard, or a touchpad.
  • the processor 1201 is configured to allocate a super block area to the file system on a first consecutive address segment of the memory 1204, where the super block area is used to record system information of the file system;
  • the system information includes a type and size of the file system;
  • a bitmap area is allocated to the file system on a second consecutive address segment of the memory 1204; and the file is on a third consecutive address segment of the memory 1204.
  • the system allocates a shared area for storing a file and an index node; the index node is configured to record a storage address of a file stored in the shared area; and the bitmap area is configured to store a usage identifier, Using an identifier for indicating whether a data block in the shared area is used, each of the data blocks corresponding to one of the usage identifiers; the first consecutive address segment, the second consecutive address segment, and the The third consecutive address segment constitutes a contiguous address segment.
  • the processor 1201 is further configured to: when the shared area allocates space for the index node, allocate from a first address end to a second address end of the shared area; when in the sharing When the area allocates space for the file, the area is allocated from the second address end of the shared area to the first address end.
  • the input device 1205 is configured to receive a request for creating a file, where the request includes a size of the file, and the processor 1201 is further configured to: determine, according to the usage identifier, that the shared area is not used. a data block; determining a size of the remaining capacity in the shared area according to the number and size of the unused data blocks; determining whether the remaining capacity is sufficient to create a location according to the size of the file and the size of the remaining capacity a file and an index node corresponding to the file; when the remaining capacity is sufficient to store the file and store an index node corresponding to the file, create the file on the unused data block and Recording a storage address of the file in the corresponding index node; changing a usage identifier of the data block corresponding to the storage address and the index node in the bitmap area to indicate that the data block has been used value.
  • the processor 1201 is further configured to: update a space size value occupied by all the index nodes stored in the shared area recorded in the super block area, and all the file occupations stored in the shared area. The size of the space.
  • the input device 1205 is configured to receive a request for querying a file, where the request includes an attribute of the file, and the processor 1201 is further configured to: query an index node corresponding to the attribute in the shared area; The storage address recorded in the corresponding index node searches for a file corresponding to the storage address in the shared area.
  • the data block area of each partition is shared, and then all the partitions also share the same data block bitmap.
  • the data block bitmap shows that the data block area has enough remaining capacity
  • the data cannot be stored in the data block area.
  • the file system management method of the embodiment of the present application enables the storage space to be fully utilized, thereby reducing the wasted space.

Landscapes

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

Abstract

A management method and device of a file system. The method comprises: allocating a data block bitmap area for a file system in a first consecutive address segment of a storage apparatus (101); allocating N partitions for the file system in a second consecutive address segment of the storage apparatus, wherein each of the N partitions is used to store system metadata of each of the partitions (102); and allocating a shared data block area of the N partitions for the file system in a third consecutive address segment of the storage apparatus, wherein the shared data block area is used to store a file (103). The data block bitmap area is used to store a first use identifier configured to indicate whether a data block of the shared data block area is used, and each of the data blocks corresponds to the first use identifier. The first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a consecutive address segment.

Description

一种文件系统的管理方法及装置File system management method and device 技术领域Technical field
本申请涉及电子技术领域,尤其涉及一种文件系统的管理方法及装置。The present application relates to the field of electronic technologies, and in particular, to a file system management method and apparatus.
背景技术Background technique
如图1a所示,为文件系统在存储设备的布局示意图。存储设备内的存储空间被划分为系统存储空间和用户存储空间。系统存储空间一般包含多个固定分区,例如图1a中的分区1、分区2至分区N。每个固定分区的大小在设备出厂时已经由设计人员设计好,设备出厂后能够被改变的可能性极小。As shown in FIG. 1a, it is a schematic diagram of a file system in a storage device. The storage space in the storage device is divided into system storage space and user storage space. The system storage space typically contains a plurality of fixed partitions, such as partition 1, partition 2 to partition N in Figure 1a. The size of each fixed partition has been designed by the designer at the time of shipment from the factory, and the possibility of being able to be changed after leaving the factory is minimal.
请同时参考图1a和图1b所示,图1b为图1a中分区1的进一步布局示意图。当对系统存储空间进行文件系统的格式化之后,分区1包括超级块区、数据块位图区、索引节点位图区、索引节点区以及数据块区。在格式化之后,不光分区1的大小是固定的,每个区的位置也是固定的。Please refer to FIG. 1a and FIG. 1b at the same time, and FIG. 1b is a schematic diagram of further layout of the partition 1 in FIG. 1a. After the file system is formatted for the system storage space, the partition 1 includes a super block area, a data block bitmap area, an inode bitmap area, an inode area, and a data block area. After formatting, not only the size of partition 1 is fixed, but the location of each zone is also fixed.
其中,超级块区用于记录分区1的文件系统的系统信息,例如文件系统的类型、大小。数据块位图区,是以位图的数据结构来定义的,每一个比特(bit)位代表一个数据块的使用与否。例如:比特位的值为0代表该比特位对应的数据块未被使用,比特位的值为1代表该比特位对应的数据块已被使用。索引节点位图区,也是以位图的数据结构来定义的,每一个bit位代表一个索引节点使用与否。索引节点区的每一个索引节点对应一个文件。索引节点记录了该文件的属性以及该文件在数据块中的存储地址。通过索引节点能够在数据块中找到该文件。数据块用来存放文件。The super block area is used to record the system information of the file system of the partition 1, such as the type and size of the file system. The data block bitmap area is defined by the data structure of the bitmap, and each bit represents the use of a data block. For example, a value of 0 indicates that the data block corresponding to the bit is not used, and a value of 1 indicates that the data block corresponding to the bit has been used. The index node bitmap area is also defined by the data structure of the bitmap, and each bit represents the use of an index node. Each index node of the inode area corresponds to a file. The index node records the attributes of the file and the storage address of the file in the data block. The file can be found in the data block by the index node. The data block is used to store files.
分区2至分区N的布局方式与分区1相同。 Partition 2 to partition N are laid out in the same way as partition 1.
通常,为了保证系统的可扩展性和产品的延续性,会为每个固定分区的分配大于分区所需空间的存储空间,所以就会导致存储空间的浪费。Generally, in order to ensure the scalability of the system and the continuity of the product, each fixed partition is allocated a storage space larger than the space required by the partition, so that the storage space is wasted.
另外,在实际运用中,经常会出现分区1已用完,但是分区2还有空闲空间、或者是分区1还有空闲空间而分区2已用完的问题。为了解决这类问题, 设计人员会在新的产品中不断的扩大分区1或分区2的大小,那么系统存储空间就会增大,所以用户存储空间就会被压缩,因此存在存储空间利用率低的问题。In addition, in actual use, it is often the case that partition 1 has been used up, but partition 2 has free space, or partition 1 has free space and partition 2 has run out. In order to solve such problems, Designers will continue to expand the size of partition 1 or partition 2 in the new product, then the system storage space will increase, so the user storage space will be compressed, so there is a problem of low storage space utilization.
发明内容Summary of the invention
本申请实施例提供一种文件系统的管理方法及装置,用以解决现有技术中的存储空间利用率低的技术问题。The embodiment of the present invention provides a file system management method and device, which are used to solve the technical problem of low storage space utilization in the prior art.
本申请第一方面提供了一种文件系统的管理方法,包括:The first aspect of the present application provides a file system management method, including:
在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;Allocating a data block bitmap area to the file system on a first consecutive address segment of the storage device;
在所述存储设备的第二连续的地址段上为所述文件系统分配N个分区,所述N个分区的每个分区分别用于存储所述每个分区的系统元数据;N为大于1的整数;Allocating N partitions to the file system on a second consecutive address segment of the storage device, each partition of the N partitions respectively for storing system metadata of each partition; N is greater than 1 Integer
在所述存储设备的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;其中,所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。Allocating a shared data block area of the N partitions for the file system on a third consecutive address segment of the storage device, the shared data block area is for storing a file; the data block bitmap area is used for Storing a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first usage identifiers; wherein the first The contiguous address segment, the second contiguous address segment, and the third contiguous address segment form a contiguous address segment.
结合第一方面,在第一方面的第一种可能的实现方式中,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块区中的文件的存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识;With reference to the first aspect, in a first possible implementation manner of the first aspect, each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing a storage address of a file in the shared data block area; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to One of the second usage identifiers;
在所述存储设备的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区之后,所述方法还包括:After the shared data block area of the N partitions is allocated to the file system on the third consecutive address segment of the storage device, the method further includes:
接收在所述N个分区中的第i个分区创建文件的请求;所述请求中包括 所述文件的大小;Receiving a request to create a file in an i-th partition of the N partitions; the request includes The size of the file;
通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;Determining, by the first usage identifier, an unused data block in the shared data block area;
根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;Determining a size of a remaining capacity in the shared data block area according to the number and size of the unused data blocks;
根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;Determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file;
当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第i个分区的索引节点位图区查找是否有未被使用的索引节点;Determining, when the remaining capacity is sufficient to create the file, a storage address to be stored in the shared data block area, and searching for an unused portion in an index node bitmap area of the i-th partition Index node;
当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;When there is an unused index node, selecting one of the unused index nodes, writing an attribute of the file and the storage address;
将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;Changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been used;
将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;Storing the file in a data block corresponding to the storage address in the shared data block area;
在所述数据块位图中将与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。The first usage identifier of the data block corresponding to the storage address is changed in the data block bitmap to a value indicating that the data block has been used.
结合第一方面,在第一方面的第二种可能的实现方式中,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,With reference to the first aspect, in a second possible implementation manner of the first aspect, each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes Corresponding to one of the second use identifiers,
在所述存储设备的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区之后,所述方法还包括:After the shared data block area of the N partitions is allocated to the file system on the third consecutive address segment of the storage device, the method further includes:
接收在所述N个分区中的分区j删除文件的请求;Receiving a request to delete a file by the partition j in the N partitions;
根据所述文件的属性在所述分区j的索引节点区查找对应的索引节点:Finding a corresponding index node in an index node area of the partition j according to an attribute of the file:
根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块; Determining, according to the storage address recorded by the index node, a data block corresponding to the storage address in the shared data block;
将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;Changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used;
将所述分区j的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。Changing the second usage identifier of the corresponding index node in the index node bitmap area of the partition j to a value indicating that the corresponding index node is not used.
本申请第二方面提供一种文件系统的管理方法,包括:The second aspect of the present application provides a file system management method, including:
在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;Allocating a data block bitmap area to the file system on a first consecutive address segment of the storage device;
在所述存储设备的第二连续的地址段上为所述文件系统分配第一分区,所述第一分区用于存储所述第一分区的系统元数据;Allocating, by the file system, a first partition on a second consecutive address segment of the storage device, where the first partition is configured to store system metadata of the first partition;
在所述存储设备的第三连续的地址段上为所述文件系统分配第二分区,所述第二分区用于存储所述第二分区的系统元数据;Allocating a second partition to the file system on a third consecutive address segment of the storage device, where the second partition is configured to store system metadata of the second partition;
在所述存储设备的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区;其中,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;所述第一连续的地址段、所述第二连续的地址段、所述第三连续的地址段和所述第四连续的地址段组成连续的地址段,所述第四连续的地址段位于所述第二连续的地址段和所述第三连续的地址段之间。Allocating a shared data block area of the first partition and the second partition to the file system on a fourth consecutive address segment of the storage device; wherein the shared data block area is used to store a file; The data block bitmap area is configured to store a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first Using an identifier; the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a contiguous address segment, the fourth consecutive The address segment is located between the second consecutive address segment and the third consecutive address segment.
结合第二方面,在第二方面的第一种可能的实现方式中,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识;With reference to the second aspect, in a first possible implementation manner of the second aspect, the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes Corresponding to one of the second use identifiers;
在所述存储设备的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区之后,所述方法还包括:After the allocating the shared data block area of the first partition and the second partition to the file system on the fourth consecutive address segment of the storage device, the method further includes:
接收在所述第一分区创建文件的请求;所述请求中包括所述文件的大小;Receiving a request to create a file in the first partition; the request includes a size of the file;
通过所述第一使用标识确定所述共用数据块区中未被使用的数据块; Determining, by the first usage identifier, an unused data block in the shared data block area;
根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;Determining a size of a remaining capacity in the shared data block area according to the number and size of the unused data blocks;
根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;Determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file;
当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第一分区的索引节点位图区查找是否有未被使用的索引节点;Determining, when the remaining capacity is sufficient to create the file, a storage address to be stored in the shared data block area, and searching for an unused portion in an index node bitmap area of the first partition Index node
当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;When there is an unused index node, selecting one of the unused index nodes, writing an attribute of the file and the storage address;
将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;Changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been used;
将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;Storing the file in a data block corresponding to the storage address in the shared data block area;
在所述数据块位图中将与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。The first usage identifier of the data block corresponding to the storage address is changed in the data block bitmap to a value indicating that the data block has been used.
结合第二方面,在第二方面的第二种可能的实现方式中,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,With reference to the second aspect, in a second possible implementation manner of the second aspect, the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes Corresponding to one of the second use identifiers,
在所述存储设备的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区之后,所述方法还包括:After the allocating the shared data block area of the first partition and the second partition to the file system on the fourth consecutive address segment of the storage device, the method further includes:
接收在所述第一分区删除文件的请求;Receiving a request to delete a file in the first partition;
根据所述文件的属性在所述第一分区的索引节点区查找对应的索引节点:Finding a corresponding index node in an index node area of the first partition according to an attribute of the file:
根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;Determining, according to the storage address recorded by the index node, a data block corresponding to the storage address in the shared data block;
将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标 识更改为表示所述数据块未被使用的值;The first use identifier of a data block corresponding to the storage address in the data block bitmap area Change to a value indicating that the data block is not used;
将所述第一分区的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。Changing the second usage identifier of the corresponding index node in the index node bitmap area of the first partition to a value indicating that the corresponding index node is not used.
本申请第三方面提供一种文件系统的管理方法,包括:The third aspect of the present application provides a file system management method, including:
在存储设备的第一连续的地址段上为所述文件系统分配超级块区,所述超级块区用于记录所述文件系统的系统信息;所述系统信息包括所述文件系统的类型、大小;Allocating a super block area to the file system on a first consecutive address segment of the storage device, where the super block area is used to record system information of the file system; the system information includes a type and size of the file system ;
在所述存储设备的第二连续的地址段上为所述文件系统分配位图区;Allocating a bitmap area to the file system on a second consecutive address segment of the storage device;
在所述存储设备的第三连续的地址段上为所述文件系统分配共享区,所述共享区用于存储文件与索引节点;所述索引节点用于记录存储在所述共享区中的文件的存储地址;所述位图区用于存储使用标识,所述使用标识用于表示所述共享区中的数据块是否被使用,每个所述数据块对应一个所述使用标识;所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。Allocating a shared area to the file system on a third consecutive address segment of the storage device, the shared area is configured to store a file and an index node; and the index node is configured to record a file stored in the shared area a storage address; the bitmap area is configured to store a usage identifier, where the usage identifier is used to indicate whether a data block in the shared area is used, and each of the data blocks corresponds to one of the usage identifiers; A contiguous address segment, the second contiguous address segment, and the third contiguous address segment form a contiguous address segment.
结合第三方面,在第三方面的第一种可能的实现方式中,所述方法还包括:In conjunction with the third aspect, in a first possible implementation manner of the third aspect, the method further includes:
当在所述共享区为所述索引节点分配空间时,从所述共享区的第一地址端向第二地址端方向进行分配;When the space is allocated to the index node in the shared area, the first address end of the shared area is allocated to the second address end;
当在所述共享区为所述文件分配空间时,从所述共享区的所述第二地址端向所述第一地址端方向进行分配。When the space is allocated to the file in the shared area, the second address end of the shared area is allocated to the first address end.
结合第三方面或第三方面的第一种可能的实现方式,在第三方面的第二种可能的实现方式中,在所述存储设备的第三连续的地址段上为所述文件系统分配共享区之后,所述方法还包括:With reference to the third aspect, or the first possible implementation manner of the third aspect, in a second possible implementation manner of the third aspect, the file system is allocated on a third consecutive address segment of the storage device After the shared area, the method further includes:
接收用于创建文件的请求;所述请求中包括所述文件的大小;Receiving a request for creating a file; the request includes a size of the file;
根据所述使用标识确定所述共享区中未被使用的数据块;Determining an unused data block in the shared area according to the usage identifier;
根据所述未被使用的数据块的数量及大小确定所述共享区中的剩余容量的大小; Determining a size of a remaining capacity in the shared area according to the number and size of the unused data blocks;
根据所述文件的大小和所述剩余容量的大小确定所述剩余容量是否足够创建所述文件以及存储所述文件对应的索引节点;Determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file and storing an index node corresponding to the file;
当所述剩余容量足够存储所述文件以及存储所述文件对应的索引节点时,在所述未被使用的数据块上创建所述文件并将所述文件的存储地址记录在所述对应的索引节点中;When the remaining capacity is sufficient to store the file and store an index node corresponding to the file, create the file on the unused data block and record a storage address of the file in the corresponding index In the node;
将所述位图区中与所述存储地址和所述索引节点对应的数据块的使用标识更改为表示所述数据块已被使用的值。Changing the usage identifier of the data block corresponding to the storage address and the index node in the bitmap area to a value indicating that the data block has been used.
结合第三方面或第三方面的第二种可能的实现方式,在第三方面的第三种可能的实现方式中,所述方法还包括:In conjunction with the third aspect or the second possible implementation manner of the third aspect, in a third possible implementation manner of the third aspect, the method further includes:
更新所述超级块区中记录的所述共享区中存储的所有所述索引节点占用的空间大小值以及所述共享区中存储的所有所述文件占用的空间大小值。And updating a space size value occupied by all the index nodes stored in the shared area recorded in the super block area and a space size value occupied by all the files stored in the shared area.
结合第三方面或第三方面的第一种可能的实现方式,在第三方面的第四种可能的实现方式中,所述索引节点还记录文件的属性,In conjunction with the third aspect, or the first possible implementation manner of the third aspect, in a fourth possible implementation manner of the third aspect, the index node further records an attribute of the file,
在所述存储设备的第三连续的地址段上为所述文件系统分配共享区之后,所述方法还包括:After the shared area is allocated to the file system on the third consecutive address segment of the storage device, the method further includes:
接收查询文件的请求,所述请求中包含所述文件的属性;Receiving a request for querying a file, the request including an attribute of the file;
在所述共享区中查询与所述属性对应的索引节点;Querying an index node corresponding to the attribute in the shared area;
根据所述对应的索引节点中记录的存储地址在所述共享区中查找与所述存储地址对应的文件。Searching for a file corresponding to the storage address in the shared area according to a storage address recorded in the corresponding index node.
本申请第四方面提供一种文件系统的管理方法,包括:A fourth aspect of the present application provides a file system management method, including:
数据块位图分配模块,用于在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;a data block bitmap allocation module, configured to allocate a data block bitmap area to the file system on a first consecutive address segment of the storage device;
元数据分区分配模块,用于在所述存储设备的第二连续的地址段上为所述文件系统分配N个分区,所述N个分区的每个分区分别用于存储所述每个分区的系统元数据;N为大于1的整数;a metadata partition allocation module, configured to allocate N partitions to the file system on a second consecutive address segment of the storage device, where each partition of the N partitions is used to store each partition System metadata; N is an integer greater than one;
数据块分配模块,用于在所述存储设备的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区,所述共用数据块区用于存储文件; 所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;其中,所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。a data block allocation module, configured to allocate a common data block area of the N partitions to the file system on a third consecutive address segment of the storage device, where the shared data block area is used to store a file; The data block bitmap area is configured to store a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first An identifier is used; wherein the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
结合第四方面,在第四方面的第一种可能的实现方式中,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块区中的文件的存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识;所述装置还包括:With reference to the fourth aspect, in a first possible implementation manner of the fourth aspect, each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing a storage address of a file in the shared data block area; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to a second use identifier; the device further comprises:
接收模块,用于接收在所述N个分区中的第i个分区创建文件的请求;所述请求中包括所述文件的大小;a receiving module, configured to receive a request for creating a file in an i-th partition of the N partitions; the request includes a size of the file;
处理模块,用于通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第i个分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;将所述数据块位图中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。a processing module, configured to determine, by using the first usage identifier, an unused data block in the shared data block region; determining a remaining portion in the shared data block region according to the number and size of the unused data blocks a size of the capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be stored in the Determining a storage address in the shared data block area, and searching whether there is an unused index node in the index node bitmap area of the i-th partition; when there is an unused index node, selecting the unused An index node in the index node, writing an attribute of the file and the storage address; changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to indicate the a value that has been used by an index node; storing the file in a data block corresponding to the storage address in the shared data block area; The first usage identifier of the data block corresponding to the storage address is changed to a value indicating that the data block has been used.
结合第四方面,在第四方面的第二种可能的实现方式中,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使 用,每个所述索引节点对应一个所述第二使用标识,所述装置还包括:With reference to the fourth aspect, in a second possible implementation manner of the fourth aspect, each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is enabled Each of the index nodes corresponds to one of the second usage identifiers, and the device further includes:
接收模块,用于接收在所述N个分区中的分区j删除文件的请求;a receiving module, configured to receive a request for deleting a file in the partition j in the N partitions;
处理模块,用于根据所述文件的属性在所述分区j的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;在所述数据块位图区中将与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;在所述分区j的索引节点位图区中将所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。a processing module, configured to search, according to an attribute of the file, a corresponding index node in an index node area of the partition j: determining, according to a storage address recorded by the index node, data corresponding to the storage address in the shared data block a block; changing, in the data block bitmap area, the first usage identifier of a data block corresponding to the storage address to a value indicating that the data block is not used; and an index node bit of the partition j The second usage identifier of the corresponding index node is changed in the map area to a value indicating that the corresponding index node is not used.
本申请第五方面提供一种文件系统的管理装置,包括:The fifth aspect of the present application provides a file system management apparatus, including:
数据块位图分配模块,用于在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;a data block bitmap allocation module, configured to allocate a data block bitmap area to the file system on a first consecutive address segment of the storage device;
元数据分区分配模块,用于在所述存储设备的第二连续的地址段上为所述文件系统分配第一分区,所述第一分区用于存储所述第一分区的系统元数据;在所述存储设备的第三连续的地址段上为所述文件系统分配第二分区,所述第二分区用于存储所述第二分区的系统元数据;a metadata partition allocation module, configured to allocate a first partition to the file system on a second consecutive address segment of the storage device, where the first partition is configured to store system metadata of the first partition; Assigning a second partition to the file system on a third consecutive address segment of the storage device, where the second partition is configured to store system metadata of the second partition;
数据块分配模块,用于在所述存储设备的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区;其中,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;所述第一连续的地址段、所述第二连续的地址段、所述第三连续的地址段和所述第四连续的地址段组成连续的地址段,所述第四连续的地址段位于所述第二连续的地址段和所述第三连续的地址段之间。a data block allocation module, configured to allocate a common data block area of the first partition and the second partition to the file system on a fourth consecutive address segment of the storage device; wherein the shared data The block area is configured to store a file; the data block bitmap area is configured to store a first use identifier, and the first use identifier is used to indicate whether a data block in the shared data block area is used, each of the data The block corresponds to one of the first usage identifiers; the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a continuous address segment The fourth consecutive address segment is located between the second consecutive address segment and the third consecutive address segment.
结合第五方面,在第五方面的第一种可能的实现方式中,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使 用;每个所述索引节点对应一个所述第二使用标识;所述装置还包括:With reference to the fifth aspect, in a first possible implementation manner of the fifth aspect, the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is enabled Each of the index nodes corresponds to one of the second usage identifiers; the device further includes:
接收模块,用于接收在所述第一分区创建文件的请求;所述请求中包括所述文件的大小;a receiving module, configured to receive a request for creating a file in the first partition; the request includes a size of the file;
处理模块,用于通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第一分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;将所述数据块位图中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。a processing module, configured to determine, by using the first usage identifier, an unused data block in the shared data block region; determining a remaining portion in the shared data block region according to the number and size of the unused data blocks a size of the capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be stored in the Determining a storage address in the shared data block area, and searching whether there is an unused index node in the index node bitmap area of the first partition; when there is an unused index node, selecting the unused one An index node in the index node, writing an attribute of the file and the storage address; changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to represent the one a value at which an index node has been used; storing the file in a data block corresponding to the storage address in the shared data block area; The data block corresponding to the memory address using a first identifier to change the value has been used to represent the data block.
结合第五方面,在第五方面的第二种可能的实现方式中,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,With reference to the fifth aspect, in a second possible implementation manner of the fifth aspect, the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes Corresponding to one of the second use identifiers,
所述装置还包括:The device also includes:
接收模块,用于接收在所述第一分区删除文件的请求;a receiving module, configured to receive a request to delete a file in the first partition;
处理模块,用于根据所述文件的属性在所述第一分区的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述第一分区的索引节点位图区中所述对应的索引节点的所述第二使用标识更改 为表示所述对应的索引节点未被使用的值。a processing module, configured to search, according to an attribute of the file, a corresponding index node in an index node area of the first partition: determining, according to a storage address recorded by the index node, a corresponding to the storage address in the shared data block a data block; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; and indexing the first partition The second usage identifier change of the corresponding index node in the bitmap area A value indicating that the corresponding index node is not used.
本申请第六方面提供一种文件系统的管理装置,包括:The sixth aspect of the present application provides a file system management apparatus, including:
超级块分配模块,用于在存储设备的第一连续的地址段上为所述文件系统分配超级块区,所述超级块区用于记录所述文件系统的系统信息;所述系统信息包括所述文件系统的类型、大小;a super block allocation module, configured to allocate a super block area for the file system on a first consecutive address segment of the storage device, where the super block area is used to record system information of the file system; The type and size of the file system;
位图分配模块,用于在所述存储设备的第二连续的地址段上为所述文件系统分配位图区;a bitmap allocation module, configured to allocate a bitmap area to the file system on a second consecutive address segment of the storage device;
共享区分配模块,用于在所述存储设备的第三连续的地址段上为所述文件系统分配共享区,所述共享区用于存储文件与索引节点;所述索引节点用于记录存储在所述共享区中的文件的存储地址;所述位图区用于存储使用标识,所述使用标识用于表示所述共享区中的数据块是否被使用,每个所述数据块对应一个所述使用标识;所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。a shared area allocation module, configured to allocate a shared area to the file system on a third consecutive address segment of the storage device, where the shared area is used for storing files and an index node; and the index node is used for recording and storing a storage address of the file in the shared area; the bitmap area is configured to store a usage identifier, where the usage identifier is used to indicate whether a data block in the shared area is used, and each of the data blocks corresponds to a The usage identifier is used; the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
结合第六方面,在第六方面的第一种可能的实现方式中,所述装置还包括处理模块,用于当在所述共享区为所述索引节点分配空间时,从所述共享区的第一地址端向第二地址端方向进行分配;当在所述共享区为所述文件分配空间时,从所述共享区的所述第二地址端向所述第一地址端方向进行分配。With reference to the sixth aspect, in a first possible implementation manner of the sixth aspect, the device further includes a processing module, when the space is allocated to the index node in the shared area, from the shared area The first address end is allocated to the second address end direction; when the shared area allocates space for the file, the second address end of the shared area is allocated to the first address end direction.
结合第六方面,在第一方面的第二种可能的实现方式中,所述装置还包括:In conjunction with the sixth aspect, in a second possible implementation manner of the first aspect, the device further includes:
接收模块,用于接收用于创建文件的请求;所述请求中包括所述文件的大小;a receiving module, configured to receive a request for creating a file; the request includes a size of the file;
处理模块,用于根据所述使用标识确定所述共享区中未被使用的数据块;根据所述未被使用的数据块的数量及大小确定所述共享区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小确定所述剩余容量是否足够创建所述文件以及存储所述文件对应的索引节点;当所述剩余容量足够存储所述文件以及存储所述文件对应的索引节点时,在所述未被使用的数据块上创建所述文件并将所述文件的存储地址记录在所述对应的索引节点中;将所 述位图区中与所述存储地址和所述索引节点对应的数据块的使用标识更改为表示所述数据块已被使用的值。a processing module, configured to determine, according to the usage identifier, an unused data block in the shared area; determining a size of a remaining capacity in the shared area according to the number and size of the unused data blocks; Determining a size of the file and a size of the remaining capacity to determine whether the remaining capacity is sufficient to create the file and storing an index node corresponding to the file; when the remaining capacity is sufficient to store the file and store an index corresponding to the file a node, creating the file on the unused data block and recording a storage address of the file in the corresponding index node; The usage identifier of the data block corresponding to the storage address and the index node in the bitmap area is changed to a value indicating that the data block has been used.
结合第六方面的第二种可能的实现方式,在第六方面的第三种可能的实现方式中,所述处理模块还用于:更新所述超级块中记录的所述共享区中存储的所有所述索引节点占用的空间大小值以及所述共享区中存储的所有所述文件占用的空间大小值。With reference to the second possible implementation manner of the sixth aspect, in a third possible implementation manner of the sixth aspect, the processing module is further configured to: update the storage in the shared area recorded in the super block a value of the size of the space occupied by all of the index nodes and a value of the size of the space occupied by all of the files stored in the shared area.
结合第六方面,在第六方面的第四种可能的实现方式中,所述装置还包括:In conjunction with the sixth aspect, in a fourth possible implementation manner of the sixth aspect, the device further includes:
接收模块,用于接收查询文件的请求,所述请求中包含所述文件的属性;a receiving module, configured to receive a request for querying a file, where the request includes an attribute of the file;
处理模块,用于在所述共享区中查询与所述属性对应的索引节点;根据所述对应的索引节点中记录的存储地址在所述共享区中查找与所述存储地址对应的文件。a processing module, configured to query an index node corresponding to the attribute in the shared area; and search for a file corresponding to the storage address in the shared area according to the storage address recorded in the corresponding index node.
本申请第七方面提供一种电子设备,包括:A seventh aspect of the present application provides an electronic device, including:
存储器;Memory
处理器,用于在所述存储器的第一连续的地址段上为所述文件系统分配一个数据块位图区;在所述存储器的第二连续的地址段上为所述文件系统分配N个分区,所述N个分区的每个分区分别用于存储所述每个分区的系统元数据;N为大于1的整数;在所述存储器的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;其中,所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。a processor for allocating a data block bitmap area to the file system on a first consecutive address segment of the memory; assigning N to the file system on a second consecutive address segment of the memory a partition, each partition of the N partitions being used to store system metadata of each partition; N is an integer greater than 1; and the file system is allocated on a third consecutive address segment of the memory a shared data block area of the N partitions, where the shared data block area is used to store a file; the data block bitmap area is used to store a first use identifier, and the first use identifier is used to represent the shared data Whether the data blocks in the block area are used, each of the data blocks corresponding to one of the first usage identifiers; wherein the first consecutive address segment, the second consecutive address segment, and the third continuous The address segments form a contiguous address segment.
结合第七方面,在第七方面的第一种可能的实现方式中,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块区中的文件的存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每 个所述索引节点对应一个所述第二使用标识,所述电子设备还包括输入装置,With reference to the seventh aspect, in a first possible implementation manner of the seventh aspect, each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing a storage address of a file in the shared data block area; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; The index node corresponds to one of the second usage identifiers, and the electronic device further includes an input device.
所述输入装置用于接收在所述N个分区中的第i个分区创建文件的请求;所述请求中包括所述文件的大小;The input device is configured to receive a request for creating a file in an i th partition of the N partitions; the request includes a size of the file;
所述处理器还用于:通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第i个分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;将所述数据块位图中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。The processor is further configured to: determine, by using the first usage identifier, an unused data block in the shared data block area; determine the shared data block area according to the number and size of the unused data blocks. a size of the remaining capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be Storing a storage address in the shared data block area, and searching for an unused index node in an index node bitmap area of the i-th partition; when there is an unused index node, selecting the An index node of an unused index node, writes an attribute of the file and the storage address; and changes the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been used; storing the file in a data block corresponding to the storage address in the shared data block area; The first usage identifier of the data block corresponding to the storage address in the figure is changed to a value indicating that the data block has been used.
结合第七方面,在第七方面的第二种可能的实现方式中,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,所述电子设备还包括输入装置,With reference to the seventh aspect, in a second possible implementation manner of the seventh aspect, each of the partitions includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes Corresponding to one of the second usage identifiers, the electronic device further includes an input device,
所述输入装置用于接收在所述N个分区中的分区j删除文件的请求;The input device is configured to receive a request for deleting a file by a partition j in the N partitions;
所述处理器还用于:根据所述文件的属性在所述分区j的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述分区j的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为 表示所述对应的索引节点未被使用的值。The processor is further configured to: search, according to an attribute of the file, a corresponding index node in an index node area of the partition j: determining, in the shared data block, the storage address according to a storage address recorded by the index node Corresponding data block; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; indexing the partition j Changing the second usage identifier of the corresponding index node in the node bitmap area to A value indicating that the corresponding index node is not used.
本申请第八方面提供一种电子设备,包括:An eighth aspect of the present application provides an electronic device, including:
存储器;Memory
处理器,用于在所述存储器的第一连续的地址段上为所述文件系统分配一个数据块位图区;在所述存储器的第二连续的地址段上为所述文件系统分配第一分区,所述第一分区用于存储所述第一分区的系统元数据;在所述存储器的第三连续的地址段上为所述文件系统分配第二分区,所述第二分区用于存储所述第二分区的系统元数据;在所述存储器的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区;其中,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;所述第一连续的地址段、所述第二连续的地址段、所述第三连续的地址段和所述第四连续的地址段组成连续的地址段,所述第四连续的地址段位于所述第二连续的地址段和所述第三连续的地址段之间。a processor for allocating a data block bitmap area to the file system on a first consecutive address segment of the memory; assigning a first to the file system on a second consecutive address segment of the memory a partition, the first partition is configured to store system metadata of the first partition; a second partition is allocated to the file system on a third consecutive address segment of the memory, the second partition is configured to store System metadata of the second partition; a shared data block region of the first partition and the second partition is allocated to the file system on a fourth consecutive address segment of the memory; wherein a shared data block area for storing a file; the data block bitmap area is for storing a first use identifier, and the first use identifier is used to indicate whether a data block in the shared data block area is used, each of the The data block corresponds to one of the first usage identifiers; the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment are consecutive Address segment, Said fourth consecutive addresses between the second consecutive addresses and consecutive addresses of said third segment.
结合第八方面,在第八方面的第一种可能的实现方式中,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识;所述电子设备还包括输入装置,With reference to the eighth aspect, in a first possible implementation manner of the eighth aspect, the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes Corresponding to one of the second usage identifiers; the electronic device further includes an input device,
所述输入装置用于接收在所述第一分区创建文件的请求;所述请求中包括所述文件的大小;The input device is configured to receive a request for creating a file in the first partition; the request includes a size of the file;
所述处理器还用于:通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文 件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第一分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;将所述数据块位图中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。The processor is further configured to: determine, by using the first usage identifier, an unused data block in the shared data block area; determine the shared data block area according to the number and size of the unused data blocks. The size of the remaining capacity; determining whether the remaining capacity is sufficient to create the file according to the size of the file and the size of the remaining capacity; when the remaining capacity is sufficient to create the file Determining, that the file is to be stored in the shared data block area, and searching for an unused index node in the index node bitmap area of the first partition; when there is an unused When the node is indexed, one of the unused index nodes is selected, the attribute of the file and the storage address are written; and the corresponding location of the index node in the bitmap area corresponding to the one index node is The second usage identifier is changed to a value indicating that the one index node has been used; the file is stored in a data block corresponding to the storage address in the shared data block area; the data block bitmap is The first usage identifier of the data block corresponding to the storage address is changed to a value indicating that the data block has been used.
结合第把方面,在第八方面的第二种可能的实现方式中,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,所述电子设备还包括输入装置,With reference to the first aspect, in a second possible implementation manner of the eighth aspect, the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used for recording and storing An attribute of the file in the shared data block and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes Corresponding to one of the second usage identifiers, the electronic device further includes an input device,
所述输入装置用于接收在所述第一分区删除文件的请求;The input device is configured to receive a request to delete a file in the first partition;
所述处理器还用于:根据所述文件的属性在所述第一分区的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述第一分区的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。The processor is further configured to: search, according to an attribute of the file, a corresponding index node in an index node area of the first partition: determining, in the shared data block, the storage according to a storage address recorded by the index node a data block corresponding to the address; changing the first usage identifier of the data block corresponding to the storage address in the bitmap area of the data block to a value indicating that the data block is not used; The second usage identifier of the corresponding index node in the index node bitmap area is changed to a value indicating that the corresponding index node is not used.
本申请第九方面提供一种电子设备,包括:The ninth aspect of the present application provides an electronic device, including:
存储器;Memory
处理器,用于在所述存储器的第一连续的地址段上为所述文件系统分配超级块区,所述超级块区用于记录所述文件系统的系统信息;所述系统信息包括所述文件系统的类型、大小;在所述存储器的第二连续的地址段上为所述文件系统分配位图区;在所述存储器的第三连续的地址段上为所述文件系 统分配共享区,所述共享区用于存储文件与索引节点;所述索引节点用于记录存储在所述共享区中的文件的存储地址;所述位图区用于存储使用标识,所述使用标识用于表示所述共享区中的数据块是否被使用,每个所述数据块对应一个所述使用标识;所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。a processor, configured to allocate a super block area for the file system on a first consecutive address segment of the memory, the super block area for recording system information of the file system; a type, a size of a file system; a bitmap area is allocated to the file system on a second consecutive address segment of the memory; and the file system is on a third consecutive address segment of the memory Allocating a shared area for storing a file and an index node; the index node is configured to record a storage address of a file stored in the shared area; and the bitmap area is configured to store a use identifier, Using an identifier for indicating whether a data block in the shared area is used, each of the data blocks corresponding to one of the usage identifiers; the first consecutive address segment, the second consecutive address segment, and the The third consecutive address segment constitutes a contiguous address segment.
结合第九方面,在第九方面的第一种可能的实现方式中,所述处理器还用于:当在所述共享区为所述索引节点分配空间时,从所述共享区的第一地址端向第二地址端方向进行分配;当在所述共享区为所述文件分配空间时,从所述共享区的所述第二地址端向所述第一地址端方向进行分配。With reference to the ninth aspect, in a first possible implementation manner of the ninth aspect, the processor is further configured to: when the space is allocated to the index node in the shared area, the first from the shared area The address end is allocated to the second address end direction; when the shared area allocates space for the file, the second address end of the shared area is allocated to the first address end direction.
结合第九方面,在第九方面的第二种可能的实现方式中,所述电子设备还包括输入装置,In conjunction with the ninth aspect, in a second possible implementation manner of the ninth aspect, the electronic device further includes an input device,
所述输入装置用于接收用于创建文件的请求;所述请求中包括所述文件的大小;The input device is configured to receive a request for creating a file; the request includes a size of the file;
所述处理器还用于:根据所述使用标识确定所述共享区中未被使用的数据块;根据所述未被使用的数据块的数量及大小确定所述共享区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小确定所述剩余容量是否足够创建所述文件以及存储所述文件对应的索引节点;当所述剩余容量足够存储所述文件以及存储所述文件对应的索引节点时,在所述未被使用的数据块上创建所述文件并将所述文件的存储地址记录在所述对应的索引节点中;将所述位图区中与所述存储地址和所述索引节点对应的数据块的使用标识更改为表示所述数据块已被使用的值。The processor is further configured to: determine, according to the usage identifier, an unused data block in the shared area; determine a size of a remaining capacity in the shared area according to the number and size of the unused data blocks. Determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file and storing an index node corresponding to the file; when the remaining capacity is sufficient to store the file and store the file And corresponding to the index node, creating the file on the unused data block and recording a storage address of the file in the corresponding index node; and the bitmap address and the storage address The usage identifier of the data block corresponding to the index node is changed to a value indicating that the data block has been used.
结合第九方面的第二种可能的实现方式,在第九方面的第三种可能的实现方式中,所述处理器还用于:更新所述超级块区中记录的所述共享区中存储的所有所述索引节点占用的空间大小值以及所述共享区中存储的所有所述文件占用的空间大小值。In conjunction with the second possible implementation of the ninth aspect, in a third possible implementation manner of the ninth aspect, the processor is further configured to: update the storage in the shared area recorded in the super block area The size of the space occupied by all of the index nodes and the size of the space occupied by all of the files stored in the shared area.
结合第九方面,在第九方面的第四种可能的实现方式中,所述电子设备还包括输入装置, In conjunction with the ninth aspect, in a fourth possible implementation manner of the ninth aspect, the electronic device further includes an input device,
所述输入装置用于接收查询文件的请求,所述请求中包含所述文件的属性;The input device is configured to receive a request for querying a file, where the request includes an attribute of the file;
所述处理器还用于:在所述共享区中查询与所述属性对应的索引节点;根据所述对应的索引节点中记录的存储地址在所述共享区中查找与所述存储地址对应的文件。The processor is further configured to: query an index node corresponding to the attribute in the shared area; and search for a storage address corresponding to the storage address in the shared area according to a storage address recorded in the corresponding index node. file.
本申请实施例中提供的一个或多个技术方案,至少具有如下技术效果或优点:One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
本申请实施例中,每个分区的数据块区共用,然后所有分区也共用同一个数据块位图。当需要在某个分区存储数据时,只要数据块位图显示数据块区有足够的剩余容量,那么就可以在数据块区存储数据。而在现有技术中,当需要在某个分区存储数据时,如果某个分区的数据块位图显示数据块区域没有足够剩余容量时,便无法存储数据。而某个分区的相邻分区还有空间,但是由于布局方式的限制,数据也无法存储到相邻分区的数据块区中。由此可见,相较于现有技术,本申请实施例的文件系统管理方法使得存储空间能够被充分利用,减少了被浪费的空间。In the embodiment of the present application, the data block area of each partition is shared, and then all the partitions also share the same data block bitmap. When it is necessary to store data in a certain partition, as long as the data block bitmap shows that the data block area has enough remaining capacity, the data can be stored in the data block area. In the prior art, when data needs to be stored in a certain partition, if the data block bitmap of a certain partition shows that the data block area does not have enough remaining capacity, the data cannot be stored. The adjacent partition of a partition has space, but due to the limitation of the layout, data cannot be stored in the data block area of the adjacent partition. Therefore, compared with the prior art, the file system management method of the embodiment of the present application enables the storage space to be fully utilized, thereby reducing the wasted space.
附图说明DRAWINGS
图1a-图1b为现有技术中的文件系统在存储设备上的布局示意图;1a-1b are schematic diagrams showing a layout of a file system in a prior art on a storage device;
图2为本申请实施例提供的一种文件系统的管理方法的流程图;2 is a flowchart of a method for managing a file system according to an embodiment of the present application;
图3a-图3b为本申请实施例中提供的多种文件系统在存储设备上的布局示意图;3a-3b are schematic diagrams of layouts of multiple file systems provided on a storage device according to an embodiment of the present application;
图4为本申请实施例提供的一种在文件系统中创建文件的方法流程图;4 is a flowchart of a method for creating a file in a file system according to an embodiment of the present application;
图5为本申请实施例提供的一种在文件系统中删除文件的方法流程图;FIG. 5 is a flowchart of a method for deleting a file in a file system according to an embodiment of the present disclosure;
图6为本申请实施例提供的另一种文件系统的管理方法的流程图;FIG. 6 is a flowchart of another method for managing a file system according to an embodiment of the present application;
图7a-图7b为本申请实施例提供的另一种文件系统在存储设备上的布局示意图; 7a-7b are schematic diagrams of layout of another file system on a storage device according to an embodiment of the present application;
图8为本申请实施例提供的再一种文件系统的管理方法的流程图;FIG. 8 is a flowchart of still another method for managing a file system according to an embodiment of the present application;
图9为本申请实施例提供的再一种系统在存储设备上的布局示意;FIG. 9 is a schematic diagram of a layout of another system on a storage device according to an embodiment of the present disclosure;
图10为本申请实施例提供的另一种在文件系统中创建文件的方法流程图;FIG. 10 is a flowchart of another method for creating a file in a file system according to an embodiment of the present disclosure;
图11为本申请实施例提供的一种在文件系统中查找文件的方法流程图;FIG. 11 is a flowchart of a method for searching for a file in a file system according to an embodiment of the present application;
图12为本申请实施例提供的一种文件系统管理装置的功能框图;FIG. 12 is a functional block diagram of a file system management apparatus according to an embodiment of the present application;
图13为本申请实施例提供的一种电子设备的结构图;FIG. 13 is a structural diagram of an electronic device according to an embodiment of the present application;
图14为本申请实施例提供的另一种文件系统管理装置的功能框图;FIG. 14 is a functional block diagram of another file system management apparatus according to an embodiment of the present application;
图15为本申请实施例提供的另一种电子设备的结构图;FIG. 15 is a structural diagram of another electronic device according to an embodiment of the present disclosure;
图16为本申请实施例提供的再一种文件系统管理装置的功能框图;FIG. 16 is a functional block diagram of still another file system management apparatus according to an embodiment of the present application;
图17为本申请实施例提供的再一种电子设备的结构图。FIG. 17 is a structural diagram of still another electronic device according to an embodiment of the present application.
具体实施方式detailed description
本申请实施例提供一种文件系统的管理方法及装置,用以解决现有技术中的存储空间利用率低的技术问题。The embodiment of the present invention provides a file system management method and device, which are used to solve the technical problem of low storage space utilization in the prior art.
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present application. It is a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without departing from the inventive scope are the scope of the present application.
请参考图2所示,为本申请实施例提供的一种文件系统的管理方法的流程图。Please refer to FIG. 2 , which is a flowchart of a method for managing a file system according to an embodiment of the present application.
如图2所示,该方法包括:As shown in Figure 2, the method includes:
步骤101:在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;Step 101: Allocating a data block bitmap area to the file system on a first consecutive address segment of the storage device;
步骤102:在存储设备的第二连续的地址段上为所述文件系统分配N个分区,N个分区的每个分区分别用于存储每个分区的系统元数据;N为大于1 的整数;Step 102: Allocate N partitions to the file system on a second consecutive address segment of the storage device. Each partition of the N partitions is used to store system metadata of each partition respectively; N is greater than 1 Integer
步骤103:在存储设备的第三连续的地址段上为所述文件系统分配N个分区的共用数据块区,共用数据块区用于存储文件。Step 103: Allocate a shared data block area of N partitions for the file system on a third consecutive address segment of the storage device, where the shared data block area is used for storing files.
其中,数据块位图区用于存储第一使用标识,第一使用标识用于表示共用数据块区中的数据块是否被使用,每个数据块对应一个第一使用标识。The data block bitmap area is used to store the first usage identifier, and the first usage identifier is used to indicate whether the data block in the shared data block area is used, and each data block corresponds to a first usage identifier.
其中,第一连续的地址段、第二连续的地址段和第三连续的地址段组成连续的地址段。The first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a continuous address segment.
具体来说,数据块位图区是以位图的数据结构来定义的,每一个比特代表一个数据块的使用与否。即一个第一使用标识的大小为一个比特。第一使用标识例如为0和1,用0来表示数据块未被使用。用1来表示数据块已被使用。当然,在实际运用中,第一使用标识可以是其它数据,只要能够表示某个数据块是否被使用即可。Specifically, the data block bitmap area is defined by the data structure of the bitmap, and each bit represents the use of a data block. That is, the size of a first use identifier is one bit. The first usage identifier is, for example, 0 and 1, with 0 indicating that the data block is not used. Use 1 to indicate that the data block has been used. Of course, in actual use, the first usage identifier may be other data as long as it can indicate whether a certain data block is used.
在步骤102中,在存储设备上为所述系统分配N个分区,具体来说,可以按照用途来确定N的数量,即每个分区的作用不同。换言之,每个分区所对应的文件的类型是不同的。举例来说,可以按照现有技术中的分区方式进行分区,即现有技术中的文件系统有几个分区,在步骤102中就分配几个分区。In step 102, N partitions are allocated to the system on the storage device. Specifically, the number of Ns may be determined according to the purpose, that is, the role of each partition is different. In other words, the type of file corresponding to each partition is different. For example, partitioning can be performed according to the partitioning method in the prior art, that is, the file system in the prior art has several partitions, and several partitions are allocated in step 102.
可选的,每个分区的大小可以相同也可以不相同。因为每个分区所存储的元数据的类型和数量不同,所以具体可以根据所存储的元数据的类型和数量来分配N个分区的大小。Optionally, the size of each partition may be the same or different. Since the type and number of metadata stored in each partition are different, the size of N partitions can be specifically allocated according to the type and number of stored metadata.
在具体实施过程中,步骤101、步骤102和步骤103之间的顺序可以任意变化,或者三个步骤同时执行。In a specific implementation process, the order between step 101, step 102, and step 103 may be arbitrarily changed, or three steps may be performed simultaneously.
需要说明的是,本实施例以及下述实施例中的存储设备可以是在物理上单独的一个硬盘、U盘的全部存储空间,也可以是一个硬盘或U盘上的部分存储空间。举例来说,假设一个硬盘的总大小为500G,那么本申请实施例中的存储设备就可以是整个500G的存储空间,也可以是其中200G的存储空间。It should be noted that the storage device in this embodiment and the following embodiments may be a physical storage space of a single hard disk or a USB disk, or may be a partial storage space on a hard disk or a USB disk. For example, if the total size of a hard disk is 500G, the storage device in the embodiment of the present application may be the entire 500G storage space or 200G storage space.
通常来讲,当用户触发格式化存储设备的操作时,安装有该存储设备的 电子设备即可执行步骤101至步骤103。Generally speaking, when a user triggers an operation of formatting a storage device, the storage device is installed. The electronic device can perform steps 101 to 103.
可选的,本申请实施例中的连续的地址段表示在逻辑地址上是连续的。因此,在步骤101至步骤103中,均是按照连续的逻辑地址分配各个区。Optionally, consecutive address segments in the embodiment of the present application indicate that the logical addresses are consecutive. Therefore, in steps 101 to 103, the respective areas are allocated in accordance with consecutive logical addresses.
进一步,第一连续的地址段、第二连续的地址段和第三连续的地址段组成连续的地址段的一种情况例如为:数据块位图区的逻辑尾地址和N个分区的第一个分区的逻辑首地址是连续的,N个分区的最后一个分区的逻辑尾地址和共用数据块区的逻辑首地址是连续的。因此,步骤102具体包括:在从所述数据块位图区的逻辑尾地址的下一地址开始的第二连续的地址段上为所述文件系统分配N个分区。步骤103具体包括:在从N个分区的最后一个分区的逻辑尾地址的下一地址开始的第三连续的地址段上为所述文件系统分配N个分区的共用数据块区。Further, a case where the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a continuous address segment is, for example, a logical tail address of the data block bitmap area and a first of the N partitions The logical first address of the partitions is contiguous, and the logical tail address of the last partition of the N partitions and the logical first address of the shared data block area are consecutive. Accordingly, step 102 specifically includes allocating N partitions to the file system on a second consecutive address segment starting from a next address of a logical tail address of the data block bitmap region. Step 103 specifically includes allocating N partition shared data block regions to the file system on a third consecutive address segment starting from a next address of a logical tail address of a last partition of the N partitions.
可选的,在分配各个区时,可以是按照由低地址端向高地址端的方向进行分配,也可以按照由高地址端向低地址端的方向进行分配。具体来说,例如:第二连续的地址段的地址高于第一连续的地址段,第三连续的地址段的地址高于第二连续的地址段。Optionally, when all the areas are allocated, the allocation may be performed in a direction from a low address end to a high address end, or may be allocated in a direction from a high address end to a low address end. Specifically, for example, the address of the second consecutive address segment is higher than the first consecutive address segment, and the address of the third consecutive address segment is higher than the second consecutive address segment.
在实际运用中,各个区的位置请参考以下几个具体的实例。In the actual application, please refer to the following specific examples for the location of each zone.
第一例:请参考图3a所示,图3a为根据图2所示的文件系统管理方法在存储设备上布局文件系统之后的布局结构示意图。The first example is as shown in FIG. 3a. FIG. 3a is a schematic diagram of a layout structure after the file system is laid out on the storage device according to the file system management method shown in FIG. 2.
在本例中,数据块位图区位于低地址端。N个分区紧接着数据块位图区布局,并且N个分区位于数据块位图区的高低端侧。然后共用数据块区紧接着N个分区的最后一个分区布局。数据块位图区的首地址至共用数据块区的尾地址之间地址均是连续的。In this example, the data block bitmap area is at the low address end. N partitions are immediately followed by a data block bitmap area layout, and N partitions are located on the high and low side of the data block bitmap area. The shared data block area is then followed by the last partition layout of the N partitions. The address between the first address of the data block bitmap area and the tail address of the shared data block area is continuous.
可选的,在向各个区存储数据时,可以是按照从低地址端向高地址端的方向进行存储。Optionally, when storing data to each area, it may be stored in a direction from a low address end to a high address end.
第二例,请参考图3b所示,图3b为根据图2所示的文件系统管理方法在存储设备上布局文件系统之后的布局结构示意图。For the second example, please refer to FIG. 3b. FIG. 3b is a schematic diagram of a layout structure after the file system is laid out on the storage device according to the file system management method shown in FIG. 2.
第二例和第一例不同的是,将共用数据块区分配在数据块位图区和N个 分区之间。The second example is different from the first example in that the shared data block area is allocated in the data block bitmap area and N blocks. Between partitions.
由以上描述可知,相比现有技术,本申请实施例的文件系统管理方法将N个分区的数据块抽离出来形成一个连续的存储空间,而每个区的数据块位图区也抽离出来形成一个连续的位图区,用于存储表示该共用数据块区的数据块是否被使用的第一使用标识。因此,在本申请实施例中,只要数据块位图显示数据块区有足够的剩余容量,那么就可以在数据块区存储数据。而在现有技术中,当需要在某个分区存储数据时,如果某个分区的数据块位图显示数据块区域没有足够剩余容量时,便无法存储数据。而某个分区的相邻分区还有空间,但是由于布局方式的限制,数据也无法存储到相邻分区的数据块区中。由此可见,相较于现有技术,本申请实施例的文件系统管理方法使得存储空间能够被充分利用,减少了被浪费的空间。同时,本申请实施例中的文件系统管理方法避免了每个分区设计的比所需大小大,进而压缩用户存储空间的问题,也因此避免了存储空间的浪费。It can be seen from the above description that the file system management method of the embodiment of the present application extracts the data blocks of the N partitions to form a continuous storage space, and the data block bitmap area of each area is also separated from the prior art. Coming out to form a continuous bitmap area for storing a first usage identifier indicating whether the data block of the shared data block area is used. Therefore, in the embodiment of the present application, as long as the data block bitmap shows that the data block area has sufficient remaining capacity, the data can be stored in the data block area. In the prior art, when data needs to be stored in a certain partition, if the data block bitmap of a certain partition shows that the data block area does not have enough remaining capacity, the data cannot be stored. The adjacent partition of a partition has space, but due to the limitation of the layout, data cannot be stored in the data block area of the adjacent partition. Therefore, compared with the prior art, the file system management method of the embodiment of the present application enables the storage space to be fully utilized, thereby reducing the wasted space. At the same time, the file system management method in the embodiment of the present application avoids the problem that each partition design is larger than the required size, thereby compressing the user storage space, thereby avoiding waste of the storage space.
进一步,通过本申请实施例中的文件系统管理方法,只需要知道整个文件系统所需空间多大即可,而不需要知道具体每个分区的大小,所以也提高了设计人员的研发效率。Further, the file system management method in the embodiment of the present application only needs to know how much space the entire file system requires, and does not need to know the size of each specific partition, thereby improving the research and development efficiency of the designer.
进一步,当图2及其实施例所描述的方法应用在用户存储空间中时,同样可以实现只要共用数据块区中有足够的存储空间,在任何一个分区都可以存储文件的技术效果。举例来说,当用户向D盘中存储一部电影时,只要共用数据块区中有足够的存储空间,那么该存储操作就能够被响应,进而将电影数据存储在D盘中。而在现有技术中,如果D盘的数据块区中没有足够存储空间时,就无法将电影数据存储在D盘中,而只能改存在其它有空闲存储空间的分区盘中,例如E盘。因此,相比现有技术,本申请实施例中的方法更加便于用户使用。Further, when the method described in FIG. 2 and its embodiment is applied in the user storage space, it is also possible to realize the technical effect that the file can be stored in any one partition as long as there is sufficient storage space in the shared data block area. For example, when a user stores a movie in the D-disc, as long as there is sufficient storage space in the shared data block area, the storage operation can be responded, thereby storing the movie data in the D-disc. In the prior art, if there is not enough storage space in the data block area of the D disk, the movie data cannot be stored in the D disk, but can only be changed to other partition disks having free storage space, such as an E disk. . Therefore, the method in the embodiment of the present application is more convenient for the user to use than the prior art.
在进一步的实施例中,N个分区的每个分区包括超级块区、索引节点位图区以及索引节点区。超级块区用于记录各分区的文件系统的系统信息,例如文件系统的类型、大小。进一步,超级块区还用于记录共用数据块区的剩 余容量大小。索引节点区的索引节点用于记录存储在共用数据块区中的文件的存储地址。进一步,索引节点还记录该文件的属性。属性包括唯一标识一个文件的信息,例如文件的名称。通过索引节点能够在共用数据块区中找到文件。一个索引节点对应一个文件的存储地址。进一步,属性还包括文件的大小等信息。In a further embodiment, each partition of the N partitions includes a super block area, an index node bitmap area, and an index node area. The super block area is used to record system information of the file system of each partition, such as the type and size of the file system. Further, the super block area is also used to record the remaining area of the shared data block area. Remaining capacity. The index node of the inode area is used to record the storage address of the file stored in the shared block area. Further, the inode also records the properties of the file. Attributes include information that uniquely identifies a file, such as the name of a file. The file can be found in the shared data block area by the index node. An index node corresponds to the storage address of a file. Further, the attribute also includes information such as the size of the file.
索引节点位图区用于存储第二使用标识,第二使用标识用于表示索引节点是否被使用。每个索引节点对应一个第二使用标识。索引节点位图区也可以是以位图的数据结构来定义的。每一个比特代表一个索引节点使用与否。The index node bitmap area is used to store the second usage identifier, and the second usage identifier is used to indicate whether the index node is used. Each index node corresponds to a second usage identifier. The index node bitmap area can also be defined by the data structure of the bitmap. Each bit represents the use of an index node or not.
因为在本申请实施例中,各个分区的数据块抽离出来形成一个整体的共用数据块区,为了保证每个分区更大能力的去使用共用数据块,其索引节点位图和索引节点区也可以适当分配大点。比如以分区1为例,现有的技术方案中,分区1有10000个数据块,可能分配2500个索引节点空间,现在可以给分区1分配5000个索引节点空间,因为每个索引节点以及索引节点位图空间占用不大,所用的空间可以忽略不计。如此可以保证在有空闲数据块时,每个分区的索引节点是足够的,这样,只要空闲数据块的大小足够存储文件,那么就可以在任何分区存储该文件。Because in the embodiment of the present application, the data blocks of each partition are extracted to form an overall shared data block area, and in order to ensure that each partition has greater capability to use the shared data block, the index node bitmap and the index node area are also Large points can be allocated appropriately. For example, with partition 1 as an example, in the existing technical solution, partition 1 has 10000 data blocks, and 2500 index node spaces may be allocated. It is now possible to allocate 5000 index node spaces to partition 1 because each index node and index node The bitmap space is small and the space used is negligible. This ensures that the index node of each partition is sufficient when there are free data blocks, so that as long as the free data block is large enough to store the file, the file can be stored in any partition.
当然,在实际运用中,索引节点的数量具体和该分区所存储数据的类型相关。举例来说,如果该分区主要用于存储大数据,那么索引节点的数量就可以少一点。如果该分区主要用于存储小数据,但是数据量很大,那么索引节点的数量就可以多一点。Of course, in actual use, the number of inodes is specifically related to the type of data stored in the partition. For example, if the partition is primarily used to store big data, the number of index nodes can be less. If the partition is mainly used to store small data, but the amount of data is large, the number of index nodes can be a little more.
以下将举例说明按照图2所示的方法进行系统布局之后,在某个分区创建一个文件的过程。例如:如图4所示,在分区i创建一个文件。The following is an example of the process of creating a file in a partition after performing system layout in accordance with the method shown in FIG. 2. For example, as shown in Figure 4, create a file in partition i.
首先,接收在分区i新增一个文件的请求,所述请求中包括所述文件的大小。接下来通过第一使用标识确定共用数据块区中未被使用的数据块。例如:0代表数据块未使用,1代表数据块已被使用。那么所有0对应的数据块即为未被使用的数据块。然后根据未被使用的数据块的数量以及大小确定共用数据块区中的剩余容量的大小。因为每个数据块的大小是已知的,所以根据未 被使用的数据块的数量和大小即可计算出剩余容量的大小。该部分内容为本领域技术人员所熟知的内容,所以在此不再赘述。First, a request to add a file to the partition i is received, the request including the size of the file. The unused data blocks in the shared data block area are then determined by the first usage identification. For example: 0 means that the data block is not used, and 1 means that the data block has been used. Then all the data blocks corresponding to 0 are unused data blocks. The size of the remaining capacity in the shared data block area is then determined based on the number and size of unused data blocks. Because the size of each data block is known, so according to The amount and size of the data blocks used can be used to calculate the size of the remaining capacity. This part of the content is well known to those skilled in the art, so it will not be described here.
在确定出共用数据块区中的剩余容量大小之后,根据所述文件的大小和剩余容量的大小,确定剩余容量是否足够创建所述文件。例如:剩余容量为10MB,如果新增的该文件的大小为8MB,那么确定的结果即为剩余容量足够。如果新增的该文件的大小为15MB,那么确定的结果是剩余容量不够。After determining the remaining capacity size in the shared data block area, it is determined whether the remaining capacity is sufficient to create the file according to the size of the file and the size of the remaining capacity. For example, the remaining capacity is 10MB. If the size of the newly added file is 8MB, the result of the determination is that the remaining capacity is sufficient. If the size of the newly added file is 15MB, then the result of the determination is that the remaining capacity is not enough.
如果剩余容量不够创建所述文件时,可以通过用户界面(UI)向用户提示磁盘空间不够。If the remaining capacity is insufficient to create the file, the user interface (UI) can be used to prompt the user for insufficient disk space.
如果剩余容量足够创建所述文件时,那么接下来确定所述文件将要存储在所述共用数据块区中的存储地址,并在分区i的索引节点位图区查找是否有未被使用的索引节点。其中,确定所述文件将要存储在所述共用数据块区中的存储地址,具体来说,可以是在未被使用的数据块中确定将要存储的数据块,然后该数据块的地址即为所述文件将要存储的存储地址。该部分内容为本领域技术人员所熟知的内容,所以在此不再赘述。If the remaining capacity is sufficient to create the file, then it is determined that the file is to be stored in the shared data block area, and the index node of the partition i is searched for an unused index node. . Wherein, determining that the file is to be stored in a storage address in the shared data block area, specifically, determining a data block to be stored in an unused data block, and then the address of the data block is The storage address where the file will be stored. This part of the content is well known to those skilled in the art, so it will not be described here.
通常,索引节点的数量设置的是足够多的,如前面所述,可以将索引节点区分配的稍大一些,这样可以保证在共用数据块区有足够的剩余容量创建文件时,索引节点区有未被使用的索引节点。当然,如果出现极端情况,索引节点已分配完,那么同样可以通过UI提示用户分区1的索引节点已分配完。Generally, the number of inodes is set to be sufficient. As mentioned above, the index node area can be allocated slightly larger, which ensures that when there is enough remaining capacity in the shared data block area to create a file, the inode area has An inode that is not being used. Of course, if there is an extreme situation, the index node has been allocated, then the UI can also prompt the user that the index node of partition 1 has been allocated.
当查找到未被使用的索引节点时,为所述文件分配一个索引节点,并在该索引节点中填充所述文件的属性以及所述存储地址。然后在索引节点位图区中将与所述一个索引节点对应的第二使用标识更改为表示所述一个索引节点已被使用的值。When an unused index node is found, the file is assigned an index node, and the attributes of the file and the storage address are populated in the index node. The second usage identifier corresponding to the one index node is then changed in the index node bitmap area to a value indicating that the one index node has been used.
将所述文件写入共用数据块区中与存储地址对应的数据块。然后在数据块位图区中将与所述存储地址对应的数据块的第一使用标识更改为表示所述数据块已被使用的值。举例来说,在数据块位图区中,将占用的数据块的第一使用标识置为1,表示该数据块已被使用。The file is written to a data block in the shared data block area corresponding to the storage address. The first usage identification of the data block corresponding to the storage address is then changed in the data block bitmap area to a value indicating that the data block has been used. For example, in the data block bitmap area, the first use identifier of the occupied data block is set to 1, indicating that the data block has been used.
需要说明的是,在以上步骤中,在不出现冲突的情况下,步骤之间的顺 序可以调换。It should be noted that in the above steps, in the case of no conflict, the steps between the steps The order can be exchanged.
由此可见,通过本申请实施例中的文件系统管理方法布局系统之后,共用数据块为一个资源池,只要通过查询数据块位图发现共用数据块区中有足够的剩余容量,就可进行数据存储。相比现有技术中,如果需要新增的文件的那个分区中容量不足时,便无法新增文件,而浪费了其它分区所对应的数据块。因此,本申请实施例中的文件系统管理方法能够节约存储空间。It can be seen that after the file system management method in the embodiment of the present application lays out the system, the shared data block is a resource pool, and the data can be performed by querying the data block bitmap to find that there is sufficient remaining capacity in the shared data block area. storage. Compared with the prior art, if the capacity of the partition that needs the newly added file is insufficient, the file cannot be added, and the data block corresponding to the other partition is wasted. Therefore, the file system management method in the embodiment of the present application can save storage space.
接下来将描述在N个分区中的分区j删除文件的过程。具体请参考图5所示。Next, the process of deleting a file by the partition j in the N partitions will be described. Please refer to Figure 5 for details.
首先,接收在分区j删除文件的请求。具体来说,例如用户在分区j,如D盘上选中一个文件,然后点击右键,在右键菜单里点选“删除”选项,那么此时电子设备就会接收到删除文件的请求。First, a request to delete a file in partition j is received. Specifically, for example, the user selects a file on the partition j, such as the D disk, and then right clicks, and selects the “delete” option in the right-click menu, then the electronic device receives the request to delete the file.
然后根据所述文件的属性在分区j的索引节点区查找对应的索引节点。具体来说,如前所述,元数据包括所述文件的存储地址。进一步,元数据还可以包括所述文件的属性,该属性包括可以唯一标识一个文件的属性值,例如文件的名称。可选的,属性还可以包括文件的大小等。所以可以通过元数据中的属性与索引节点区中的每个索引节点记录的元数据进行匹配。当匹配成功时,匹配成功的索引节点即为所述文件对应的索引节点。Then, the corresponding index node is searched in the index node area of the partition j according to the attributes of the file. Specifically, as previously mentioned, the metadata includes the storage address of the file. Further, the metadata may further include an attribute of the file, the attribute including an attribute value that can uniquely identify a file, such as a name of the file. Optionally, the attribute may also include the size of the file, and the like. Therefore, the attributes in the metadata can be matched with the metadata recorded by each index node in the inode area. When the matching is successful, the index node that successfully matches is the index node corresponding to the file.
在查找到所述文件对应的索引节点后,根据所述索引节点记录的存储地址确定共用数据块中与所述存储地址对应的数据块。然后在数据块位图区中将与所述存储地址对应的数据块的第一使用标识更改为表示所述数据块未被使用的值。该步骤即表示对被删除文件所占用的数据块进行回收。在实际使用中,可以是在确定所述文件所占用的数据块之后,可以将所述数据块中的文件擦除。当然,也可以不进行擦除操作,因为在数据块位图中已经将所述数据块对应的第一使用标识更改为表示所述数据块未被使用的值,所以在后续如果有创建文件的请求时,确定共用数据块区中的剩余容量时,所述数据块的状态是未被使用,即可以存入新的数据。因此,如果在所述数据块上存储新的数据时,只要覆盖该数据块中的原数据即可。 After finding the index node corresponding to the file, determining a data block corresponding to the storage address in the shared data block according to the storage address recorded by the index node. The first usage identification of the data block corresponding to the storage address is then changed in the data block bitmap area to a value indicating that the data block is not used. This step means that the data blocks occupied by the deleted files are recycled. In actual use, the files in the data block may be erased after determining the data blocks occupied by the file. Of course, the erasing operation may not be performed because the first usage identifier corresponding to the data block has been changed to a value indicating that the data block is not used in the data block bitmap, so if there is a file created later At the time of request, when the remaining capacity in the shared data block area is determined, the state of the data block is unused, that is, new data can be stored. Therefore, if new data is stored on the data block, it is only necessary to overwrite the original data in the data block.
接下来,在分区j的索引节点位图区中将所述对应的索引节点的第二使用标识更改为表示所述对应的索引节点未被使用的值,对所述文件对应的索引节点进行回收。类似的,也可以删除所述对应的索引节点中所述文件的属性以及存储地址,也可以不删除,而是在下次存储时直接覆盖所述文件的属性以及存储地址。Next, in the index node bitmap area of the partition j, the second usage identifier of the corresponding index node is changed to a value indicating that the corresponding index node is not used, and the index node corresponding to the file is recovered. . Similarly, the attributes of the file and the storage address in the corresponding index node may also be deleted, or may not be deleted, but the attributes of the file and the storage address may be directly overwritten at the next storage.
基于与图2所示方法同一发明构思,本申请实施例还提供一种文件系统,该文件系统包括:数据块位图区、N个分区、共用数据块区。其中,这些区的含义以及相互之间的布局关系与前述图2所示方法及其实施例中所描述的相同,所以在此不再赘述。Based on the same inventive concept as the method shown in FIG. 2, the embodiment of the present application further provides a file system, where the file system includes: a data block bitmap area, N partitions, and a shared data block area. The meanings of these areas and the layout relationship between them are the same as those described in the foregoing method shown in FIG. 2 and its embodiments, and therefore will not be described herein.
接下来请参考图6所示,为本申请实施例提供的另一种文件系统的管理方法的流程图。如图6所示,该方法包括:Next, please refer to FIG. 6 , which is a flowchart of another method for managing a file system according to an embodiment of the present application. As shown in FIG. 6, the method includes:
步骤201:在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;Step 201: Allocating a data block bitmap area to the file system on a first consecutive address segment of the storage device;
步骤202:在存储设备的第二连续的地址段上为所述文件系统分配第一分区,第一分区用于存储第一分区的系统元数据;Step 202: Allocating a first partition to the file system on a second consecutive address segment of the storage device, where the first partition is used to store system metadata of the first partition;
步骤203:在存储设备的第三连续的地址段上为所述文件系统分配第二分区,第二分区用于存储第二分区的系统元数据;Step 203: Allocating a second partition to the file system on a third consecutive address segment of the storage device, where the second partition is configured to store system metadata of the second partition.
步骤204:在存储设备的第四连续的地址段上,为所述文件系统分配第一分区和第二分区的共用数据块区;其中,共用数据块区用于存储文件;数据块位图区用于存储第一使用标识,第一使用标识用于表示共用数据块区中的数据块是否被使用,每个数据块对应一个第一使用标识。Step 204: Allocating a shared data block area of the first partition and the second partition to the file system on a fourth consecutive address segment of the storage device; wherein, the shared data block area is used for storing a file; and the data block bitmap area is And configured to store a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block region is used, and each data block corresponds to a first usage identifier.
其中,第一连续的地址段、第二连续的地址段、第三连续的地址段和第四连续的地址段组成连续的地址段。第四连续的地址段位于第二连续的地址段和第三连续的地址段之间。The first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a contiguous address segment. The fourth consecutive address segment is located between the second consecutive address segment and the third consecutive address segment.
其中,连续的地址段的含义,以及组成连续的地址段的含义与前述图2及其实施例中所描述的含义相同。The meaning of the consecutive address segments and the meaning of the consecutive address segments are the same as those described in the foregoing FIG. 2 and its embodiments.
如图7a所示,为根据图6所示文件系统管理方法对文件系统进行布局之 后的布局示意图。As shown in FIG. 7a, the file system is laid out according to the file system management method shown in FIG. After the layout diagram.
在本例中,数据块位图区位于低地址端,分区1紧接着数据块位图区,并位于数据块位图区的高地址端侧。然后是共用数据块区紧接着分区1,并位于分区1的高地址端侧。然后是分区2紧接着共用数据块区并位于共用数据块区的高地址端侧。In this example, the data block bitmap area is located at the lower address end, and the partition 1 is immediately followed by the data block bitmap area and is located at the high address side of the data block bitmap area. Then, the shared data block area is next to the partition 1 and is located on the high address side of the partition 1. Then, the partition 2 is next to the shared data block area and is located on the high address side of the shared data block area.
当然,在实际运用中,各个区之间的位置关系还可以其它情况,例如与图7a的顺序正好相反,数据块位图区位于高地址端,而分区2位于低地址端。Of course, in actual use, the positional relationship between the zones can be other situations, for example, the reverse of the sequence of FIG. 7a, the data block bitmap area is located at the high address end, and the partition 2 is located at the low address end.
与图2及其实施例类似的,第一分区和第二分区,也包含超级块区、索引节点区和索引节点位图区。超级块区、索引节点区和索引节点位图区的含义与前述描述的类似,所以在此不再赘述。Similar to FIG. 2 and its embodiment, the first partition and the second partition also include a super block area, an index node area, and an index node bitmap area. The meanings of the super block area, the inode area, and the index node bitmap area are similar to those described above, and therefore will not be described herein.
需要说明的是,对于共用数据块位于第一分区和第二分区之间的情况,位于共用数据块区低地址端的分区包含的超级块区、索引节点位图区以及索引节点区的顺序和位于共用数据块区高地址端的分区包含的超级块区、索引节点位图区以及索引节点区的顺序可以相反。It should be noted that, in the case where the shared data block is located between the first partition and the second partition, the order and location of the super block area, the index node bitmap area, and the index node area included in the partition located at the lower address end of the shared data block area The order of the super block area, the index node bitmap area, and the index node area included in the partition of the high address side of the shared data block area may be reversed.
举例来说,请参考图7b所示,分区1和分区2分别位于共用数据块区的低地址端和高地址端。分区1的三个子分区在低地址端向高地址端的方向上的顺序为超级块区、索引节点位图区、索引节点区。分区2的三个子分区从低地址端向高地址端的方向上,顺序分别为索引节点区、索引节点位图区、超级块区。因此分区2的文件系统是“逆生长”的。For example, referring to FIG. 7b, the partition 1 and the partition 2 are respectively located at the lower address end and the upper address end of the shared data block area. The order of the three sub-partitions of the partition 1 in the direction from the low address end to the high address end is the super block area, the index node bitmap area, and the index node area. The three sub-partitions of partition 2 are in the direction from the low address end to the high address end, and are respectively in the order of the index node area, the index node bitmap area, and the super block area. Therefore, the file system of partition 2 is "reverse growth".
对于本实施例中的文件系统布局方式,在第一分区或第二分区创建文件的过程和前述描述的创建文件的过程相同,即前述的分区i可以被替换为第一分区或第二分区。在第一分区或第二分区删除文件的过程和前述描述的删除文件过程相同,即前述分区j可以被替换为第一分区或第二分区。为了说明书的简洁,在此不再赘述。For the file system layout manner in this embodiment, the process of creating a file in the first partition or the second partition is the same as the process of creating a file described above, that is, the foregoing partition i may be replaced with the first partition or the second partition. The process of deleting a file in the first partition or the second partition is the same as the process of deleting the file described above, that is, the aforementioned partition j may be replaced with the first partition or the second partition. For the sake of brevity of the description, it will not be repeated here.
基于与图6所示方法同一发明构思,本申请实施例提提供一种文件系统,该文件系统包括:数据块位图区、第一分区、共用数据块区以及第二分区。其中,每个区的含义及布局与前述图6所示方法及其实施例所描述的相同, 所以在此不再赘述。Based on the same inventive concept as the method shown in FIG. 6, the embodiment of the present application provides a file system, where the file system includes: a data block bitmap area, a first partition, a shared data block area, and a second partition. Wherein, the meaning and layout of each zone are the same as those described in the foregoing method and its embodiment shown in FIG. So I won't go into details here.
接下来请参考图8所示,为本申请实施例提供的再一种文件系统的管理方法的流程图。如图8所示,该方法包括:Next, please refer to FIG. 8 , which is a flowchart of still another method for managing a file system according to an embodiment of the present application. As shown in Figure 8, the method includes:
步骤301:在存储设备的第一连续的地址段上为所述文件系统分配超级块区,超级块区用于记录文件系统的系统信息;系统信息包括文件系统的类型、大小;Step 301: Allocating a super block area to the file system on a first consecutive address segment of the storage device, where the super block area is used to record system information of the file system; the system information includes a type and a size of the file system;
步骤302:在存储设备的第二连续的地址段上为所述文件系统分配位图区;Step 302: Allocating a bitmap area to the file system on a second consecutive address segment of the storage device;
步骤303:在存储设备的第三连续的地址段上为所述文件系统分配共享区,共享区用于存储文件与索引节点。Step 303: Allocate a shared area to the file system on a third consecutive address segment of the storage device, where the shared area is used to store files and index nodes.
其中,索引节点用于记录存储在共享区中的文件的存储地址。位图区用于存储使用标识,使用标识用于表示共享区中的数据块是否被使用。每个数据块对应一个使用标识。第一连续的地址段、第二连续的地址段和第三连续的地址段组成连续的地址段。The index node is used to record the storage address of the file stored in the shared area. The bitmap area is used to store the usage identifier, and the usage identifier is used to indicate whether the data block in the shared area is used. Each data block corresponds to a usage identifier. The first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
进一步,超级块区还用于记录共享区中的所有索引节点所占用的空间大小以及共享区中所有文件所占用的空间大小。进一步,超级块区还用于记录共享区的总大小。根据共享区的总大小、所有索引节点所占用的空间大小以及所有文件所占用的空间大小可以获得共享区中的剩余空间的大小。超级块区中记录的以上所描述的信息,便于后续对超级块区对应的分区进行管理。Further, the super block area is also used to record the size of the space occupied by all the index nodes in the shared area and the space occupied by all the files in the shared area. Further, the super block area is also used to record the total size of the shared area. The size of the remaining space in the shared area can be obtained according to the total size of the shared area, the size of the space occupied by all the index nodes, and the size of the space occupied by all the files. The information described above recorded in the super block area facilitates subsequent management of the partition corresponding to the super block area.
进一步,索引节点区的索引节点还用于记录数据块区所存储的文件的属性。属性包括可以唯一标识一个文件的信息,例如文件名称。进一步,属性还包括文件大小等信息。Further, the index node of the inode area is also used to record the attributes of the file stored in the data block area. Properties include information that uniquely identifies a file, such as a file name. Further, the attribute also includes information such as file size.
在以上各实施例中,存储地址例如为地址指针、地址本身或者地址偏量等表示地址的信息。In the above embodiments, the storage address is, for example, information indicating an address such as an address pointer, an address itself, or an address offset.
在现有技术中,如图1b所示,通常当分区1用于存储大文件时,索引节点区往往有很多空间使用不完,所以造成存储空间的浪费。在本实施例中,将索引节点的剩余区域也作为存储文件的存储空间来使用,所以降低了对存 储空间的浪费,提高了存储空间的利用率。In the prior art, as shown in FIG. 1b, when the partition 1 is used to store large files, the index node area often has a lot of space to use, thus causing waste of storage space. In this embodiment, the remaining area of the index node is also used as the storage space of the storage file, so the storage is reduced. The waste of storage space increases the utilization of storage space.
具体来说,请参考图9所示,为根据图所8示方法布局文件系统之后,文件系统在存储设备上的布局示意图。Specifically, please refer to FIG. 9 , which is a schematic diagram of the layout of the file system on the storage device after the file system is laid out according to the method shown in FIG. 8 .
可选的,便于高效的利用存储空间,所以该方法还包括:当在索引节点区为索引节点分配空间时,从共享区的第一地址端向第二地址端方向进行分配;当在共享区为文件分配空间时,从共享区的第二地址端向第一地址端方向进行分配。具体来说,第一地址端例如为低地址端,第二地址端例如为高地址端。Optionally, the storage space is conveniently utilized, so the method further includes: when the index node is allocated space for the index node, the first address end of the shared area is allocated to the second address end; when in the shared area When space is allocated for a file, allocation is made from the second address end of the shared area to the first address end. Specifically, the first address end is, for example, a low address end, and the second address end is, for example, a high address end.
基于与图8所示方法同一发明构思,本申请实施例提提供一种文件系统,该文件系统包括:超级块区、位图区、共享区。其中,每个区的含义及布局与前述图8所示方法及其实施例所描述的相同,所以在此不再赘述。Based on the same inventive concept as the method shown in FIG. 8, the embodiment of the present application provides a file system, where the file system includes: a super block area, a bitmap area, and a shared area. The meaning and layout of each area are the same as those described in the foregoing method shown in FIG. 8 and its embodiments, and therefore are not described herein again.
接下来请参考图10所示,为本申请实施例提供的一种在文件系统中创建文件的方法流程图。该文件系统在存储设备上的布局方式例如是按照图8所示的布局方式进行的。Next, please refer to FIG. 10, which is a flowchart of a method for creating a file in a file system according to an embodiment of the present application. The layout of the file system on the storage device is performed, for example, in accordance with the layout shown in FIG.
如图10所示,该方法包括:As shown in FIG. 10, the method includes:
步骤401:接收用于创建文件的请求;所述请求中包括所述文件的大小;Step 401: Receive a request for creating a file, where the request includes a size of the file.
步骤402:根据位图区中的使用标识确定共享区中未被使用的数据块;Step 402: Determine, according to the usage identifier in the bitmap area, an unused data block in the shared area.
步骤403:根据未被使用的数据块的数量及大小确定共享区中的剩余容量的大小;Step 403: Determine the size of the remaining capacity in the shared area according to the number and size of the unused data blocks.
步骤404:根据所述文件的大小和剩余容量的大小确定剩余容量是否足够创建所述文件以及存储所述文件对应的索引节点;Step 404: Determine, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file and store an index node corresponding to the file.
步骤405:当剩余容量足够存储所述文件以及存储所述文件对应的索引节点时,在未被使用的数据块上创建所述文件并将所述文件的存储地址记录在对应的索引节点中;Step 405: When the remaining capacity is sufficient to store the file and store the index node corresponding to the file, create the file on the unused data block and record the storage address of the file in the corresponding index node;
步骤406:将位图区中与所述存储地址和所述索引节点对应的数据块的使用标识更改为表示所述数据块已被使用的值。Step 406: Change the usage identifier of the data block corresponding to the storage address and the index node in the bitmap area to a value indicating that the data block has been used.
其中,存储地址例如是地址指针,当然也可以是地址本身,或者是地址 偏量等用于指示地址的信息。The storage address is, for example, an address pointer, and may of course be the address itself or an address. A bias or the like is used to indicate information of an address.
由此可以看出,相较于现有技术中,即使索引节点区还有剩余存储空间,而当确定出数据块区的剩余空间不足时便无法创建新的文件的情况,本申请实施例中,因为索引节点和文件共同使用同一个共享区,所以只要共享区中有足够的存储空间存储文件和文件对应的索引节点,即可存储文件,所以提高了存储空间的利用率,降低了对存储空间的浪费。It can be seen that, in the prior art, even if there is a remaining storage space in the index node area, and a new file cannot be created when it is determined that the remaining space of the data block area is insufficient, in the embodiment of the present application, Because the index node and the file use the same shared area together, as long as there is enough storage space in the shared area to store the file and the corresponding index node of the file, the file can be stored, thereby improving the utilization of the storage space and reducing the storage. The waste of space.
如前所述,在共享区为索引节点分配存储空间时,是从低地址端向高地址端分配。而在创建文件时,是从高地址端向低地址端分配存储空间。如此一来,索引节点所占用的空间和文件所占用的空间之间是一个完整的连续的存储空间,便于存储各类大小的数据,避免了随意分配空间之后,共享区有几个不连续的存储空间,这样能存储的文件的大小容易被限制,所以本实施例中的方法可以进一步提高存储空间的利用率。As described above, when the storage area is allocated to the index node in the shared area, it is allocated from the low address end to the high address end. When creating a file, the storage space is allocated from the high address side to the low address side. In this way, the space occupied by the index node and the space occupied by the file is a complete continuous storage space, which is convenient for storing various sizes of data, and avoids the need to randomly allocate space, and the shared area has several discontinuities. The storage space, such that the size of the file that can be stored is easily limited, so the method in this embodiment can further improve the utilization of the storage space.
可选的,步骤406之后,该方法还包括:更新超级块区中记录的共享区中存储的所有索引节点占用的空间大小值以及共享区中存储的所有文件占用的空间大小值。因为通过步骤401至步骤406,共享区中的索引节点占用的空间和文件占用的空间已经发生变化,所以在步骤406之后要进行更新。如此可以使得超级块能够记录最新的情况,便于后续对整个分区的管理。Optionally, after step 406, the method further includes: updating a space size value occupied by all index nodes stored in the shared area recorded in the super block area and a space size value occupied by all files stored in the shared area. Since the space occupied by the index node in the shared area and the space occupied by the file have changed through steps 401 to 406, the update is performed after step 406. This allows the superblock to keep track of the latest situation and facilitate subsequent management of the entire partition.
以上描述了创建文件的过程,接下来将描述如何查找文件的过程。请参考图11所示,为本申请实施例提供的一种文件系统中的查找文件的方法流程图。The process of creating a file is described above, and the process of how to find a file will be described next. Please refer to FIG. 11 , which is a flowchart of a method for searching for a file in a file system according to an embodiment of the present application.
如图11所示,该方法包括:As shown in FIG. 11, the method includes:
步骤501:接收查询文件的请求,所述请求中包含所述文件的属性;Step 501: Receive a request for querying a file, where the request includes an attribute of the file;
步骤502:在共享区中查询与所述属性对应的索引节点;Step 502: Query an index node corresponding to the attribute in the shared area.
步骤503:根据所述对应的索引节点中记录的存储地址在共享区中查找与存储地址对应的文件。Step 503: Search for a file corresponding to the storage address in the shared area according to the storage address recorded in the corresponding index node.
在步骤501中,接收查询文件的请求,可以是由查询操作本身触发的请求,也可以是基于其它操作请求触发的请求,例如删除该文件的操作,也会 先触发查找文件的过程。In step 501, the request for receiving the query file may be a request triggered by the query operation itself, or may be a request triggered by another operation request, for example, deleting the file, and The process of triggering a file search first.
当根据图11所示的方法查找到该文件之后,可以对该文件进行所需要的操作,例如删除。After the file is found according to the method shown in FIG. 11, the file may be subjected to a desired operation, such as deletion.
当删除文件之后,该方法还包括:将位图区中与该存储地址和索引节点对应的使用标识修改为表示该存储地址和索引节点对应的数据块已被使用的值。After deleting the file, the method further includes: modifying the usage identifier corresponding to the storage address and the index node in the bitmap area to a value indicating that the storage address and the data block corresponding to the index node have been used.
基于同一发明构思,参考图12所示,为本申请实施例提供的一种文件系统的管理装置的功能框图,用于实现本发明图2至图5所示的文件系统管理方法,本实施例中所涉及术语的含义请参考前述实施例中所描述的内容。该文件系统的管理装置包括:数据块位图分配模块601,用于用于在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;元数据分区分配模块602,用于在存储设备的第二连续的地址段上为所述文件系统分配N个分区,所述N个分区的每个分区分别用于存储所述每个分区的系统元数据;N为大于1的整数;数据块分配模块603,用于在存储设备第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;其中,所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。Based on the same inventive concept, with reference to FIG. 12, it is a functional block diagram of a file system management apparatus according to an embodiment of the present application, which is used to implement the file system management method shown in FIG. 2 to FIG. 5 of the present invention. For the meaning of the terms involved in the above, please refer to the contents described in the foregoing embodiments. The file system management device includes: a data block bitmap allocation module 601, configured to allocate a data block bitmap area for the file system on a first consecutive address segment of the storage device; the metadata partition allocation module 602 </ RTI> for allocating N partitions to the file system on a second consecutive address segment of the storage device, each partition of the N partitions respectively for storing system metadata of each partition; N is greater than An integer of 1; a data block allocating module 603, configured to allocate, for the file system, a shared data block area of the N partitions on a third consecutive address segment of the storage device, where the shared data block area is used to store a file; The data block bitmap area is configured to store a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first An identifier is used; wherein the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
可选的,每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块区中的文件的存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识;所述装置还包括:Optionally, each partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record a storage address of a file stored in the shared data block area; the index node bitmap The device is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second usage identifiers;
接收模块,用于接收在所述N个分区中的第i个分区创建文件的请求;所述请求中包括所述文件的大小;a receiving module, configured to receive a request for creating a file in an i-th partition of the N partitions; the request includes a size of the file;
处理模块,用于通过所述第一使用标识确定所述共用数据块区中未被使 用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第i个分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;将所述数据块位图中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。a processing module, configured to determine, by using the first usage identifier, that the shared data block area is not enabled a data block; determining a size of the remaining capacity in the shared data block area according to the number and size of the unused data blocks; determining the remaining according to the size of the file and the size of the remaining capacity Whether the capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determine a storage address to be stored in the shared data block area, and an index node bit in the i-th partition The map area is searched for whether there is an unused index node; when there is an unused index node, one of the unused index nodes is selected, and the attribute of the file and the storage address are written; Changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been used; storing the file in the shared data block area a data block corresponding to the storage address; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap to represent the data The value that the block has been used.
可选的,每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,所述装置还包括:Optionally, each partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The device area is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second usage identifiers, and the device further includes:
接收模块,用于接收在所述N个分区中的分区j删除文件的请求;a receiving module, configured to receive a request for deleting a file in the partition j in the N partitions;
处理模块,用于根据所述文件的属性在所述分区j的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述分区j的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。a processing module, configured to search, according to an attribute of the file, a corresponding index node in an index node area of the partition j: determining, according to a storage address recorded by the index node, data corresponding to the storage address in the shared data block Blocking; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; and using an index node bitmap of the partition j The second usage identifier of the corresponding index node in the zone is changed to a value indicating that the corresponding index node is not used.
前述图2至图5实施例中的文件系统管理方法中的各种变化方式和具体实例同样适用于本实施例的管理装置,通过前述对文件系统管理方法的详细描述,本领域技术人员可以清楚的知道本实施例中管理装置的实施方法,所以为了说明书的简洁,在此不再详述。 The various changes and specific examples in the foregoing file system management method in the foregoing embodiments of FIG. 2 to FIG. 5 are also applicable to the management apparatus of the present embodiment. The foregoing detailed description of the file system management method can be clearly understood by those skilled in the art. Knowing the implementation method of the management device in this embodiment, for the sake of brevity of the description, it will not be described in detail herein.
基于同一发明构思,参考图13所示,为本申请实施例提供的一种电子设备的结构框图,用于实现本发明图2至图5所示的文件系统管理方法,本实施例中所涉及的术语的含义请参考前述实施例中所描述的内容。该电子设备包括:处理器701、发送器702、接收器703、存储器704和输入装置705。处理器701具体可以是通用的中央处理器(CPU),可以是特定应用集成电路(英文:Application Specific Integrated Circuit,简称:ASIC),可以是一个或多个用于控制程序执行的集成电路。存储器704的数量可以是一个或多个。存储器704例如为硬盘、U盘。这些存储器704、接收器703和发送器702通过总线与处理器701相连接。接收器703和发送器702用于与外部设备进行网络通信,具体可以通过以太网、无线接入网、无线局域网等网络与外部设备进行通信。接收器703和发送器702可以是物理上相互独立的两个元件,也可以是物理上的同一个元件。输入装置705可以例如为键盘、鼠标、触摸板。Based on the same inventive concept, with reference to FIG. 13 , a structural block diagram of an electronic device according to an embodiment of the present application is used to implement the file system management method shown in FIG. 2 to FIG. 5 of the present invention. For the meaning of the terms, please refer to the content described in the foregoing embodiments. The electronic device includes a processor 701, a transmitter 702, a receiver 703, a memory 704, and an input device 705. The processor 701 may be a general-purpose central processing unit (CPU), may be an application specific integrated circuit (ASIC), and may be one or more integrated circuits for controlling program execution. The number of memories 704 can be one or more. The memory 704 is, for example, a hard disk or a USB disk. These memories 704, receiver 703 and transmitter 702 are connected to the processor 701 via a bus. The receiver 703 and the transmitter 702 are configured to perform network communication with an external device, and specifically communicate with an external device through a network such as an Ethernet, a wireless access network, or a wireless local area network. Receiver 703 and transmitter 702 may be physically separate components or may be physically identical components. The input device 705 can be, for example, a keyboard, a mouse, or a touch pad.
具体来说,处理器701,用于在存储器704的第一连续的地址段上为所述文件系统分配一个数据块位图区;在存储器704的第二连续的地址段上为所述文件系统分配N个分区,所述N个分区的每个分区分别用于存储所述每个分区的系统元数据;N为大于1的整数;在存储器704的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;其中,所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。Specifically, the processor 701 is configured to allocate a data block bitmap area to the file system on a first consecutive address segment of the memory 704; and to the file system on a second consecutive address segment of the memory 704. N partitions are allocated, each of the N partitions being used to store system metadata for each partition; N is an integer greater than 1; the file is on a third consecutive address segment of memory 704 The system allocates a shared data block area of the N partitions, the shared data block area is used to store a file; the data block bitmap area is used to store a first use identifier, and the first use identifier is used to indicate the Whether the data blocks in the shared data block area are used, each of the data blocks corresponding to one of the first use identifiers; wherein the first consecutive address segment, the second consecutive address segment, and the first Three consecutive address segments form a contiguous address segment.
可选的,每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块区中的文件的存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识。输入装置705用于接收在所述N个分区中的第i个分区创建文件的请求;所述请求 中包括所述文件的大小;处理器701还用于:通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第i个分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;将所述数据块位图中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。Optionally, each partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record a storage address of a file stored in the shared data block area; the index node bitmap The area is used to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second usage identifiers. The input device 705 is configured to receive a request for creating a file in an i-th partition of the N partitions; the request Included in the size of the file; the processor 701 is further configured to: determine, by using the first usage identifier, an unused data block in the shared data block area; according to the number and size of the unused data blocks Determining a size of the remaining capacity in the shared data block area; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file Determining whether the file is to be stored in a storage address in the shared data block area, and searching for an unused index node in an index node bitmap area of the i-th partition; when there is an unused When the node is indexed, one of the unused index nodes is selected, the attribute of the file and the storage address are written; and the corresponding location of the index node in the bitmap area corresponding to the one index node is Changing the second usage identifier to a value indicating that the one index node has been used; storing the file in the shared data block area corresponding to the storage address And the first usage identifier of the data block corresponding to the storage address in the data block bitmap is changed to a value indicating that the data block has been used.
可选的,每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识。输入装置705用于接收在所述N个分区中的分区j删除文件的请求。处理器701还用于:根据所述文件的属性在所述分区j的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述分区j的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。Optionally, each partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The map area is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second usage identifiers. The input device 705 is configured to receive a request for deleting a file by the partition j in the N partitions. The processor 701 is further configured to: search, according to an attribute of the file, a corresponding index node in an index node area of the partition j: determining, according to a storage address recorded by the index node, that the shared data block corresponds to the storage address Data block; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; and indexing the partition j The second usage identifier of the corresponding index node in the bitmap area is changed to a value indicating that the corresponding index node is not used.
前述图2至图5实施例中的文件系统管理方法中的各种变化方式和具体实例同样适用于本实施例的电子设备,通过前述对文件系统管理方法的详细描述,本领域技术人员可以清楚的知道本实施例中电子设备的实施方法,所以为了说明书的简洁,在此不再详述。 The various changes and specific examples in the foregoing file system management method in the foregoing embodiments of FIG. 2 to FIG. 5 are also applicable to the electronic device of the present embodiment. The foregoing detailed description of the file system management method can be clearly understood by those skilled in the art. The implementation method of the electronic device in this embodiment is known, so for the sake of brevity of the description, it will not be described in detail herein.
基于同一发明构思,参考图14所示,为本申请实施例提供的另一种文件系统的管理装置的功能框图,用于实现本发明图6至图7b所示的文件系统管理方法,本实施例中所涉及术语的含义请参考前述实施例中所描述的内容。该管理装置包括:数据块位图分配模块801,用于在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;元数据分区分配模块802,用于在所述存储设备的第二连续的地址段上为所述文件系统分配第一分区,所述第一分区用于存储所述第一分区的系统元数据;在所述存储设备的第三连续的地址段上为所述文件系统分配第二分区,所述第二分区用于存储所述第二分区的系统元数据;数据块分配模块803,用于在所述存储设备的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区;其中,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;所述第一连续的地址段、所述第二连续的地址段、所述第三连续的地址段和所述第四连续的地址段组成连续的地址段,所述第四连续的地址段位于所述第二连续的地址段和所述第三连续的地址段之间。Based on the same inventive concept, with reference to FIG. 14 , a functional block diagram of another file system management apparatus provided by an embodiment of the present application is used to implement the file system management method shown in FIG. 6 to FIG. 7 b of the present invention. For the meaning of the terms involved in the examples, please refer to the contents described in the foregoing embodiments. The management device includes: a data block bitmap allocation module 801, configured to allocate a data block bitmap area for the file system on a first consecutive address segment of the storage device; and a metadata partition allocation module 802 for Assigning, to the file system, a first partition on a second consecutive address segment of the storage device, the first partition for storing system metadata of the first partition; and a third consecutive address of the storage device Assigning a second partition to the file system, the second partition is configured to store system metadata of the second partition, and the data block allocating module 803 is configured to be in a fourth consecutive address segment of the storage device. And allocating, for the file system, the shared data block area of the first partition and the second partition; wherein the shared data block area is used for storing a file; and the data block bitmap area is used for storing the first Using the identifier, the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first usage identifiers; the first consecutive address segment, The second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a contiguous address segment, and the fourth consecutive address segment is located at the second consecutive address segment and Between the third consecutive address segments.
可选的,第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识;所述装置还包括:Optionally, the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The mapping area is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second usage identifiers;
接收模块,用于接收在所述第一分区创建文件的请求;所述请求中包括所述文件的大小;a receiving module, configured to receive a request for creating a file in the first partition; the request includes a size of the file;
处理模块,用于通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件 时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第一分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;将所述数据块位图中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。a processing module, configured to determine, by using the first usage identifier, an unused data block in the shared data block region; determining a remaining portion in the shared data block region according to the number and size of the unused data blocks a size of the capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file Determining whether the file is to be stored in a storage address in the shared data block area, and searching for an unused index node in an index node bitmap area of the first partition; when there is an unused index a node, selecting one of the unused index nodes, writing an attribute of the file and the storage address; and referring to the index node in the index node corresponding to the one index node The second usage identifier is changed to a value indicating that the one index node has been used; the file is stored in a data block corresponding to the storage address in the shared data block area; and the data block bitmap is The first usage identifier of the data block corresponding to the storage address is changed to a value indicating that the data block has been used.
可选的,第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,Optionally, the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The map area is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second usage identifiers.
所述装置还包括:The device also includes:
接收模块,用于接收在所述第一分区删除文件的请求;a receiving module, configured to receive a request to delete a file in the first partition;
处理模块,用于根据所述文件的属性在所述第一分区的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述第一分区的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。a processing module, configured to search, according to an attribute of the file, a corresponding index node in an index node area of the first partition: determining, according to a storage address recorded by the index node, a corresponding to the storage address in the shared data block a data block; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; and indexing the first partition The second usage identifier of the corresponding index node in the bitmap area is changed to a value indicating that the corresponding index node is not used.
前述图6至图7b实施例中的文件系统管理方法中的各种变化方式和具体实例同样适用于本实施例的管理装置,通过前述对文件系统管理方法的详细描述,本领域技术人员可以清楚的知道本实施例中管理装置的实施方法,所以为了说明书的简洁,在此不再详述。The various changes and specific examples in the foregoing file system management method in the foregoing embodiments of FIG. 6 to FIG. 7b are also applicable to the management apparatus of the present embodiment. The foregoing detailed description of the file system management method can be clearly understood by those skilled in the art. Knowing the implementation method of the management device in this embodiment, for the sake of brevity of the description, it will not be described in detail herein.
基于同一发明构思,参考图15所示,为本申请实施例提供的一种电子设备的结构框图,用于实现本发明图6至图7b所示的文件系统管理方法,本实施例中所涉及的术语的含义请参考前述实施例中所描述的内容。该电子设备 包括:处理器901、发送器902、接收器903、存储器904和输入装置905。处理器901具体可以是通用的中央处理器(CPU),可以是特定应用集成电路(英文:Application Specific Integrated Circuit,简称:ASIC),可以是一个或多个用于控制程序执行的集成电路。存储器904的数量可以是一个或多个。存储器904例如为硬盘为U盘。这些存储器904、接收器903和发送器902通过总线与处理器901相连接。接收器903和发送器902用于与外部设备进行网络通信,具体可以通过以太网、无线接入网、无线局域网等网络与外部设备进行通信。接收器903和发送器902可以是物理上相互独立的两个元件,也可以是物理上的同一个元件。输入装置905例如为鼠标、键盘、触摸板。Based on the same inventive concept, with reference to FIG. 15 , a structural block diagram of an electronic device according to an embodiment of the present application is used to implement the file system management method shown in FIG. 6 to FIG. 7 b of the present invention. For the meaning of the terms, please refer to the content described in the foregoing embodiments. The electronic device The processor 901, the transmitter 902, the receiver 903, the memory 904, and the input device 905 are included. The processor 901 may be a general-purpose central processing unit (CPU), may be an application specific integrated circuit (ASIC), and may be one or more integrated circuits for controlling program execution. The number of memories 904 can be one or more. The memory 904 is, for example, a hard disk as a USB flash drive. These memories 904, receiver 903 and transmitter 902 are connected to the processor 901 via a bus. The receiver 903 and the transmitter 902 are configured to perform network communication with an external device, and specifically communicate with an external device through a network such as an Ethernet, a wireless access network, or a wireless local area network. The receiver 903 and the transmitter 902 may be physically separate components or may be physically the same component. The input device 905 is, for example, a mouse, a keyboard, or a touch panel.
具体来说,处理器901,用于在存储器904的第一连续的地址段上为所述文件系统分配一个数据块位图区;在存储器904的第二连续的地址段上为所述文件系统分配第一分区,所述第一分区用于存储所述第一分区的系统元数据;在存储器904的第三连续的地址段上为所述文件系统分配第二分区,所述第二分区用于存储所述第二分区的系统元数据;在存储器904的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区;其中,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;所述第一连续的地址段、所述第二连续的地址段、所述第三连续的地址段和所述第四连续的地址段组成连续的地址段,所述第四连续的地址段位于所述第二连续的地址段和所述第三连续的地址段之间。Specifically, the processor 901 is configured to allocate a data block bitmap area to the file system on a first consecutive address segment of the memory 904; and to the file system on a second consecutive address segment of the memory 904. Allocating a first partition for storing system metadata of the first partition; assigning a second partition to the file system on a third consecutive address segment of the memory 904, the second partition And storing the system metadata of the second partition; and sharing, on the fourth consecutive address segment of the memory 904, the shared data block area of the first partition and the second partition for the file system; The shared data block area is configured to store a file; the data block bitmap area is configured to store a first use identifier, and the first use identifier is used to indicate whether a data block in the shared data block area is used, and each The data block corresponds to one of the first usage identifiers; the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a continuous the address of Between the fourth consecutive addresses in the second consecutive addresses and the third consecutive addresses.
可选的,第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识。Optionally, the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The map area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second usage identifiers.
输入装置905用于接收在第一分区创建文件的请求;所述请求中包括所述文件的大小;处理器901还用于:通过所述第一使用标识确定所述共用数 据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第一分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;将所述数据块位图中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。The input device 905 is configured to receive a request for creating a file in the first partition, where the request includes a size of the file, and the processor 901 is further configured to: determine, by using the first usage identifier, the shared number Determining an unused data block in the block area; determining a size of the remaining capacity in the shared data block area according to the number and size of the unused data blocks; according to the size of the file and the remaining capacity a size, determining whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be stored in a storage address in the shared data block area, and at the first The indexed index node of the partition finds whether there is an unused index node; when there is an unused index node, selects one of the unused index nodes, writes the attributes of the file and The storage address; changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been used; storing the file in the And a data block corresponding to the storage address in the shared data block area; changing the first use identifier of the data block corresponding to the storage address in the data block bitmap Value represents the data block has been used.
可选的,第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识。Optionally, the first partition includes an index node area and an index node bitmap area, where the index node of the index node area is used to record attributes of the file stored in the shared data block and a storage address; the index node bit The map area is configured to store a second usage identifier, where the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second usage identifiers.
输入装置905用于接收在第一分区删除文件的请求;处理器901还用于:根据所述文件的属性在所述第一分区的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述第一分区的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。The input device 905 is configured to receive a request for deleting a file in the first partition; the processor 901 is further configured to: search, according to an attribute of the file, a corresponding index node in an index node area of the first partition: record according to the index node The storage address determines a data block corresponding to the storage address in the shared data block; changing the first use identifier of the data block corresponding to the storage address in the data block bitmap area to indicate the a value that the data block is not used; changing the second usage identifier of the corresponding index node in the index node bitmap area of the first partition to a value indicating that the corresponding index node is not used.
前述图6至图7b实施例中的文件系统管理方法中的各种变化方式和具体实例同样适用于本实施例的电子设备,通过前述对文件系统管理方法的详细描述,本领域技术人员可以清楚的知道本实施例中电子设备的实施方法,所以为了说明书的简洁,在此不再详述。The various changes and specific examples in the foregoing file system management method in the foregoing embodiments of FIG. 6 to FIG. 7b are also applicable to the electronic device of the present embodiment. The foregoing detailed description of the file system management method can be clearly understood by those skilled in the art. The implementation method of the electronic device in this embodiment is known, so for the sake of brevity of the description, it will not be described in detail herein.
基于同一发明构思,参考图16所示,为本申请实施例提供的一种文件系 统管理装置的功能框图,用于实现本发明图8至图11所示的文件系统管理方法,本实施例中所涉及术语的含义请参考前述实施例中所描述的内容。该管理装置包括:超级块分配模块1001,用于在存储设备的第一连续的地址段上为所述文件系统分配超级块区,所述超级块区用于记录所述文件系统的系统信息;所述系统信息包括所述文件系统的类型、大小;位图分配模块1002,用于在所述存储设备的第二连续的地址段上为所述文件系统分配位图区;共享区分配模块1003,用于在所述存储设备的第三连续的地址段上为所述文件系统分配共享区,所述共享区用于存储文件与索引节点;所述索引节点用于记录存储在所述共享区中的文件的存储地址;所述位图区用于存储使用标识,所述使用标识用于表示所述共享区中的数据块是否被使用,每个所述数据块对应一个所述使用标识;所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。Based on the same inventive concept, referring to FIG. 16 , a file system provided by an embodiment of the present application is provided. The functional block diagram of the management device is used to implement the file system management method shown in FIG. 8 to FIG. 11 of the present invention. For the meanings of the terms involved in this embodiment, refer to the content described in the foregoing embodiments. The management device includes: a super block allocation module 1001, configured to allocate a super block area for the file system on a first consecutive address segment of the storage device, where the super block area is used to record system information of the file system; The system information includes a type and a size of the file system; the bitmap allocation module 1002 is configured to allocate a bitmap area to the file system on a second consecutive address segment of the storage device; the shared area allocation module 1003 And a shared area for the file system on a third consecutive address segment of the storage device, where the shared area is used for storing files and an index node; and the index node is used for recording and storing in the shared area. a storage address of the file; the bitmap area is configured to store a usage identifier, where the usage identifier is used to indicate whether a data block in the shared area is used, and each of the data blocks corresponds to one of the usage identifiers; The first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
可选的,所述装置还包括处理模块,用于当在所述共享区为所述索引节点分配空间时,从所述共享区的第一地址端向第二地址端方向进行分配;当在所述共享区为所述文件分配空间时,从所述共享区的所述第二地址端向所述第一地址端方向进行分配。Optionally, the device further includes: a processing module, configured to allocate from the first address end to the second address end of the shared area when the shared area allocates space for the index node; When the shared area allocates space for the file, the shared area is allocated from the second address end of the shared area to the first address end.
可选的,所述装置还包括:Optionally, the device further includes:
接收模块,用于接收用于创建文件的请求;所述请求中包括所述文件的大小;a receiving module, configured to receive a request for creating a file; the request includes a size of the file;
处理模块,用于根据所述使用标识确定所述共享区中未被使用的数据块;根据所述未被使用的数据块的数量及大小确定所述共享区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小确定所述剩余容量是否足够创建所述文件以及存储所述文件对应的索引节点;当所述剩余容量足够存储所述文件以及存储所述文件对应的索引节点时,在所述未被使用的数据块上创建所述文件并将所述文件的存储地址记录在所述对应的索引节点中;将所述位图区中与所述存储地址和所述索引节点对应的数据块的使用标识更改为表示所述数据块已被使用的值。 a processing module, configured to determine, according to the usage identifier, an unused data block in the shared area; determining a size of a remaining capacity in the shared area according to the number and size of the unused data blocks; Determining a size of the file and a size of the remaining capacity to determine whether the remaining capacity is sufficient to create the file and storing an index node corresponding to the file; when the remaining capacity is sufficient to store the file and store an index corresponding to the file a node, creating the file on the unused data block and recording a storage address of the file in the corresponding index node; storing the bitmap area with the storage address and the The usage identifier of the data block corresponding to the index node is changed to a value indicating that the data block has been used.
可选的,处理模块还用于:更新所述超级块中记录的所述共享区中存储的所有所述索引节点占用的空间大小值以及所述共享区中存储的所有所述文件占用的空间大小值。Optionally, the processing module is further configured to: update a space size value occupied by all the index nodes stored in the shared area recorded in the super block, and a space occupied by all the files stored in the shared area Size value.
可选的,所述装置还包括:Optionally, the device further includes:
接收模块,用于接收查询文件的请求,所述请求中包含所述文件的属性;a receiving module, configured to receive a request for querying a file, where the request includes an attribute of the file;
处理模块,用于在所述共享区中查询与所述属性对应的索引节点;根据所述对应的索引节点中记录的存储地址在所述共享区中查找与所述存储地址对应的文件。a processing module, configured to query an index node corresponding to the attribute in the shared area; and search for a file corresponding to the storage address in the shared area according to the storage address recorded in the corresponding index node.
前述图8至图11实施例中的文件系统管理方法中的各种变化方式和具体实例同样适用于本实施例的管理装置,通过前述对查找文件的方法的详细描述,本领域技术人员可以清楚的知道本实施例中管理装置的实施方法,所以为了说明书的简洁,在此不再详述。The various changes and specific examples in the foregoing file system management method in the foregoing embodiments of FIG. 8 to FIG. 11 are also applicable to the management apparatus of the present embodiment. The foregoing detailed description of the method for searching for a file can be clearly understood by those skilled in the art. Knowing the implementation method of the management device in this embodiment, for the sake of brevity of the description, it will not be described in detail herein.
基于同一发明构思,参考图17所示,为本申请实施例提供的一种电子设备的结构框图,用于实现本发明图8至图11所示的文件系统管理方法,本实施例中所涉及的术语的含义请参考前述实施例中所描述的内容。该电子设备包括:处理器1201、发送器1202、接收器1203、存储器1204和输入装置1205。处理器1201具体可以是通用的中央处理器(CPU),可以是特定应用集成电路(英文:Application Specific Integrated Circuit,简称:ASIC),可以是一个或多个用于控制程序执行的集成电路。存储器1204的数量可以是一个或多个。存储器1204例如为硬盘为U盘。这些存储器1204、接收器1203和发送器1202通过总线与处理器1201相连接。接收器1203和发送器1202用于与外部设备进行网络通信,具体可以通过以太网、无线接入网、无线局域网等网络与外部设备进行通信。接收器1203和发送器1202可以是物理上相互独立的两个元件,也可以是物理上的同一个元件。输入装置1205可以为鼠标、键盘或者触控板。Based on the same inventive concept, with reference to FIG. 17, a structural block diagram of an electronic device according to an embodiment of the present application is used to implement the file system management method shown in FIG. 8 to FIG. 11 of the present invention. For the meaning of the terms, please refer to the content described in the foregoing embodiments. The electronic device includes a processor 1201, a transmitter 1202, a receiver 1203, a memory 1204, and an input device 1205. The processor 1201 may be a general-purpose central processing unit (CPU), may be an application specific integrated circuit (ASIC), and may be one or more integrated circuits for controlling program execution. The number of memories 1204 can be one or more. The memory 1204 is, for example, a hard disk as a USB flash drive. These memories 1204, receivers 1203, and transmitters 1202 are coupled to the processor 1201 via a bus. The receiver 1203 and the transmitter 1202 are configured to perform network communication with an external device, and specifically communicate with an external device through a network such as an Ethernet, a wireless access network, or a wireless local area network. Receiver 1203 and transmitter 1202 may be physically separate components or may be physically identical components. The input device 1205 can be a mouse, a keyboard, or a touchpad.
具体来说,处理器1201,用于在存储器1204的第一连续的地址段上为所述文件系统分配超级块区,所述超级块区用于记录所述文件系统的系统信息; 所述系统信息包括所述文件系统的类型、大小;在存储器1204的第二连续的地址段上为所述文件系统分配位图区;在存储器1204的第三连续的地址段上为所述文件系统分配共享区,所述共享区用于存储文件与索引节点;所述索引节点用于记录存储在所述共享区中的文件的存储地址;所述位图区用于存储使用标识,所述使用标识用于表示所述共享区中的数据块是否被使用,每个所述数据块对应一个所述使用标识;所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。Specifically, the processor 1201 is configured to allocate a super block area to the file system on a first consecutive address segment of the memory 1204, where the super block area is used to record system information of the file system; The system information includes a type and size of the file system; a bitmap area is allocated to the file system on a second consecutive address segment of the memory 1204; and the file is on a third consecutive address segment of the memory 1204. The system allocates a shared area for storing a file and an index node; the index node is configured to record a storage address of a file stored in the shared area; and the bitmap area is configured to store a usage identifier, Using an identifier for indicating whether a data block in the shared area is used, each of the data blocks corresponding to one of the usage identifiers; the first consecutive address segment, the second consecutive address segment, and the The third consecutive address segment constitutes a contiguous address segment.
可选的,处理器1201还用于:当在所述共享区为所述索引节点分配空间时,从所述共享区的第一地址端向第二地址端方向进行分配;当在所述共享区为所述文件分配空间时,从所述共享区的所述第二地址端向所述第一地址端方向进行分配。Optionally, the processor 1201 is further configured to: when the shared area allocates space for the index node, allocate from a first address end to a second address end of the shared area; when in the sharing When the area allocates space for the file, the area is allocated from the second address end of the shared area to the first address end.
可选的,输入装置1205用于接收用于创建文件的请求;所述请求中包括所述文件的大小;处理器1201还用于:根据所述使用标识确定所述共享区中未被使用的数据块;根据所述未被使用的数据块的数量及大小确定所述共享区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小确定所述剩余容量是否足够创建所述文件以及存储所述文件对应的索引节点;当所述剩余容量足够存储所述文件以及存储所述文件对应的索引节点时,在所述未被使用的数据块上创建所述文件并将所述文件的存储地址记录在所述对应的索引节点中;将所述位图区中与所述存储地址和所述索引节点对应的数据块的使用标识更改为表示所述数据块已被使用的值。Optionally, the input device 1205 is configured to receive a request for creating a file, where the request includes a size of the file, and the processor 1201 is further configured to: determine, according to the usage identifier, that the shared area is not used. a data block; determining a size of the remaining capacity in the shared area according to the number and size of the unused data blocks; determining whether the remaining capacity is sufficient to create a location according to the size of the file and the size of the remaining capacity a file and an index node corresponding to the file; when the remaining capacity is sufficient to store the file and store an index node corresponding to the file, create the file on the unused data block and Recording a storage address of the file in the corresponding index node; changing a usage identifier of the data block corresponding to the storage address and the index node in the bitmap area to indicate that the data block has been used value.
可选的,处理器1201还用于:更新所述超级块区中记录的所述共享区中存储的所有所述索引节点占用的空间大小值以及所述共享区中存储的所有所述文件占用的空间大小值。Optionally, the processor 1201 is further configured to: update a space size value occupied by all the index nodes stored in the shared area recorded in the super block area, and all the file occupations stored in the shared area. The size of the space.
可选的,输入装置1205用于接收查询文件的请求,所述请求中包含所述文件的属性;处理器1201还用于:在所述共享区中查询与所述属性对应的索引节点;根据所述对应的索引节点中记录的存储地址在所述共享区中查找与所述存储地址对应的文件。 Optionally, the input device 1205 is configured to receive a request for querying a file, where the request includes an attribute of the file, and the processor 1201 is further configured to: query an index node corresponding to the attribute in the shared area; The storage address recorded in the corresponding index node searches for a file corresponding to the storage address in the shared area.
前述图8至图11实施例中的文件系统管理方法中的各种变化方式和具体实例同样适用于本实施例的电子设备,通过前述对查找文件的方法的详细描述,本领域技术人员可以清楚的知道本实施例中电子设备的实施方法,所以为了说明书的简洁,在此不再详述。The various changes and specific examples in the foregoing file system management method in the foregoing embodiments of FIG. 8 to FIG. 11 are also applicable to the electronic device of the present embodiment. Those skilled in the art can clearly understand the foregoing detailed description of the method for searching for a file. The implementation method of the electronic device in this embodiment is known, so for the sake of brevity of the description, it will not be described in detail herein.
申请实施例中提供的一个或多个技术方案,至少具有如下技术效果或优点:One or more technical solutions provided in the application embodiments have at least the following technical effects or advantages:
本申请实施例中,每个分区的数据块区共用,然后所有分区也共用同一个数据块位图。当需要在某个分区存储数据时,只要数据块位图显示数据块区有足够的剩余容量,那么就可以在数据块区存储数据。而在现有技术中,当需要在某个分区存储数据时,如果某个分区的数据块位图显示数据块区域没有足够剩余容量时,便无法存储数据。而某个分区的相邻分区还有空间,但是由于布局方式的限制,数据也无法存储到相邻分区的数据块区中。由此可见,相较于现有技术,本申请实施例的文件系统管理方法使得存储空间能够被充分利用,减少了被浪费的空间。In the embodiment of the present application, the data block area of each partition is shared, and then all the partitions also share the same data block bitmap. When it is necessary to store data in a certain partition, as long as the data block bitmap shows that the data block area has enough remaining capacity, the data can be stored in the data block area. In the prior art, when data needs to be stored in a certain partition, if the data block bitmap of a certain partition shows that the data block area does not have enough remaining capacity, the data cannot be stored. The adjacent partition of a partition has space, but due to the limitation of the layout, data cannot be stored in the data block area of the adjacent partition. Therefore, compared with the prior art, the file system management method of the embodiment of the present application enables the storage space to be fully utilized, thereby reducing the wasted space.
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。 It will be apparent to those skilled in the art that various modifications and changes can be made in the present application without departing from the spirit and scope of the application. Thus, it is intended that the present invention cover the modifications and variations of the present invention.

Claims (33)

  1. 一种文件系统的管理方法,其特征在于,包括:A method for managing a file system, comprising:
    在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;Allocating a data block bitmap area to the file system on a first consecutive address segment of the storage device;
    在所述存储设备的第二连续的地址段上为所述文件系统分配N个分区,所述N个分区的每个分区分别用于存储所述每个分区的系统元数据;N为大于1的整数;Allocating N partitions to the file system on a second consecutive address segment of the storage device, each partition of the N partitions respectively for storing system metadata of each partition; N is greater than 1 Integer
    在所述存储设备的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;其中,所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。Allocating a shared data block area of the N partitions for the file system on a third consecutive address segment of the storage device, the shared data block area is for storing a file; the data block bitmap area is used for Storing a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first usage identifiers; wherein the first The contiguous address segment, the second contiguous address segment, and the third contiguous address segment form a contiguous address segment.
  2. 如权利要求1所述的方法,其特征在于,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块区中的文件的存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识;The method according to claim 1, wherein each of the partitions includes an index node area and an index node bitmap area, and an index node of the index node area is used for recording in the shared data block area. a storage address of the file; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second usage Identification
    在所述存储设备的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区之后,所述方法还包括:After the shared data block area of the N partitions is allocated to the file system on the third consecutive address segment of the storage device, the method further includes:
    接收在所述N个分区中的第i个分区创建文件的请求;所述请求中包括所述文件的大小;Receiving a request to create a file in an i-th partition of the N partitions; the request includes a size of the file;
    通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;Determining, by the first usage identifier, an unused data block in the shared data block area;
    根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;Determining a size of a remaining capacity in the shared data block area according to the number and size of the unused data blocks;
    根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足 够创建所述文件;Determining whether the remaining capacity is sufficient according to the size of the file and the size of the remaining capacity Enough to create the file;
    当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第i个分区的索引节点位图区查找是否有未被使用的索引节点;Determining, when the remaining capacity is sufficient to create the file, a storage address to be stored in the shared data block area, and searching for an unused portion in an index node bitmap area of the i-th partition Index node;
    当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;When there is an unused index node, selecting one of the unused index nodes, writing an attribute of the file and the storage address;
    将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;Changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been used;
    将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;Storing the file in a data block corresponding to the storage address in the shared data block area;
    在所述数据块位图中将与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。The first usage identifier of the data block corresponding to the storage address is changed in the data block bitmap to a value indicating that the data block has been used.
  3. 如权利要求1所述的方法,其特征在于,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,The method of claim 1 wherein said each partition comprises an index node area and an index node bitmap area, said index node area index node for recording files stored in said common data block The attribute and the storage address; the index node bitmap area is configured to store a second usage identifier, the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second Use the logo,
    在所述存储设备的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区之后,所述方法还包括:After the shared data block area of the N partitions is allocated to the file system on the third consecutive address segment of the storage device, the method further includes:
    接收在所述N个分区中的分区j删除文件的请求;Receiving a request to delete a file by the partition j in the N partitions;
    根据所述文件的属性在所述分区j的索引节点区查找对应的索引节点:Finding a corresponding index node in an index node area of the partition j according to an attribute of the file:
    根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;Determining, according to the storage address recorded by the index node, a data block corresponding to the storage address in the shared data block;
    将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;Changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used;
    将所述分区j的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。Changing the second usage identifier of the corresponding index node in the index node bitmap area of the partition j to a value indicating that the corresponding index node is not used.
  4. 一种文件系统的管理方法,其特征在于,包括: A method for managing a file system, comprising:
    在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;Allocating a data block bitmap area to the file system on a first consecutive address segment of the storage device;
    在所述存储设备的第二连续的地址段上为所述文件系统分配第一分区,所述第一分区用于存储所述第一分区的系统元数据;Allocating, by the file system, a first partition on a second consecutive address segment of the storage device, where the first partition is configured to store system metadata of the first partition;
    在所述存储设备的第三连续的地址段上为所述文件系统分配第二分区,所述第二分区用于存储所述第二分区的系统元数据;Allocating a second partition to the file system on a third consecutive address segment of the storage device, where the second partition is configured to store system metadata of the second partition;
    在所述存储设备的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区;其中,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;所述第一连续的地址段、所述第二连续的地址段、所述第三连续的地址段和所述第四连续的地址段组成连续的地址段,所述第四连续的地址段位于所述第二连续的地址段和所述第三连续的地址段之间。Allocating a shared data block area of the first partition and the second partition to the file system on a fourth consecutive address segment of the storage device; wherein the shared data block area is used to store a file; The data block bitmap area is configured to store a first usage identifier, where the first usage identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first Using an identifier; the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a contiguous address segment, the fourth consecutive The address segment is located between the second consecutive address segment and the third consecutive address segment.
  5. 如权利要求4所述的方法,其特征在于,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识;The method of claim 4, wherein the first partition comprises an index node area and an index node bitmap area, and an index node of the index node area is used to record a file stored in the shared data block And an address of the storage node; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second Use the logo;
    在所述存储设备的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区之后,所述方法还包括:After the allocating the shared data block area of the first partition and the second partition to the file system on the fourth consecutive address segment of the storage device, the method further includes:
    接收在所述第一分区创建文件的请求;所述请求中包括所述文件的大小;Receiving a request to create a file in the first partition; the request includes a size of the file;
    通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;Determining, by the first usage identifier, an unused data block in the shared data block area;
    根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;Determining a size of a remaining capacity in the shared data block area according to the number and size of the unused data blocks;
    根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;Determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file;
    当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共 用数据块区中的存储地址,并在所述第一分区的索引节点位图区查找是否有未被使用的索引节点;Determining that the file is to be stored in the total when the remaining capacity is sufficient to create the file Using the storage address in the data block area, and searching for an unused index node in the index node bitmap area of the first partition;
    当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;When there is an unused index node, selecting one of the unused index nodes, writing an attribute of the file and the storage address;
    将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;Changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been used;
    将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;Storing the file in a data block corresponding to the storage address in the shared data block area;
    在所述数据块位图中将与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。The first usage identifier of the data block corresponding to the storage address is changed in the data block bitmap to a value indicating that the data block has been used.
  6. 如权利要求4所述的方法,其特征在于,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,The method of claim 4, wherein the first partition comprises an index node area and an index node bitmap area, and an index node of the index node area is used to record a file stored in the shared data block The attribute and the storage address; the index node bitmap area is configured to store a second usage identifier, the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second Use the logo,
    在所述存储设备的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区之后,所述方法还包括:After the allocating the shared data block area of the first partition and the second partition to the file system on the fourth consecutive address segment of the storage device, the method further includes:
    接收在所述第一分区删除文件的请求;Receiving a request to delete a file in the first partition;
    根据所述文件的属性在所述第一分区的索引节点区查找对应的索引节点:Finding a corresponding index node in an index node area of the first partition according to an attribute of the file:
    根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;Determining, according to the storage address recorded by the index node, a data block corresponding to the storage address in the shared data block;
    将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;Changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used;
    将所述第一分区的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。Changing the second usage identifier of the corresponding index node in the index node bitmap area of the first partition to a value indicating that the corresponding index node is not used.
  7. 一种文件系统的管理方法,其特征在于,包括:A method for managing a file system, comprising:
    在存储设备的第一连续的地址段上为所述文件系统分配超级块区,所述 超级块区用于记录所述文件系统的系统信息;所述系统信息包括所述文件系统的类型、大小;Allocating a superblock area to the file system on a first consecutive address segment of the storage device, The super block area is used to record system information of the file system; the system information includes a type and a size of the file system;
    在所述存储设备的第二连续的地址段上为所述文件系统分配位图区;Allocating a bitmap area to the file system on a second consecutive address segment of the storage device;
    在所述存储设备的第三连续的地址段上为所述文件系统分配共享区,所述共享区用于存储文件与索引节点;所述索引节点用于记录存储在所述共享区中的文件的存储地址;所述位图区用于存储使用标识,所述使用标识用于表示所述共享区中的数据块是否被使用,每个所述数据块对应一个所述使用标识;所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。Allocating a shared area to the file system on a third consecutive address segment of the storage device, the shared area is configured to store a file and an index node; and the index node is configured to record a file stored in the shared area a storage address; the bitmap area is configured to store a usage identifier, where the usage identifier is used to indicate whether a data block in the shared area is used, and each of the data blocks corresponds to one of the usage identifiers; A contiguous address segment, the second contiguous address segment, and the third contiguous address segment form a contiguous address segment.
  8. 如权利要求7所述的方法,其特征在于,所述方法还包括:The method of claim 7 wherein the method further comprises:
    当在所述共享区为所述索引节点分配空间时,从所述共享区的第一地址端向第二地址端方向进行分配;When the space is allocated to the index node in the shared area, the first address end of the shared area is allocated to the second address end;
    当在所述共享区为所述文件分配空间时,从所述共享区的所述第二地址端向所述第一地址端方向进行分配。When the space is allocated to the file in the shared area, the second address end of the shared area is allocated to the first address end.
  9. 如权利要求7或8所述的方法,其特征在于,在所述存储设备的第三连续的地址段上为所述文件系统分配共享区之后,所述方法还包括:The method of claim 7 or 8, wherein after the sharing of the shared area for the file system on the third consecutive address segment of the storage device, the method further comprises:
    接收用于创建文件的请求;所述请求中包括所述文件的大小;Receiving a request for creating a file; the request includes a size of the file;
    根据所述使用标识确定所述共享区中未被使用的数据块;Determining an unused data block in the shared area according to the usage identifier;
    根据所述未被使用的数据块的数量及大小确定所述共享区中的剩余容量的大小;Determining a size of a remaining capacity in the shared area according to the number and size of the unused data blocks;
    根据所述文件的大小和所述剩余容量的大小确定所述剩余容量是否足够创建所述文件以及存储所述文件对应的索引节点;Determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file and storing an index node corresponding to the file;
    当所述剩余容量足够存储所述文件以及存储所述文件对应的索引节点时,在所述未被使用的数据块上创建所述文件并将所述文件的存储地址记录在所述对应的索引节点中;When the remaining capacity is sufficient to store the file and store an index node corresponding to the file, create the file on the unused data block and record a storage address of the file in the corresponding index In the node;
    将所述位图区中与所述存储地址和所述索引节点对应的数据块的使用标识更改为表示所述数据块已被使用的值。 Changing the usage identifier of the data block corresponding to the storage address and the index node in the bitmap area to a value indicating that the data block has been used.
  10. 如权利要求9所述的方法,其特征在于,所述方法还包括:The method of claim 9 wherein the method further comprises:
    更新所述超级块区中记录的所述共享区中存储的所有所述索引节点占用的空间大小值以及所述共享区中存储的所有所述文件占用的空间大小值。And updating a space size value occupied by all the index nodes stored in the shared area recorded in the super block area and a space size value occupied by all the files stored in the shared area.
  11. 如权利要求7或8所述的方法,其特征在于,所述索引节点还记录文件的属性,The method according to claim 7 or 8, wherein said index node further records attributes of the file,
    在所述存储设备的第三连续的地址段上为所述文件系统分配共享区之后,所述方法还包括:After the shared area is allocated to the file system on the third consecutive address segment of the storage device, the method further includes:
    接收查询文件的请求,所述请求中包含所述文件的属性;Receiving a request for querying a file, the request including an attribute of the file;
    在所述共享区中查询与所述属性对应的索引节点;Querying an index node corresponding to the attribute in the shared area;
    根据所述对应的索引节点中记录的存储地址在所述共享区中查找与所述存储地址对应的文件。Searching for a file corresponding to the storage address in the shared area according to a storage address recorded in the corresponding index node.
  12. 一种文件系统的管理装置,其特征在于,包括:A file system management device, comprising:
    数据块位图分配模块,用于在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;a data block bitmap allocation module, configured to allocate a data block bitmap area to the file system on a first consecutive address segment of the storage device;
    元数据分区分配模块,用于在所述存储设备的第二连续的地址段上为所述文件系统分配N个分区,所述N个分区的每个分区分别用于存储所述每个分区的系统元数据;N为大于1的整数;a metadata partition allocation module, configured to allocate N partitions to the file system on a second consecutive address segment of the storage device, where each partition of the N partitions is used to store each partition System metadata; N is an integer greater than one;
    数据块分配模块,用于在所述存储设备的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;其中,所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。a data block allocation module, configured to allocate, to the file system, a common data block area of the N partitions on a third consecutive address segment of the storage device, where the shared data block area is used to store a file; The data block bitmap area is configured to store a first use identifier, where the first use identifier is used to indicate whether a data block in the shared data block area is used, and each of the data blocks corresponds to one of the first use identifiers Wherein the first consecutive address segment, the second consecutive address segment, and the third consecutive address segment form a contiguous address segment.
  13. 如权利要求12所述的装置,其特征在于,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块区中的文件的存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引 节点对应一个所述第二使用标识;所述装置还包括:The apparatus according to claim 12, wherein each of the partitions includes an index node area and an index node bitmap area, and an index node of the index node area is used for recording in the shared data block area. a storage address of the file; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the indexes The node corresponds to one of the second usage identifiers; the device further includes:
    接收模块,用于接收在所述N个分区中的第i个分区创建文件的请求;所述请求中包括所述文件的大小;a receiving module, configured to receive a request for creating a file in an i-th partition of the N partitions; the request includes a size of the file;
    处理模块,用于通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第i个分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;将所述数据块位图中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。a processing module, configured to determine, by using the first usage identifier, an unused data block in the shared data block region; determining a remaining portion in the shared data block region according to the number and size of the unused data blocks a size of the capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be stored in the Determining a storage address in the shared data block area, and searching whether there is an unused index node in the index node bitmap area of the i-th partition; when there is an unused index node, selecting the unused An index node in the index node, writing an attribute of the file and the storage address; changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to indicate the a value that has been used by an index node; storing the file in a data block corresponding to the storage address in the shared data block area; The first usage identifier of the data block corresponding to the storage address is changed to a value indicating that the data block has been used.
  14. 如权利要求12所述的装置,其特征在于,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,所述装置还包括:The apparatus according to claim 12, wherein each of the partitions includes an index node area and an index node bitmap area, and an index node of the index node area is used to record a file stored in the shared data block The attribute and the storage address; the index node bitmap area is configured to store a second usage identifier, the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second Using the identification, the device further includes:
    接收模块,用于接收在所述N个分区中的分区j删除文件的请求;a receiving module, configured to receive a request for deleting a file in the partition j in the N partitions;
    处理模块,用于根据所述文件的属性在所述分区j的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述分区j的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。 a processing module, configured to search, according to an attribute of the file, a corresponding index node in an index node area of the partition j: determining, according to a storage address recorded by the index node, data corresponding to the storage address in the shared data block Blocking; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; and using an index node bitmap of the partition j The second usage identifier of the corresponding index node in the zone is changed to a value indicating that the corresponding index node is not used.
  15. 一种文件系统的管理装置,其特征在于,包括:A file system management device, comprising:
    数据块位图分配模块,用于在存储设备的第一连续的地址段上为所述文件系统分配一个数据块位图区;a data block bitmap allocation module, configured to allocate a data block bitmap area to the file system on a first consecutive address segment of the storage device;
    元数据分区分配模块,用于在所述存储设备的第二连续的地址段上为所述文件系统分配第一分区,所述第一分区用于存储所述第一分区的系统元数据;在所述存储设备的第三连续的地址段上为所述文件系统分配第二分区,所述第二分区用于存储所述第二分区的系统元数据;a metadata partition allocation module, configured to allocate a first partition to the file system on a second consecutive address segment of the storage device, where the first partition is configured to store system metadata of the first partition; Assigning a second partition to the file system on a third consecutive address segment of the storage device, where the second partition is configured to store system metadata of the second partition;
    数据块分配模块,用于在所述存储设备的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区;其中,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;所述第一连续的地址段、所述第二连续的地址段、所述第三连续的地址段和所述第四连续的地址段组成连续的地址段,所述第四连续的地址段位于所述第二连续的地址段和所述第三连续的地址段之间。a data block allocation module, configured to allocate a common data block area of the first partition and the second partition to the file system on a fourth consecutive address segment of the storage device; wherein the shared data The block area is configured to store a file; the data block bitmap area is configured to store a first use identifier, and the first use identifier is used to indicate whether a data block in the shared data block area is used, each of the data The block corresponds to one of the first usage identifiers; the first consecutive address segment, the second consecutive address segment, the third consecutive address segment, and the fourth consecutive address segment form a continuous address segment The fourth consecutive address segment is located between the second consecutive address segment and the third consecutive address segment.
  16. 如权利要求15所述的装置,其特征在于,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识;所述装置还包括:The apparatus according to claim 15, wherein said first partition comprises an index node area and an index node bitmap area, and said index node area index node is for recording a file stored in said common data block And an address of the storage node; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second The identification is used; the device further includes:
    接收模块,用于接收在所述第一分区创建文件的请求;所述请求中包括所述文件的大小;a receiving module, configured to receive a request for creating a file in the first partition; the request includes a size of the file;
    处理模块,用于通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第 一分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;在所述数据块位图中将与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。a processing module, configured to determine, by using the first usage identifier, an unused data block in the shared data block region; determining a remaining portion in the shared data block region according to the number and size of the unused data blocks a size of the capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be stored in the a storage address in the shared data block area, and in the A partitioned index node bitmap area finds whether there is an unused index node; when there is an unused index node, selects one of the unused index nodes, and writes attributes of the file And the storage address; changing the second usage identifier corresponding to the one index node in the bitmap node bitmap area to a value indicating that the one index node has been used; storing the file in the location Determining, in the data block bitmap, the first use identifier of the data block corresponding to the storage address to indicate that the data block has been The value used.
  17. 如权利要求15所述的装置,其特征在于,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,The apparatus according to claim 15, wherein said first partition comprises an index node area and an index node bitmap area, and said index node area index node is for recording a file stored in said common data block The attribute and the storage address; the index node bitmap area is configured to store a second usage identifier, the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the second Use the logo,
    所述装置还包括:The device also includes:
    接收模块,用于接收在所述第一分区删除文件的请求;a receiving module, configured to receive a request to delete a file in the first partition;
    处理模块,用于根据所述文件的属性在所述第一分区的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述第一分区的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。a processing module, configured to search, according to an attribute of the file, a corresponding index node in an index node area of the first partition: determining, according to a storage address recorded by the index node, a corresponding to the storage address in the shared data block a data block; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; and indexing the first partition The second usage identifier of the corresponding index node in the bitmap area is changed to a value indicating that the corresponding index node is not used.
  18. 一种文件系统的管理装置,其特征在于,包括:A file system management device, comprising:
    超级块分配模块,用于在存储设备的第一连续的地址段上为所述文件系统分配超级块区,所述超级块区用于记录所述文件系统的系统信息;所述系统信息包括所述文件系统的类型、大小;a super block allocation module, configured to allocate a super block area for the file system on a first consecutive address segment of the storage device, where the super block area is used to record system information of the file system; The type and size of the file system;
    位图分配模块,用于在所述存储设备的第二连续的地址段上为所述文件系统分配位图区;a bitmap allocation module, configured to allocate a bitmap area to the file system on a second consecutive address segment of the storage device;
    共享区分配模块,用于在所述存储设备的第三连续的地址段上为所述文 件系统分配共享区,所述共享区用于存储文件与索引节点;所述索引节点用于记录存储在所述共享区中的文件的存储地址;所述位图区用于存储使用标识,所述使用标识用于表示所述共享区中的数据块是否被使用,每个所述数据块对应一个所述使用标识;所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。a shared area allocation module, configured to be in the third consecutive address segment of the storage device The partition system is configured to store a file and an index node; the index node is configured to record a storage address of a file stored in the shared area; and the bitmap area is configured to store a usage identifier, The usage identifier is used to indicate whether a data block in the shared area is used, and each of the data blocks corresponds to one of the usage identifiers; the first consecutive address segment, the second consecutive address segment, and The third consecutive address segment constitutes a contiguous address segment.
  19. 如权利要求18所述的装置,其特征在于,所述装置还包括处理模块,用于当在所述共享区为所述索引节点分配空间时,从所述共享区的第一地址端向第二地址端方向进行分配;当在所述共享区为所述文件分配空间时,从所述共享区的所述第二地址端向所述第一地址端方向进行分配。The apparatus according to claim 18, wherein said apparatus further comprises: a processing module, configured to: when the space is allocated to said index node in said shared area, from said first address end of said shared area to said The second address end direction is allocated; when the space is allocated to the file in the shared area, the second address end of the shared area is allocated to the first address end direction.
  20. 如权利要求18所述的装置,其特征在于,所述装置还包括:The device of claim 18, wherein the device further comprises:
    接收模块,用于接收用于创建文件的请求;所述请求中包括所述文件的大小;a receiving module, configured to receive a request for creating a file; the request includes a size of the file;
    处理模块,用于根据所述使用标识确定所述共享区中未被使用的数据块;根据所述未被使用的数据块的数量及大小确定所述共享区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小确定所述剩余容量是否足够创建所述文件以及存储所述文件对应的索引节点;当所述剩余容量足够存储所述文件以及存储所述文件对应的索引节点时,在所述未被使用的数据块上创建所述文件并将所述文件的存储地址记录在所述对应的索引节点中;将所述位图区中与所述存储地址和所述索引节点对应的数据块的使用标识更改为表示所述数据块已被使用的值。a processing module, configured to determine, according to the usage identifier, an unused data block in the shared area; determining a size of a remaining capacity in the shared area according to the number and size of the unused data blocks; Determining a size of the file and a size of the remaining capacity to determine whether the remaining capacity is sufficient to create the file and storing an index node corresponding to the file; when the remaining capacity is sufficient to store the file and store an index corresponding to the file a node, creating the file on the unused data block and recording a storage address of the file in the corresponding index node; storing the bitmap area with the storage address and the The usage identifier of the data block corresponding to the index node is changed to a value indicating that the data block has been used.
  21. 如权利要求20所述的装置,其特征在于,所述处理模块还用于:更新所述超级块中记录的所述共享区中存储的所有所述索引节点占用的空间大小值以及所述共享区中存储的所有所述文件占用的空间大小值。The device according to claim 20, wherein the processing module is further configured to: update a spatial size value occupied by all the index nodes stored in the shared area recorded in the super block, and the sharing The size of the space used by all of the files stored in the zone.
  22. 如权利要求18所述的装置,其特征在于,所述装置还包括:The device of claim 18, wherein the device further comprises:
    接收模块,用于接收查询文件的请求,所述请求中包含所述文件的属性;a receiving module, configured to receive a request for querying a file, where the request includes an attribute of the file;
    处理模块,用于在所述共享区中查询与所述属性对应的索引节点;根据所述对应的索引节点中记录的存储地址在所述共享区中查找与所述存储地址 对应的文件。a processing module, configured to query an index node corresponding to the attribute in the shared area; and search for the storage address in the shared area according to a storage address recorded in the corresponding index node Corresponding file.
  23. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    存储器;Memory
    处理器,用于在所述存储器的第一连续的地址段上为所述文件系统分配一个数据块位图区;在所述存储器的第二连续的地址段上为所述文件系统分配N个分区,所述N个分区的每个分区分别用于存储所述每个分区的系统元数据;N为大于1的整数;在所述存储器的第三连续的地址段上为所述文件系统分配所述N个分区的共用数据块区,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;其中,所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。a processor for allocating a data block bitmap area to the file system on a first consecutive address segment of the memory; assigning N to the file system on a second consecutive address segment of the memory a partition, each partition of the N partitions being used to store system metadata of each partition; N is an integer greater than 1; and the file system is allocated on a third consecutive address segment of the memory a shared data block area of the N partitions, where the shared data block area is used to store a file; the data block bitmap area is used to store a first use identifier, and the first use identifier is used to represent the shared data Whether the data blocks in the block area are used, each of the data blocks corresponding to one of the first usage identifiers; wherein the first consecutive address segment, the second consecutive address segment, and the third continuous The address segments form a contiguous address segment.
  24. 如权利要求23所述的电子设备,其特征在于,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块区中的文件的存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识,所述电子设备还包括输入装置,The electronic device according to claim 23, wherein each of the partitions includes an index node area and an index node bitmap area, and an index node of the index node area is used for recording in the shared data block area. a storage address of the file; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the second Using the identification, the electronic device further includes an input device,
    所述输入装置用于接收在所述N个分区中的第i个分区创建文件的请求;所述请求中包括所述文件的大小;The input device is configured to receive a request for creating a file in an i th partition of the N partitions; the request includes a size of the file;
    所述处理器还用于:通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第i个分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节 点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;在所述数据块位图中将与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。The processor is further configured to: determine, by using the first usage identifier, an unused data block in the shared data block area; determine the shared data block area according to the number and size of the unused data blocks. a size of the remaining capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be Storing a storage address in the shared data block area, and searching for an unused index node in an index node bitmap area of the i-th partition; when there is an unused index node, selecting the An index node of an unused index node that writes an attribute of the file and the storage address; and the index node area of the index node and the one index section The second usage identifier corresponding to the point is changed to a value indicating that the one index node has been used; storing the file in a data block corresponding to the storage address in the shared data block area; The first usage identifier of the data block corresponding to the storage address is changed in the block bitmap to a value indicating that the data block has been used.
  25. 如权利要求23所述的电子设备,其特征在于,所述每个分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,所述电子设备还包括输入装置,The electronic device according to claim 23, wherein each of the partitions includes an index node area and an index node bitmap area, and an index node of the index node area is used for recording in the shared data block. An attribute of the file and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the Second, using the identifier, the electronic device further includes an input device,
    所述输入装置用于接收在所述N个分区中的分区j删除文件的请求;The input device is configured to receive a request for deleting a file by a partition j in the N partitions;
    所述处理器还用于:根据所述文件的属性在所述分区j的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述分区j的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。The processor is further configured to: search, according to an attribute of the file, a corresponding index node in an index node area of the partition j: determining, in the shared data block, the storage address according to a storage address recorded by the index node Corresponding data block; changing the first usage identifier of the data block corresponding to the storage address in the data block bitmap area to a value indicating that the data block is not used; indexing the partition j The second usage identifier of the corresponding index node in the node bitmap area is changed to a value indicating that the corresponding index node is not used.
  26. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    存储器;Memory
    处理器,用于在所述存储器的第一连续的地址段上为所述文件系统分配一个数据块位图区;在所述存储器的第二连续的地址段上为所述文件系统分配第一分区,所述第一分区用于存储所述第一分区的系统元数据;在所述存储器的第三连续的地址段上为所述文件系统分配第二分区,所述第二分区用于存储所述第二分区的系统元数据;在所述存储器的第四连续的地址段上,为所述文件系统分配所述第一分区和所述第二分区的共用数据块区;其中,所述共用数据块区用于存储文件;所述数据块位图区用于存储第一使用标识,所述第一使用标识用于表示所述共用数据块区中的数据块是否被使用,每个所述数据块对应一个所述第一使用标识;所述第一连续的地址段、所述第二 连续的地址段、所述第三连续的地址段和所述第四连续的地址段组成连续的地址段,所述第四连续的地址段位于所述第二连续的地址段和所述第三连续的地址段之间。a processor for allocating a data block bitmap area to the file system on a first consecutive address segment of the memory; assigning a first to the file system on a second consecutive address segment of the memory a partition, the first partition is configured to store system metadata of the first partition; a second partition is allocated to the file system on a third consecutive address segment of the memory, the second partition is configured to store System metadata of the second partition; a shared data block region of the first partition and the second partition is allocated to the file system on a fourth consecutive address segment of the memory; wherein a shared data block area for storing a file; the data block bitmap area is for storing a first use identifier, and the first use identifier is used to indicate whether a data block in the shared data block area is used, each of the The data block corresponds to one of the first use identifiers; the first consecutive address segment, the second The consecutive address segments, the third consecutive address segment, and the fourth consecutive address segment form a contiguous address segment, the fourth consecutive address segment being located in the second consecutive address segment and the third Between consecutive address segments.
  27. 如权利要求26所述的电子设备,其特征在于,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用;每个所述索引节点对应一个所述第二使用标识;所述电子设备还包括输入装置,The electronic device according to claim 26, wherein the first partition comprises an index node area and an index node bitmap area, and the index node of the index node area is used for recording in the shared data block. An attribute of the file and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used; each of the index nodes corresponds to one of the Second, using the identifier; the electronic device further includes an input device,
    所述输入装置用于接收在所述第一分区创建文件的请求;所述请求中包括所述文件的大小;The input device is configured to receive a request for creating a file in the first partition; the request includes a size of the file;
    所述处理器还用于:通过所述第一使用标识确定所述共用数据块区中未被使用的数据块;根据所述未被使用的数据块的数量以及大小确定所述共用数据块区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小,确定所述剩余容量是否足够创建所述文件;当所述剩余容量足够创建所述文件时,确定所述文件将要存储在所述共用数据块区中的存储地址,并在所述第一分区的索引节点位图区查找是否有未被使用的索引节点;当有未被使用的索引节点时,选择所述未被使用的索引节点中的一个索引节点,写入所述文件的属性以及所述存储地址;将所述索引节点位图区中与所述一个索引节点对应的所述第二使用标识更改为表示所述一个索引节点已被使用的值;将所述文件存储在所述共用数据块区中与所述存储地址对应的数据块;在所述数据块位图中将与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块已被使用的值。The processor is further configured to: determine, by using the first usage identifier, an unused data block in the shared data block area; determine the shared data block area according to the number and size of the unused data blocks. a size of the remaining capacity; determining, according to the size of the file and the size of the remaining capacity, whether the remaining capacity is sufficient to create the file; when the remaining capacity is sufficient to create the file, determining that the file is to be Storing a storage address in the shared data block area, and searching for an unused index node in an index node bitmap area of the first partition; when there is an unused index node, selecting the un An index node of the used index node, writes an attribute of the file and the storage address; and changes the second use identifier corresponding to the one index node in the bitmap node bitmap area to a representation a value that the one index node has been used; storing the file in a data block corresponding to the storage address in the shared data block area; at the data block bit The address will be stored with the data block corresponding to a first change value using the identification data block has been used to represent the.
  28. 如权利要求26所述的电子设备,其特征在于,所述第一分区包括索引节点区以及索引节点位图区,所述索引节点区的索引节点用于记录存储在所述共用数据块中的文件的属性以及存储地址;所述索引节点位图区用于存储第二使用标识,所述第二使用标识用于表示所述索引节点是否被使用,每个所述索引节点对应一个所述第二使用标识,所述电子设备还包括输入装置, The electronic device according to claim 26, wherein the first partition comprises an index node area and an index node bitmap area, and the index node of the index node area is used for recording in the shared data block. An attribute of the file and a storage address; the index node bitmap area is configured to store a second usage identifier, and the second usage identifier is used to indicate whether the index node is used, and each of the index nodes corresponds to one of the Second, using the identifier, the electronic device further includes an input device,
    所述输入装置用于接收在所述第一分区删除文件的请求;The input device is configured to receive a request to delete a file in the first partition;
    所述处理器还用于:根据所述文件的属性在所述第一分区的索引节点区查找对应的索引节点:根据所述索引节点记录的存储地址确定所述共用数据块中与所述存储地址对应的数据块;将所述数据块位图区中与所述存储地址对应的数据块的所述第一使用标识更改为表示所述数据块未被使用的值;将所述第一分区的索引节点位图区中所述对应的索引节点的所述第二使用标识更改为表示所述对应的索引节点未被使用的值。The processor is further configured to: search, according to an attribute of the file, a corresponding index node in an index node area of the first partition: determining, in the shared data block, the storage according to a storage address recorded by the index node a data block corresponding to the address; changing the first usage identifier of the data block corresponding to the storage address in the bitmap area of the data block to a value indicating that the data block is not used; The second usage identifier of the corresponding index node in the index node bitmap area is changed to a value indicating that the corresponding index node is not used.
  29. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    存储器;Memory
    处理器,用于在所述存储器的第一连续的地址段上为所述文件系统分配超级块区,所述超级块区用于记录所述文件系统的系统信息;所述系统信息包括所述文件系统的类型、大小;在所述存储器的第二连续的地址段上为所述文件系统分配位图区;在所述存储器的第三连续的地址段上为所述文件系统分配共享区,所述共享区用于存储文件与索引节点;所述索引节点用于记录存储在所述共享区中的文件的存储地址;所述位图区用于存储使用标识,所述使用标识用于表示所述共享区中的数据块是否被使用,每个所述数据块对应一个所述使用标识;所述第一连续的地址段、所述第二连续的地址段和所述第三连续的地址段组成连续的地址段。a processor, configured to allocate a super block area for the file system on a first consecutive address segment of the memory, the super block area for recording system information of the file system; a type, a size of a file system; a bitmap area is allocated to the file system on a second consecutive address segment of the memory; and a shared area is allocated to the file system on a third consecutive address segment of the memory, The shared area is configured to store a file and an index node; the index node is configured to record a storage address of a file stored in the shared area; the bitmap area is configured to store a use identifier, and the use identifier is used to represent Whether the data blocks in the shared area are used, each of the data blocks corresponding to one of the usage identifiers; the first consecutive address segment, the second consecutive address segment, and the third consecutive address Segments form a contiguous range of addresses.
  30. 如权利要求29所述的电子设备,其特征在于,所述处理器还用于:当在所述共享区为所述索引节点分配空间时,从所述共享区的第一地址端向第二地址端方向进行分配;当在所述共享区为所述文件分配空间时,从所述共享区的所述第二地址端向所述第一地址端方向进行分配。The electronic device according to claim 29, wherein the processor is further configured to: when the space is allocated to the index node in the shared area, from the first address end to the second end of the shared area The address end direction is allocated; when the space is allocated to the file in the shared area, the second address end of the shared area is allocated to the first address end direction.
  31. 如权利要求29所述的电子设备,其特征在于,所述电子设备还包括输入装置,The electronic device according to claim 29, wherein said electronic device further comprises an input device,
    所述输入装置用于接收用于创建文件的请求;所述请求中包括所述文件的大小;The input device is configured to receive a request for creating a file; the request includes a size of the file;
    所述处理器还用于:根据所述使用标识确定所述共享区中未被使用的数 据块;根据所述未被使用的数据块的数量及大小确定所述共享区中的剩余容量的大小;根据所述文件的大小和所述剩余容量的大小确定所述剩余容量是否足够创建所述文件以及存储所述文件对应的索引节点;当所述剩余容量足够存储所述文件以及存储所述文件对应的索引节点时,在所述未被使用的数据块上创建所述文件并将所述文件的存储地址记录在所述对应的索引节点中;将所述位图区中与所述存储地址和所述索引节点对应的数据块的使用标识更改为表示所述数据块已被使用的值。The processor is further configured to: determine, according to the usage identifier, an unused number in the shared area Determining a size of the remaining capacity in the shared area according to the number and size of the unused data blocks; determining whether the remaining capacity is sufficient to create a location according to the size of the file and the size of the remaining capacity a file and an index node corresponding to the file; when the remaining capacity is sufficient to store the file and store an index node corresponding to the file, create the file on the unused data block and Recording a storage address of the file in the corresponding index node; changing a usage identifier of the data block corresponding to the storage address and the index node in the bitmap area to indicate that the data block has been used value.
  32. 如权利要求31所述的电子设备,其特征在于,所述处理器还用于:更新所述超级块区中记录的所述共享区中存储的所有所述索引节点占用的空间大小值以及所述共享区中存储的所有所述文件占用的空间大小值。The electronic device according to claim 31, wherein the processor is further configured to: update a space size value occupied by all the index nodes stored in the shared area recorded in the super block area, and The size of the space occupied by all the files stored in the shared area.
  33. 如权利要求29所述的电子设备,其特征在于,所述电子设备还包括输入装置,The electronic device according to claim 29, wherein said electronic device further comprises an input device,
    所述输入装置用于接收查询文件的请求,所述请求中包含所述文件的属性;The input device is configured to receive a request for querying a file, where the request includes an attribute of the file;
    所述处理器还用于:在所述共享区中查询与所述属性对应的索引节点;根据所述对应的索引节点中记录的存储地址在所述共享区中查找与所述存储地址对应的文件。 The processor is further configured to: query an index node corresponding to the attribute in the shared area; and search for a storage address corresponding to the storage address in the shared area according to a storage address recorded in the corresponding index node. file.
PCT/CN2015/080371 2015-05-29 2015-05-29 Management method and device of file system WO2016191964A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2015/080371 WO2016191964A1 (en) 2015-05-29 2015-05-29 Management method and device of file system
CN201580064360.0A CN107111549B (en) 2015-05-29 2015-05-29 File system management method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/080371 WO2016191964A1 (en) 2015-05-29 2015-05-29 Management method and device of file system

Publications (1)

Publication Number Publication Date
WO2016191964A1 true WO2016191964A1 (en) 2016-12-08

Family

ID=57439818

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/080371 WO2016191964A1 (en) 2015-05-29 2015-05-29 Management method and device of file system

Country Status (2)

Country Link
CN (1) CN107111549B (en)
WO (1) WO2016191964A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114138566A (en) * 2022-02-07 2022-03-04 苏州浪潮智能科技有限公司 Data storage method and device of virtual machine, virtual machine and storage medium
CN115809027A (en) * 2023-01-11 2023-03-17 杭州广科安德生物科技有限公司 Biological data acquisition and management system, device and method

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134645B (en) * 2019-04-15 2023-07-11 深圳市战音科技有限公司 File system storage management method, file system storage reading method, file system storage management device and file system storage reading device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070288938A1 (en) * 2006-06-12 2007-12-13 Daniel Zilavy Sharing data between partitions in a partitionable system
CN102682015A (en) * 2011-03-15 2012-09-19 中国科学院声学研究所 High-definition media-oriented embedded file storage structure and method
CN103714013A (en) * 2013-12-31 2014-04-09 华为技术有限公司 Method and device for allocating storage space of file system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070288938A1 (en) * 2006-06-12 2007-12-13 Daniel Zilavy Sharing data between partitions in a partitionable system
CN102682015A (en) * 2011-03-15 2012-09-19 中国科学院声学研究所 High-definition media-oriented embedded file storage structure and method
CN103714013A (en) * 2013-12-31 2014-04-09 华为技术有限公司 Method and device for allocating storage space of file system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114138566A (en) * 2022-02-07 2022-03-04 苏州浪潮智能科技有限公司 Data storage method and device of virtual machine, virtual machine and storage medium
CN115809027A (en) * 2023-01-11 2023-03-17 杭州广科安德生物科技有限公司 Biological data acquisition and management system, device and method
CN115809027B (en) * 2023-01-11 2023-05-30 杭州广科安德生物科技有限公司 Biological data acquisition and management system, device and method

Also Published As

Publication number Publication date
CN107111549A (en) 2017-08-29
CN107111549B (en) 2020-09-08

Similar Documents

Publication Publication Date Title
US8423733B1 (en) Single-copy implicit sharing among clones
US9558223B2 (en) Extending cluster allocations in an extensible file system
US11003625B2 (en) Method and apparatus for operating on file
WO2019062574A1 (en) Metadata query method and device
WO2016086819A1 (en) Method and apparatus for writing data into shingled magnetic record smr hard disk
CN108804510A (en) Key assignments file system
US20130066883A1 (en) Data management apparatus and system
CN111459885B (en) Data processing method and device, computer equipment and storage medium
WO2019001020A1 (en) Storage space arrangement method, apparatus, and system based on distributed system
US9430492B1 (en) Efficient scavenging of data and metadata file system blocks
CN109804359A (en) For the system and method by write back data to storage equipment
CN103714013A (en) Method and device for allocating storage space of file system
KR20150071500A (en) Method and Apparatus for Managing Data
WO2016191964A1 (en) Management method and device of file system
US9696919B1 (en) Source/copy reference tracking with block pointer sets
US20060036663A1 (en) Method and apparatus for effective data management of files
WO2016106757A1 (en) Method for managing storage data, storage manager and storage system
CN113853778B (en) Cloning method and device of file system
CN108804571B (en) Data storage method, device and equipment
US11132134B2 (en) Flexible over-provisioning of storage space within solid-state storage devices (SSDs)
EP3436990B1 (en) Systems and methods for enabling modifications of multiple data objects within a file system volume
CN104537023A (en) Storage method and device for reverse index records
US20220365905A1 (en) Metadata processing method and apparatus, and a computer-readable storage medium
CN106033454B (en) Formatting method, processing method and device of virtual file system
WO2023071137A1 (en) Data processing method and related apparatus

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

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

Country of ref document: EP

Kind code of ref document: A1