WO2023178899A1 - Data management method and apparatus of file system, electronic device, and storage medium - Google Patents

Data management method and apparatus of file system, electronic device, and storage medium Download PDF

Info

Publication number
WO2023178899A1
WO2023178899A1 PCT/CN2022/107919 CN2022107919W WO2023178899A1 WO 2023178899 A1 WO2023178899 A1 WO 2023178899A1 CN 2022107919 W CN2022107919 W CN 2022107919W WO 2023178899 A1 WO2023178899 A1 WO 2023178899A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
bitmap
snapshot
item
bits
Prior art date
Application number
PCT/CN2022/107919
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 联想凌拓科技有限公司
Publication of WO2023178899A1 publication Critical patent/WO2023178899A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types

Definitions

  • Embodiments of the present disclosure relate to a data management method and data management device for a file system, electronic equipment, and storage media.
  • Snapshot is a data backup method. Because it can be completed instantly and achieve zero-window backup of data, snapshots have become a common and basic data backup technology among many data backup technologies. Snapshots have become the cornerstone of backup in the storage industry.
  • a snapshot refers to a fully available copy of a specified data collection, which includes an image of the corresponding data at a certain point in time (the point in time when the copy starts).
  • the main function of snapshots is to enable data backup and recovery. When an application failure or file corruption occurs on the storage device, rapid data recovery can be performed to restore the data to a certain available point in time, thereby meeting the enterprise's requirements for business continuity and data reliability.
  • At least one embodiment of the present disclosure provides a data management method for a file system, wherein the file system includes file data divided into multiple data slices; the file system further includes source file items and Snapshot item, the source file item includes a first bitmap and a second bitmap, the snapshot item includes a third bitmap; multiple bits of the first bitmap correspond to the multiple data pieces one-to-one , the first bitmap is used to record the writing status of the multiple data slices; the multiple bits of the second bitmap correspond to the multiple data slices one-to-one, and the second bitmap uses In recording the snapshot generation status of the plurality of data pieces; a plurality of bits of the third bitmap correspond to the plurality of data pieces, and the third bitmap is used to record the plurality of data pieces.
  • the method includes: in response to receiving a data write request, determining whether to perform data migration according to the first bitmap and the second bitmap; in response to determining to perform data migration, performing a data migration operation and updating Corresponding bits in the first bitmap, the second bitmap, and the third bitmap.
  • determining whether to perform data migration based on the first bitmap and the second bitmap includes: determining the data slice to be operated on based on the data write request; reading The bits in the first bitmap corresponding to the data piece are read, and the bits in the second bitmap corresponding to the data piece are read; in response to the bits in the first bitmap corresponding to the data piece. If the bit corresponding to the slice is a valid value and the bit corresponding to the data slice in the second bitmap is a valid value, it is determined to perform data migration.
  • determining whether to perform data migration based on the first bitmap and the second bitmap further includes: responding to the difference between the first bitmap and the data slice. If the corresponding bit is an invalid value or the bit corresponding to the data slice in the second bitmap is an invalid value, it is determined that data migration is not performed.
  • performing the data migration operation and updating corresponding bits in the first bitmap, the second bitmap, and the third bitmap includes: reading Get the data slice corresponding to the data migration operation, construct the read data slice into a snapshot type data object and store it; update the corresponding bits in the first image to a valid value, and convert the second The corresponding bits in the bitmap are updated to invalid values, and the corresponding bits in the third bitmap are updated to valid values.
  • reading the data slice corresponding to the data migration operation constructing the read data slice into a data object of the snapshot type and storing it includes: obtaining the file path The latest snapshot version number; read the data slice corresponding to the data migration operation, and store the read data slice as a data object; add the latest snapshot version number and identification information indicating the snapshot type to the data In the information field of the object; associate the snapshot item corresponding to the latest snapshot version number with the data object.
  • the corresponding bits in the first bitmap are updated to valid values
  • the corresponding bits in the second bitmap are updated to invalid values
  • the corresponding bits in the second bitmap are updated to invalid values.
  • Updating the corresponding bits in the third bitmap to a valid value includes: updating the corresponding bits in the first bitmap of the source file item to a valid value, and updating the second bitmap of the source file item to a valid value.
  • the corresponding bits in the bitmap are updated to invalid values; the latest snapshot version number of the file path is obtained; and the corresponding bits in the third bitmap of the snapshot item corresponding to the latest snapshot version number are updated to valid values.
  • the method provided by an embodiment of the present disclosure further includes: in response to receiving the data write request, determining whether the data write request is an initial write request; in response to the data write request being the initial write request, The content of the first bitmap is synchronized to the second bitmap, and all bit positions of the third bitmap are set to invalid values.
  • the snapshot item further includes a fourth bitmap, and a plurality of bits of the fourth bitmap correspond to the plurality of data slices in a one-to-one manner.
  • the bitmap is used to record the writing status of the corresponding source file item when the snapshot item is created; the method also includes: in response to the data write request being the initial write request, converting the content of the first bitmap to Sync to the fourth bitmap.
  • a method provided by an embodiment of the present disclosure further includes: in response to receiving a snapshot read request, determining the data location according to the third bitmap of each version of the snapshot item and reading the data.
  • determining the data location and reading the data according to the third bitmap of the snapshot item of each version includes: determining the current snapshot item according to the snapshot read request, wherein the current snapshot item The snapshot item is a snapshot item of the version that needs to be read; the corresponding bit in the third bitmap of the current snapshot item is obtained; in response to the corresponding bit in the third bitmap of the current snapshot item being a valid value, Determine the data location according to the current snapshot item and read the data; in response to the corresponding bit in the third bitmap of the current snapshot item being an invalid value, obtain the third bitmap of the snapshot item with a larger version number in sequence.
  • the file system further includes a clone item, and the clone item is a copy of the snapshot item; the method further includes: in response to receiving a clone write request, based on The snapshot item associated with the clone item determines the data location, copies the required data to the storage location corresponding to the clone item, and performs a write operation.
  • a method provided by an embodiment of the present disclosure further includes: in response to receiving a clone read request, determining the data location based on the snapshot item associated with the clone item and reading the required data.
  • the The method further includes: performing a write operation on the source file item.
  • the method further includes: in response to determining not to perform data migration, The source file item performs a write operation.
  • At least one embodiment of the present disclosure also provides a data management device for a file system, wherein the file system includes file data, and the file data is divided into multiple data slices; the file system also includes source file items and a snapshot item, the source file item includes a first bitmap and a second bitmap, the snapshot item includes a third bitmap; the multiple bits of the first image are identical to the multiple data pieces.
  • the first bitmap is used to record the writing status of the multiple data slices;
  • the multiple bits of the second bitmap correspond to the multiple data slices one-to-one, and the second bitmap used to record the snapshot generation status of the plurality of data pieces;
  • a plurality of bits of the third bitmap correspond to the plurality of data pieces, and the third bitmap is used to record the plurality of data
  • the migration status of the slice; the device includes: a judgment unit configured to respond to receiving a data write request and determine whether to perform data migration according to the first bitmap and the second bitmap; a processing unit configured to respond to It is determined to perform data migration, perform a data migration operation and update corresponding bits in the first bitmap, the second bitmap, and the third bitmap.
  • At least one embodiment of the present disclosure also provides an electronic device, including the data management apparatus for a file system provided by any embodiment of the present disclosure.
  • At least one embodiment of the present disclosure also provides an electronic device, including: a processor; a memory including one or more computer program modules; wherein the one or more computer program modules are stored in the memory and configured To be executed by the processor, the one or more computer program modules include a method for implementing the data management method for a file system provided by any embodiment of the present disclosure.
  • At least one embodiment of the present disclosure also provides a storage medium for storing non-transitory computer-readable instructions.
  • the non-transitory computer-readable instructions are executed by a computer, the methods provided by any embodiment of the present disclosure can be implemented. File system data management methods.
  • Figure 1 is a schematic diagram of the file structure of a file system
  • Figure 2 is a schematic diagram of a bitmap in a file system provided by some embodiments of the present disclosure
  • Figure 3 is a schematic flowchart of a data management method for a file system provided by some embodiments of the present disclosure
  • Figure 4 is an exemplary flow chart of step S10 in Figure 3;
  • FIG. 5 is an exemplary flow chart of step S20 in Figure 3;
  • Figure 6 is an exemplary flow chart of step S21 in Figure 5;
  • Figure 7 is an exemplary flow chart of step S22 in Figure 5;
  • Figure 8 is a schematic flowchart of another data management method for a file system provided by some embodiments of the present disclosure.
  • Figure 9 is a schematic flowchart of another data management method for a file system provided by some embodiments of the present disclosure.
  • Figure 10 is an exemplary flow chart of step S80 in Figure 9;
  • Figure 11A is one of the schematic diagrams of the data structure used in the data management method provided by some embodiments of the present disclosure.
  • Figure 11B is a second schematic diagram of the data structure used in the data management method provided by some embodiments of the present disclosure.
  • Figure 12A is a schematic diagram of a read operation in a data management method provided by some embodiments of the present disclosure.
  • Figure 12B is a schematic diagram of a write operation in a data management method provided by some embodiments of the present disclosure.
  • Figure 13 is a schematic block diagram of a data management device for a file system provided by some embodiments of the present disclosure.
  • Figure 14 is a schematic block diagram of an electronic device provided by some embodiments of the present disclosure.
  • Figure 15 is a schematic block diagram of another electronic device provided by some embodiments of the present disclosure.
  • Figure 16 is a schematic diagram of a storage medium provided by some embodiments of the present disclosure.
  • Snapshots are usually used in file systems. Since file systems have complex metadata, data and other information, snapshot implementation is more complicated. For example, when generating snapshots, the cascading relationship between snapshots cannot be realized. That is, if a snapshot is taken of this directory, it will generally make it impossible to take snapshots of subdirectories. This limits the implementation of snapshots and leads to inconvenience in use. Moreover, the data part of the snapshot has a strong dependence on the Object Storage Device (OSD), which limits the optimization, reconstruction, and development of new features for OSD, and makes it inconvenient to maintain the snapshot function.
  • OSD Object Storage Device
  • At least one embodiment of the present disclosure provides a data management method and data management device, electronic device and storage medium for a file system.
  • This data management method separates the data part of the snapshot from the object storage device (OSD), reduces the dependence of the file system snapshot on the object storage device, facilitates management and maintenance of the overall snapshot function, and facilitates developers to make changes to the object storage device.
  • OSD object storage device
  • At least one embodiment of the present disclosure provides a data management method for a file system.
  • the file system includes file data, and the file data is divided into multiple data pieces.
  • the file system also includes source file entries and snapshot entries.
  • the source file item includes the first bitmap and the second bitmap, and the snapshot item includes the third bitmap.
  • Multiple bits in the first bit map correspond to multiple data slices one-to-one, and the first bit image is used to record the writing status of multiple data slices.
  • Multiple bits of the second bitmap correspond to multiple data slices one-to-one, and the second bitmap is used to record the snapshot generation status of the multiple data slices.
  • Multiple bits of the third bitmap correspond to multiple data slices one-to-one, and the third bitmap is used to record the transition status of the multiple data slices.
  • the method includes: in response to receiving a data write request, determining whether to perform data migration based on the first bitmap and the second bitmap; in response to determining to perform data migration, performing a data migration operation and updating the first bitmap and the second bitmap. , the corresponding bit in the third bitmap.
  • Metadata is data used to describe data (data about data). It mainly describes information about data attributes and is used to support functions such as indicating storage location, historical data, resource search, file recording, etc.
  • Metadata of a file system includes, for example, directory entries (dentries) and index nodes (inodes). Directory entries are used to describe the organizational form of files (or folders) in the file system, and index nodes are attribute information of files (or folders).
  • directory entries are used to describe the organizational form of files (or folders) in the file system
  • index nodes are attribute information of files (or folders).
  • each file corresponds to an index node, which serves as the unique number of the file. The file system accesses the information of the index node through the index node number (inodeid).
  • Data is the specific content of each file. Metadata can be used to obtain the attribute information of the data part, thereby determining the storage location (or storage address) of the data part, so that the data part can be read and written. .
  • Metadata can be used to obtain the attribute information of the data part, thereby determining the storage location (or storage address) of the data part, so that the data part can be read and written.
  • a tree structure reflecting the organizational information of the file system can be obtained, and then using the files (or folders) dir1, dir2, dir3, file1 , the index node number of file2 obtains the information of the corresponding index node, so that the specific content of each file (or folder) can be read, that is, the corresponding data part.
  • dir1, dir2, and dir3 represent folders
  • file1 and file2 represent files.
  • the file system includes file data, and the file data is the aforementioned data part.
  • file data refers to data in the file system other than metadata.
  • file data is divided into multiple data pieces.
  • the size of each data piece is, for example, 512K.
  • the embodiments of the present disclosure are not limited to this, and the size of each data piece can also be 256K, 1M, 2M, or any other size, which can be determined according to actual needs, such as the characteristics of the file system.
  • the file system also includes source file items and snapshot items.
  • the source file item refers to the data object for the file or folder of the file system itself
  • the snapshot item refers to the data object for the snapshot of the file system.
  • different snapshot items target different versions of snapshots.
  • the source file item includes a first bitmap and a second bitmap
  • the snapshot item includes a third bitmap.
  • the first bitmap, the second bitmap, and the third bitmap all refer to bitmaps, and "first", “second", and “third” are used to distinguish different bitmaps.
  • Each bitmap includes a plurality of bits, and the size of the bitmap (bitmap size) is, for example, 4k, or can be any other applicable size. The embodiments of the present disclosure do not limit this.
  • Multiple bits in the first bit map correspond to multiple data slices one-to-one, and the first bit image is used to record the writing status of multiple data slices.
  • each bit of the first bit map corresponds to a piece of data, and different bits correspond to different pieces of data.
  • For each bit of the first bit map when the bit is a valid value, it means that the corresponding data piece has been written, and when the bit is an invalid value, it means that the corresponding data piece has not been written. For example, you can use "1" to represent valid values and "0" to represent invalid values.
  • Multiple bits of the second bitmap correspond to multiple data slices one-to-one, and the second bitmap is used to record the snapshot generation status of the multiple data slices.
  • each bit of the second bitmap corresponds to a data piece, and different bits correspond to different data pieces.
  • when the bit is a valid value it means that the corresponding data piece has been snapshotted, and when the bit is an invalid value, it means that the corresponding data piece has not been snapshotted. For example, you can use "1" to represent valid values and "0" to represent invalid values.
  • Multiple bits of the third bitmap correspond to multiple data slices one-to-one, and the third bitmap is used to record the transition status of the multiple data slices.
  • each bit of the third bitmap corresponds to a data piece, and different bits correspond to different data pieces.
  • For each bit of the third bitmap when the bit is a valid value, it means that the corresponding data piece has been migrated. When the bit is an invalid value, it means that the corresponding data piece has not been migrated. For example, you can use "1" to represent valid values and "0" to represent invalid values.
  • data migration may refer to copy-on-write (COW). When a COW operation is performed, the corresponding data piece will be copied to a new storage location as the data part of the snapshot.
  • COW copy-on-write
  • Figure 2 is a schematic diagram of a bitmap in a file system provided by some embodiments of the present disclosure.
  • the bitmap includes multiple bits.
  • Each box in Figure 2 represents a bit in the bitmap, and each bit corresponds to a piece of data.
  • the bit may be 1 or 0, indicating different meanings.
  • the first bitmap, the second bitmap, and the third bitmap can all use similar bitmap structures, but the meanings of the bits in different bitmaps are different.
  • Figure 3 is a schematic flowchart of a data management method for a file system provided by some embodiments of the present disclosure. As shown in Figure 3, in some embodiments, the data management method includes the following operations.
  • Step S10 In response to receiving the data write request, determine whether to perform data migration based on the first bitmap and the second bitmap;
  • Step S20 In response to determining to perform data migration, perform a data migration operation and update corresponding bits in the first bitmap, the second bitmap, and the third bitmap.
  • the data write request may trigger a data write operation for the source file item, thereby modifying the file or folder of the file system itself. Since data writing operations will change the data content, if the corresponding files or folders have been snapshotted, data migration (such as COW) is required. Therefore, after receiving the data write request, it is necessary to determine whether to perform data migration based on the first bitmap and the second bitmap. For example, if the collection of snapshot items is a data warehouse, only repeated writing of the source file items will COW the data to the corresponding position of the last snapshot item, while the data of other previous versions of the snapshot items will not change.
  • data migration such as COW
  • FIG. 4 is an exemplary flow chart of step S10 in FIG. 3 .
  • the above step S10 includes the following operations.
  • Step S11 Determine the data piece to be operated according to the data write request
  • Step S12 Read the bits corresponding to the data slice in the first bitmap, and read the bits corresponding to the data slice in the second bitmap;
  • Step S13 In response to the bit in the first bitmap corresponding to the data slice being a valid value and the bit in the second bitmap corresponding to the data slice being a valid value, it is determined to perform data migration.
  • Step S14 In response to the bit in the first bitmap corresponding to the data slice being an invalid value or the bit in the second bitmap corresponding to the data slice being an invalid value, determine not to perform data migration.
  • the data write request will carry information to indicate which data slice or data slices the write request is for the write operation. Therefore, the information carried by the data write request can be parsed to determine the data slice to be operated on.
  • step S12 since the data piece that needs to be operated has been determined, based on the correspondence between the data piece and the first bitmap and the second bitmap, the bits in the first bitmap corresponding to the data piece can be determined. , and determine the bits corresponding to the data piece in the second bitmap, thereby reading the bits corresponding to the data piece in the first bitmap and the second bitmap respectively.
  • step S13 if the bit corresponding to the data piece in the first bitmap is a valid value (for example, 1) and the bit corresponding to the data piece in the second bitmap is a valid value (for example, 1) ), it is determined that data migration is required. For example, if the bit corresponding to the data piece in the first bit of the map is a valid value, it means that the data piece has been written, so file data exists. If the bit corresponding to the data slice in the second bitmap is a valid value, it means that a snapshot has been generated for the data slice. Therefore, data migration (such as COW) is required before the write operation is performed, so that after the write operation is performed, the data slice can still be processed according to the Snapshot obtains the original file data.
  • data migration such as COW
  • step S14 if the bit corresponding to the data piece in the first bitmap is an invalid value (for example, 0) or the bit corresponding to the data piece in the second bitmap is an invalid value (for example, 0) ), it is determined not to perform data migration. For example, if the bit corresponding to the data slice in the first bit of the map is an invalid value, it means that the data slice has not been written, so of course there is no need to perform data migration. If the bit corresponding to the data slice in the second bitmap is an invalid value, it means that the data slice has not been snapshotted. Therefore, even if a write operation is to be performed on the data slice, there is no need to perform data migration.
  • step S20 if it is determined to perform data migration, the data migration operation is performed and the corresponding bits in the first bitmap, the second bitmap, and the third bitmap are updated.
  • FIG. 5 is an exemplary flowchart of step S20 in FIG. 3 .
  • the above step S20 includes the following operations.
  • Step S21 Read the data slice corresponding to the data migration operation, construct the read data slice into a snapshot type data object and store it;
  • Step S22 Update the corresponding bits in the first bitmap to valid values, update the corresponding bits in the second bitmap to invalid values, and update the corresponding bits in the third bitmap to valid values.
  • the data migration operation can be similar to a normal COW, that is, the corresponding data piece is copied to a new storage location, and the snapshot of the corresponding version can be located in the new storage location, thereby facilitating Write the data piece in the original storage location.
  • the data part of the snapshot is logically abstracted, so that it can be implemented uniformly according to the file system data interface.
  • the data part in the file system can be divided into a data part corresponding to the source file item and a data part corresponding to the snapshot item.
  • a snap field can be added to the identifier (oid) of the object.
  • FIG. 6 is an exemplary flowchart of step S21 in FIG. 5 .
  • the above step S21 includes the following operations.
  • Step S211 Obtain the latest snapshot version number of the file path
  • Step S212 Read the data slice corresponding to the data migration operation, and store the read data slice as a data object;
  • Step S213 Add the latest snapshot version number and identification information indicating the snapshot type to the information field of the data object;
  • Step S214 Associate the snapshot item corresponding to the latest snapshot version number with the data object.
  • the latest snapshot version number of the file path is first obtained.
  • the file path refers to the path to the data piece to be operated, and the latest snapshot version number of the file path records the latest snapshot version of the data piece to be operated.
  • the latest snapshot version number may be 3, which means that the latest snapshot version of the data piece is the version 3 snapshot; in other examples, the latest snapshot version number may be 5, which means that the latest snapshot version number may be 5.
  • the latest snapshot version of the data sheet is the version 5 snapshot.
  • the above description of the latest snapshot version number is only illustrative, not restrictive, and does not constitute a limitation on the embodiments of the present disclosure.
  • step S212 the data slice corresponding to the data migration operation is read, and the read data slice is stored as a data object.
  • the read data piece can be constructed as a snapshot type data object.
  • snapshot type data object please refer to the previous description and will not be repeated here.
  • step S213 the latest snapshot version number and identification information indicating the snapshot type are added to the information field of the data object.
  • information describing the data object can be recorded in the information field of the data object. Therefore, the latest snapshot version number can be recorded in the information field, and identification information (such as a snap field) indicating the snapshot type can also be recorded in the information field. Therefore, when reading a data object of the snapshot type, it can be learned that the data object is the data part of the snapshot item, and the snapshot version corresponding to the data object can be learned.
  • the snapshot item corresponding to the latest snapshot version number is associated with the data object.
  • an appropriate addressing method can be used to establish a relationship between the data object and the corresponding snapshot item, so that the storage location of the data object can be located according to the corresponding snapshot item to facilitate reading of the data object.
  • the snapshot item corresponding to the data object is the snapshot item corresponding to the latest snapshot version number.
  • the latest snapshot version number is 5
  • the data object is associated with the snapshot item of version 5. Therefore, the storage location of the data object can be located based on the snapshot item of version 5, so that Read this data object.
  • step S22 the corresponding bits in the first bitmap are updated to valid values, the corresponding bits in the second bitmap are updated to invalid values, and the corresponding bits in the third bitmap are updated. Bits are updated to valid values.
  • FIG. 7 is an exemplary flowchart of step S22 in FIG. 5 .
  • the above step S22 includes the following operations.
  • Step S221 Update the corresponding bits in the first bitmap of the source file item to a valid value, and update the corresponding bits in the second bitmap of the source file item to an invalid value;
  • Step S222 Obtain the latest snapshot version number of the file path
  • Step S223 Update the corresponding bit in the third bitmap of the snapshot item corresponding to the latest snapshot version number to a valid value.
  • step S221 the corresponding bit in the first bit of the source file item is updated to a valid value (for example, updated to 1), thereby indicating that the data piece corresponding to the bit is written. Since the data slice corresponding to this bit has been migrated before the write operation, and the data slice after the write operation has not been snapshotted, the corresponding bit in the second bitmap of the source file item is updated to Invalid value (for example, updated to 0), which means that the data piece corresponding to this bit has not been snapshotted.
  • a valid value for example, updated to 1
  • step S222 the latest snapshot version number of the file path is obtained.
  • the latest snapshot version number of the file path you can refer to the previous content and will not be repeated here.
  • step S223 the corresponding bit in the third bitmap of the snapshot item corresponding to the latest snapshot version number is updated to a valid value, thereby indicating that the corresponding data piece has been processed in the snapshot item corresponding to the latest snapshot version number.
  • data migration For example, in some examples, assuming that the latest snapshot version number is 5, the bit corresponding to the data piece in the third bitmap of the snapshot item of version 5 is updated to a valid value, thereby indicating that the data piece is in the third bitmap. Data migration has been done in the snapshot item of version 5.
  • Figure 8 is a schematic flowchart of another data management method for a file system provided by some embodiments of the present disclosure.
  • the data management method may further include steps S30-S70.
  • steps S10-S20 you may refer to the above content and will not be described again here.
  • Step S30 In response to receiving the data write request, determine whether the data write request is an initial write request
  • Step S40 In response to the data write request being an initial write request, synchronize the content of the first bitmap to the second bitmap, and set all bit positions of the third bitmap to invalid values;
  • Step S50 In response to the data write request being an initial write request, synchronize the content of the first bitmap to the fourth bitmap;
  • Step S60 After performing the data migration operation and updating the corresponding bits in the first bitmap, the second bitmap, and the third bitmap, perform a write operation on the source file item;
  • Step S70 After determining whether to perform data migration based on the first bitmap and the second bitmap, in response to determining not to perform data migration, perform a write operation on the source file item.
  • step S30 after receiving the data write request, it is necessary to determine whether the data write request is an initial write request.
  • the global snapshot version number and the snapshot version number of the file path are not updated synchronously, the global snapshot version number may be delayed from the snapshot version number of the file path.
  • the second bitmap and The third bitmap may not exist before the initial write operation. Therefore, the second bitmap and the third bitmap need to be copied during the initial write operation. Therefore, it is necessary to determine whether the data write request is the first write request, which is, for example, a first cover write.
  • whether the data write request is an initial write request can be determined by determining whether the global snapshot version number and the snapshot version number of the file path are the same. If the global snapshot version number is different from the snapshot version number of the file path, it means that the data write request is the first write request; if the global snapshot version number is the same as the snapshot version number of the file path, it means that the data write request is not the first write request. ask.
  • step S40 if the data write request is an initial write request, the content of the first bitmap is synchronized to the second bitmap, and all bits of the third bitmap are set to invalid values. For example, you can copy the contents of the first bitmap to serve as the second bitmap, that is, make the second bitmap identical to the first bitmap. For example, all bits of the third bitmap are set to invalid values, which means that no data migration is performed.
  • the snapshot item in addition to the third bitmap, also includes a fourth bitmap. Multiple bits of the fourth bitmap correspond to multiple data slices one-to-one.
  • the fourth bitmap is used to record creation. This snapshot item is the writing status of the corresponding source file item.
  • the third bitmap and the fourth bitmap can be used for copying and deleting operations when reading and writing snapshot items.
  • step S50 if the data write request is an initial write request, the content of the first bit image is synchronized to the fourth bit image. For example, you can copy the contents of the first bitmap as the fourth bitmap, that is, make the fourth bitmap the same as the first bitmap. For example, when COW is triggered, the fourth bitmap does not change, and only the writing status of the source file when the snapshot item is created is recorded.
  • step S60 after performing the data migration operation and updating the corresponding bits in the first bitmap, the second bitmap, and the third bitmap (that is, after executing step S20), a write operation is performed on the source file item .
  • the write operation is triggered by a data write request, and the write operation can modify the data part of the source file item. Since before performing the operation of step S60, it has been judged whether data migration is required and each bitmap is updated when the data migration operation is performed. Therefore, the data slice can be written at this time without affecting the data that has been executed. The data portion of the data migration operation.
  • step S70 after determining whether to perform data migration based on the first bitmap and the second bitmap (that is, after executing step S10), if it is determined that data migration is not to be performed, then writing is performed on the data part of the source file item. operate. Since data migration is not required, the data portion of the source file item can be directly written.
  • Figure 9 is a schematic flowchart of another data management method for a file system provided by some embodiments of the present disclosure. As shown in Figure 9, in some embodiments, the data management method may also include the following operations.
  • Step S80 In response to receiving the snapshot read request, determine the data location according to the third bitmap of each version of the snapshot item and read the data;
  • Step S91 In response to receiving the clone write request, determine the data location based on the snapshot item associated with the clone item, copy the required data to the storage location corresponding to the clone item, and perform a write operation;
  • Step S92 In response to receiving the clone read request, determine the data location based on the snapshot item associated with the clone item and read the required data.
  • step S80 after receiving the snapshot read request, the data location is determined according to the third bitmap of the snapshot item of each version and the data is read.
  • FIG. 10 is an exemplary flowchart of step S80 in FIG. 9 .
  • the above step S80 includes the following operations.
  • Step S81 Determine the current snapshot item according to the snapshot read request, where the current snapshot item is the snapshot item of the version that needs to be read;
  • Step S82 Obtain the corresponding bits in the third bitmap of the current snapshot item
  • Step S83 In response to the corresponding bit in the third bitmap of the current snapshot item being a valid value, determine the data location according to the current snapshot item and read the data;
  • Step S84 In response to the corresponding bit in the third bitmap of the current snapshot item being an invalid value, sequentially obtain the corresponding bits in the third bitmap of the snapshot item with a larger version number until the acquired bit is a valid value. , determine the data location and read the data based on the snapshot item of the version corresponding to the valid value;
  • Step S85 In response to the fact that the corresponding bits in the third bitmap of all versions of the snapshot items are invalid values, determine the data location according to the source file item and read the data.
  • a snapshot read request can trigger a data read operation on the snapshot item, thereby reading the data portion of the snapshot item.
  • the current snapshot item is the snapshot item of the version that needs to be read.
  • a snapshot read request it is necessary to determine which version of the snapshot item among the five versions the snapshot read request is to read.
  • a snapshot read request will carry version information to know the version number of the snapshot item to be read.
  • step S82 after the current snapshot item is determined, the corresponding bits in the third bitmap of the current snapshot item are obtained.
  • the third bitmap records the migration status of each corresponding data piece.
  • step S83 if the corresponding bit in the third bitmap of the current snapshot item is a valid value, the data location is determined based on the current snapshot item and the data is read.
  • the corresponding bit in the third bitmap is a valid value, indicating that the corresponding data piece has undergone data migration, so the data location can be located based on the current snapshot item and the data can be read.
  • step S84 if the corresponding bit in the third bitmap of the current snapshot item is an invalid value, then the corresponding bits in the third bitmap of the snapshot item with a larger version number are obtained sequentially until the obtained bit
  • the bit is a valid value, and the data location is determined based on the snapshot item of the version corresponding to the valid value and the data is read.
  • the corresponding bit in the third bitmap of the current snapshot item is an invalid value, which means that the corresponding data piece has not been migrated. Therefore, the current snapshot item does not have a corresponding data part, and the data location cannot be located based on the current snapshot item. Therefore, it is necessary to obtain the corresponding bit in the third bitmap of the snapshot item with a larger version number. If the obtained bit is an invalid value, continue to obtain the corresponding bit in the third bitmap of the snapshot item with a larger version number. bit until the acquired bit is a valid value.
  • the current snapshot item is a snapshot item of version 5
  • the corresponding bit in its third bitmap is an invalid value
  • the corresponding bit in its third bitmap is If the corresponding bit is still an invalid value
  • the corresponding bit in the third bitmap of the 7th version snapshot item is a valid value, it means that the 7th version snapshot item has performed data migration for this data piece.
  • the data location can be determined based on the 7th version snapshot item and Read data.
  • step S85 if the corresponding bits in the third bitmap of all versions of the snapshot items are invalid values, the data location is determined according to the source file item and the data is read. For example, the corresponding bits in the third bitmap of all versions of the snapshot items are all invalid values, which means that no data migration has been performed on the snapshot items of all versions, so the data location can only be located and the data can be read based on the source file item.
  • the snapshot read request can be received and the read operation of the data part of the corresponding snapshot item can be completed. It should be noted that any read operation triggered by a read request will directly find the data location and will not trigger data migration.
  • the file system also includes clones, which are copies of the snapshot entries.
  • snapshot items cannot be written, but clone items can be written.
  • the clone item is an editable version of the corresponding snapshot item.
  • a clone write request can trigger a data write operation on the clone item, thereby making changes to the data portion of the clone item.
  • a clone item corresponds to a certain snapshot item, and when the clone item is generated, the content of the corresponding snapshot item is used as the content of the clone item. Therefore, it is necessary to determine the data location based on the snapshot item associated with the clone item, then copy the required data to the storage location corresponding to the clone item, and then perform the write operation.
  • clone item 1 exists in the file system, and clone item 1 is a clone version corresponding to the version 1 snapshot item, that is, clone item 1 is associated with the version 1 snapshot item.
  • clone item 1 is a clone version corresponding to the version 1 snapshot item, that is, clone item 1 is associated with the version 1 snapshot item.
  • step S80 may be used to determine the data location corresponding to the first version snapshot item, which will not be described again here. After that, copy the data to the storage location corresponding to clone item 1, and then perform the write operation for clone item 1.
  • step S92 if a clone read request is received, the data location is determined based on the snapshot item associated with the clone item and the required data is read.
  • a clone read request can trigger a data read operation on the clone item, thereby reading the data portion of the clone item.
  • clone item 1 exists in the file system, and clone item 1 is a clone version corresponding to the version 1 snapshot item, that is, clone item 1 is associated with the version 1 snapshot item.
  • step S80 may be used to determine the data location corresponding to the first version snapshot item, which will not be described again here. After that, just read the data according to the determined data location.
  • Figure 11A is one of the schematic diagrams of the data structure used by the data management method provided by some embodiments of the present disclosure.
  • the data structure is, for example, the structure of file data.
  • Fh is the file handle of any open file
  • uint32_t last_snap_id represents the global maximum snapshot version number
  • uint32_t max_peer_id represents the maximum snapshot version number of the file path.
  • uint32_t snap_id represents the id of the snapshot item. If it is a file type data object, uint32_t snap_id is all 0.
  • uint32_t peer_id represents the id of the snapshot item on the file path.
  • uint32_t snap_id is the id of the snapshot item
  • uint32_t peer_id is 0.
  • Bitmap base_alloc represents the first bitmap
  • Bitmap base_peer represents the second bitmap
  • Bitmap last_snap_alloc represents the third bitmap of the latest version of the snapshot item
  • Bitmap last_snap_peer represents the fourth bitmap of the latest version of the snapshot item.
  • Bitmap last_snap_alloc and Bitmap last_snap_peer in this data structure are redundant information that not only exists in this data structure, but is also stored in other locations in the file system.
  • Figure 11B is a second schematic diagram of the data structure used in the data management method provided by some embodiments of the present disclosure.
  • the data structure is, for example, a metadata structure.
  • uint32_t last_cow_snap_id represents the id of the snapshot item for the last data migration
  • uint32_t snap_id represents the id of the snapshot item
  • uint32_t peer_id represents the id of the snapshot item on the file path.
  • bitmap information bitmap information
  • Each operation is temporarily recorded in Fh, and then persisted to the disk.
  • the object (such as oid) dropped to the disk is determined by the metadata id (such as inodeid).
  • offset such as offset
  • bitmap such as bitmap
  • the data structure used in the embodiments of the present disclosure is not limited to the data structure shown in FIG. 11A and FIG. 11B , and any other applicable data structure may also be used, and the embodiments of the present disclosure are not limited to this.
  • the data structures shown in Figure 11A and Figure 11B are only illustrative and not restrictive.
  • the actual data structure used can also include more or less fields, parameters, functions, etc., which can be determined according to actual needs. .
  • Figure 12A is a schematic diagram of a read operation in a data management method provided by some embodiments of the present disclosure.
  • the read operation for the snapshot item and the read operation for the clone item will be briefly described below with reference to FIG. 12A.
  • the first version of the snapshot item (snapid:1) is generated, and the bit corresponding to w1 in the fourth bitmap of the snapshot item is 1.
  • a version 2 snapshot item (snapid:2) is generated, and the bits corresponding to w1 and w2 in the fourth bitmap of the snapshot item are 1 respectively.
  • a version 3 snapshot item (snapid:3) is generated, and the bits corresponding to w1, w2, and w3 in the fourth bitmap of the snapshot item are 1 respectively.
  • the bits corresponding to w1, w2, and w3 are 1, and since three snapshots were taken, the latest snapshot version number peerid of the file path is 3.
  • the data object (osd) consists of metadata id (inodeid), offset (offset), global snapshot version number (snapid) and file path snapshot version number (peerid). Data writing of snapshot items is triggered by the write process. If the corresponding bits in the third bitmap of each snapshot item larger than the current snapid are all 0, read the data object of the source file item basefs.
  • TFS_NOSNAP is the identification information indicating the read source file item. If it is TFS_NOSNAP, it is a read request for the source file item. This does not require additional operations. The process of reading the source file item in the normal file system can be used. If it is not TFS_NOSNAP, it is a read request for a snapshot item, and the value of snap_id is the version number of the snapshot item that needs to be read. This requires the process described above.
  • Figure 12B is a schematic diagram of a write operation in a data management method provided by some embodiments of the present disclosure.
  • the writing operation for the source file item and the writing operation for the clone item will be briefly described below with reference to FIG. 12B.
  • the source file item basefs namely w1, w2, and w3.
  • the first version of the snapshot item (snapid:1) is generated, and the bit corresponding to w1 in the fourth bitmap of the snapshot item is 1.
  • a version 2 snapshot item (snapid:2) is generated, and the bits corresponding to w1 and w2 in the fourth bitmap of the snapshot item are 1 respectively.
  • a version 3 snapshot item (snapid:3) is generated, and the bits corresponding to w1, w2, and w3 in the fourth bitmap of the snapshot item are 1 respectively.
  • the data corresponding to the source file item is read, and the oid of the snapshot type data object is constructed, which is composed of inodeid, offset, snapid and peerid. And, construct the data object oid to be newly written (that is, the data object of w2-1).
  • the difference between these two data objects is that the snapid of the data object of w2-1 is 0, while the snapid of the oid of the snapshot object is the version number of the largest snapshot id on the current file path.
  • the data of the original file w2 is migrated, and the snapshot item for data migration is the version 3 snapshot item.
  • the bits corresponding to w1, w2-1, and w3 in the fourth bitmap of the snapshot item are 1 respectively. Since 4 snapshots were taken, the latest snapshot version number peerid of the file path is 4.
  • the data write request refers to a write request for a source file item. For example, the judgment can be made based on the snap_id, for example, whether the snap_id is TFS_NOSNAP.
  • TFS_NOSNAP represents the identification information of the write source file item. If it is TFS_NOSNAP, it is a write operation of the source file item and a data write request. If it is not TFS_NOSNAP, it is a write operation of the snapshot item, and it will prompt that it cannot be written and return directly.
  • the data part is managed by introducing a bitmap (bitmap), and the data part in the snapshot of the distributed network attached storage (Network Attached Storage, NAS) file system is removed from the object storage device (OSD).
  • bitmap Bitmap
  • OSD object storage device
  • the data part logic of the snapshot is abstractly described, which can be easily implemented in the file system without using pointers to manage the data part.
  • the data part of the snapshot is implemented in a unified manner according to the file system data interface.
  • the data part of the snapshot and the data part of the file system are distinguished by the object name, for example, adding a snap field to the object oid.
  • the data management method provided by the embodiments of the present disclosure is not limited to application in NAS file systems, and can also be applied in file systems of any architecture. The embodiments of the present disclosure do not limit this.
  • the above-mentioned data management method for a file system may also include more or fewer steps, and the execution order of each step is not limited and may be determined according to actual needs.
  • At least one embodiment of the present disclosure also provides a data management device for a file system.
  • the data management device separates the data part of the snapshot from the object storage device, reduces the dependence of the file system snapshot on the object storage device, facilitates management and maintenance of the overall function of the snapshot, and facilitates developers to make changes to the object storage device.
  • Figure 13 is a schematic block diagram of a data management device for a file system provided by some embodiments of the present disclosure. As shown in FIG. 13 , in some embodiments, the data management device 100 includes a judgment unit 110 and a processing unit 120 .
  • a file system includes file data, and the file data is divided into multiple data pieces.
  • the file system also includes a source file item and a snapshot item.
  • the source file item includes the first bitmap and the second bitmap
  • the snapshot item includes the third bitmap.
  • Multiple bits in the first bit map correspond to multiple data slices one-to-one, and the first bit image is used to record the writing status of multiple data slices.
  • Multiple bits of the second bitmap correspond to multiple data slices one-to-one, and the second bitmap is used to record the snapshot generation status of the multiple data slices.
  • Multiple bits of the third bitmap correspond to multiple data slices one-to-one, and the third bitmap is used to record the transition status of the multiple data slices.
  • the determination unit 110 is configured to determine whether to perform data migration according to the first bitmap and the second bitmap in response to receiving the data write request. For example, the judgment unit 110 may execute step S10 of the data management method as shown in FIG. 3 .
  • the processing unit 120 is configured to perform data migration in response to the determination, perform a data migration operation and update corresponding bits in the first bitmap, the second bitmap, and the third bitmap. For example, the processing unit 120 may execute step S20 of the data management method as shown in FIG. 3 .
  • the judgment unit 110 and the processing unit 120 may be hardware, software, firmware, or any feasible combination thereof.
  • the judgment unit 110 and the processing unit 120 may be dedicated or general-purpose circuits, chips or devices, or may be a combination of a processor and a memory.
  • the embodiments of the present disclosure do not limit this.
  • each unit of the data management device 100 corresponds to each step of the aforementioned data management method.
  • the specific functions of the data management device 100 please refer to the relevant description of the data management method above. No further details will be given here.
  • the components and structures of the data management device 100 shown in Figure 13 are only exemplary and not restrictive.
  • the data management device 100 may also include other components and structures as needed.
  • At least one embodiment of the present disclosure also provides an electronic device, which includes the data management apparatus for a file system provided by any embodiment of the present disclosure.
  • This electronic device separates the data part of the snapshot from the object storage device, reduces the dependence of the file system snapshot on the object storage device, facilitates management and maintenance of the overall function of the snapshot, and facilitates developers to make changes to the object storage device.
  • FIG. 14 is a schematic block diagram of an electronic device provided by some embodiments of the present disclosure.
  • the electronic device 200 includes a data management device 210 , which may be the data management device 100 shown in FIG. 13 .
  • the electronic device 200 can be a distributed NAS system or any other system that needs to implement snapshots, and the embodiments of the present disclosure are not limited thereto.
  • the electronic device 200 please refer to the above description of the data management device 100, and will not be described again here.
  • At least one embodiment of the present disclosure also provides an electronic device.
  • the electronic device includes a processor and a memory.
  • One or more computer program modules are stored in the memory and configured to be executed by the processor.
  • One or more computers The program module includes a method for implementing the data management method for a file system provided by any embodiment of the present disclosure.
  • This electronic device separates the data part of the snapshot from the object storage device, reduces the dependence of the file system snapshot on the object storage device, facilitates management and maintenance of the overall function of the snapshot, and facilitates developers to make changes to the object storage device.
  • FIG. 15 is a schematic block diagram of another electronic device provided by some embodiments of the present disclosure.
  • the electronic device 300 includes a processor 310 and a memory 320 .
  • Memory 320 is used to store non-transitory computer-readable instructions (eg, one or more computer program modules).
  • the processor 310 is configured to execute non-transitory computer readable instructions. When the non-transitory computer readable instructions are executed by the processor 310, they may perform one or more steps in the data management method for a file system described above.
  • Memory 320 and processor 310 may be interconnected by a bus system and/or other forms of connection mechanisms (not shown).
  • the processor 310 may be a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), or other form of processing unit with data processing capabilities and/or program execution capabilities, such as field programmable Gate array (FPGA), etc.; for example, the central processing unit (CPU) can be X86 or ARM architecture, etc.
  • the processor 310 may be a general-purpose processor or a special-purpose processor that may control other components in the electronic device 300 to perform desired functions.
  • memory 320 may include any combination of one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory.
  • Volatile memory may include, for example, random access memory (RAM) and/or cache memory (cache).
  • Non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, and the like.
  • One or more computer program modules may be stored on the computer-readable storage medium, and the processor 310 may run the one or more computer program modules to implement various functions of the electronic device 300 .
  • Various application programs and various data, as well as various data used and/or generated by the application programs, etc. can also be stored in the computer-readable storage medium.
  • At least one embodiment of the present disclosure also provides a storage medium for storing non-transitory computer-readable instructions.
  • the non-transitory computer-readable instructions When executed by a computer, the method for file provided by any embodiment of the present disclosure can be implemented.
  • Systematic approach to data management Using this storage medium, the data part of the snapshot can be separated from the object storage device, reducing the dependence of the file system snapshot on the object storage device, making it easier to manage and maintain the overall function of the snapshot, and making it easier for developers to make changes to the object storage device.
  • Figure 16 is a schematic diagram of a storage medium provided by some embodiments of the present disclosure.
  • storage medium 400 is used to store non-transitory computer-readable instructions 410 .
  • the non-transitory computer readable instructions 410 when executed by a computer may perform one or more steps in the data management method for a file system described above.
  • the storage medium 400 can be applied to the above-mentioned electronic device.
  • the storage medium 400 may be the memory 320 in the electronic device 300 shown in FIG. 15 .
  • the storage medium 400 for relevant description of the storage medium 400, reference may be made to the corresponding description of the memory 320 in the electronic device 300 shown in FIG. 15, which will not be described again here.

Abstract

A data management method and apparatus for a file system, an electronic device, and a storage medium. A file system comprises file data, and the file data is divided into a plurality of data slices. The file system further comprises a source file item and a snapshot item. The source file item comprises a first bitmap and a second bitmap. The snapshot item comprises a third bitmap. The first bitmap is used for recording the writing states of a plurality of data slices. The second bitmap is used for recording the snapshot generation states of a plurality of data slices. The third bitmap is used for recording the migration states of a plurality of data slices. The method comprises: in response to receiving a data write request, determining, according to a first bitmap and a second bitmap, whether to perform data migration (S10); and in response to determining to perform data migration, executing a data migration operation and updating corresponding bits in the first bitmap, the second bitmap and a third bitmap (S20). In the described method, the data part of a snapshot is separated from an object storage device, reducing the dependence of a file system snapshot on the object storage device, thus the overall function of the snapshot is convenient to manage and maintain.

Description

文件系统的数据管理方法及装置、电子设备及存储介质Data management method and device, electronic equipment and storage medium of file system
本申请要求于2022年3月21日递交的中国专利申请第202210274271.0号的优先权,在此全文引用上述中国专利申请公开的内容以作为本申请的一部分。This application claims priority from Chinese Patent Application No. 202210274271.0 submitted on March 21, 2022. The disclosure of the above Chinese patent application is hereby cited in its entirety as part of this application.
技术领域Technical field
本公开的实施例涉及一种用于文件系统的数据管理方法及数据管理装置、电子设备及存储介质。Embodiments of the present disclosure relate to a data management method and data management device for a file system, electronic equipment, and storage media.
背景技术Background technique
在存储领域中,随着数据体积的日益增长,数据备份的重要性逐渐凸显。对于存储系统而言,存储数据并保证数据安全是其最基本的功能和要求。快照是一种数据备份方法,由于可以瞬间完成,实现数据的零窗口备份,因此快照成为众多数据备份技术中一种常用的、基础的数据备份技术,实现快照成为存储行业中备份的基石。In the storage field, with the increasing volume of data, the importance of data backup has gradually become more and more prominent. For a storage system, storing data and ensuring data security are its most basic functions and requirements. Snapshot is a data backup method. Because it can be completed instantly and achieve zero-window backup of data, snapshots have become a common and basic data backup technology among many data backup technologies. Snapshots have become the cornerstone of backup in the storage industry.
快照是指关于指定数据集合的一个完全可用拷贝,该拷贝包括相应数据在某个时间点(拷贝开始的时间点)的映像。快照的主要作用是能够进行数据备份与恢复。当存储设备发生应用故障或者文件损坏时可以进行快速的数据恢复,将数据恢复至某个可用的时间点的状态,由此可以满足企业对业务连续性和数据可靠性的要求。A snapshot refers to a fully available copy of a specified data collection, which includes an image of the corresponding data at a certain point in time (the point in time when the copy starts). The main function of snapshots is to enable data backup and recovery. When an application failure or file corruption occurs on the storage device, rapid data recovery can be performed to restore the data to a certain available point in time, thereby meeting the enterprise's requirements for business continuity and data reliability.
发明内容Contents of the invention
本公开至少一个实施例提供一种用于文件系统的数据管理方法,其中,所述文件系统包括文件数据,所述文件数据被划分为多个数据片;所述文件系统还包括源文件项和快照项,所述源文件项包括第一位图和第二位图,所述快照项包括第三位图;所述第一位图的多个比特位与所述多个数据片一一对应,所述第一位图用于记录所述多个数据片的写入状态;所述第二位图的多个比特位与所述多个数据片一一对应,所述第二位图用于记录所述多个数据片的快照生成状态;所述第三位图的多个比特位与所述多个数据片一一对应,所述第三位 图用于记录所述多个数据片的迁移状态;所述方法包括:响应于接收到数据写请求,根据所述第一位图和所述第二位图判断是否进行数据迁移;响应于确定进行数据迁移,执行数据迁移操作并更新所述第一位图、所述第二位图、所述第三位图中对应的比特位。At least one embodiment of the present disclosure provides a data management method for a file system, wherein the file system includes file data divided into multiple data slices; the file system further includes source file items and Snapshot item, the source file item includes a first bitmap and a second bitmap, the snapshot item includes a third bitmap; multiple bits of the first bitmap correspond to the multiple data pieces one-to-one , the first bitmap is used to record the writing status of the multiple data slices; the multiple bits of the second bitmap correspond to the multiple data slices one-to-one, and the second bitmap uses In recording the snapshot generation status of the plurality of data pieces; a plurality of bits of the third bitmap correspond to the plurality of data pieces, and the third bitmap is used to record the plurality of data pieces. migration status; the method includes: in response to receiving a data write request, determining whether to perform data migration according to the first bitmap and the second bitmap; in response to determining to perform data migration, performing a data migration operation and updating Corresponding bits in the first bitmap, the second bitmap, and the third bitmap.
例如,在本公开一实施例提供的方法中,根据所述第一位图和所述第二位图判断是否进行数据迁移,包括:根据所述数据写请求确定所要操作的数据片;读取所述第一位图中与所述数据片对应的比特位,并且读取所述第二位图中与所述数据片对应的比特位;响应于所述第一位图中与所述数据片对应的比特位为有效值且所述第二位图中与所述数据片对应的比特位为有效值,确定进行数据迁移。For example, in a method provided by an embodiment of the present disclosure, determining whether to perform data migration based on the first bitmap and the second bitmap includes: determining the data slice to be operated on based on the data write request; reading The bits in the first bitmap corresponding to the data piece are read, and the bits in the second bitmap corresponding to the data piece are read; in response to the bits in the first bitmap corresponding to the data piece. If the bit corresponding to the slice is a valid value and the bit corresponding to the data slice in the second bitmap is a valid value, it is determined to perform data migration.
例如,在本公开一实施例提供的方法中,根据所述第一位图和所述第二位图判断是否进行数据迁移,还包括:响应于所述第一位图中与所述数据片对应的比特位为无效值或者所述第二位图中与所述数据片对应的比特位为无效值,确定不进行数据迁移。For example, in a method provided by an embodiment of the present disclosure, determining whether to perform data migration based on the first bitmap and the second bitmap further includes: responding to the difference between the first bitmap and the data slice. If the corresponding bit is an invalid value or the bit corresponding to the data slice in the second bitmap is an invalid value, it is determined that data migration is not performed.
例如,在本公开一实施例提供的方法中,执行所述数据迁移操作并更新所述第一位图、所述第二位图、所述第三位图中对应的比特位,包括:读取所述数据迁移操作对应的数据片,将读取的数据片构造为快照类型的数据对象并进行存储;将所述第一位图中对应的比特位更新为有效值,将所述第二位图中对应的比特位更新为无效值,将所述第三位图中对应的比特位更新为有效值。For example, in a method provided by an embodiment of the present disclosure, performing the data migration operation and updating corresponding bits in the first bitmap, the second bitmap, and the third bitmap includes: reading Get the data slice corresponding to the data migration operation, construct the read data slice into a snapshot type data object and store it; update the corresponding bits in the first image to a valid value, and convert the second The corresponding bits in the bitmap are updated to invalid values, and the corresponding bits in the third bitmap are updated to valid values.
例如,在本公开一实施例提供的方法中,读取所述数据迁移操作对应的数据片,将读取的数据片构造为所述快照类型的数据对象并进行存储,包括:获取文件路径的最新快照版本号;读取所述数据迁移操作对应的数据片,将读取的数据片作为数据对象进行存储;将所述最新快照版本号以及表示所述快照类型的标识信息增加到所述数据对象的信息域中;将对应于所述最新快照版本号的快照项与所述数据对象关联。For example, in a method provided by an embodiment of the present disclosure, reading the data slice corresponding to the data migration operation, constructing the read data slice into a data object of the snapshot type and storing it includes: obtaining the file path The latest snapshot version number; read the data slice corresponding to the data migration operation, and store the read data slice as a data object; add the latest snapshot version number and identification information indicating the snapshot type to the data In the information field of the object; associate the snapshot item corresponding to the latest snapshot version number with the data object.
例如,在本公开一实施例提供的方法中,将所述第一位图中对应的比特位更新为有效值,将所述第二位图中对应的比特位更新为无效值,将所述第三位图中对应的比特位更新为有效值,包括:将所述源文件项的所述第一位图中对应的比特位更新为有效值,将所述源文件项的所述第二位图中对应的比特位更新为无效值;获取文件路径的最新快照版本号;将所述最新快照版本号对应的快照项的所述第三位图中对应的比特位更新为有效值。For example, in a method provided by an embodiment of the present disclosure, the corresponding bits in the first bitmap are updated to valid values, the corresponding bits in the second bitmap are updated to invalid values, and the corresponding bits in the second bitmap are updated to invalid values. Updating the corresponding bits in the third bitmap to a valid value includes: updating the corresponding bits in the first bitmap of the source file item to a valid value, and updating the second bitmap of the source file item to a valid value. The corresponding bits in the bitmap are updated to invalid values; the latest snapshot version number of the file path is obtained; and the corresponding bits in the third bitmap of the snapshot item corresponding to the latest snapshot version number are updated to valid values.
例如,本公开一实施例提供的方法还包括:响应于接收到所述数据写请求,判断所述数据写请求是否为初次写请求;响应于所述数据写请求为所述初次写请求,将所述第一位图的内容同步到所述第二位图,并将所述第三位图的全部比特位置为无效值。For example, the method provided by an embodiment of the present disclosure further includes: in response to receiving the data write request, determining whether the data write request is an initial write request; in response to the data write request being the initial write request, The content of the first bitmap is synchronized to the second bitmap, and all bit positions of the third bitmap are set to invalid values.
例如,在本公开一实施例提供的方法中,所述快照项还包括第四位图,所述第四位图的多个比特位与所述多个数据片一一对应,所述第四位图用于记录创建所述快照项时对应的源文件项的写入状态;所述方法还包括:响应于所述数据写请求为所述初次写请求,将所述第一位图的内容同步到所述第四位图。For example, in the method provided by an embodiment of the present disclosure, the snapshot item further includes a fourth bitmap, and a plurality of bits of the fourth bitmap correspond to the plurality of data slices in a one-to-one manner. The bitmap is used to record the writing status of the corresponding source file item when the snapshot item is created; the method also includes: in response to the data write request being the initial write request, converting the content of the first bitmap to Sync to the fourth bitmap.
例如,本公开一实施例提供的方法还包括:响应于接收到快照读请求,根据各个版本的快照项的第三位图确定数据位置并读取数据。For example, a method provided by an embodiment of the present disclosure further includes: in response to receiving a snapshot read request, determining the data location according to the third bitmap of each version of the snapshot item and reading the data.
例如,在本公开一实施例提供的方法中,根据各个版本的快照项的第三位图确定数据位置并读取数据,包括:根据所述快照读请求确定当前快照项,其中,所述当前快照项是需要读取的版本的快照项;获取所述当前快照项的第三位图中对应的比特位;响应于所述当前快照项的第三位图中对应的比特位为有效值,根据所述当前快照项确定数据位置并读取数据;响应于所述当前快照项的第三位图中对应的比特位为无效值,依次获取更大版本号的快照项的第三位图中对应的比特位,直到获取的比特位为有效值,根据所述有效值对应的版本的快照项确定数据位置并读取数据;响应于全部版本的快照项的第三位图中对应的比特位均为无效值,根据所述源文件项确定数据位置并读取数据。For example, in a method provided by an embodiment of the present disclosure, determining the data location and reading the data according to the third bitmap of the snapshot item of each version includes: determining the current snapshot item according to the snapshot read request, wherein the current snapshot item The snapshot item is a snapshot item of the version that needs to be read; the corresponding bit in the third bitmap of the current snapshot item is obtained; in response to the corresponding bit in the third bitmap of the current snapshot item being a valid value, Determine the data location according to the current snapshot item and read the data; in response to the corresponding bit in the third bitmap of the current snapshot item being an invalid value, obtain the third bitmap of the snapshot item with a larger version number in sequence. Corresponding bits, until the obtained bits are valid values, determine the data location and read the data according to the snapshot item of the version corresponding to the valid value; respond to the corresponding bits in the third bitmap of all versions of the snapshot items All are invalid values. Determine the data location and read the data based on the source file item.
例如,在本公开一实施例提供的方法中,所述文件系统还包括克隆项,所述克隆项是所述快照项的拷贝;所述方法还包括:响应于接收到克隆写请求,基于与所述克隆项关联的快照项确定数据位置并将需要的数据复制到所述克隆项对应的存储位置,并执行写操作。For example, in a method provided by an embodiment of the present disclosure, the file system further includes a clone item, and the clone item is a copy of the snapshot item; the method further includes: in response to receiving a clone write request, based on The snapshot item associated with the clone item determines the data location, copies the required data to the storage location corresponding to the clone item, and performs a write operation.
例如,本公开一实施例提供的方法还包括:响应于接收到克隆读请求,基于与所述克隆项关联的快照项确定数据位置并读取所需要的数据。For example, a method provided by an embodiment of the present disclosure further includes: in response to receiving a clone read request, determining the data location based on the snapshot item associated with the clone item and reading the required data.
例如,在本公开一实施例提供的方法中,在执行所述数据迁移操作并更新所述第一位图、所述第二位图、所述第三位图中对应的比特位之后,所述方法还包括:对所述源文件项执行写操作。For example, in the method provided by an embodiment of the present disclosure, after performing the data migration operation and updating the corresponding bits in the first bitmap, the second bitmap, and the third bitmap, the The method further includes: performing a write operation on the source file item.
例如,在本公开一实施例提供的方法中,在根据所述第一位图和所述第二位图判断是否进行数据迁移之后,所述方法还包括:响应于确定不进行数据迁移,对所述源文件项执行写操作。For example, in a method provided by an embodiment of the present disclosure, after determining whether to perform data migration based on the first bitmap and the second bitmap, the method further includes: in response to determining not to perform data migration, The source file item performs a write operation.
本公开至少一个实施例还提供一种用于文件系统的数据管理装置,其中,所述文件系统包括文件数据,所述文件数据被划分为多个数据片;所述文件系统还包括源文件项和快照项,所述源文件项包括第一位图和第二位图,所述快照项包括第三位图;所述第一位图的多个比特位与所述多个数据片一一对应,所述第一位图用于记录所述多个数据片的写入状态;所述第二位图的多个比特位与所述多个数据片一一对应,所述第二位图用于记录所述多个数据片的快照生成状态;所述第三位图的多个比特位与所述多个数据片一一对应,所述第三位图用于记录所述多个数据片的迁移状态;所述装置包括:判断单元,配置为响应于接收到数据写请求,根据所述第一位图和所述第二位图判断是否进行数据迁移;处理单元,配置为响应于确定进行数据迁移,执行数据迁移操作并更新所述第一位图、所述第二位图、所述第三位图中对应的比特位。At least one embodiment of the present disclosure also provides a data management device for a file system, wherein the file system includes file data, and the file data is divided into multiple data slices; the file system also includes source file items and a snapshot item, the source file item includes a first bitmap and a second bitmap, the snapshot item includes a third bitmap; the multiple bits of the first image are identical to the multiple data pieces. Correspondingly, the first bitmap is used to record the writing status of the multiple data slices; the multiple bits of the second bitmap correspond to the multiple data slices one-to-one, and the second bitmap used to record the snapshot generation status of the plurality of data pieces; a plurality of bits of the third bitmap correspond to the plurality of data pieces, and the third bitmap is used to record the plurality of data The migration status of the slice; the device includes: a judgment unit configured to respond to receiving a data write request and determine whether to perform data migration according to the first bitmap and the second bitmap; a processing unit configured to respond to It is determined to perform data migration, perform a data migration operation and update corresponding bits in the first bitmap, the second bitmap, and the third bitmap.
本公开至少一个实施例还提供一种电子设备,包括本公开任一实施例提供的用于文件系统的数据管理装置。At least one embodiment of the present disclosure also provides an electronic device, including the data management apparatus for a file system provided by any embodiment of the present disclosure.
本公开至少一个实施例还提供一种电子设备,包括:处理器;存储器,包括一个或多个计算机程序模块;其中,所述一个或多个计算机程序模块被存储在所述存储器中并被配置为由所述处理器执行,所述一个或多个计算机程序模块包括用于实现本公开任一实施例提供的用于文件系统的数据管理方法。At least one embodiment of the present disclosure also provides an electronic device, including: a processor; a memory including one or more computer program modules; wherein the one or more computer program modules are stored in the memory and configured To be executed by the processor, the one or more computer program modules include a method for implementing the data management method for a file system provided by any embodiment of the present disclosure.
本公开至少一个实施例还提供一种存储介质,用于存储非暂时性计算机可读指令,当所述非暂时性计算机可读指令由计算机执行时可以实现本公开任一实施例提供的用于文件系统的数据管理方法。At least one embodiment of the present disclosure also provides a storage medium for storing non-transitory computer-readable instructions. When the non-transitory computer-readable instructions are executed by a computer, the methods provided by any embodiment of the present disclosure can be implemented. File system data management methods.
附图说明Description of the drawings
为了更清楚地说明本公开实施例的技术方案,下面将对实施例的附图作简单地介绍,显而易见地,下面描述中的附图仅仅涉及本公开的一些实施例,而非对本公开的限制。In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings in the following description only relate to some embodiments of the present disclosure and do not limit the present disclosure. .
图1为一种文件系统的文件结构示意图;Figure 1 is a schematic diagram of the file structure of a file system;
图2为本公开一些实施例提供的一种文件系统中的位图的示意图;Figure 2 is a schematic diagram of a bitmap in a file system provided by some embodiments of the present disclosure;
图3为本公开一些实施例提供的一种用于文件系统的数据管理方法的流程示意图;Figure 3 is a schematic flowchart of a data management method for a file system provided by some embodiments of the present disclosure;
图4为图3中步骤S10的示例性流程图;Figure 4 is an exemplary flow chart of step S10 in Figure 3;
图5为图3中步骤S20的示例性流程图;Figure 5 is an exemplary flow chart of step S20 in Figure 3;
图6为图5中步骤S21的示例性流程图;Figure 6 is an exemplary flow chart of step S21 in Figure 5;
图7为图5中步骤S22的示例性流程图;Figure 7 is an exemplary flow chart of step S22 in Figure 5;
图8为本公开一些实施例提供的另一种用于文件系统的数据管理方法的流程示意图;Figure 8 is a schematic flowchart of another data management method for a file system provided by some embodiments of the present disclosure;
图9为本公开一些实施例提供的另一种用于文件系统的数据管理方法的流程示意图;Figure 9 is a schematic flowchart of another data management method for a file system provided by some embodiments of the present disclosure;
图10为图9中步骤S80的示例性流程图;Figure 10 is an exemplary flow chart of step S80 in Figure 9;
图11A为本公开一些实施例提供的数据管理方法所采用的数据结构示意图之一;Figure 11A is one of the schematic diagrams of the data structure used in the data management method provided by some embodiments of the present disclosure;
图11B为本公开一些实施例提供的数据管理方法所采用的数据结构示意图之二;Figure 11B is a second schematic diagram of the data structure used in the data management method provided by some embodiments of the present disclosure;
图12A为本公开一些实施例提供的数据管理方法中的读操作的示意图;Figure 12A is a schematic diagram of a read operation in a data management method provided by some embodiments of the present disclosure;
图12B为本公开一些实施例提供的数据管理方法中的写操作的示意图;Figure 12B is a schematic diagram of a write operation in a data management method provided by some embodiments of the present disclosure;
图13为本公开一些实施例提供的一种用于文件系统的数据管理装置的示意框图;Figure 13 is a schematic block diagram of a data management device for a file system provided by some embodiments of the present disclosure;
图14为本公开一些实施例提供的一种电子设备的示意框图;Figure 14 is a schematic block diagram of an electronic device provided by some embodiments of the present disclosure;
图15为本公开一些实施例提供的另一种电子设备的示意框图;Figure 15 is a schematic block diagram of another electronic device provided by some embodiments of the present disclosure;
图16为本公开一些实施例提供的一种存储介质的示意图。Figure 16 is a schematic diagram of a storage medium provided by some embodiments of the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例的附图,对本公开实施例的技术方案进行清楚、完整地描述。显然,所描述的实施例是本公开的一部分实施例,而不是全部的实施例。基于所描述的本公开的实施例,本领域普通技术人员在无需创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings of the embodiments of the present disclosure. Obviously, the described embodiments are some, but not all, of the embodiments of the present disclosure. Based on the described embodiments of the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present disclosure.
除非另外定义,本公开使用的技术术语或者科学术语应当为本公开所属领域内具有一般技能的人士所理解的通常意义。本公开中使用的“第一”、“第二”以及类似的词语并不表示任何顺序、数量或者重要性,而只是用来区分不同的组成部分。同样,“一个”、“一”或者“该”等类似词语也不表示数量限制,而是表示存在至少一个。“包括”或者“包含”等类似的词语意指出现该词前面的元件或者物件涵盖出现在该词后面列举的元件或者物件及其等同, 而不排除其他元件或者物件。“连接”或者“相连”等类似的词语并非限定于物理的或者机械的连接,而是可以包括电性的连接,不管是直接的还是间接的。“上”、“下”、“左”、“右”等仅用于表示相对位置关系,当被描述对象的绝对位置改变后,则该相对位置关系也可能相应地改变。Unless otherwise defined, technical terms or scientific terms used in this disclosure shall have the usual meaning understood by a person with ordinary skill in the art to which this disclosure belongs. "First", "second" and similar words used in this disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Likewise, similar words such as "a", "an" or "the" do not indicate a quantitative limitation but rather indicate the presence of at least one. Words such as "include" or "include" mean that the elements or things appearing before the word include the elements or things listed after the word and their equivalents, without excluding other elements or things. Words such as "connected" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right", etc. are only used to express relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
快照通常用于文件系统,由于文件系统具有复杂的元数据、数据等信息,这导致快照实现较为复杂。例如,在生成快照时,无法实现快照之间的级联关系,即本目录做了快照,一般会使得子目录无法再做快照,这对快照的实现造成了限制,导致使用不便。并且,快照的数据部分对对象存储设备(Object Storage Device,OSD)的依赖性强,使得针对OSD的优化、重构、新特性开发受到限制,也不便于维护快照功能。Snapshots are usually used in file systems. Since file systems have complex metadata, data and other information, snapshot implementation is more complicated. For example, when generating snapshots, the cascading relationship between snapshots cannot be realized. That is, if a snapshot is taken of this directory, it will generally make it impossible to take snapshots of subdirectories. This limits the implementation of snapshots and leads to inconvenience in use. Moreover, the data part of the snapshot has a strong dependence on the Object Storage Device (OSD), which limits the optimization, reconstruction, and development of new features for OSD, and makes it inconvenient to maintain the snapshot function.
本公开至少一个实施例提供一种用于文件系统的数据管理方法及数据管理装置、电子设备及存储介质。该数据管理方法将快照的数据部分从对象存储设备(OSD)中独立出来,减少了文件系统快照对对象存储设备的依赖,便于管理维护快照整体功能,便于开发者对对象存储设备进行更改。At least one embodiment of the present disclosure provides a data management method and data management device, electronic device and storage medium for a file system. This data management method separates the data part of the snapshot from the object storage device (OSD), reduces the dependence of the file system snapshot on the object storage device, facilitates management and maintenance of the overall snapshot function, and facilitates developers to make changes to the object storage device.
下面,将参考附图详细地说明本公开的实施例。应当注意的是,不同的附图中相同的附图标记将用于指代已描述的相同的元件。Hereinafter, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings. It should be noted that the same reference numbers in different figures will be used to refer to the same elements that have been described.
本公开至少一个实施例提供一种用于文件系统的数据管理方法。该文件系统包括文件数据,文件数据被划分为多个数据片。文件系统还包括源文件项和快照项。源文件项包括第一位图和第二位图,快照项包括第三位图。第一位图的多个比特位与多个数据片一一对应,第一位图用于记录多个数据片的写入状态。第二位图的多个比特位与多个数据片一一对应,第二位图用于记录多个数据片的快照生成状态。第三位图的多个比特位与多个数据片一一对应,第三位图用于记录多个数据片的迁移状态。该方法包括:响应于接收到数据写请求,根据第一位图和第二位图判断是否进行数据迁移;响应于确定进行数据迁移,执行数据迁移操作并更新第一位图、第二位图、第三位图中对应的比特位。At least one embodiment of the present disclosure provides a data management method for a file system. The file system includes file data, and the file data is divided into multiple data pieces. The file system also includes source file entries and snapshot entries. The source file item includes the first bitmap and the second bitmap, and the snapshot item includes the third bitmap. Multiple bits in the first bit map correspond to multiple data slices one-to-one, and the first bit image is used to record the writing status of multiple data slices. Multiple bits of the second bitmap correspond to multiple data slices one-to-one, and the second bitmap is used to record the snapshot generation status of the multiple data slices. Multiple bits of the third bitmap correspond to multiple data slices one-to-one, and the third bitmap is used to record the transition status of the multiple data slices. The method includes: in response to receiving a data write request, determining whether to perform data migration based on the first bitmap and the second bitmap; in response to determining to perform data migration, performing a data migration operation and updating the first bitmap and the second bitmap. , the corresponding bit in the third bitmap.
例如,文件系统通常包括数据和元数据。元数据是用于描述数据的数据(data about data),主要描述数据属性的信息,用来支持例如指示存储位置、历史数据、资源查找、文件记录等功能。文件系统的元数据例如包括目录项(dentry)和索引节点(inode)。目录项用于描述文件系统中文件(或文件夹)的组织形式,索引节点为文件(或文件夹)的属性信息。在文件系统中,每个文件都对应一个索引节点,以作为该文件的唯一编号,文件系统通过索引节点 编号(inodeid)来访问索引节点的信息。For example, file systems typically include data and metadata. Metadata is data used to describe data (data about data). It mainly describes information about data attributes and is used to support functions such as indicating storage location, historical data, resource search, file recording, etc. Metadata of a file system includes, for example, directory entries (dentries) and index nodes (inodes). Directory entries are used to describe the organizational form of files (or folders) in the file system, and index nodes are attribute information of files (or folders). In the file system, each file corresponds to an index node, which serves as the unique number of the file. The file system accesses the information of the index node through the index node number (inodeid).
数据(或称为数据部分)是每个文件的具体内容,利用元数据可以得到数据部分的属性信息,从而确定数据部分的存储位置(或存储地址),由此可以对数据部分进行读写操作。例如,在一些示例中,如图1所示,利用该文件系统的目录项,可以得到反映该文件系统组织信息的树状结构,然后,利用文件(或文件夹)dir1、dir2、dir3、file1、file2的索引节点编号获取对应的索引节点的信息,从而可以读取到每个文件(或文件夹)的具体内容,也即对应的数据部分。例如,在该示例中,dir1、dir2、dir3表示文件夹,file1、file2表示文件。Data (or data part) is the specific content of each file. Metadata can be used to obtain the attribute information of the data part, thereby determining the storage location (or storage address) of the data part, so that the data part can be read and written. . For example, in some examples, as shown in Figure 1, using the directory entries of the file system, a tree structure reflecting the organizational information of the file system can be obtained, and then using the files (or folders) dir1, dir2, dir3, file1 , the index node number of file2 obtains the information of the corresponding index node, so that the specific content of each file (or folder) can be read, that is, the corresponding data part. For example, in this example, dir1, dir2, and dir3 represent folders, and file1 and file2 represent files.
例如,在本公开的实施例中,文件系统包括文件数据,文件数据即为前述的数据部分。例如,文件数据是指该文件系统中除了元数据以外的数据。例如,文件数据被划分为多个数据片。每个数据片的大小例如为512K。当然,本公开的实施例不限于此,每个数据片的大小也可以为256K、1M、2M或其他任意的大小,这可以根据实际需求而定,例如根据文件系统的特性而定。For example, in the embodiment of the present disclosure, the file system includes file data, and the file data is the aforementioned data part. For example, file data refers to data in the file system other than metadata. For example, file data is divided into multiple data pieces. The size of each data piece is, for example, 512K. Of course, the embodiments of the present disclosure are not limited to this, and the size of each data piece can also be 256K, 1M, 2M, or any other size, which can be determined according to actual needs, such as the characteristics of the file system.
在本公开的实施例中,文件系统还包括源文件项和快照项。源文件项是指针对文件系统本身的文件或文件夹的数据对象,而快照项是指针对文件系统的快照的数据对象。例如,不同的快照项针对不同版本的快照。In embodiments of the present disclosure, the file system also includes source file items and snapshot items. The source file item refers to the data object for the file or folder of the file system itself, and the snapshot item refers to the data object for the snapshot of the file system. For example, different snapshot items target different versions of snapshots.
在本公开的实施例中,例如,源文件项包括第一位图和第二位图,快照项包括第三位图。这里,第一位图、第二位图、第三位图均是指bitmap,“第一”、“第二”、“第三”用于区分不同的bitmap。每个位图包括多个比特位(bit),位图的大小(bitmap size)例如为4k,也可以为其他任意适用的大小,本公开的实施例对此不作限制。例如,在一些示例中,位图的每个比特位(bit)对应大小为512K的数据片,因此位图的每字节对应一个4M的数据块(block),4k的位图(bitmap size=4k)可以对应16G的文件数据,每当文件写入内容超过16G后,位图会再动态申请4k大小。例如,第一位图、第二位图、第三位图的大小可以相同或不同。In an embodiment of the present disclosure, for example, the source file item includes a first bitmap and a second bitmap, and the snapshot item includes a third bitmap. Here, the first bitmap, the second bitmap, and the third bitmap all refer to bitmaps, and "first", "second", and "third" are used to distinguish different bitmaps. Each bitmap includes a plurality of bits, and the size of the bitmap (bitmap size) is, for example, 4k, or can be any other applicable size. The embodiments of the present disclosure do not limit this. For example, in some examples, each bit of the bitmap corresponds to a data piece of size 512K, so each byte of the bitmap corresponds to a 4M data block, and the 4k bitmap (bitmap size = 4k) can correspond to 16G file data. Whenever the file written content exceeds 16G, the bitmap will dynamically apply for 4k size. For example, the size of the first bitmap, the second bitmap, and the third bitmap can be the same or different.
第一位图的多个比特位与多个数据片一一对应,第一位图用于记录多个数据片的写入状态。例如,第一位图的每个比特位对应于一个数据片,不同的比特位对应于不同的数据片。对于第一位图的每个比特位,该比特位为有效值时表示对应的数据片已被写入,该比特位为无效值时表示对应的数据片未被写入。例如,可以用“1”表示有效值,用“0”表示无效值。Multiple bits in the first bit map correspond to multiple data slices one-to-one, and the first bit image is used to record the writing status of multiple data slices. For example, each bit of the first bit map corresponds to a piece of data, and different bits correspond to different pieces of data. For each bit of the first bit map, when the bit is a valid value, it means that the corresponding data piece has been written, and when the bit is an invalid value, it means that the corresponding data piece has not been written. For example, you can use "1" to represent valid values and "0" to represent invalid values.
第二位图的多个比特位与多个数据片一一对应,第二位图用于记录多个数据片的快照生成状态。例如,第二位图的每个比特位对应于一个数据片,不同的比特位对应于不同的数据片。对于第二位图的每个比特位,该比特位为有效值时表示对应的数据片已打过快照,该比特位为无效值时表示对应的数据片还未打过快照。例如,可以用“1”表示有效值,用“0”表示无效值。Multiple bits of the second bitmap correspond to multiple data slices one-to-one, and the second bitmap is used to record the snapshot generation status of the multiple data slices. For example, each bit of the second bitmap corresponds to a data piece, and different bits correspond to different data pieces. For each bit of the second bitmap, when the bit is a valid value, it means that the corresponding data piece has been snapshotted, and when the bit is an invalid value, it means that the corresponding data piece has not been snapshotted. For example, you can use "1" to represent valid values and "0" to represent invalid values.
第三位图的多个比特位与多个数据片一一对应,第三位图用于记录多个数据片的迁移状态。例如,第三位图的每个比特位对应于一个数据片,不同的比特位对应于不同的数据片。对于第三位图的每个比特位,该比特位为有效值时表示对应的数据片已做过数据迁移,该比特位为无效值时表示对应的数据片未做过数据迁移。例如,可以用“1”表示有效值,用“0”表示无效值。例如,数据迁移可以指写时拷贝(copy-on-write,COW),当进行COW操作时,相应的数据片会被拷贝至新的存储位置以作为快照的数据部分。Multiple bits of the third bitmap correspond to multiple data slices one-to-one, and the third bitmap is used to record the transition status of the multiple data slices. For example, each bit of the third bitmap corresponds to a data piece, and different bits correspond to different data pieces. For each bit of the third bitmap, when the bit is a valid value, it means that the corresponding data piece has been migrated. When the bit is an invalid value, it means that the corresponding data piece has not been migrated. For example, you can use "1" to represent valid values and "0" to represent invalid values. For example, data migration may refer to copy-on-write (COW). When a COW operation is performed, the corresponding data piece will be copied to a new storage location as the data part of the snapshot.
图2为本公开一些实施例提供的一种文件系统中的位图的示意图。在一些示例中,如图2所示,位图包括多个比特位,图2中每个方框表示位图中的一个比特位,每个比特位对应于一个数据片。例如,该比特位有可能是1,也有可能是0,从而表示不同的含义。例如,第一位图、第二位图、第三位图都可以采用类似的bitmap结构,只不过不同的位图中比特位的含义有所不同。Figure 2 is a schematic diagram of a bitmap in a file system provided by some embodiments of the present disclosure. In some examples, as shown in Figure 2, the bitmap includes multiple bits. Each box in Figure 2 represents a bit in the bitmap, and each bit corresponds to a piece of data. For example, the bit may be 1 or 0, indicating different meanings. For example, the first bitmap, the second bitmap, and the third bitmap can all use similar bitmap structures, but the meanings of the bits in different bitmaps are different.
图3为本公开一些实施例提供的一种用于文件系统的数据管理方法的流程示意图。如图3所示,在一些实施例中,该数据管理方法包括如下操作。Figure 3 is a schematic flowchart of a data management method for a file system provided by some embodiments of the present disclosure. As shown in Figure 3, in some embodiments, the data management method includes the following operations.
步骤S10:响应于接收到数据写请求,根据第一位图和第二位图判断是否进行数据迁移;Step S10: In response to receiving the data write request, determine whether to perform data migration based on the first bitmap and the second bitmap;
步骤S20:响应于确定进行数据迁移,执行数据迁移操作并更新第一位图、第二位图、第三位图中对应的比特位。Step S20: In response to determining to perform data migration, perform a data migration operation and update corresponding bits in the first bitmap, the second bitmap, and the third bitmap.
例如,在步骤S10中,数据写请求可以触发针对源文件项的数据写操作,从而对文件系统本身的文件或文件夹进行修改。由于数据写操作会更改数据内容,因此如果相应的文件或文件夹已经打过快照,那么需要进行数据迁移(例如COW)。因此,接收到数据写请求后,需要根据第一位图和第二位图判断是否进行数据迁移。例如,快照项集合为数据仓库,只有对源文件项的重复写会将数据COW到最后一个快照项的对应位置,而其他在先版本的快照项的数据不会再变化。For example, in step S10, the data write request may trigger a data write operation for the source file item, thereby modifying the file or folder of the file system itself. Since data writing operations will change the data content, if the corresponding files or folders have been snapshotted, data migration (such as COW) is required. Therefore, after receiving the data write request, it is necessary to determine whether to perform data migration based on the first bitmap and the second bitmap. For example, if the collection of snapshot items is a data warehouse, only repeated writing of the source file items will COW the data to the corresponding position of the last snapshot item, while the data of other previous versions of the snapshot items will not change.
图4为图3中步骤S10的示例性流程图。在一些示例中,如图4所示,上 述步骤S10包括如下操作。FIG. 4 is an exemplary flow chart of step S10 in FIG. 3 . In some examples, as shown in Figure 4, the above step S10 includes the following operations.
步骤S11:根据数据写请求确定所要操作的数据片;Step S11: Determine the data piece to be operated according to the data write request;
步骤S12:读取第一位图中与该数据片对应的比特位,并且读取第二位图中与该数据片对应的比特位;Step S12: Read the bits corresponding to the data slice in the first bitmap, and read the bits corresponding to the data slice in the second bitmap;
步骤S13:响应于第一位图中与该数据片对应的比特位为有效值且第二位图中与该数据片对应的比特位为有效值,确定进行数据迁移。Step S13: In response to the bit in the first bitmap corresponding to the data slice being a valid value and the bit in the second bitmap corresponding to the data slice being a valid value, it is determined to perform data migration.
步骤S14:响应于第一位图中与该数据片对应的比特位为无效值或者第二位图中与该数据片对应的比特位为无效值,确定不进行数据迁移。Step S14: In response to the bit in the first bitmap corresponding to the data slice being an invalid value or the bit in the second bitmap corresponding to the data slice being an invalid value, determine not to perform data migration.
例如,在步骤S11中,数据写请求会携带信息以表示该写请求是针对哪个或哪些数据片进行写操作,因此,可以解析数据写请求携带的信息而确定所要操作的数据片。For example, in step S11, the data write request will carry information to indicate which data slice or data slices the write request is for the write operation. Therefore, the information carried by the data write request can be parsed to determine the data slice to be operated on.
例如,在步骤S12中,由于已经确定了需要操作的数据片,根据数据片与第一位图、第二位图的对应关系,可以确定出第一位图中对应于该数据片的比特位,并且确定出第二位图中对应于该数据片的比特位,由此,分别读取第一位图和第二位图中与该数据片对应的比特位。For example, in step S12, since the data piece that needs to be operated has been determined, based on the correspondence between the data piece and the first bitmap and the second bitmap, the bits in the first bitmap corresponding to the data piece can be determined. , and determine the bits corresponding to the data piece in the second bitmap, thereby reading the bits corresponding to the data piece in the first bitmap and the second bitmap respectively.
例如,在步骤S13中,若第一位图中与该数据片对应的比特位为有效值(例如为1)且第二位图中与该数据片对应的比特位为有效值(例如为1),则确定需要进行数据迁移。例如,第一位图中与该数据片对应的比特位为有效值表示该数据片已被写入,因此存在文件数据。第二位图中与该数据片对应的比特位为有效值表示该数据片已生成过快照,因此,在进行写操作之前需要进行数据迁移(例如COW),从而在执行写操作之后仍然能够根据快照获取原来的文件数据。For example, in step S13, if the bit corresponding to the data piece in the first bitmap is a valid value (for example, 1) and the bit corresponding to the data piece in the second bitmap is a valid value (for example, 1) ), it is determined that data migration is required. For example, if the bit corresponding to the data piece in the first bit of the map is a valid value, it means that the data piece has been written, so file data exists. If the bit corresponding to the data slice in the second bitmap is a valid value, it means that a snapshot has been generated for the data slice. Therefore, data migration (such as COW) is required before the write operation is performed, so that after the write operation is performed, the data slice can still be processed according to the Snapshot obtains the original file data.
例如,在步骤S14中,若第一位图中与该数据片对应的比特位为无效值(例如为0)或者第二位图中与该数据片对应的比特位为无效值(例如为0),则确定不进行数据迁移。例如,第一位图中与该数据片对应的比特位为无效值表示该数据片没有被写入,因此当然不需要做数据迁移。第二位图中与该数据片对应的比特位为无效值表示该数据片没有打过快照,因此即使要对该数据片进行写操作,也无需进行数据迁移。For example, in step S14, if the bit corresponding to the data piece in the first bitmap is an invalid value (for example, 0) or the bit corresponding to the data piece in the second bitmap is an invalid value (for example, 0) ), it is determined not to perform data migration. For example, if the bit corresponding to the data slice in the first bit of the map is an invalid value, it means that the data slice has not been written, so of course there is no need to perform data migration. If the bit corresponding to the data slice in the second bitmap is an invalid value, it means that the data slice has not been snapshotted. Therefore, even if a write operation is to be performed on the data slice, there is no need to perform data migration.
返回至图3,例如,在步骤S20中,若确定进行数据迁移,则执行数据迁移操作并更新第一位图、第二位图、第三位图中对应的比特位。Returning to FIG. 3 , for example, in step S20 , if it is determined to perform data migration, the data migration operation is performed and the corresponding bits in the first bitmap, the second bitmap, and the third bitmap are updated.
图5为图3中步骤S20的示例性流程图。在一些示例中,如图5所示,上 述步骤S20包括如下操作。FIG. 5 is an exemplary flowchart of step S20 in FIG. 3 . In some examples, as shown in Figure 5, the above step S20 includes the following operations.
步骤S21:读取数据迁移操作对应的数据片,将读取的数据片构造为快照类型的数据对象并进行存储;Step S21: Read the data slice corresponding to the data migration operation, construct the read data slice into a snapshot type data object and store it;
步骤S22:将第一位图中对应的比特位更新为有效值,将第二位图中对应的比特位更新为无效值,将第三位图中对应的比特位更新为有效值。Step S22: Update the corresponding bits in the first bitmap to valid values, update the corresponding bits in the second bitmap to invalid values, and update the corresponding bits in the third bitmap to valid values.
例如,在步骤S21中,数据迁移操作可以与通常的COW类似,也即是,将对应的数据片复制到新的存储位置,并使相应版本的快照可以定位到该新的存储位置,从而便于对原存储位置中的该数据片进行写操作。需要注意的是,在本公开的实施例中,将数据片存储到新的存储位置时,需要将其构造为快照类型的数据对象。在本公开的实施例中,将快照的数据部分进行逻辑抽象,从而可以按照文件系统数据接口进行统一实现。文件系统中的数据部分可以分为对应于源文件项的数据部分和对应于快照项的数据部分,这些都是数据对象,将其分别称为文件类型的数据对象和快照类型的数据对象。例如,可以由对象名称进行区分,例如,对于快照类型的数据对象,可以在对象的标识符(oid)中添加snap字段。For example, in step S21, the data migration operation can be similar to a normal COW, that is, the corresponding data piece is copied to a new storage location, and the snapshot of the corresponding version can be located in the new storage location, thereby facilitating Write the data piece in the original storage location. It should be noted that in the embodiment of the present disclosure, when storing a data piece to a new storage location, it needs to be constructed as a snapshot type data object. In the embodiment of the present disclosure, the data part of the snapshot is logically abstracted, so that it can be implemented uniformly according to the file system data interface. The data part in the file system can be divided into a data part corresponding to the source file item and a data part corresponding to the snapshot item. These are data objects, which are called file type data objects and snapshot type data objects respectively. For example, it can be distinguished by the object name. For example, for a snapshot type data object, a snap field can be added to the identifier (oid) of the object.
图6为图5中步骤S21的示例性流程图。在一些示例中,如图6所示,上述步骤S21包括如下操作。FIG. 6 is an exemplary flowchart of step S21 in FIG. 5 . In some examples, as shown in Figure 6, the above step S21 includes the following operations.
步骤S211:获取文件路径的最新快照版本号;Step S211: Obtain the latest snapshot version number of the file path;
步骤S212:读取数据迁移操作对应的数据片,将读取的数据片作为数据对象进行存储;Step S212: Read the data slice corresponding to the data migration operation, and store the read data slice as a data object;
步骤S213:将最新快照版本号以及表示快照类型的标识信息增加到数据对象的信息域中;Step S213: Add the latest snapshot version number and identification information indicating the snapshot type to the information field of the data object;
步骤S214:将对应于最新快照版本号的快照项与数据对象关联。Step S214: Associate the snapshot item corresponding to the latest snapshot version number with the data object.
例如,在步骤S211中,首先获取文件路径的最新快照版本号。例如,文件路径是指针对所要操作的数据片的路径,文件路径的最新快照版本号记录了所要操作的数据片的最新的快照版本。例如,在一些示例中,该最新快照版本号可以为3,则表示该数据片的最新的快照版本是第3版快照;在另一些示例中,该最新快照版本号可以为5,则表示该数据片的最新的快照版本是第5版快照。上述针对最新快照版本号的说明只是示例性的,而非限制性的,这并不构成对本公开实施例的限制。For example, in step S211, the latest snapshot version number of the file path is first obtained. For example, the file path refers to the path to the data piece to be operated, and the latest snapshot version number of the file path records the latest snapshot version of the data piece to be operated. For example, in some examples, the latest snapshot version number may be 3, which means that the latest snapshot version of the data piece is the version 3 snapshot; in other examples, the latest snapshot version number may be 5, which means that the latest snapshot version number may be 5. The latest snapshot version of the data sheet is the version 5 snapshot. The above description of the latest snapshot version number is only illustrative, not restrictive, and does not constitute a limitation on the embodiments of the present disclosure.
例如,在步骤S212中,读取数据迁移操作对应的数据片,将读取的数据 片作为数据对象进行存储。例如,可以将读取的数据片构造为快照类型的数据对象,关于快照类型的数据对象的详细说明可以参考前文描述,此处不再赘述。For example, in step S212, the data slice corresponding to the data migration operation is read, and the read data slice is stored as a data object. For example, the read data piece can be constructed as a snapshot type data object. For detailed description of the snapshot type data object, please refer to the previous description and will not be repeated here.
例如,在步骤S213中,将最新快照版本号以及表示快照类型的标识信息增加到数据对象的信息域中。例如,数据对象的信息域中可以记录描述该数据对象的信息,因此可以将最新快照版本号记录在信息域中,并且将表示快照类型的标识信息(例如snap字段)也记录到信息域中。由此,读取该快照类型的数据对象时,可以获知该数据对象是快照项的数据部分,并且获知该数据对象所对应的快照版本。For example, in step S213, the latest snapshot version number and identification information indicating the snapshot type are added to the information field of the data object. For example, information describing the data object can be recorded in the information field of the data object. Therefore, the latest snapshot version number can be recorded in the information field, and identification information (such as a snap field) indicating the snapshot type can also be recorded in the information field. Therefore, when reading a data object of the snapshot type, it can be learned that the data object is the data part of the snapshot item, and the snapshot version corresponding to the data object can be learned.
例如,在步骤S214中,将对应于最新快照版本号的快照项与数据对象关联。例如,可以采用适当的寻址方式在该数据对象与对应的快照项之间建立联系,从而可以根据对应的快照项定位到该数据对象的存储位置,以便于读取该数据对象。例如,与该数据对象对应的快照项是对应于最新快照版本号的快照项。例如,在一些示例中,假设最新快照版本号为5,则该数据对象与第5版的快照项建立关联,由此,可以根据第5版的快照项定位到该数据对象的存储位置,从而读取该数据对象。For example, in step S214, the snapshot item corresponding to the latest snapshot version number is associated with the data object. For example, an appropriate addressing method can be used to establish a relationship between the data object and the corresponding snapshot item, so that the storage location of the data object can be located according to the corresponding snapshot item to facilitate reading of the data object. For example, the snapshot item corresponding to the data object is the snapshot item corresponding to the latest snapshot version number. For example, in some examples, assuming that the latest snapshot version number is 5, the data object is associated with the snapshot item of version 5. Therefore, the storage location of the data object can be located based on the snapshot item of version 5, so that Read this data object.
返回至图5,例如,在步骤S22中,将第一位图中对应的比特位更新为有效值,将第二位图中对应的比特位更新为无效值,将第三位图中对应的比特位更新为有效值。Returning to Figure 5, for example, in step S22, the corresponding bits in the first bitmap are updated to valid values, the corresponding bits in the second bitmap are updated to invalid values, and the corresponding bits in the third bitmap are updated. Bits are updated to valid values.
图7为图5中步骤S22的示例性流程图。在一些示例中,如图7所示,上述步骤S22包括如下操作。FIG. 7 is an exemplary flowchart of step S22 in FIG. 5 . In some examples, as shown in Figure 7, the above step S22 includes the following operations.
步骤S221:将源文件项的第一位图中对应的比特位更新为有效值,将源文件项的第二位图中对应的比特位更新为无效值;Step S221: Update the corresponding bits in the first bitmap of the source file item to a valid value, and update the corresponding bits in the second bitmap of the source file item to an invalid value;
步骤S222:获取文件路径的最新快照版本号;Step S222: Obtain the latest snapshot version number of the file path;
步骤S223:将最新快照版本号对应的快照项的第三位图中对应的比特位更新为有效值。Step S223: Update the corresponding bit in the third bitmap of the snapshot item corresponding to the latest snapshot version number to a valid value.
例如,在步骤S221中,将源文件项的第一位图中对应的比特位更新为有效值(例如更新为1),由此表示该比特位对应的数据片被写入。由于该比特位对应的数据片在进行写操作之前已经做了数据迁移,进行写操作之后的数据片还未打过快照,因此,将源文件项的第二位图中对应的比特位更新为无效值(例如更新为0),由此表示该比特位对应的数据片还没有打过快照。For example, in step S221, the corresponding bit in the first bit of the source file item is updated to a valid value (for example, updated to 1), thereby indicating that the data piece corresponding to the bit is written. Since the data slice corresponding to this bit has been migrated before the write operation, and the data slice after the write operation has not been snapshotted, the corresponding bit in the second bitmap of the source file item is updated to Invalid value (for example, updated to 0), which means that the data piece corresponding to this bit has not been snapshotted.
例如,在步骤S222中,获取文件路径的最新快照版本号。关于文件路径 的最新快照版本号,可以参考前文内容,此处不再赘述。For example, in step S222, the latest snapshot version number of the file path is obtained. Regarding the latest snapshot version number of the file path, you can refer to the previous content and will not be repeated here.
例如,在步骤S223中,将最新快照版本号对应的快照项的第三位图中对应的比特位更新为有效值,由此表示对应的数据片在最新快照版本号对应的快照项中做了数据迁移。例如,在一些示例中,假设最新快照版本号为5,则将第5版的快照项的第三位图中与该数据片对应的比特位更新为有效值,由此表示该数据片在第5版的快照项中做了数据迁移。For example, in step S223, the corresponding bit in the third bitmap of the snapshot item corresponding to the latest snapshot version number is updated to a valid value, thereby indicating that the corresponding data piece has been processed in the snapshot item corresponding to the latest snapshot version number. data migration. For example, in some examples, assuming that the latest snapshot version number is 5, the bit corresponding to the data piece in the third bitmap of the snapshot item of version 5 is updated to a valid value, thereby indicating that the data piece is in the third bitmap. Data migration has been done in the snapshot item of version 5.
由此,根据图3至图7所描述的步骤,在接收到数据写请求时,可以根据第一位图和第二位图判断是否做数据迁移,如果进行数据迁移,则在迁移之后更新第一位图、第二位图、第三位图对应的比特位。通过这种方式,可以将快照的数据部分从对象存储设备中独立出来,可以独立管理和维护。Therefore, according to the steps described in Figures 3 to 7, when a data write request is received, it can be determined whether to perform data migration based on the first bitmap and the second bitmap. If data migration is performed, the third bitmap is updated after the migration. The bits corresponding to the first bitmap, the second bitmap, and the third bitmap. In this way, the data part of the snapshot can be separated from the object storage device and can be managed and maintained independently.
图8为本公开一些实施例提供的另一种用于文件系统的数据管理方法的流程示意图。在一些实施例中,如图8所示,在前述步骤S10和步骤S20的基础上,该数据管理方法还可以进一步包括步骤S30-S70。关于步骤S10-S20,可以参考上文内容,此处不再赘述。Figure 8 is a schematic flowchart of another data management method for a file system provided by some embodiments of the present disclosure. In some embodiments, as shown in Figure 8, based on the aforementioned steps S10 and S20, the data management method may further include steps S30-S70. Regarding steps S10-S20, you may refer to the above content and will not be described again here.
步骤S30:响应于接收到数据写请求,判断数据写请求是否为初次写请求;Step S30: In response to receiving the data write request, determine whether the data write request is an initial write request;
步骤S40:响应于数据写请求为初次写请求,将第一位图的内容同步到第二位图,并将第三位图的全部比特位置为无效值;Step S40: In response to the data write request being an initial write request, synchronize the content of the first bitmap to the second bitmap, and set all bit positions of the third bitmap to invalid values;
步骤S50:响应于数据写请求为初次写请求,将第一位图的内容同步到第四位图;Step S50: In response to the data write request being an initial write request, synchronize the content of the first bitmap to the fourth bitmap;
步骤S60:在执行数据迁移操作并更新第一位图、第二位图、第三位图中对应的比特位之后,对源文件项执行写操作;Step S60: After performing the data migration operation and updating the corresponding bits in the first bitmap, the second bitmap, and the third bitmap, perform a write operation on the source file item;
步骤S70:在根据第一位图和第二位图判断是否进行数据迁移之后,响应于确定不进行数据迁移,对源文件项执行写操作。Step S70: After determining whether to perform data migration based on the first bitmap and the second bitmap, in response to determining not to perform data migration, perform a write operation on the source file item.
例如,在步骤S30中,在接收到数据写请求后,需要判断数据写请求是否为初次写请求。例如,在本公开的实施例中,由于全局的快照版本号与文件路径的快照版本号不会同步更新,全局的快照版本号可能会延后于文件路径的快照版本号,第二位图和第三位图在初次写操作之前可能不存在,因此,在初次写操作时需要拷贝得到第二位图和第三位图。由此,需要判断数据写请求是否为初次写请求,该初次写请求例如为first cover write。For example, in step S30, after receiving the data write request, it is necessary to determine whether the data write request is an initial write request. For example, in the embodiment of the present disclosure, since the global snapshot version number and the snapshot version number of the file path are not updated synchronously, the global snapshot version number may be delayed from the snapshot version number of the file path. The second bitmap and The third bitmap may not exist before the initial write operation. Therefore, the second bitmap and the third bitmap need to be copied during the initial write operation. Therefore, it is necessary to determine whether the data write request is the first write request, which is, for example, a first cover write.
例如,可以通过判断全局的快照版本号与文件路径的快照版本号是否相同来确定数据写请求是否为初次写请求。若全局的快照版本号与文件路径的快照 版本号不同,则表示该数据写请求为初次写请求;若全局的快照版本号与文件路径的快照版本号相同,则表示该数据写请求不是初次写请求。For example, whether the data write request is an initial write request can be determined by determining whether the global snapshot version number and the snapshot version number of the file path are the same. If the global snapshot version number is different from the snapshot version number of the file path, it means that the data write request is the first write request; if the global snapshot version number is the same as the snapshot version number of the file path, it means that the data write request is not the first write request. ask.
例如,在步骤S40中,若数据写请求为初次写请求,则将第一位图的内容同步到第二位图,并将第三位图的全部比特位设置为无效值。例如,可以复制第一位图的内容,以作为第二位图,也即是,使第二位图与第一位图相同。例如,将第三位图的全部比特位设置为无效值,由此表示并未做任何数据迁移。For example, in step S40, if the data write request is an initial write request, the content of the first bitmap is synchronized to the second bitmap, and all bits of the third bitmap are set to invalid values. For example, you can copy the contents of the first bitmap to serve as the second bitmap, that is, make the second bitmap identical to the first bitmap. For example, all bits of the third bitmap are set to invalid values, which means that no data migration is performed.
例如,在一些示例中,快照项除了包括第三位图外,还包括第四位图,第四位图的多个比特位与多个数据片一一对应,第四位图用于记录创建该快照项时对应的源文件项的写入状态。第三位图和第四位图可以用于对快照项进行读、写时的拷贝及删除操作。For example, in some examples, in addition to the third bitmap, the snapshot item also includes a fourth bitmap. Multiple bits of the fourth bitmap correspond to multiple data slices one-to-one. The fourth bitmap is used to record creation. This snapshot item is the writing status of the corresponding source file item. The third bitmap and the fourth bitmap can be used for copying and deleting operations when reading and writing snapshot items.
例如,在步骤S50中,若数据写请求为初次写请求,则将第一位图的内容同步到第四位图。例如,可以复制第一位图的内容,以作为第四位图,也即是,使第四位图与第一位图相同。例如,在触发COW的情形下,第四位图不发生变化,仅记录创建该快照项时源文件的写入情况。For example, in step S50, if the data write request is an initial write request, the content of the first bit image is synchronized to the fourth bit image. For example, you can copy the contents of the first bitmap as the fourth bitmap, that is, make the fourth bitmap the same as the first bitmap. For example, when COW is triggered, the fourth bitmap does not change, and only the writing status of the source file when the snapshot item is created is recorded.
例如,在步骤S60中,在执行数据迁移操作并更新第一位图、第二位图、第三位图中对应的比特位之后(也即执行步骤S20之后),对源文件项执行写操作。例如,该写操作为数据写请求所触发的,该写操作可以对源文件项的数据部分进行修改。由于在执行步骤S60的操作之前,已经判断了是否需要进行数据迁移并且在执行数据迁移操作的情况下更新了各个位图,因此,此时可以对数据片进行写操作,不会影响已经执行了数据迁移操作的数据部分。For example, in step S60, after performing the data migration operation and updating the corresponding bits in the first bitmap, the second bitmap, and the third bitmap (that is, after executing step S20), a write operation is performed on the source file item . For example, the write operation is triggered by a data write request, and the write operation can modify the data part of the source file item. Since before performing the operation of step S60, it has been judged whether data migration is required and each bitmap is updated when the data migration operation is performed. Therefore, the data slice can be written at this time without affecting the data that has been executed. The data portion of the data migration operation.
例如,在步骤S70中,在根据第一位图和第二位图判断是否进行数据迁移之后(也即执行步骤S10之后),若确定不进行数据迁移,则对源文件项的数据部分执行写操作。由于无需进行数据迁移,则可以直接对源文件项的数据部分进行写操作。For example, in step S70, after determining whether to perform data migration based on the first bitmap and the second bitmap (that is, after executing step S10), if it is determined that data migration is not to be performed, then writing is performed on the data part of the source file item. operate. Since data migration is not required, the data portion of the source file item can be directly written.
通过这种方式,可以实现数据写操作,并且可以根据需要进行数据迁移,维护快照的数据部分,将快照的数据部分从对象存储设备中独立出来。In this way, data writing operations can be implemented, and data migration can be performed as needed to maintain the data part of the snapshot and separate it from the object storage device.
图9为本公开一些实施例提供的另一种用于文件系统的数据管理方法的流程示意图。如图9所示,在一些实施例中,该数据管理方法还可以包括如下操作。Figure 9 is a schematic flowchart of another data management method for a file system provided by some embodiments of the present disclosure. As shown in Figure 9, in some embodiments, the data management method may also include the following operations.
步骤S80:响应于接收到快照读请求,根据各个版本的快照项的第三位图确定数据位置并读取数据;Step S80: In response to receiving the snapshot read request, determine the data location according to the third bitmap of each version of the snapshot item and read the data;
步骤S91:响应于接收到克隆写请求,基于与克隆项关联的快照项确定数据位置并将需要的数据复制到克隆项对应的存储位置,并执行写操作;Step S91: In response to receiving the clone write request, determine the data location based on the snapshot item associated with the clone item, copy the required data to the storage location corresponding to the clone item, and perform a write operation;
步骤S92:响应于接收到克隆读请求,基于与克隆项关联的快照项确定数据位置并读取所需要的数据。Step S92: In response to receiving the clone read request, determine the data location based on the snapshot item associated with the clone item and read the required data.
例如,在步骤S80中,在接收到快照读请求后,根据各个版本的快照项的第三位图确定数据位置并读取数据。For example, in step S80, after receiving the snapshot read request, the data location is determined according to the third bitmap of the snapshot item of each version and the data is read.
图10为图9中步骤S80的示例性流程图。在一些示例中,如图10所示,上述步骤S80包括如下操作。FIG. 10 is an exemplary flowchart of step S80 in FIG. 9 . In some examples, as shown in Figure 10, the above step S80 includes the following operations.
步骤S81:根据快照读请求确定当前快照项,其中,当前快照项是需要读取的版本的快照项;Step S81: Determine the current snapshot item according to the snapshot read request, where the current snapshot item is the snapshot item of the version that needs to be read;
步骤S82:获取当前快照项的第三位图中对应的比特位;Step S82: Obtain the corresponding bits in the third bitmap of the current snapshot item;
步骤S83:响应于当前快照项的第三位图中对应的比特位为有效值,根据当前快照项确定数据位置并读取数据;Step S83: In response to the corresponding bit in the third bitmap of the current snapshot item being a valid value, determine the data location according to the current snapshot item and read the data;
步骤S84:响应于当前快照项的第三位图中对应的比特位为无效值,依次获取更大版本号的快照项的第三位图中对应的比特位,直到获取的比特位为有效值,根据有效值对应的版本的快照项确定数据位置并读取数据;Step S84: In response to the corresponding bit in the third bitmap of the current snapshot item being an invalid value, sequentially obtain the corresponding bits in the third bitmap of the snapshot item with a larger version number until the acquired bit is a valid value. , determine the data location and read the data based on the snapshot item of the version corresponding to the valid value;
步骤S85:响应于全部版本的快照项的第三位图中对应的比特位均为无效值,根据源文件项确定数据位置并读取数据。Step S85: In response to the fact that the corresponding bits in the third bitmap of all versions of the snapshot items are invalid values, determine the data location according to the source file item and read the data.
例如,在步骤S81中,在接收到快照读请求时,需要确定当前快照项。例如,快照读请求可以触发针对快照项的数据读操作,从而读取快照项的数据部分。例如,当前快照项是需要读取的版本的快照项。例如,在一些示例中,假设该文件系统存在5个版本的快照项,在接收到快照读请求时,需要确定该快照读请求是要读取这5个版本中的哪个版本的快照项。例如,快照读请求会携带版本信息,从而获知所要读取的快照项的版本号。For example, in step S81, when a snapshot read request is received, the current snapshot item needs to be determined. For example, a snapshot read request can trigger a data read operation on the snapshot item, thereby reading the data portion of the snapshot item. For example, the current snapshot item is the snapshot item of the version that needs to be read. For example, in some examples, it is assumed that there are five versions of snapshot items in the file system. When receiving a snapshot read request, it is necessary to determine which version of the snapshot item among the five versions the snapshot read request is to read. For example, a snapshot read request will carry version information to know the version number of the snapshot item to be read.
例如,在步骤S82中,在确定了当前快照项之后,获取当前快照项的第三位图中对应的比特位。例如,第三位图记录了各个对应的数据片的迁移状态。通过获取当前快照项的第三位图中对应的比特位,可以获知对应的数据片是否进行了数据迁移。例如,若第三位图中对应的比特位为有效值,则表示对应的数据片进行了数据迁移;若第三位图中对应的比特位为无效值,则表示对应的数据片没有做数据迁移。For example, in step S82, after the current snapshot item is determined, the corresponding bits in the third bitmap of the current snapshot item are obtained. For example, the third bitmap records the migration status of each corresponding data piece. By obtaining the corresponding bit in the third bitmap of the current snapshot item, you can learn whether data migration has been performed on the corresponding data piece. For example, if the corresponding bit in the third bitmap is a valid value, it means that the corresponding data piece has undergone data migration; if the corresponding bit in the third bitmap is an invalid value, it means that the corresponding data piece has not done data migration. migrate.
例如,在步骤S83中,若当前快照项的第三位图中对应的比特位为有效值, 则根据当前快照项确定数据位置并读取数据。例如,第三位图中对应的比特位为有效值,表示对应的数据片进行了数据迁移,因此可以根据当前快照项定位数据位置并读取数据。For example, in step S83, if the corresponding bit in the third bitmap of the current snapshot item is a valid value, the data location is determined based on the current snapshot item and the data is read. For example, the corresponding bit in the third bitmap is a valid value, indicating that the corresponding data piece has undergone data migration, so the data location can be located based on the current snapshot item and the data can be read.
例如,在步骤S84中,若当前快照项的第三位图中对应的比特位为无效值,则依次获取更大版本号的快照项的第三位图中对应的比特位,直到获取的比特位为有效值,根据有效值对应的版本的快照项确定数据位置并读取数据。例如,当前快照项的第三位图中对应的比特位为无效值,表示对应的数据片没有做数据迁移,因此当前快照项没有对应的数据部分,无法根据当前快照项定位数据位置。因此,需要获取更大版本号的快照项的第三位图中对应的比特位,若获取的比特位为无效值,则继续获取更大版本号的快照项的第三位图中对应的比特位,直到获取的比特位为有效值。For example, in step S84, if the corresponding bit in the third bitmap of the current snapshot item is an invalid value, then the corresponding bits in the third bitmap of the snapshot item with a larger version number are obtained sequentially until the obtained bit The bit is a valid value, and the data location is determined based on the snapshot item of the version corresponding to the valid value and the data is read. For example, the corresponding bit in the third bitmap of the current snapshot item is an invalid value, which means that the corresponding data piece has not been migrated. Therefore, the current snapshot item does not have a corresponding data part, and the data location cannot be located based on the current snapshot item. Therefore, it is necessary to obtain the corresponding bit in the third bitmap of the snapshot item with a larger version number. If the obtained bit is an invalid value, continue to obtain the corresponding bit in the third bitmap of the snapshot item with a larger version number. bit until the acquired bit is a valid value.
例如,在一些示例中,假设当前快照项为第5版本的快照项,其第三位图中对应的比特位为无效值,则继续获取第6版本的快照项,若其第三位图中对应的比特位仍然为无效值,则继续获取第7版本的快照项,以此类推。假设第7版本的快照项的第三位图中对应的比特位为有效值,则表示第7版本的快照项针对该数据片做了数据迁移,可以根据第7版本的快照项确定数据位置并读取数据。For example, in some examples, assuming that the current snapshot item is a snapshot item of version 5, and the corresponding bit in its third bitmap is an invalid value, then continue to obtain the snapshot item of version 6, if the corresponding bit in its third bitmap is If the corresponding bit is still an invalid value, continue to obtain the snapshot item of version 7, and so on. Assuming that the corresponding bit in the third bitmap of the 7th version snapshot item is a valid value, it means that the 7th version snapshot item has performed data migration for this data piece. The data location can be determined based on the 7th version snapshot item and Read data.
例如,在步骤S85中,若全部版本的快照项的第三位图中对应的比特位均为无效值,则根据源文件项确定数据位置并读取数据。例如,全部版本的快照项的第三位图中对应的比特位均为无效值,表示所有版本的快照项均没有做数据迁移,因此只能根据源文件项来定位数据位置并读取数据。For example, in step S85, if the corresponding bits in the third bitmap of all versions of the snapshot items are invalid values, the data location is determined according to the source file item and the data is read. For example, the corresponding bits in the third bitmap of all versions of the snapshot items are all invalid values, which means that no data migration has been performed on the snapshot items of all versions, so the data location can only be located and the data can be read based on the source file item.
由此,通过上述操作,可以接收快照读请求,并完成相应的快照项的数据部分的读操作。需要说明的是,任何读请求所触发的读操作都会直接找到数据位置,不会触发数据迁移。Therefore, through the above operations, the snapshot read request can be received and the read operation of the data part of the corresponding snapshot item can be completed. It should be noted that any read operation triggered by a read request will directly find the data location and will not trigger data migration.
例如,在一些示例中,文件系统还包括克隆项,克隆项是快照项的拷贝。例如,快照项无法进行写操作,而克隆项可以进行写操作,克隆项是对应的快照项的可编辑版本。For example, in some examples, the file system also includes clones, which are copies of the snapshot entries. For example, snapshot items cannot be written, but clone items can be written. The clone item is an editable version of the corresponding snapshot item.
返回至图9,在步骤S91中,若接收到克隆写请求,则基于与克隆项关联的快照项确定数据位置并将需要的数据复制到克隆项对应的存储位置,并执行写操作。例如,克隆写请求可以触发针对克隆项的数据写操作,从而对克隆项的数据部分进行更改。例如,克隆项对应于某一快照项,生成该克隆项时将对 应的快照项的内容作为该克隆项的内容。因此,需要基于与克隆项关联的快照项确定数据位置,然后,将需要的数据复制到克隆项对应的存储位置,接着执行写操作。Returning to Figure 9, in step S91, if a clone write request is received, the data location is determined based on the snapshot item associated with the clone item, the required data is copied to the storage location corresponding to the clone item, and the write operation is performed. For example, a clone write request can trigger a data write operation on the clone item, thereby making changes to the data portion of the clone item. For example, a clone item corresponds to a certain snapshot item, and when the clone item is generated, the content of the corresponding snapshot item is used as the content of the clone item. Therefore, it is necessary to determine the data location based on the snapshot item associated with the clone item, then copy the required data to the storage location corresponding to the clone item, and then perform the write operation.
例如,在一些示例中,假设文件系统存在克隆项1,该克隆项1是对应于第1版快照项的克隆版本,也即是,克隆项1与第1版快照项关联。当需要对克隆项1进行写操作时,需要根据第1版快照项确定数据位置。例如,可以采用步骤S80的方式来确定第1版快照项对应的数据位置,此处不再赘述。之后,将数据复制到克隆项1对应的存储位置,接着执行针对克隆项1的写操作即可。For example, in some examples, it is assumed that clone item 1 exists in the file system, and clone item 1 is a clone version corresponding to the version 1 snapshot item, that is, clone item 1 is associated with the version 1 snapshot item. When a write operation needs to be performed on clone item 1, the data location needs to be determined based on the version 1 snapshot item. For example, step S80 may be used to determine the data location corresponding to the first version snapshot item, which will not be described again here. After that, copy the data to the storage location corresponding to clone item 1, and then perform the write operation for clone item 1.
例如,在步骤S92中,若接收到克隆读请求,则基于与克隆项关联的快照项确定数据位置并读取所需要的数据。例如,克隆读请求可以触发针对克隆项的数据读操作,从而读取克隆项的数据部分。例如,在一些示例中,假设文件系统存在克隆项1,该克隆项1是对应于第1版快照项的克隆版本,也即是,克隆项1与第1版快照项关联。当需要对克隆项1进行读操作时,需要根据第1版快照项确定数据位置。例如,可以采用步骤S80的方式来确定第1版快照项对应的数据位置,此处不再赘述。之后,根据确定的数据位置读取数据即可。For example, in step S92, if a clone read request is received, the data location is determined based on the snapshot item associated with the clone item and the required data is read. For example, a clone read request can trigger a data read operation on the clone item, thereby reading the data portion of the clone item. For example, in some examples, it is assumed that clone item 1 exists in the file system, and clone item 1 is a clone version corresponding to the version 1 snapshot item, that is, clone item 1 is associated with the version 1 snapshot item. When a read operation needs to be performed on clone item 1, the data location needs to be determined based on the snapshot item of version 1. For example, step S80 may be used to determine the data location corresponding to the first version snapshot item, which will not be described again here. After that, just read the data according to the determined data location.
图11A为本公开一些实施例提供的数据管理方法所采用的数据结构示意图之一,该数据结构例如为文件数据的结构。例如,Fh是任何文件打开状态的文件句柄,uint32_t last_snap_id表示全局的最大的快照版本号,uint32_t max_peer_id表示文件路径的最大的快照版本号。uint32_t snap_id表示快照项的id,若是文件类型的数据对象,则uint32_t snap_id全为0。uint32_t peer_id表示文件路径上的快照项的id,对于快照类型的数据对象,uint32_t snap_id为快照项的id,uint32_t peer_id为0。在该数据结构中,Bitmap base_alloc表示第一位图,Bitmap base_peer表示第二位图。Bitmap last_snap_alloc表示最新版本的快照项的第三位图,Bitmap last_snap_peer表示最新版本的快照项的第四位图。例如,该数据结构中的Bitmap last_snap_alloc和Bitmap last_snap_peer是冗余信息,不仅仅存在于该数据结构中,也存储于文件系统的其他位置。Figure 11A is one of the schematic diagrams of the data structure used by the data management method provided by some embodiments of the present disclosure. The data structure is, for example, the structure of file data. For example, Fh is the file handle of any open file, uint32_t last_snap_id represents the global maximum snapshot version number, and uint32_t max_peer_id represents the maximum snapshot version number of the file path. uint32_t snap_id represents the id of the snapshot item. If it is a file type data object, uint32_t snap_id is all 0. uint32_t peer_id represents the id of the snapshot item on the file path. For snapshot type data objects, uint32_t snap_id is the id of the snapshot item, and uint32_t peer_id is 0. In this data structure, Bitmap base_alloc represents the first bitmap, and Bitmap base_peer represents the second bitmap. Bitmap last_snap_alloc represents the third bitmap of the latest version of the snapshot item, and Bitmap last_snap_peer represents the fourth bitmap of the latest version of the snapshot item. For example, Bitmap last_snap_alloc and Bitmap last_snap_peer in this data structure are redundant information that not only exists in this data structure, but is also stored in other locations in the file system.
图11B为本公开一些实施例提供的数据管理方法所采用的数据结构示意图之二,该数据结构例如为元数据的结构。例如,uint32_t last_cow_snap_id表示上一次做数据迁移的快照项的id,uint32_t snap_id表示快照项的id,uint32_t peer_id表示文件路径上的快照项的id。元数据(例如inode)里不记录任何的位图信息(bitmap信息),每次操作临时记录在Fh中,然后持久化落盘,落 盘的对象(例如oid)由元数据id(例如inodeid)、偏移量(例如offset)、位图(例如bitmap)组合而成。Figure 11B is a second schematic diagram of the data structure used in the data management method provided by some embodiments of the present disclosure. The data structure is, for example, a metadata structure. For example, uint32_t last_cow_snap_id represents the id of the snapshot item for the last data migration, uint32_t snap_id represents the id of the snapshot item, and uint32_t peer_id represents the id of the snapshot item on the file path. No bitmap information (bitmap information) is recorded in the metadata (such as inode). Each operation is temporarily recorded in Fh, and then persisted to the disk. The object (such as oid) dropped to the disk is determined by the metadata id (such as inodeid). , offset (such as offset), and bitmap (such as bitmap).
通过采用上述数据结构,可以便于对数据进行管理。需要说明的是,本公开的实施例所采用的数据结构不限于图11A和图11B中所示的数据结构,也可以采用其他任意适用的数据结构,本公开的实施例对此不作限制。图11A和图11B所示的数据结构仅是示意性的,而非限制性的,实际采用的数据结构还可以包括更多或更少的字段、参数、函数等,这可以根据实际需求而定。By adopting the above data structure, data management can be facilitated. It should be noted that the data structure used in the embodiments of the present disclosure is not limited to the data structure shown in FIG. 11A and FIG. 11B , and any other applicable data structure may also be used, and the embodiments of the present disclosure are not limited to this. The data structures shown in Figure 11A and Figure 11B are only illustrative and not restrictive. The actual data structure used can also include more or less fields, parameters, functions, etc., which can be determined according to actual needs. .
图12A为本公开一些实施例提供的数据管理方法中的读操作的示意图。下面结合图12A对针对快照项的读操作和针对克隆项的读操作进行简要说明。Figure 12A is a schematic diagram of a read operation in a data management method provided by some embodiments of the present disclosure. The read operation for the snapshot item and the read operation for the clone item will be briefly described below with reference to FIG. 12A.
例如,在该示例中,假设源文件项basefs中有三个数据片被写入,分别为w1、w2、w3。在写入w1之后,生成了第1版快照项(snapid:1),该快照项的第四位图中与w1对应的比特位为1。在写入w2之后,生成了第2版快照项(snapid:2),该快照项的第四位图中与w1、w2分别对应的比特位为1。在写入w3之后,生成了第3版快照项(snapid:3),该快照项的第四位图中与w1、w2、w3分别对应的比特位为1。在源文件项basefs的第二位图中,与w1、w2、w3分别对应的比特位为1,并且,由于打了3次快照,因此文件路径的最新快照版本号peerid为3。For example, in this example, assume that three data pieces are written in the source file item basefs, namely w1, w2, and w3. After writing w1, the first version of the snapshot item (snapid:1) is generated, and the bit corresponding to w1 in the fourth bitmap of the snapshot item is 1. After writing w2, a version 2 snapshot item (snapid:2) is generated, and the bits corresponding to w1 and w2 in the fourth bitmap of the snapshot item are 1 respectively. After writing w3, a version 3 snapshot item (snapid:3) is generated, and the bits corresponding to w1, w2, and w3 in the fourth bitmap of the snapshot item are 1 respectively. In the second bitmap of the source file item basefs, the bits corresponding to w1, w2, and w3 are 1, and since three snapshots were taken, the latest snapshot version number peerid of the file path is 3.
当需要读取第2版快照项中的w2时,查看第2版快照项的Fh记录的第三位图last_snap_alloc对应的比特位,若last_snap_alloc中对应的比特位为1,则表示针对第2版快照项做过COW,因此读取第2版快照项的数据对象即可。若Fh记录的第三位图last_snap_alloc对应的比特位为0,则表示没有针对第2版快照项做COW,因此获取比当前snapid更大的快照项的第三位图中对应的比特位,也即,获取第3版快照项的第三位图中对应的比特位,若为1,则读取第3版快照项的数据对象。该数据对象(osd)由元数据id(inodeid)、偏移量(offset)、全局快照版本号(snapid)和文件路径快照版本号(peerid)组成,快照项的数据写入由写流程触发。若比当前snapid更大的各个快照项的第三位图中对应的比特位均为0,则读取源文件项basefs的数据对象。When you need to read w2 in the version 2 snapshot item, check the bit corresponding to last_snap_alloc in the third bitmap of the Fh record of the version 2 snapshot item. If the corresponding bit in last_snap_alloc is 1, it means that it is for version 2. The snapshot item has been COWed, so just read the data object of the second version of the snapshot item. If the bit corresponding to last_snap_alloc in the third bitmap recorded by Fh is 0, it means that no COW is performed for the second version of the snapshot item, so the corresponding bit in the third bitmap of the snapshot item larger than the current snapid is obtained, and That is, the corresponding bit in the third bitmap of the version 3 snapshot item is obtained. If it is 1, the data object of the version 3 snapshot item is read. The data object (osd) consists of metadata id (inodeid), offset (offset), global snapshot version number (snapid) and file path snapshot version number (peerid). Data writing of snapshot items is triggered by the write process. If the corresponding bits in the third bitmap of each snapshot item larger than the current snapid are all 0, read the data object of the source file item basefs.
需要说明的是,在接收到读请求时,需要首先判断是否为快照读请求。例如,可以判断元数据(inode)里的snap_id是否为TFS_NOSNAP,这里,TFS_NOSNAP为表示读取源文件项的标识信息。若是TFS_NOSNAP,则为源文件项的读请求,这无需额外操作,可以采用通常的文件系统中读取源文件项 的流程。若不是TFS_NOSNAP,则为快照项的读请求,且snap_id的数值为所需要读取的快照项的版本号,这需要采用上文中描述的流程操作。It should be noted that when receiving a read request, it is necessary to first determine whether it is a snapshot read request. For example, you can determine whether the snap_id in the metadata (inode) is TFS_NOSNAP. Here, TFS_NOSNAP is the identification information indicating the read source file item. If it is TFS_NOSNAP, it is a read request for the source file item. This does not require additional operations. The process of reading the source file item in the normal file system can be used. If it is not TFS_NOSNAP, it is a read request for a snapshot item, and the value of snap_id is the version number of the snapshot item that needs to be read. This requires the process described above.
例如,如图12A所示,假设针对第2版快照项(snapid:2)生成了两个克隆项,分别为克隆项2-1(attachid:1)和克隆项2-2(attachid:2)。当需要读取克隆项2-1中的w2时,首先根据克隆项2-1确定出关联的快照项,也即确定出第2版快照项,然后,采用与读取第2版快照项相同的流程读取w2,由此完成针对克隆项2-1的读操作。For example, as shown in Figure 12A, assume that two clone items are generated for the version 2 snapshot item (snapid:2), namely clone item 2-1 (attachid:1) and clone item 2-2 (attachid:2) . When it is necessary to read w2 in clone item 2-1, first determine the associated snapshot item based on clone item 2-1, that is, determine the second version snapshot item, and then use the same method as reading the second version snapshot item. The process reads w2, thereby completing the read operation for clone item 2-1.
图12B为本公开一些实施例提供的数据管理方法中的写操作的示意图。下面结合图12B对针对源文件项的写操作和针对克隆项的写操作进行简要说明。Figure 12B is a schematic diagram of a write operation in a data management method provided by some embodiments of the present disclosure. The writing operation for the source file item and the writing operation for the clone item will be briefly described below with reference to FIG. 12B.
例如,在该示例中,仍然假设源文件项basefs中有三个数据片被写入,分别为w1、w2、w3。在写入w1之后,生成了第1版快照项(snapid:1),该快照项的第四位图中与w1对应的比特位为1。在写入w2之后,生成了第2版快照项(snapid:2),该快照项的第四位图中与w1、w2分别对应的比特位为1。在写入w3之后,生成了第3版快照项(snapid:3),该快照项的第四位图中与w1、w2、w3分别对应的比特位为1。For example, in this example, it is still assumed that three data pieces are written in the source file item basefs, namely w1, w2, and w3. After writing w1, the first version of the snapshot item (snapid:1) is generated, and the bit corresponding to w1 in the fourth bitmap of the snapshot item is 1. After writing w2, a version 2 snapshot item (snapid:2) is generated, and the bits corresponding to w1 and w2 in the fourth bitmap of the snapshot item are 1 respectively. After writing w3, a version 3 snapshot item (snapid:3) is generated, and the bits corresponding to w1, w2, and w3 in the fourth bitmap of the snapshot item are 1 respectively.
当需要在w2的数据片位置重新写入新的文件w2-1时,首先获取当前文件路径上最新快照版本号max_peer_id。如果max_peer_id发生变化,则表示该次写入为first cover write。因此,需要对快照的位图进行初始化。例如,进行初始化时,复制源文件项的第一位图,以作为源文件项的第二位图和快照项的第四位图,并且将快照项的第三位图全部比特位设置为0,也即是,base_peer=last_snap_peer=base_alloc,last_snap_alloc=0。然后,由于max_peer_id>last_cow_snap_id,读取元数据(inode)的信息(例如用attr表示),更新对应的last_snap_id的cow的信息,并使last_cow_snap_id=max_peer_id。由此,在写新的文件w2-1之前,记录下要做数据迁移的快照版本以及相关信息。When it is necessary to rewrite a new file w2-1 at the data slice location of w2, first obtain the latest snapshot version number max_peer_id on the current file path. If max_peer_id changes, it means that the write is the first cover write. Therefore, the snapshot's bitmap needs to be initialized. For example, when initializing, copy the first bitmap of the source file item as the second bitmap of the source file item and the fourth bitmap of the snapshot item, and set all bits of the third bitmap of the snapshot item to 0. , that is, base_peer=last_snap_peer=base_alloc, last_snap_alloc=0. Then, since max_peer_id>last_cow_snap_id, the metadata (inode) information (for example, represented by attr) is read, the cow information of the corresponding last_snap_id is updated, and last_cow_snap_id=max_peer_id. Therefore, before writing the new file w2-1, record the snapshot version to be migrated and related information.
接着,将Fh的peerid和当前文件路径上max_peer_id作对比,如果两者相等,则直接写源文件项中对应的数据片。如果Fh记录的源文件项的第一位图中对应的比特位为0,也即base_alloc=0,或者第一位图与第二位图中对应的比特位不相等,也即base_alloc!=base_peer,则也直接写源文件项中对应的数据片。如果第一位图和第二位图中对应的比特位均为有效值,也即base_alloc等于base_peer且两者均为1,则需做数据迁移(COW)。此时,读取源文件 项对应的数据,构造快照类型的数据对象的oid,由inodeid、offset、snapid和peerid组成。并且,构造要新写入的数据对象oid(也即w2-1的数据对象)。这两个数据对象的区别在于,w2-1的数据对象的snapid为0,而快照对象的oid的snapid是当前文件路径上最大的快照id的版本号。Then, compare the peerid of Fh with the max_peer_id on the current file path. If the two are equal, the corresponding data piece in the source file item is written directly. If the corresponding bit in the first bit of the source file item recorded by Fh is 0, that is, base_alloc=0, or the corresponding bit in the first bit of the image and the second bitmap are not equal, that is, base_alloc! =base_peer, the corresponding data piece in the source file item is also written directly. If the corresponding bits in the first bitmap and the second bitmap are both valid values, that is, base_alloc is equal to base_peer and both are 1, then data migration (COW) is required. At this time, the data corresponding to the source file item is read, and the oid of the snapshot type data object is constructed, which is composed of inodeid, offset, snapid and peerid. And, construct the data object oid to be newly written (that is, the data object of w2-1). The difference between these two data objects is that the snapid of the data object of w2-1 is 0, while the snapid of the oid of the snapshot object is the version number of the largest snapshot id on the current file path.
由此,在写入新的文件w2-1之前,将原来的文件w2做了数据迁移,做数据迁移的快照项是第3版快照项。之后,可以继续生成第4版快照项(snapid:4),该快照项的第四位图中与w1、w2-1、w3分别对应的比特位为1。由于打了4次快照,因此文件路径的最新快照版本号peerid为4。Therefore, before writing the new file w2-1, the data of the original file w2 is migrated, and the snapshot item for data migration is the version 3 snapshot item. After that, you can continue to generate the fourth version of the snapshot item (snapid:4). The bits corresponding to w1, w2-1, and w3 in the fourth bitmap of the snapshot item are 1 respectively. Since 4 snapshots were taken, the latest snapshot version number peerid of the file path is 4.
需要说明的是,在接收到写请求时,需要首先判断是否为数据写请求,数据写请求是指针对源文件项的写请求。例如可以根据snap_id进行判断,例如判断snap_id是否为TFS_NOSNAP。这里,TFS_NOSNAP为表示写源文件项的标识信息。若是TFS_NOSNAP,则为源文件项的写操作,是数据写请求。若不是TFS_NOSNAP,则为快照项的写操作,则提示不可写,并直接返回。It should be noted that when receiving a write request, it is necessary to first determine whether it is a data write request. The data write request refers to a write request for a source file item. For example, the judgment can be made based on the snap_id, for example, whether the snap_id is TFS_NOSNAP. Here, TFS_NOSNAP represents the identification information of the write source file item. If it is TFS_NOSNAP, it is a write operation of the source file item and a data write request. If it is not TFS_NOSNAP, it is a write operation of the snapshot item, and it will prompt that it cannot be written and return directly.
例如,如图12B所示,假设针对第2版快照项(snapid:2)生成了两个克隆项,分别为克隆项2-1(attachid:1)和克隆项2-2(attachid:2)。当需要针对克隆项2-1写w2-1时,首先根据克隆项2-1确定出关联的快照项,也即确定出第2版快照项,然后,采用与读取第2版快照项相同的流程读取w2,将w2复制到克隆项2-1对应的存储位置,然后在w2的基础上写w2-1。由此,完成针对克隆项2-1的写操作。For example, as shown in Figure 12B, assume that two clone items are generated for the version 2 snapshot item (snapid:2), namely clone item 2-1 (attachid:1) and clone item 2-2 (attachid:2) . When it is necessary to write w2-1 for clone item 2-1, first determine the associated snapshot item based on clone item 2-1, that is, determine the second version snapshot item, and then use the same method as reading the second version snapshot item. The process reads w2, copies w2 to the storage location corresponding to clone item 2-1, and then writes w2-1 based on w2. Thus, the writing operation for clone item 2-1 is completed.
需要说明的是,图12A和图12B所示的读操作和写操作的流程仅为示例性的,而非限制性的。根据实际需求,可以根据各个位图的信息采用其他适用的流程来实现读操作和写操作,本公开的实施例对此不作限制。It should be noted that the processes of read operations and write operations shown in FIG. 12A and FIG. 12B are only exemplary and not restrictive. According to actual needs, other applicable processes can be used to implement read operations and write operations according to the information of each bitmap, and the embodiments of the present disclosure do not limit this.
在本公开的实施例中,通过引入位图(bitmap)对数据部分进行管理,将分布式网络附属存储(Network Attached Storage,NAS)文件系统的快照中的数据部分从对象存储设备(OSD)中独立出来,将快照的数据部分逻辑进行抽象描述,可以方便在文件系统中进行实现,无需使用指针来管理数据部分。例如,快照的数据部分按照文件系统数据接口进行统一实现,快照的数据部分和文件系统的数据部分由对象名称进行区分,例如在对象oid添加snap字段。通过上述方式,可以便于管理维护快照整体功能,提升系统性能,减少了文件系统快照对对象存储设备的依赖和性能压力,便于开发者对对象存储设备进行进一步优化、重构、新特性的开发。当然,本公开实施例提供的数据管理方法不 限于应用在NAS文件系统中,也可以应用在任意架构的文件系统中,本公开的实施例对此不作限制。In the embodiment of the present disclosure, the data part is managed by introducing a bitmap (bitmap), and the data part in the snapshot of the distributed network attached storage (Network Attached Storage, NAS) file system is removed from the object storage device (OSD). Independently, the data part logic of the snapshot is abstractly described, which can be easily implemented in the file system without using pointers to manage the data part. For example, the data part of the snapshot is implemented in a unified manner according to the file system data interface. The data part of the snapshot and the data part of the file system are distinguished by the object name, for example, adding a snap field to the object oid. Through the above method, it is easy to manage and maintain the overall function of snapshots, improve system performance, reduce the dependence and performance pressure of file system snapshots on object storage devices, and facilitate developers to further optimize, reconstruct, and develop new features of object storage devices. Of course, the data management method provided by the embodiments of the present disclosure is not limited to application in NAS file systems, and can also be applied in file systems of any architecture. The embodiments of the present disclosure do not limit this.
需要说明的是,本公开的实施例中,上述用于文件系统的数据管理方法还可以包括更多或更少的步骤,各个步骤的执行顺序不受限制,这可以根据实际需求而定。It should be noted that in the embodiments of the present disclosure, the above-mentioned data management method for a file system may also include more or fewer steps, and the execution order of each step is not limited and may be determined according to actual needs.
本公开至少一个实施例还提供一种用于文件系统的数据管理装置。该数据管理装置将快照的数据部分从对象存储设备中独立出来,减少了文件系统快照对对象存储设备的依赖,便于管理维护快照整体功能,便于开发者对对象存储设备进行更改。At least one embodiment of the present disclosure also provides a data management device for a file system. The data management device separates the data part of the snapshot from the object storage device, reduces the dependence of the file system snapshot on the object storage device, facilitates management and maintenance of the overall function of the snapshot, and facilitates developers to make changes to the object storage device.
图13为本公开一些实施例提供的一种用于文件系统的数据管理装置的示意框图。如图13所示,在一些实施例中,该数据管理装置100包括判断单元110和处理单元120。Figure 13 is a schematic block diagram of a data management device for a file system provided by some embodiments of the present disclosure. As shown in FIG. 13 , in some embodiments, the data management device 100 includes a judgment unit 110 and a processing unit 120 .
例如,文件系统包括文件数据,文件数据被划分为多个数据片。文件系统还包括源文件项和快照项,源文件项包括第一位图和第二位图,快照项包括第三位图。第一位图的多个比特位与多个数据片一一对应,第一位图用于记录多个数据片的写入状态。第二位图的多个比特位与多个数据片一一对应,第二位图用于记录多个数据片的快照生成状态。第三位图的多个比特位与多个数据片一一对应,第三位图用于记录多个数据片的迁移状态。For example, a file system includes file data, and the file data is divided into multiple data pieces. The file system also includes a source file item and a snapshot item. The source file item includes the first bitmap and the second bitmap, and the snapshot item includes the third bitmap. Multiple bits in the first bit map correspond to multiple data slices one-to-one, and the first bit image is used to record the writing status of multiple data slices. Multiple bits of the second bitmap correspond to multiple data slices one-to-one, and the second bitmap is used to record the snapshot generation status of the multiple data slices. Multiple bits of the third bitmap correspond to multiple data slices one-to-one, and the third bitmap is used to record the transition status of the multiple data slices.
判断单元110配置为响应于接收到数据写请求,根据第一位图和第二位图判断是否进行数据迁移。例如,判断单元110可以执行如图3所示的数据管理方法的步骤S10。The determination unit 110 is configured to determine whether to perform data migration according to the first bitmap and the second bitmap in response to receiving the data write request. For example, the judgment unit 110 may execute step S10 of the data management method as shown in FIG. 3 .
处理单元120配置为响应于确定进行数据迁移,执行数据迁移操作并更新第一位图、第二位图、第三位图中对应的比特位。例如,处理单元120可以执行如图3所示的数据管理方法的步骤S20。The processing unit 120 is configured to perform data migration in response to the determination, perform a data migration operation and update corresponding bits in the first bitmap, the second bitmap, and the third bitmap. For example, the processing unit 120 may execute step S20 of the data management method as shown in FIG. 3 .
例如,判断单元110和处理单元120可以为硬件、软件、固件以及它们的任意可行的组合。例如,判断单元110和处理单元120可以为专用或通用的电路、芯片或装置等,也可以为处理器和存储器的结合。关于判断单元110和处理单元120的具体实现形式,本公开的实施例对此不作限制。For example, the judgment unit 110 and the processing unit 120 may be hardware, software, firmware, or any feasible combination thereof. For example, the judgment unit 110 and the processing unit 120 may be dedicated or general-purpose circuits, chips or devices, or may be a combination of a processor and a memory. Regarding the specific implementation forms of the judgment unit 110 and the processing unit 120, the embodiments of the present disclosure do not limit this.
需要说明的是,本公开的实施例中,数据管理装置100的各个单元与前述的数据管理方法的各个步骤对应,关于该数据管理装置100的具体功能可以参考上文中数据管理方法的相关描述,此处不再赘述。图13所示的数据管理装 置100的组件和结构只是示例性的,而非限制性的,根据需要,该数据管理装置100还可以包括其他组件和结构。It should be noted that in the embodiment of the present disclosure, each unit of the data management device 100 corresponds to each step of the aforementioned data management method. Regarding the specific functions of the data management device 100, please refer to the relevant description of the data management method above. No further details will be given here. The components and structures of the data management device 100 shown in Figure 13 are only exemplary and not restrictive. The data management device 100 may also include other components and structures as needed.
本公开至少一个实施例还提供一种电子设备,该电子设备包括本公开任一实施例提供的用于文件系统的数据管理装置。该电子设备将快照的数据部分从对象存储设备中独立出来,减少了文件系统快照对对象存储设备的依赖,便于管理维护快照整体功能,便于开发者对对象存储设备进行更改。At least one embodiment of the present disclosure also provides an electronic device, which includes the data management apparatus for a file system provided by any embodiment of the present disclosure. This electronic device separates the data part of the snapshot from the object storage device, reduces the dependence of the file system snapshot on the object storage device, facilitates management and maintenance of the overall function of the snapshot, and facilitates developers to make changes to the object storage device.
图14为本公开一些实施例提供的一种电子设备的示意框图。如图14所示,电子设备200包括数据管理装置210,该数据管理装置210可以为图13所示的数据管理装置100。例如,该电子设备200可以为分布式NAS系统或其他任意的需要实现快照的系统,本公开的实施例对此不作限制。关于该电子设备200的相关说明可参考上文中关于数据管理装置100的描述,此处不再赘述。Figure 14 is a schematic block diagram of an electronic device provided by some embodiments of the present disclosure. As shown in FIG. 14 , the electronic device 200 includes a data management device 210 , which may be the data management device 100 shown in FIG. 13 . For example, the electronic device 200 can be a distributed NAS system or any other system that needs to implement snapshots, and the embodiments of the present disclosure are not limited thereto. For relevant descriptions of the electronic device 200, please refer to the above description of the data management device 100, and will not be described again here.
本公开至少一个实施例还提供一种电子设备,该电子设备包括处理器和存储器,一个或多个计算机程序模块被存储在该存储器中并被配置为由该处理器执行,一个或多个计算机程序模块包括用于实现本公开任一实施例提供的用于文件系统的数据管理方法。该电子设备将快照的数据部分从对象存储设备中独立出来,减少了文件系统快照对对象存储设备的依赖,便于管理维护快照整体功能,便于开发者对对象存储设备进行更改。At least one embodiment of the present disclosure also provides an electronic device. The electronic device includes a processor and a memory. One or more computer program modules are stored in the memory and configured to be executed by the processor. One or more computers The program module includes a method for implementing the data management method for a file system provided by any embodiment of the present disclosure. This electronic device separates the data part of the snapshot from the object storage device, reduces the dependence of the file system snapshot on the object storage device, facilitates management and maintenance of the overall function of the snapshot, and facilitates developers to make changes to the object storage device.
图15为本公开一些实施例提供的另一种电子设备的示意框图。如图15所示,该电子设备300包括处理器310和存储器320。存储器320用于存储非暂时性计算机可读指令(例如一个或多个计算机程序模块)。处理器310用于运行非暂时性计算机可读指令,非暂时性计算机可读指令被处理器310运行时可以执行上文所述的用于文件系统的数据管理方法中的一个或多个步骤。存储器320和处理器310可以通过总线系统和/或其它形式的连接机构(未示出)互连。Figure 15 is a schematic block diagram of another electronic device provided by some embodiments of the present disclosure. As shown in FIG. 15 , the electronic device 300 includes a processor 310 and a memory 320 . Memory 320 is used to store non-transitory computer-readable instructions (eg, one or more computer program modules). The processor 310 is configured to execute non-transitory computer readable instructions. When the non-transitory computer readable instructions are executed by the processor 310, they may perform one or more steps in the data management method for a file system described above. Memory 320 and processor 310 may be interconnected by a bus system and/or other forms of connection mechanisms (not shown).
例如,处理器310可以是中央处理单元(CPU)、图形处理单元(GPU)、数字信号处理器(DSP)或者具有数据处理能力和/或程序执行能力的其它形式的处理单元,例如现场可编程门阵列(FPGA)等;例如,中央处理单元(CPU)可以为X86或ARM架构等。处理器310可以为通用处理器或专用处理器,可以控制电子设备300中的其它组件以执行期望的功能。For example, the processor 310 may be a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), or other form of processing unit with data processing capabilities and/or program execution capabilities, such as field programmable Gate array (FPGA), etc.; for example, the central processing unit (CPU) can be X86 or ARM architecture, etc. The processor 310 may be a general-purpose processor or a special-purpose processor that may control other components in the electronic device 300 to perform desired functions.
例如,存储器320可以包括一个或多个计算机程序产品的任意组合,计算机程序产品可以包括各种形式的计算机可读存储介质,例如易失性存储器和/或非易失性存储器。易失性存储器例如可以包括随机存取存储器(RAM)和/ 或高速缓冲存储器(cache)等。非易失性存储器例如可以包括只读存储器(ROM)、硬盘、可擦除可编程只读存储器(EPROM)、便携式紧致盘只读存储器(CD-ROM)、USB存储器、闪存等。在计算机可读存储介质上可以存储一个或多个计算机程序模块,处理器310可以运行一个或多个计算机程序模块,以实现电子设备300的各种功能。在计算机可读存储介质中还可以存储各种应用程序和各种数据以及应用程序使用和/或产生的各种数据等。For example, memory 320 may include any combination of one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and/or cache memory (cache). Non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, and the like. One or more computer program modules may be stored on the computer-readable storage medium, and the processor 310 may run the one or more computer program modules to implement various functions of the electronic device 300 . Various application programs and various data, as well as various data used and/or generated by the application programs, etc. can also be stored in the computer-readable storage medium.
需要说明的是,本公开的实施例中,电子设备300的具体功能和技术效果可以参考上文中关于数据管理方法的描述,此处不再赘述。It should be noted that in the embodiment of the present disclosure, for the specific functions and technical effects of the electronic device 300, reference can be made to the above description of the data management method, which will not be described again here.
本公开至少一个实施例还提供一种存储介质,用于存储非暂时性计算机可读指令,当该非暂时性计算机可读指令由计算机执行时可以实现本公开任一实施例提供的用于文件系统的数据管理方法。利用该存储介质,可以将快照的数据部分从对象存储设备中独立出来,减少了文件系统快照对对象存储设备的依赖,便于管理维护快照整体功能,便于开发者对对象存储设备进行更改。At least one embodiment of the present disclosure also provides a storage medium for storing non-transitory computer-readable instructions. When the non-transitory computer-readable instructions are executed by a computer, the method for file provided by any embodiment of the present disclosure can be implemented. Systematic approach to data management. Using this storage medium, the data part of the snapshot can be separated from the object storage device, reducing the dependence of the file system snapshot on the object storage device, making it easier to manage and maintain the overall function of the snapshot, and making it easier for developers to make changes to the object storage device.
图16为本公开一些实施例提供的一种存储介质的示意图。如图16所示,存储介质400用于存储非暂时性计算机可读指令410。例如,当非暂时性计算机可读指令410由计算机执行时可以执行根据上文所述的用于文件系统的数据管理方法中的一个或多个步骤。Figure 16 is a schematic diagram of a storage medium provided by some embodiments of the present disclosure. As shown in FIG. 16 , storage medium 400 is used to store non-transitory computer-readable instructions 410 . For example, the non-transitory computer readable instructions 410 when executed by a computer may perform one or more steps in the data management method for a file system described above.
例如,该存储介质400可以应用于上述电子设备中。例如,存储介质400可以为图15所示的电子设备300中的存储器320。例如,关于存储介质400的相关说明可以参考图15所示的电子设备300中的存储器320的相应描述,此处不再赘述。For example, the storage medium 400 can be applied to the above-mentioned electronic device. For example, the storage medium 400 may be the memory 320 in the electronic device 300 shown in FIG. 15 . For example, for relevant description of the storage medium 400, reference may be made to the corresponding description of the memory 320 in the electronic device 300 shown in FIG. 15, which will not be described again here.
有以下几点需要说明:The following points need to be explained:
(1)本公开实施例附图只涉及到本公开实施例涉及到的结构,其他结构可参考通常设计。(1) The drawings of the embodiments of this disclosure only relate to the structures involved in the embodiments of this disclosure, and other structures can refer to common designs.
(2)在不冲突的情况下,本公开的实施例及实施例中的特征可以相互组合以得到新的实施例。(2) Without conflict, the embodiments of the present disclosure and the features in the embodiments can be combined with each other to obtain new embodiments.
以上所述,仅为本公开的具体实施方式,但本公开的保护范围并不局限于此,本公开的保护范围应以所述权利要求的保护范围为准。The above are only specific embodiments of the present disclosure, but the protection scope of the present disclosure is not limited thereto. The protection scope of the present disclosure should be subject to the protection scope of the claims.

Claims (18)

  1. 一种用于文件系统的数据管理方法,其中,所述文件系统包括文件数据,所述文件数据被划分为多个数据片;A data management method for a file system, wherein the file system includes file data, and the file data is divided into multiple data slices;
    所述文件系统还包括源文件项和快照项,所述源文件项包括第一位图和第二位图,所述快照项包括第三位图;The file system also includes a source file item and a snapshot item, the source file item includes a first bitmap and a second bitmap, and the snapshot item includes a third bitmap;
    所述第一位图的多个比特位与所述多个数据片一一对应,所述第一位图用于记录所述多个数据片的写入状态;The plurality of bits of the first bit map correspond to the plurality of data slices one-to-one, and the first bit map is used to record the writing status of the plurality of data slices;
    所述第二位图的多个比特位与所述多个数据片一一对应,所述第二位图用于记录所述多个数据片的快照生成状态;The plurality of bits of the second bitmap correspond to the plurality of data slices one-to-one, and the second bitmap is used to record the snapshot generation status of the plurality of data slices;
    所述第三位图的多个比特位与所述多个数据片一一对应,所述第三位图用于记录所述多个数据片的迁移状态;The plurality of bits of the third bitmap correspond to the plurality of data slices one-to-one, and the third bitmap is used to record the migration status of the plurality of data slices;
    所述方法包括:The methods include:
    响应于接收到数据写请求,根据所述第一位图和所述第二位图判断是否进行数据迁移;In response to receiving the data write request, determine whether to perform data migration based on the first bitmap and the second bitmap;
    响应于确定进行数据迁移,执行数据迁移操作并更新所述第一位图、所述第二位图、所述第三位图中对应的比特位。In response to determining to perform data migration, a data migration operation is performed and corresponding bits in the first bitmap, the second bitmap, and the third bitmap are updated.
  2. 根据权利要求1所述的方法,其中,根据所述第一位图和所述第二位图判断是否进行数据迁移,包括:The method according to claim 1, wherein determining whether to perform data migration based on the first bitmap and the second bitmap includes:
    根据所述数据写请求确定所要操作的数据片;Determine the data piece to be operated according to the data write request;
    读取所述第一位图中与所述数据片对应的比特位,并且读取所述第二位图中与所述数据片对应的比特位;Read the bits corresponding to the data slice in the first bitmap, and read the bits corresponding to the data slice in the second bitmap;
    响应于所述第一位图中与所述数据片对应的比特位为有效值且所述第二位图中与所述数据片对应的比特位为有效值,确定进行数据迁移。In response to the bits corresponding to the data slices in the first bitmap being valid values and the bits corresponding to the data slices being valid values in the second bitmap, it is determined to perform data migration.
  3. 根据权利要求2所述的方法,其中,根据所述第一位图和所述第二位图判断是否进行数据迁移,还包括:The method of claim 2, wherein determining whether to perform data migration based on the first bitmap and the second bitmap further includes:
    响应于所述第一位图中与所述数据片对应的比特位为无效值或者所述第二位图中与所述数据片对应的比特位为无效值,确定不进行数据迁移。In response to the bit in the first bitmap corresponding to the data slice being an invalid value or the bit in the second bitmap corresponding to the data slice being an invalid value, it is determined not to perform data migration.
  4. 根据权利要求1-3中的任一项所述的方法,其中,执行所述数据迁移操作并更新所述第一位图、所述第二位图、所述第三位图中对应的比特位,包括:The method according to any one of claims 1-3, wherein the data migration operation is performed and corresponding bits in the first bitmap, the second bitmap, and the third bitmap are updated. bits, including:
    读取所述数据迁移操作对应的数据片,将读取的数据片构造为快照类型的 数据对象并进行存储;Read the data slice corresponding to the data migration operation, construct the read data slice into a snapshot type data object and store it;
    将所述第一位图中对应的比特位更新为有效值,将所述第二位图中对应的比特位更新为无效值,将所述第三位图中对应的比特位更新为有效值。Update the corresponding bits in the first bitmap to a valid value, update the corresponding bits in the second bitmap to an invalid value, and update the corresponding bits in the third bitmap to a valid value. .
  5. 根据权利要求4所述的方法,其中,读取所述数据迁移操作对应的数据片,将读取的数据片构造为所述快照类型的数据对象并进行存储,包括:The method according to claim 4, wherein reading the data slice corresponding to the data migration operation, constructing the read data slice into the snapshot type data object and storing it includes:
    获取文件路径的最新快照版本号;Get the latest snapshot version number of the file path;
    读取所述数据迁移操作对应的数据片,将读取的数据片作为数据对象进行存储;Read the data slice corresponding to the data migration operation, and store the read data slice as a data object;
    将所述最新快照版本号以及表示所述快照类型的标识信息增加到所述数据对象的信息域中;Add the latest snapshot version number and identification information indicating the snapshot type to the information field of the data object;
    将对应于所述最新快照版本号的快照项与所述数据对象关联。Associate a snapshot item corresponding to the latest snapshot version number with the data object.
  6. 根据权利要求4所述的方法,其中,将所述第一位图中对应的比特位更新为有效值,将所述第二位图中对应的比特位更新为无效值,将所述第三位图中对应的比特位更新为有效值,包括:The method according to claim 4, wherein the corresponding bits in the first bitmap are updated to valid values, the corresponding bits in the second bitmap are updated to invalid values, and the third bitmaps are updated to invalid values. The corresponding bits in the bitmap are updated to valid values, including:
    将所述源文件项的所述第一位图中对应的比特位更新为有效值,将所述源文件项的所述第二位图中对应的比特位更新为无效值;Update the corresponding bits in the first bitmap of the source file item to a valid value, and update the corresponding bits in the second bitmap of the source file item to an invalid value;
    获取文件路径的最新快照版本号;Get the latest snapshot version number of the file path;
    将所述最新快照版本号对应的快照项的所述第三位图中对应的比特位更新为有效值。Update the corresponding bit in the third bitmap of the snapshot item corresponding to the latest snapshot version number to a valid value.
  7. 根据权利要求1-6中的任一项所述的方法,还包括:The method according to any one of claims 1-6, further comprising:
    响应于接收到所述数据写请求,判断所述数据写请求是否为初次写请求;In response to receiving the data write request, determine whether the data write request is an initial write request;
    响应于所述数据写请求为所述初次写请求,将所述第一位图的内容同步到所述第二位图,并将所述第三位图的全部比特位置为无效值。In response to the data write request being the initial write request, the content of the first bitmap is synchronized to the second bitmap, and all bit positions of the third bitmap are set to invalid values.
  8. 根据权利要求7所述的方法,其中,所述快照项还包括第四位图,所述第四位图的多个比特位与所述多个数据片一一对应,所述第四位图用于记录创建所述快照项时对应的源文件项的写入状态;The method according to claim 7, wherein the snapshot item further includes a fourth bitmap, a plurality of bits of the fourth bitmap correspond to the plurality of data pieces, and the fourth bitmap Used to record the writing status of the corresponding source file item when the snapshot item is created;
    所述方法还包括:The method also includes:
    响应于所述数据写请求为所述初次写请求,将所述第一位图的内容同步到所述第四位图。In response to the data write request being the initial write request, the content of the first bitmap is synchronized to the fourth bitmap.
  9. 根据权利要求1-8中的任一项所述的方法,还包括:The method according to any one of claims 1-8, further comprising:
    响应于接收到快照读请求,根据各个版本的快照项的第三位图确定数据位 置并读取数据。In response to receiving the snapshot read request, the data location is determined based on the third bitmap of the snapshot item of each version and the data is read.
  10. 根据权利要求9所述的方法,其中,根据各个版本的快照项的第三位图确定数据位置并读取数据,包括:The method of claim 9, wherein determining the data location and reading the data according to the third bitmap of each version of the snapshot item includes:
    根据所述快照读请求确定当前快照项,其中,所述当前快照项是需要读取的版本的快照项;Determine the current snapshot item according to the snapshot read request, where the current snapshot item is a snapshot item of the version that needs to be read;
    获取所述当前快照项的第三位图中对应的比特位;Obtain the corresponding bit in the third bitmap of the current snapshot item;
    响应于所述当前快照项的第三位图中对应的比特位为有效值,根据所述当前快照项确定数据位置并读取数据;In response to the corresponding bit in the third bitmap of the current snapshot item being a valid value, determine the data location according to the current snapshot item and read the data;
    响应于所述当前快照项的第三位图中对应的比特位为无效值,依次获取更大版本号的快照项的第三位图中对应的比特位,直到获取的比特位为有效值,根据所述有效值对应的版本的快照项确定数据位置并读取数据;In response to the corresponding bit in the third bitmap of the current snapshot item being an invalid value, sequentially acquiring the corresponding bits in the third bitmap of the snapshot item with a larger version number until the acquired bit is a valid value, Determine the data location and read the data according to the snapshot item of the version corresponding to the valid value;
    响应于全部版本的快照项的第三位图中对应的比特位均为无效值,根据所述源文件项确定数据位置并读取数据。In response to the corresponding bits in the third bitmap of all versions of the snapshot items being invalid values, the data location is determined according to the source file item and the data is read.
  11. 根据权利要求1-10中的任一项所述的方法,其中,所述文件系统还包括克隆项,所述克隆项是所述快照项的拷贝;The method according to any one of claims 1-10, wherein the file system further includes a clone item, and the clone item is a copy of the snapshot item;
    所述方法还包括:The method also includes:
    响应于接收到克隆写请求,基于与所述克隆项关联的快照项确定数据位置并将需要的数据复制到所述克隆项对应的存储位置,并执行写操作。In response to receiving the clone write request, determine the data location based on the snapshot item associated with the clone item, copy the required data to the storage location corresponding to the clone item, and perform a write operation.
  12. 根据权利要求11所述的方法,还包括:The method of claim 11, further comprising:
    响应于接收到克隆读请求,基于与所述克隆项关联的快照项确定数据位置并读取所需要的数据。In response to receiving the clone read request, a data location is determined based on the snapshot item associated with the clone item and the required data is read.
  13. 根据权利要求1-12中的任一项所述的方法,其中,在执行所述数据迁移操作并更新所述第一位图、所述第二位图、所述第三位图中对应的比特位之后,所述方法还包括:The method according to any one of claims 1-12, wherein when performing the data migration operation and updating corresponding ones of the first bitmap, the second bitmap and the third bitmap After bit, the method also includes:
    对所述源文件项执行写操作。Perform a write operation on the source file item.
  14. 根据权利要求1-13中的任一项所述的方法,其中,在根据所述第一位图和所述第二位图判断是否进行数据迁移之后,所述方法还包括:The method according to any one of claims 1-13, wherein after determining whether to perform data migration according to the first bitmap and the second bitmap, the method further includes:
    响应于确定不进行数据迁移,对所述源文件项执行写操作。In response to determining that data migration is not to be performed, a write operation is performed on the source file item.
  15. 一种用于文件系统的数据管理装置,其中,所述文件系统包括文件数据,所述文件数据被划分为多个数据片;A data management device for a file system, wherein the file system includes file data, and the file data is divided into a plurality of data slices;
    所述文件系统还包括源文件项和快照项,所述源文件项包括第一位图和第 二位图,所述快照项包括第三位图;The file system also includes a source file item and a snapshot item, the source file item includes a first bitmap and a second bitmap, and the snapshot item includes a third bitmap;
    所述第一位图的多个比特位与所述多个数据片一一对应,所述第一位图用于记录所述多个数据片的写入状态;The plurality of bits of the first bit map correspond to the plurality of data slices one-to-one, and the first bit map is used to record the writing status of the plurality of data slices;
    所述第二位图的多个比特位与所述多个数据片一一对应,所述第二位图用于记录所述多个数据片的快照生成状态;The plurality of bits of the second bitmap correspond to the plurality of data slices one-to-one, and the second bitmap is used to record the snapshot generation status of the plurality of data slices;
    所述第三位图的多个比特位与所述多个数据片一一对应,所述第三位图用于记录所述多个数据片的迁移状态;The plurality of bits of the third bitmap correspond to the plurality of data slices one-to-one, and the third bitmap is used to record the migration status of the plurality of data slices;
    所述装置包括:The device includes:
    判断单元,配置为响应于接收到数据写请求,根据所述第一位图和所述第二位图判断是否进行数据迁移;A judgment unit configured to, in response to receiving a data write request, judge whether to perform data migration according to the first bitmap and the second bitmap;
    处理单元,配置为响应于确定进行数据迁移,执行数据迁移操作并更新所述第一位图、所述第二位图、所述第三位图中对应的比特位。A processing unit configured to perform data migration in response to determining to perform data migration, and update corresponding bits in the first bitmap, the second bitmap, and the third bitmap.
  16. 一种电子设备,包括权利要求15所述的用于文件系统的数据管理装置。An electronic device includes the data management device for a file system according to claim 15.
  17. 一种电子设备,包括:An electronic device including:
    处理器;processor;
    存储器,包括一个或多个计算机程序模块;Memory, including one or more computer program modules;
    其中,所述一个或多个计算机程序模块被存储在所述存储器中并被配置为由所述处理器执行,所述一个或多个计算机程序模块包括用于实现权利要求1-14任一项所述的用于文件系统的数据管理方法。Wherein, the one or more computer program modules are stored in the memory and configured to be executed by the processor, the one or more computer program modules include a computer program module for implementing any one of claims 1-14 The data management method for a file system.
  18. 一种存储介质,用于存储非暂时性计算机可读指令,当所述非暂时性计算机可读指令由计算机执行时可以实现权利要求1-14任一项所述的用于文件系统的数据管理方法。A storage medium for storing non-transitory computer-readable instructions. When the non-transitory computer-readable instructions are executed by a computer, the data management for the file system described in any one of claims 1-14 can be implemented. method.
PCT/CN2022/107919 2022-03-21 2022-07-26 Data management method and apparatus of file system, electronic device, and storage medium WO2023178899A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210274271.0A CN114356849B (en) 2022-03-21 2022-03-21 Data management method and device of file system, electronic equipment and storage medium
CN202210274271.0 2022-03-21

Publications (1)

Publication Number Publication Date
WO2023178899A1 true WO2023178899A1 (en) 2023-09-28

Family

ID=81094373

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/107919 WO2023178899A1 (en) 2022-03-21 2022-07-26 Data management method and apparatus of file system, electronic device, and storage medium

Country Status (2)

Country Link
CN (1) CN114356849B (en)
WO (1) WO2023178899A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114356849B (en) * 2022-03-21 2022-05-17 联想凌拓科技有限公司 Data management method and device of file system, electronic equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6434681B1 (en) * 1999-12-02 2002-08-13 Emc Corporation Snapshot copy facility for a data storage system permitting continued host read/write access
CN101482838A (en) * 2009-02-06 2009-07-15 杭州华三通信技术有限公司 Data write-in method and apparatus based on copy-on-write
CN101840362A (en) * 2009-10-28 2010-09-22 创新科存储技术有限公司 Method and device for achieving copy-on-write snapshot
CN102411524A (en) * 2011-12-30 2012-04-11 云海创想信息技术(天津)有限公司 Snapshot volume data copying method
US9547655B1 (en) * 2013-07-11 2017-01-17 Ca, Inc. Filesystem independent snapshot driver
CN113468105A (en) * 2020-03-31 2021-10-01 阿里巴巴集团控股有限公司 Data structure of data snapshot, related data processing method, device and system
CN114356849A (en) * 2022-03-21 2022-04-15 联想凌拓科技有限公司 Data management method and device of file system, electronic equipment and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106126370A (en) * 2016-06-15 2016-11-16 上海爱数信息技术股份有限公司 Based on the Server free backup method and the system that store increment bitmap between snapshot
CN106844095B (en) * 2016-12-27 2020-04-28 上海爱数信息技术股份有限公司 File backup method and system and client with system
CN110188068B (en) * 2019-05-16 2024-01-23 上海爱数信息技术股份有限公司 Volume-level backup method and device for guaranteeing consistency of file system data

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6434681B1 (en) * 1999-12-02 2002-08-13 Emc Corporation Snapshot copy facility for a data storage system permitting continued host read/write access
CN101482838A (en) * 2009-02-06 2009-07-15 杭州华三通信技术有限公司 Data write-in method and apparatus based on copy-on-write
CN101840362A (en) * 2009-10-28 2010-09-22 创新科存储技术有限公司 Method and device for achieving copy-on-write snapshot
CN102411524A (en) * 2011-12-30 2012-04-11 云海创想信息技术(天津)有限公司 Snapshot volume data copying method
US9547655B1 (en) * 2013-07-11 2017-01-17 Ca, Inc. Filesystem independent snapshot driver
CN113468105A (en) * 2020-03-31 2021-10-01 阿里巴巴集团控股有限公司 Data structure of data snapshot, related data processing method, device and system
CN114356849A (en) * 2022-03-21 2022-04-15 联想凌拓科技有限公司 Data management method and device of file system, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN114356849B (en) 2022-05-17
CN114356849A (en) 2022-04-15

Similar Documents

Publication Publication Date Title
US11461202B2 (en) Remote data replication method and system
US11947809B2 (en) Data management system
US10762038B2 (en) System and method for virtual machine conversion
US9292327B1 (en) Optimization for incremental backup of VMS
US9727273B1 (en) Scalable clusterwide de-duplication
US8417907B2 (en) Synchronizing snapshot volumes across hosts
JP4741371B2 (en) System, server apparatus, and snapshot format conversion method
JP4419884B2 (en) Data replication apparatus, method, program, and storage system
US20120136832A1 (en) Incremental restore of data between storage systems having dissimilar storage operating systems associated therewith
WO2017041654A1 (en) Method and apparatus for writing and acquiring data in distributed storage system
US20190370236A1 (en) Persistent Version Control for Data Transfer between Heterogeneous Data Stores
US10628298B1 (en) Resumable garbage collection
CN115185891B (en) Data management method and device of file system, electronic equipment and storage medium
WO2023005688A1 (en) Snapshot implementation method and apparatus, electronic device, and computer readable storage medium
WO2023178899A1 (en) Data management method and apparatus of file system, electronic device, and storage medium
CN115586872A (en) Container mirror image management method, device, equipment and storage medium
US10372683B1 (en) Method to determine a base file relationship between a current generation of files and a last replicated generation of files
Wang et al. Towards cluster-wide deduplication based on Ceph
US11755425B1 (en) Methods and systems for synchronous distributed data backup and metadata aggregation

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

Country of ref document: EP

Kind code of ref document: A1