WO2015066850A1 - 存储文件的方法和装置 - Google Patents

存储文件的方法和装置 Download PDF

Info

Publication number
WO2015066850A1
WO2015066850A1 PCT/CN2013/086591 CN2013086591W WO2015066850A1 WO 2015066850 A1 WO2015066850 A1 WO 2015066850A1 CN 2013086591 W CN2013086591 W CN 2013086591W WO 2015066850 A1 WO2015066850 A1 WO 2015066850A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
data blocks
data
blocks
stored
Prior art date
Application number
PCT/CN2013/086591
Other languages
English (en)
French (fr)
Inventor
曹宇
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201380002592.4A priority Critical patent/CN103797455B/zh
Priority to PCT/CN2013/086591 priority patent/WO2015066850A1/zh
Publication of WO2015066850A1 publication Critical patent/WO2015066850A1/zh

Links

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/17Details of further file system functions
    • G06F16/174Redundancy elimination performed by the file system
    • G06F16/1748De-duplication implemented within the file system, e.g. based on file segments
    • G06F16/1752De-duplication implemented within the file system, e.g. based on file segments based on file chunks

Definitions

  • the present invention relates to the field of information technology, and in particular, to a method and apparatus for storing files. Background technique
  • Embodiments of the present invention provide a method and an apparatus for storing a file, which can save storage space.
  • a method for storing a file including: determining a number of data blocks of a file to be stored, T is a positive integer; if T is less than N, organizing the file into a N according to a redundancy relationship a data block and a data block set of M check blocks, wherein the N data blocks include T data blocks of the file and invalid data blocks, the data in the invalid data block is zero, and N and M are positive integers. ; store T data blocks of the file and the M check blocks.
  • the method further includes:
  • the storage of the N data blocks is recorded, including:
  • each of the N data blocks is stored is identified by a bitmap Bitmap.
  • the storage of the N data blocks is recorded, including: The total size of the T data blocks of the file being stored is recorded.
  • the storage of the data blocks is recorded, including: The storage is recorded in the metadata.
  • the method further includes:
  • the one data block and the one check block are read.
  • the second aspect provides an apparatus for storing a file, including: a determining module, configured to determine a number of data blocks of a file to be stored, ⁇ is a positive integer; and a processing module, configured to be used when ⁇ is less than ⁇
  • the file is organized into a data block set including a data block and a check block according to a redundancy relationship, wherein the data block includes one data block of the file and an invalid data block, where the invalid data block is The data is zero, ⁇ and ⁇ are positive integers; the storage module is used to store the data blocks of the file and the two check blocks.
  • the apparatus further includes:
  • a recording module for recording the storage of the data blocks.
  • the recording module is specifically configured to identify, by using a bitmap, a bitmap, whether each of the N data blocks is stored.
  • the recording module is specifically configured to record the total size of the T data blocks of the file being stored.
  • the recording module is specifically configured to record the storage in the metadata of the file. happening.
  • the apparatus further includes:
  • the reading module is configured to: when the data of the file is read, obtain the storage condition, determine T data blocks in which the file is stored according to the storage condition, and read the T data blocks and the M check blocks.
  • the method and apparatus for storing a file when the number of data blocks of the file to be stored is smaller than the number of data blocks required for the organization data block set, Storing data blocks and check blocks of the file in the data block set can save storage space and improve read and write efficiency.
  • FIG. 1 is a schematic illustration of a striping in accordance with an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of a method of storing a file according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a small file storage in accordance with an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a storage status record in accordance with an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a method of reading a file according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of file size changes in accordance with an embodiment of the present invention.
  • FIG. 7 is a schematic block diagram of an apparatus for storing a file according to an embodiment of the present invention.
  • FIG. 8 is a schematic block diagram of an apparatus for storing a file according to another embodiment of the present invention.
  • FIG. 9 is a structural diagram of an apparatus for storing a file according to still another embodiment of the present invention. detailed description
  • the technical solution of the embodiment of the present invention may be used for a system for organizing files in a redundant relationship, and the redundancy relationship may be an Erasure Code redundancy relationship or other redundancy relationship, which is not limited by the embodiment of the present invention.
  • the data block set in the embodiment of the present invention includes N data blocks and M check blocks organized according to a redundancy relationship.
  • the data block set may be a stripe, but the embodiment of the present invention is not limited thereto.
  • FIG. 2 shows a schematic flow diagram of a method 100 of storing a file in accordance with an embodiment of the present invention.
  • the method of Figure 2 is performed by a device that stores files.
  • the method 100 includes:
  • T is less than N
  • a data block the data in the invalid data block is zero, and N and M are positive integers;
  • the device storing the file when the device storing the file organizes the file to be stored into a data block set including N data blocks and M check blocks according to the redundancy relationship, and first stores the data block of the file to be stored.
  • T data blocks and M parity blocks are stored, thereby saving storage space. Moreover, the number of data blocks read and written while reading and writing files is also reduced, and the efficiency of reading and writing can also be improved.
  • the method for storing a file in the embodiment of the present invention stores only the data block of the file in the data block set when the number of data blocks of the file to be stored is smaller than the number of data blocks required for the organization data block set.
  • the check block can save storage space and improve read and write efficiency.
  • the method 100 further includes:
  • the device storing the file When storing the T data blocks of the file and the M check blocks, the device storing the file simultaneously records the storage of the N data blocks. That is to say, the case where each of the N data blocks is stored is recorded. This storage case is used to determine that the file has several data blocks when reading the file. Specific In other words, since all N data blocks are not stored, the number of data blocks of the file is not fixed N, and therefore, the storage condition is required to determine the number of data blocks of the file when the file is read.
  • the device storing the file determines the number T of data blocks of the file to be stored. Specifically, the device storing the file determines the number of data blocks of the file to be stored according to the size of the file to be stored and the size of the data block, wherein the data block size can be preset. For example, if the data block size is 128K, the file to be stored is 100K, then ⁇ is 1; if the file to be stored is 300 ⁇ , then ⁇ is 3.
  • the file when the device storing the file is less than ⁇ , the file is organized into a data block set including the data block and the check block according to the redundancy relationship, wherein the data block includes the file.
  • the data block includes the file.
  • One data block and an invalid data block, the data in the invalid data block is zero.
  • the data block set is a set of data blocks and check blocks determined by the redundancy relationship.
  • the redundant relationship between the backup data and the redundancy it is necessary to calculate the redundancy based on the data. That is to say, it is necessary to generate one parity block based on one data block calculation.
  • is smaller than ⁇ , that is, when the number of data blocks of the file to be stored is smaller than the data block required to organize the data block set according to the redundancy relationship, when the data block set is organized, the zero is still added. To make up for each data block. These data blocks obtained by adding zeros are called invalid data blocks. For example, as shown in FIG.
  • the data block set (for example, striping in the figure) includes 4 data blocks and 2 check blocks, and only one data block is available in the file data. (ie, ⁇ is 1), three invalid data blocks are added, so that the check block is obtained according to the redundancy calculation to form a stripe.
  • the device storing the file stores the data blocks of the file and the one of the check blocks.
  • the device storing the file stores only one data block of the file and the one check block, that is, only one data block of the file and the one check block are stored to the disk without storing the invalid data block. That is, although two data blocks and one parity block are generated when the data block set is organized according to the redundancy relationship, only one data block of the file and the one check are stored in the embodiment of the present invention. Piece.
  • the device storing the file records the storage of the data blocks.
  • the storage condition of the data blocks is used to indicate that one of the data blocks in the data block set is stored. According to this storage situation, it is possible to determine that the file has several data blocks when the file is read.
  • the storage of the data blocks is recorded, including: Whether each of the N data blocks is stored is identified by a bitmap Bitmap. Specifically, each bit in the Bitmap is used to identify the storage of each data block. For example, 1 means that the data block is stored, and 0 means that the data block is not stored. It should be understood that since the check block needs to be stored, it is not necessary to record the storage condition of the check block, that is, only the storage condition of the N data blocks in the data block set can be recorded. As shown in FIG. 4, for a stripe composed of 4 data blocks and 2 check blocks, a 4-bit Bitmap can be used, and each bit identifies one data block.
  • the number of bits of the Bitmap is not limited.
  • the number of bits of the Bitmap may be more than the number of data blocks, or equal to the total number of data blocks and check blocks, and the Bitmap may also be At the same time, the storage status of the check block is recorded.
  • the storage condition of the N data blocks is recorded, including:
  • the total size of the T data blocks of the file being stored is recorded.
  • the storage of N data blocks in a data block set can also be identified by recording the total size of the T data blocks being stored. Specifically, the total size of all the data blocks to be stored is recorded, and then the size of one data block is modulo, and the number of stored data blocks is obtained, thereby obtaining a storage condition. Taking striping as an example, if a stripe is 1MB, including 8 data blocks (N is 8) and 2 check blocks (M is 2), then one data block is 128KB. It is possible to record the total size of the actually stored data block in a stripe, for example 640KB, then 640/128 is equal to 5, so 5 data blocks and 2 check blocks are stored, and 3 invalid data blocks are not stored.
  • the index may be used, and different values indicate different storage situations.
  • the embodiment of the present invention does not limit the manner in which the storage is recorded.
  • the storage condition of the N data blocks is recorded, including:
  • the storage is recorded in the metadata of the file.
  • the storage is recorded in the metadata of the file. In this way, it is possible to know that the stored file has several data blocks when reading the metadata.
  • the storage condition of the N data blocks is recorded, including: The storage is recorded in the stored data block.
  • the storage condition is recorded in the data block.
  • the storage condition may be stored in a higher level block, stored in a file index node (inode), or a file container may be stored in a file container attribute or the like.
  • the method 100 further includes:
  • the T data blocks and the M parity blocks are read.
  • the device storing the file acquires a storage condition corresponding to the file, and determines, according to the storage condition, that the file is stored as T data blocks, thereby reading the T data blocks and the M check blocks, and according to the T data blocks and the M check blocks get the data of the file. If the storage condition is recorded in the metadata, the storage condition is acquired together when the metadata is read, and then the data block is read according to the storage condition. If the storage condition is recorded in the stored data block, the storage condition is read together when the data block is read. For example, when accessing a data block, each data block can be read at a time, and then, according to the storage condition recorded in the data block, it is determined how many data blocks the file should have, thereby collecting the data blocks of the file.
  • the metadata of the file is read first, and the storage condition is obtained. According to the storage situation, it is determined that the file has only one data block, and therefore, one data block and two check blocks are read. .
  • the number of data blocks read when the file is read is also reduced, so that the reading efficiency can be improved.
  • the method for storing files by using the embodiment of the present invention can also implement the conversion of the size file well.
  • striping as an example, as shown in Fig. 6, when the file is enlarged, the data block of the file becomes larger until the entire stripe is occupied, that is, all the data blocks in the stripe become the data block of the file.
  • the storage condition is also adjusted to facilitate subsequent storage and reading of the data block. In this way, when the data of the file is less than one stripe, the storage space can be occupied at least, and as the data of the file increases, the entire stripe is gradually occupied, thereby achieving the purpose of automatic adjustment. Therefore, the method for storing a file in the embodiment of the present invention can implement the conversion of the size file.
  • the method for storing a file in the embodiment of the present invention stores only the data block of the file in the data block set when the number of data blocks of the file to be stored is smaller than the number of data blocks required for the organization data block set. And the check block, and record the storage of the data block in the data block set, which can save storage space, improve read and write efficiency, and facilitate conversion of large and small files. .
  • the size of the sequence numbers of the above processes does not mean the order of execution, and the order of execution of each process should be determined by its function and internal logic, and should not be taken to the embodiments of the present invention.
  • the implementation process constitutes any limitation.
  • FIG. 7 shows a schematic block diagram of an apparatus 700 for storing files in accordance with an embodiment of the present invention.
  • the apparatus 700 includes:
  • a determining module 710 configured to determine a number of data blocks of the file to be stored, T is a positive integer
  • a processing module 720 configured to organize the file into N data according to a redundancy relationship when T is less than N a data block set of a block and M check blocks, wherein the N data blocks include T data blocks of the file and invalid data blocks, the data in the invalid data block is zero, and N and M are positive integers;
  • the storage module 730 is configured to store T data blocks of the file and the M check blocks.
  • the determining module 710 determines the file to be stored.
  • the number of data blocks T When T is smaller than N, that is, when the number of data blocks of the file is smaller than the number of data blocks required by the data block set (the file in this case becomes a small file), the data block set organized by the processing module 720
  • the N data blocks include T data blocks of the file and invalid data blocks, wherein the data in the invalid data block is zero. That is, in this case, the data block set includes a data block of the file to be stored, an invalid data block, and a check block.
  • the storage module 730 stores only the T data blocks of the file and the M check blocks, that is, only the T data blocks and the M check blocks of the file are stored to the disk without storing the invalid data blocks.
  • T data blocks and M check blocks are stored, thereby saving The storage space. Moreover, the number of data blocks read and written when reading and writing files is also reduced, and the efficiency of reading and writing can also be improved.
  • the apparatus for storing a file in the embodiment of the present invention stores only the data block of the file in the data block set when the number of data blocks of the file to be stored is smaller than the number of data blocks required for the organization data block set.
  • the check block can save storage space and improve read and write efficiency.
  • the device 700 further includes: a recording module 740, configured to record a storage condition of the N data blocks.
  • the recording module 740 records the storage of the N data blocks. That is, the case where each of the N data blocks is stored is recorded. This storage case is used to determine that the file has several data blocks when reading the file. Specifically, since all N data blocks are not stored, the number of data blocks of the file is not a fixed number N, and therefore, the storage condition is required to determine the number of data blocks of the file when the file is read.
  • the recording module 740 is specifically configured to identify, by using a bitmap Bitmap, whether each of the N data blocks is stored.
  • each bit in the Bitmap is used to identify the storage of each data block. For example, 1 means that the data block is stored, and 0 means that the data block is not stored. It should be understood that since the check blocks are required to be stored, it is not necessary to record the storage condition of the check block, that is, it is possible to record only the storage of N data blocks in the data block set. As shown in Fig. 4, for a strip consisting of 4 data blocks and 2 check blocks, a 4-bit Bitmap can be used, and each bit identifies a data block.
  • the recording module 740 is specifically configured to record the total size of the T data blocks of the file to be stored.
  • the storage of N data blocks in a data block set can also be identified by recording the total size of the T data blocks being stored. Specifically, the total size of all the data blocks to be stored is recorded, and then the size of one data block is modulo, and the number of stored data blocks is obtained, thereby obtaining a storage condition.
  • the recording module 740 is specifically configured to record the storage condition in the metadata of the file.
  • the device 700 further includes: The reading module 750 is configured to: when the data of the file is read, obtain the storage condition, determine T data blocks in which the file is stored according to the storage condition, and read the T data blocks and the M check blocks. .
  • the device storing the file acquires a storage condition corresponding to the file, and determines, according to the storage condition, that the file is stored as T data blocks, thereby reading the T data blocks and the M check blocks, and according to the T data blocks and the M check blocks get the data of the file. If the storage condition is recorded in the metadata, the storage condition is acquired together when the metadata is read, and then the data block is read according to the storage condition. If the storage condition is recorded in the stored data block, the storage condition is read together when the data block is read.
  • the number of data blocks read when the file is read is also reduced, so that the reading efficiency can be improved.
  • the redundancy relationship is an erasure code Erasure Code redundancy relationship.
  • the data block set is a stripe stripe.
  • the apparatus 700 for storing a file according to an embodiment of the present invention may correspond to an execution body of a method of storing a file according to an embodiment of the present invention, and the above-described and other operations and/or functions of respective modules in the apparatus 700 storing the file are respectively implemented for The corresponding processes of the respective methods in FIG. 1 to FIG. 6 are not described here.
  • the device for storing a file stores only the data block of the file in the data block set and when the number of data blocks of the file to be stored is smaller than the number of data blocks required for the organization data block set.
  • the block is checked, and the storage of the data block in the data block set is recorded, which can save storage space, improve read and write efficiency, and facilitate conversion of large and small files.
  • FIG. 9 shows a structure of an apparatus for storing a file according to another embodiment of the present invention, comprising at least one processor 902 (for example, a CPU), at least one network interface 905 or other communication interface, a memory 906, and at least one communication bus. 903, used to implement connection communication between these devices.
  • the storage 906 may include a high speed random access memory (RAM: Random Access Memory), and may also include a non-volatile memory such as at least one disk storage.
  • the communication connection with at least one other network element is implemented by at least one network interface 905 (which may be wired or wireless), and may use an Internet, a wide area network, a local area network, a metropolitan area network, or the like.
  • the memory 906 stores a program 9061, and the processor 902 executes the program 9061 for:
  • T Determining the number of data blocks of the file to be stored ⁇ , T is a positive integer
  • the file is organized into a data block set including N data blocks and M check blocks according to a redundancy relationship, where the N data blocks include T data blocks of the file and invalid data blocks. , the data in the invalid data block is zero, N and M are positive integers;
  • the processor 902 is further configured to record a storage condition of the N data blocks.
  • the processor 902 is specifically configured to identify, by using a bitmap, a bitmap, whether each of the N data blocks is stored.
  • the processor 902 is specifically configured to record the total size of the T data blocks of the file being stored.
  • the processor 902 is specifically configured to record the storage condition in the metadata of the file.
  • the processor 902 is further configured to:
  • the T data blocks and the M parity blocks are read.
  • the redundancy relationship is an erasure code Erasure Code redundancy relationship.
  • the data block set is a stripe stripe.
  • the embodiment of the present invention stores only the data block set when the number of data blocks of the file to be stored is smaller than the number of data blocks required for the organization data block set.
  • the data block and the check block of the file can save storage space and improve read and write efficiency.
  • the term "and/or” is merely an association describing the associated object, indicating that there may be three relationships.
  • a and / or B can mean: A exists separately, there are A and B, and there are three cases of B alone.
  • the character "/" in this article generally indicates that the contextual object is an "or" relationship.
  • the disclosed systems, devices, and methods may be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, or an electrical, mechanical or other form of connection.
  • the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the embodiments of the present invention.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • the technical solution of the present invention contributes in essence or to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium.
  • a number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a removable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and the like, which can store program codes. .

Landscapes

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

Abstract

本发明公开了一种存储文件的方法和装置。该方法包括:确定待存储的文件的数据块的个数 T,T为正整数;若T小于N,则按照冗余关系将该文件组织为包括N个数据块和M个校验块的数据块集合,其中,该N个数据块包括该文件的T个数据块以及无效数据块,该无效数据块中的数据为零,N和M为正整数;存储该文件的T个数据块和该M个校验块。本发明实施例的存储文件的方法和装置,能够节省存储空间和提高读写效率

Description

存储文件的方法和装置 技术领域
本发明涉及信息技术领域, 尤其涉及存储文件的方法和装置。 背景技术
现有技术在按照冗余关系组织文件并存储时, 例如, 按照冗余关系将文 件组织为分条(stripe )存储时, 会将整个分条存储到磁盘。 在文件数据的大 小小于一个分条大小时, 也会存储整个分条, 即占用一个分条大小的磁盘空 间。 比如, 在纠删码( Erasure Code ) 冗余方式中, 将 N份数据进行 Erasure Code冗余校验计算,计算之后产生 M份冗余。在文件数据不足 N份数据时, 会添加零以补足 N份数据。 N分数据和 M份冗余组成一个分条, 在存储时 会将 N分数据和 M份冗余都存储到磁盘, 这样会造成多占用存储空间。 在 独立冗余磁盘阵歹 'J ( Redundant Array of Inexpensive Disks , RAID )方式中, 如果文件大小不足一个分条, 也会占用一个分条大小的磁盘空间, 导致多占 用存储空间。 发明内容
本发明实施例提供了一种存储文件的方法和装置, 能够节省存储空间。 第一方面, 提供了一种存储文件的方法, 包括: 确定待存储的文件的数 据块的个数 Τ, T为正整数; 若 T小于 N, 则按照冗余关系将该文件组织为 包括 N个数据块和 M个校验块的数据块集合, 其中, 该 N个数据块包括该 文件的 T个数据块以及无效数据块, 该无效数据块中的数据为零, N和 M 为正整数; 存储该文件的 T个数据块和该 M个校验块。
在第一种可能的实现方式中, 该方法还包括:
记录该 N个数据块的存储情况。
结合第一方面的第一种可能的实现方式, 在第二种可能的实现方式中, 记录该 N个数据块的存储情况, 包括:
通过位图 Bitmap标识该 N个数据块中的每一个数据块是否被存储。 结合第一方面的第一种可能的实现方式, 在第三种可能的实现方式中, 记录该 N个数据块的存储情况, 包括: 记录被存储的该文件的 T个数据块的总大小。
结合第一方面的第一至三种可能的实现方式中的任一种可能的实现方 式, 在第四种可能的实现方式中, 记录该 Ν个数据块的存储情况, 包括: 在该文件的元数据中记录该存储情况。
结合第一方面的第一至四种可能的实现方式中的任一种可能的实现方 式, 在第五种可能的实现方式中, 该方法还包括:
在读取该文件的数据时, 获取该存储情况;
根据该存储情况确定该文件被存储的 Τ个数据块;
读取该 Τ个数据块和该 Μ个校验块。
第二方面, 提供了一种存储文件的装置, 包括: 确定模块, 用于确定待 存储的文件的数据块的个数 Τ, Τ为正整数; 处理模块, 用于在 Τ小于 Ν的 情况下按照冗余关系将该文件组织为包括 Ν个数据块和 Μ个校验块的数据 块集合, 其中, 该 Ν个数据块包括该文件的 Τ个数据块以及无效数据块, 该无效数据块中的数据为零, Ν和 Μ为正整数; 存储模块, 用于存储该文 件的 Τ个数据块和该 Μ个校验块。
在第一种可能的实现方式中, 该装置还包括:
记录模块, 用于记录该 Ν个数据块的存储情况。
结合第二方面的第一种可能的实现方式, 在第二种可能的实现方式中, 该记录模块具体用于通过位图 Bitmap标识该 N个数据块中的每一个数据块 是否被存储。
结合第二方面的第一种可能的实现方式, 在第三种可能的实现方式中, 该记录模块具体用于记录被存储的该文件的 T个数据块的总大小。
结合第二方面的第一至三种可能的实现方式中的任一种可能的实现方 式, 在第四种可能的实现方式中, 该记录模块具体用于在该文件的元数据中 记录该存储情况。
结合第二方面的第一至四种可能的实现方式中的任一种可能的实现方 式, 在第五种可能的实现方式中, 该装置还包括:
读取模块, 用于在读取该文件的数据时, 获取该存储情况, 根据该存储 情况确定该文件被存储的 T个数据块,读取该 T个数据块和该 M个校验块。
基于上述技术方案, 本发明实施例的存储文件的方法和装置, 通过在待 存储的文件的数据块的个数小于组织数据块集合所需的数据块的个数时,只 存储数据块集合中该文件的数据块以及校验块, 能够节省存储空间和提高读 写效率。 附图说明
为了更清楚地说明本发明实施例的技术方案, 下面将对本发明实施例中 所需要使用的附图作筒单地介绍, 显而易见地, 下面描述中的附图仅仅是本 发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动的 前提下, 还可以根据这些附图获得其他的附图。
图 1是根据本发明实施例的分条的示意图。
图 2是根据本发明实施例的存储文件的方法的示意性流程图。
图 3是根据本发明实施例的小文件存储的示意图。
图 4是根据本发明实施例的存储情况记录的示意图。
图 5是根据本发明实施例的读取文件的方法的示意图。
图 6是根据本发明实施例的文件大小变化的示意图。
图 7是根据本发明实施例的存储文件的装置的示意性框图。
图 8是根据本发明另一实施例的存储文件的装置的示意性框图。
图 9是根据本发明又一实施例的存储文件的装置的结构图。 具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行 清楚、 完整地描述, 显然, 所描述的实施例是本发明的一部分实施例, 而不 是全部实施例。 基于本发明中的实施例, 本领域普通技术人员在没有作出创 造性劳动的前提下所获得的所有其他实施例, 都应属于本发明保护的范围。
本发明实施例的技术方案可以用于以冗余关系组织文件的系统, 该冗余 关系可以是 Erasure Code冗余关系或者其他冗余关系, 本发明实施例对此不 限定。
本发明实施例中的数据块集合包括按照冗余关系组织的 N 个数据块和 M个校验块。 该数据块集合可以为分条, 但本发明实施例对此并不限定。
例如, 如图 1所示, 一个分条由四个数据块和两个校验块构成, 它们之 间存在 Erasure Code冗余关系。 应理解, 图 1只是示例, 不应对本发明实施 例构成限定。 图 2示出了根据本发明实施例的存储文件的方法 100的示意性流程图。 图 2的方法由存储文件的装置执行。 如图 2所示, 该方法 100包括:
S110, 确定待存储的文件的数据块的个数 T, T为正整数;
S120, 若 T小于 N, 则按照冗余关系将该文件组织为包括 N个数据块 和 M个校验块的数据块集合, 其中, 该 N个数据块包括该文件的 T个数据 块以及无效数据块, 该无效数据块中的数据为零, N和 M为正整数;
S130, 存储该文件的 T个数据块和该 M个校验块。
在本发明实施例中,存储文件的装置在按照冗余关系将待存储文件组织 为包括 N个数据块和 M个校验块的数据块集合并存储时, 首先确定待存储 的文件的数据块的个数1\在 T小于 N时, 即该文件的数据块的个数小于上 述数据块集合所需要的数据块的个数(这种情况中的文件称为小文件) 时, 该数据块集合的 N个数据块包括该文件的 T个数据块以及无效数据块, 其 中, 该无效数据块中的数据为零。 也就是说, 在这种情况下, 数据块集合包 括待存储文件的数据块, 无效数据块以及校验块。 然后, 存储文件的装置只 存储该文件的 T个数据块和该 M个校验块, 即只将该文件的 T个数据块和 该 M个校验块存储到磁盘, 而不存储无效数据块。
在现有技术中, 在 T小于 N时, 也是存储全部 N个数据块以及 M个校 验块。 例如, 如图 1所示, 在文件的数据只够一个数据块时, 后面三个无效 数据块也要存储到磁盘上, 在读取数据时也要读取所有的数据块, 这样不但 占用了空间, 读取效率也较低。
而在本发明实施例中, 只存储 T个数据块和 M个校验块, 因此, 节省 了存储空间。 并且, 在读写文件时所读写的数据块个数也减少, 读写效率也 能够提高。
因此, 本发明实施例的存储文件的方法, 通过在待存储的文件的数据块 的个数小于组织数据块集合所需的数据块的个数时, 只存储数据块集合中该 文件的数据块以及校验块, 能够节省存储空间和提高读写效率。
在本发明实施例中, 可选地, 该方法 100还包括:
记录该 N个数据块的存储情况。
在存储该文件的 T个数据块和该 M个校验块时, 存储文件的装置同时 记录该 N个数据块的存储情况。 也就是说, 记录该 N个数据块中各数据块 被存储的情况。 该存储情况用于在读取文件时确定文件有几个数据块。 具体 而言, 由于没有存储全部 N个数据块, 文件的数据块个数不是固定的 N个, 因此, 需要该存储情况以便于在读取文件时确定文件的数据块个数。
在 S110中, 存储文件的装置确定待存储的文件的数据块的个数 T。 具体而言,存储文件的装置根据待存储的文件的大小以及数据块的大小 确定待存储的文件的数据块的个数 Τ,其中数据块大小可以预先设定。例如, 若数据块大小为 128K, 待存储的文件为 100K, 则 Τ为 1 ; 若待存储的文件 为 300Κ, 则 Τ为 3。
在 S120中, 存储文件的装置在 Τ小于 Ν时, 按照冗余关系将该文件组 织为包括 Ν个数据块和 Μ个校验块的数据块集合, 其中, 该 Ν个数据块包 括该文件的 Τ个数据块以及无效数据块, 该无效数据块中的数据为零。
数据块集合为由冗余关系所决定的数据块和校验块的集合。在 Ν份数据 和 Μ份冗余的冗余关系中, 需要根据 Ν份数据计算得到 Μ份冗余。 也就是 说, 需要根据 Ν个数据块计算产生 Μ个校验块。 在本发明实施例中, 当 Τ 小于 Ν时,即待存储的文件的数据块个数小于根据冗余关系组织数据块集合 所需的数据块时,在组织数据块集合时,仍然通过补充零以补足 Ν个数据块。 这些通过补充零得到的数据块称为无效数据块。 例如, 如图 3所示, 若 Ν为 4, Μ为 2, 即数据块集合(图中以分条为例) 包括 4个数据块和 2个校验 块, 在文件数据只够一个数据块(即 Τ为 1 ) 时, 补充 3个无效数据块, 从 而根据冗余计算得到校验块, 以形成分条。
在 S130中,存储文件的装置存储该文件的 Τ个数据块和该 Μ个校验块。 存储文件的装置只存储该文件的 Τ个数据块和该 Μ个校验块, 即只将 该文件的 Τ个数据块和该 Μ个校验块存储到磁盘, 而不存储无效数据块。 也就是说,尽管在根据冗余关系组织数据块集合时,会产生 Ν个数据块和 Μ 个校验块,在本发明实施例中只存储该文件的 Τ个数据块和该 Μ个校验块。
如图 3所示, 在文件只有一个数据块时, 只存储这一个数据块和两个校 验块, 不存储另外三个无效数据块。
为了便于后续的读取, 存储文件的装置记录该 Ν个数据块的存储情况。 Ν个数据块的存储情况用于表示数据块集合中的 Ν个数据块被存储的情况。 根据该存储情况能够在读取文件时确定文件有几个数据块。
在本发明实施例中, 记录该 Ν个数据块的存储情况可以有多种方式。 可选地, 记录该 Ν个数据块的存储情况, 包括: 通过位图 Bitmap标识该 N个数据块中的每一个数据块是否被存储。 具体而言, 利用 Bitmap 中的各个位分别标识各个数据块的存储情况。 例如, 1表示数据块被存储, 0表示数据块没有被存储。 应理解, 由于校验 块都需要存储, 因此不需要记录校验块的存储情况, 即可以只记录数据块集 合中 N个数据块的存储情况。如图 4所示,对于由 4个数据块和 2个校验块 构成的分条, 可以采用 4位的 Bitmap, 每一位标识一个数据块。 若 4个数据 块都为文件的数据块, 即不是无效数据块, 则 4个数据块都要存储到磁盘, 因此 Bitmap为 1111; 若只有第一数据块为文件的数据块, 其他三个数据块 为无效数据块, 则只存储第一个数据块, 因此 Bitmap为 1000。
应理解, 在通过 Bitmap记录存储情况的方式中, Bitmap的位数也不限 定, 例如, Bitmap的位数可以多于数据块的个数, 或者等于数据块和校验块 的总数, Bitmap还可以同时记录校验块的存储情况等等。
可选地, 记录该 N个数据块的存储情况, 包括:
记录被存储的该文件的 T个数据块的总大小。
数据块集合中 N个数据块的存储情况还可以通过记录被存储的 T个数 据块的总大小而标识。具体而言,将被存储的所有数据块的总大小记录下来, 然后对一个数据块的大小取模, 得到被存储的数据块的个数, 从而得到存储 情况。 以分条为例, 如果一个分条是 1MB, 包括 8个数据块(N为 8 ), 2 个校验块(M为 2 ), 那么一个数据块为 128KB。 可以记录一个分条中实际 被存储的数据块的总大小, 比如 640KB, 那么 640/128等于 5, 所以存储了 5个数据块以及 2个校验块, 还有 3个无效数据块没有存储。
应理解, 记录存储情况的方式还可以有其他方式, 比如, 可以采用索引 的方式, 不同的值表示不同的存储情况, 本发明实施例不限定记录存储情况 的方式。
在本发明实施例中, 该 N 个数据块的存储情况记录在哪儿也有多种情 况。
可选地, 记录该 N个数据块的存储情况, 包括:
在该文件的元数据中记录该存储情况。
在这种实施方式中, 存储情况记录在文件的元数据中。 这样, 就可以在 读取元数据时知道被存储的文件有几个数据块。
可选地, 记录该 N个数据块的存储情况, 包括: 在被存储的数据块中记录该存储情况。
在这种实施方式中, 存储情况记录在数据块中。 在存储数据块时, 同时 记录存储情况, 如图 4所示。
应理解, 存储情况记录的方式还可以有其他方式, 例如, 可以将存储情 况存储在上级块中, 存储在文件索引节点(inode )中, 或者构建一个文件容 器存储在文件容器的属性中等等。
在本发明实施例中, 可选地, 该方法 100还包括:
在读取该文件的数据时, 获取该存储情况;
根据该存储情况确定该文件被存储的 T个数据块;
读取该 T个数据块和该 M个校验块。
具体而言, 由于在存储时只存储了文件的 T个数据块以及 M个校验块, 在读取文件时, 也只需读取 T个数据块以及 M个校验块。 存储文件的装置 获取与文件对应的存储情况, 根据该存储情况确定文件被存储为 T 个数据 块, 从而读取该 T个数据块以及 M个校验块, 并根据该 T个数据块以及该 M个校验块得到该文件的数据。 若存储情况记录在元数据中, 则在读取元数 据时一并获取该存储情况, 然后根据该存储情况读取数据块。 若存储情况记 录在被存储的数据块中, 则在读取数据块时一并读取该存储情况。 例如, 访 问数据块的时候, 各数据块可以一次读取上来, 然后, 根据数据块中记录的 存储情况判断文件应该有多少个数据块, 从而收集齐文件的数据块。
例如, 如图 5所示, 在读取文件时, 先读取文件的元数据, 获取存储情 况, 根据该存储情况确定文件只有一个数据块, 因此, 读取一个数据块以及 两个校验块。
因此, 本发明实施例的存储文件的方法, 在读取文件时所读取的数据块 的个数也减少, 从而能够提高读取效率。
采用本发明实施例的存储文件的方法还能够很好地实现大小文件的转 换。 以分条为例, 如图 6所示, 当文件增大时, 文件的数据块变多, 直到占 满整个分条, 即分条内所有数据块都变为文件的数据块。 在存储数据块的同 时, 存储情况也随之调整, 以便于后续的数据块存储和读取。 这样, 在文件 的数据不满一个分条时,能够最少地占用存储空间,随着文件的数据的增多, 逐渐占满整个分条, 从而达到自动调整的目的。 因而, 本发明实施例的存储 文件的方法能够 ^艮好地实现大小文件的转换。 因此, 本发明实施例的存储文件的方法, 通过在待存储的文件的数据块 的个数小于组织数据块集合所需的数据块的个数时, 只存储数据块集合中该 文件的数据块以及校验块, 并记录数据块集合中数据块的存储情况, 能够节 省存储空间, 提高读写效率, 还便于实现大小文件的转换。。
应理解, 在本发明的各种实施例中, 上述各过程的序号的大小并不意味 着执行顺序的先后, 各过程的执行顺序应以其功能和内在逻辑确定, 而不应 对本发明实施例的实施过程构成任何限定。
上文中结合图 1至图 6, 详细描述了根据本发明实施例的存储文件的方 法, 下面将结合图 7至图 9, 描述根据本发明实施例的存储文件的装置。
图 7示出了根据本发明实施例的存储文件的装置 700的示意性框图。如 图 7所示, 该装置 700包括:
确定模块 710, 用于确定待存储的文件的数据块的个数 Τ, T为正整数; 处理模块 720,用于在 T小于 N的情况下按照冗余关系将该文件组织为 包括 N个数据块和 M个校验块的数据块集合, 其中, 该 N个数据块包括该 文件的 T个数据块以及无效数据块, 该无效数据块中的数据为零, N和 M 为正整数;
存储模块 730, 用于存储该文件的 T个数据块和该 M个校验块。
在本发明实施例中,存储文件的装置 700在按照冗余关系将待存储文件 组织为包括 N个数据块和 M个校验块的数据块集合并存储时,确定模块 710 确定待存储的文件的数据块的个数 T。在 T小于 N时, 即该文件的数据块的 个数小于上述数据块集合所需要的数据块的个数(这种情况中的文件成为小 文件)时, 处理模块 720组织的该数据块集合的 N个数据块包括该文件的 T 个数据块以及无效数据块, 其中, 该无效数据块中的数据为零。 也就是说, 在这种情况下, 数据块集合包括待存储文件的数据块, 无效数据块以及校验 块。 存储模块 730只存储该文件的 T个数据块和该 M个校验块, 即只将该 文件的 T个数据块和该 M个校验块存储到磁盘, 而不存储无效数据块。
在现有技术中, 在 T小于 N时, 也会存储全部 N个数据块以及 M个校 验块。 例如, 如图 1所示, 在文件的数据只够一个数据块时, 后面三个无效 数据块也要存储到磁盘上, 在读取数据时也要读取所有的数据块, 这样不但 占用了空间, 读取效率也较低。
而在本发明实施例中, 只存储 T个数据块和 M个校验块, 因此, 节省 了存储空间。 并且, 在读写文件时所读写的数据块个数也减少, 读写效率也 能够提高。
因此, 本发明实施例的存储文件的装置, 通过在待存储的文件的数据块 的个数小于组织数据块集合所需的数据块的个数时, 只存储数据块集合中该 文件的数据块以及校验块, 能够节省存储空间和提高读写效率。
在本发明实施例中, 如图 8所示, 可选地, 该装置 700还包括: 记录模块 740, 用于记录该 N个数据块的存储情况。
在存储模块 730存储该文件的 T个数据块和该 M个校验块时, 记录模 块 740记录该 N个数据块的存储情况。 也就是说, 记录该 N个数据块中各 数据块被存储的情况。 该存储情况用于在读取文件时确定文件有几个数据 块。 具体而言, 由于没有存储全部 N个数据块, 文件的数据块个数不是固定 的 N个,因此,需要该存储情况以便于在读取文件时确定文件的数据块个数。
在本发明实施例中, 可选地, 该记录模块 740具体用于通过位图 Bitmap 标识该 N个数据块中的每一个数据块是否被存储。
具体而言, 利用 Bitmap 中的各个位分别标识各个数据块的存储情况。 例如, 1表示数据块被存储, 0表示数据块没有被存储。 应理解, 由于校验 块都需要存储, 因此不需要记录校验块的存储情况, 即可以只记录数据块集 合中 N个数据块的存储情况。如图 4所示,对于由 4个数据块和 2个校验块 构成的分条, 可以采用 4位的 Bitmap, 每一位标识一个数据块。 若 4个数据 块都为文件的数据块, 即不是无效数据块, 则 4个数据块都要存储到磁盘, 因此 Bitmap为 1111; 若只有第一数据块为文件的数据块, 其他三个数据块 为无效数据块, 则只存储第一个数据块, 因此 Bitmap为 1000。
在本发明实施例中, 可选地, 该记录模块 740具体用于记录被存储的该 文件的 T个数据块的总大小。
数据块集合中 N个数据块的存储情况还可以通过记录被存储的 T个数 据块的总大小而标识。具体而言,将被存储的所有数据块的总大小记录下来, 然后对一个数据块的大小取模, 得到被存储的数据块的个数, 从而得到存储 情况。
在本发明实施例中, 可选地, 该记录模块 740具体用于在该文件的元数 据中记录该存储情况。
在本发明实施例中, 如图 8所示, 可选地, 该装置 700还包括: 读取模块 750, 用于在读取该文件的数据时, 获取该存储情况, 根据该 存储情况确定该文件被存储的 T个数据块, 读取该 T个数据块和该 M个校 验块。
具体而言, 由于在存储时只存储了文件的 T个数据块以及 M个校验块, 在读取文件时, 也只需读取 T个数据块以及 M个校验块。 存储文件的装置 获取与文件对应的存储情况, 根据该存储情况确定文件被存储为 T 个数据 块, 从而读取该 T个数据块以及 M个校验块, 并根据该 T个数据块以及该 M个校验块得到该文件的数据。 若存储情况记录在元数据中, 则在读取元数 据时一并获取该存储情况, 然后根据该存储情况读取数据块。 若存储情况记 录在被存储的数据块中, 则在读取数据块时一并读取该存储情况。
本发明实施例的存储文件的装置,在读取文件时所读取的数据块的个数 也减少, 从而能够提高读取效率。
在本发明实施例中, 可选地, 该冗余关系为纠删码 Erasure Code冗余关 系。
在本发明实施例中, 可选地, 该数据块集合为分条 stripe。
根据本发明实施例的存储文件的装置 700可对应于根据本发明实施例的 存储文件的方法的执行主体, 并且存储文件的装置 700中的各个模块的上述 和其它操作和 /或功能分别为了实现图 1至图 6中的各个方法的相应流程,为 了筒洁, 在此不再赘述。
本发明实施例的存储文件的装置,通过在待存储的文件的数据块的个数 小于组织数据块集合所需的数据块的个数时, 只存储数据块集合中该文件的 数据块以及校验块, 并记录数据块集合中数据块的存储情况, 能够节省存储 空间, 提高读写效率, 还便于实现大小文件的转换。
图 9示出了本发明的另一实施例提供的存储文件的装置的结构, 包括至 少一个处理器 902 (例如 CPU ) , 至少一个网络接口 905或者其他通信接口, 存储器 906, 和至少一个通信总线 903 , 用于实现这些装置之间的连接通信。 储器 906可能包含高速随机存取存储器 ( RAM: Random Access Memory ), 也可能还包括非不稳定的存储器( non- volatile memory ), 例如至少一个磁盘 存储器。 通过至少一个网络接口 905 (可以是有线或者无线) 实现与至少一 个其他网元之间的通信连接, 可以使用互联网, 广域网, 本地网, 城域网等。 在一些实施方式中,存储器 906存储了程序 9061 ,处理器 902执行程序 9061 , 用于:
确定待存储的文件的数据块的个数 τ, T为正整数;
若 T小于 N, 则按照冗余关系将该文件组织为包括 N个数据块和 M个 校验块的数据块集合, 其中, 该 N个数据块包括该文件的 T个数据块以及 无效数据块, 该无效数据块中的数据为零, N和 M为正整数;
存储该文件的 T个数据块和该 M个校验块。
可选地, 处理器 902还用于记录该 N个数据块的存储情况。
可选地, 处理器 902具体用于通过位图 Bitmap标识该 N个数据块中的 每一个数据块是否被存储。
可选地,处理器 902具体用于记录被存储的该文件的 T个数据块的总大 小。
可选地, 处理器 902具体用于在该文件的元数据中记录该存储情况。 可选地, 处理器 902还用于:
在读取该文件的数据时, 获取该存储情况;
根据该存储情况确定该文件被存储的 T个数据块;
读取该 T个数据块和该 M个校验块。
可选地, 该冗余关系为纠删码 Erasure Code冗余关系。
可选地, 该数据块集合为分条 stripe。
从本发明实施例提供的以上技术方案可以看出,本发明实施例通过在待 存储的文件的数据块的个数小于组织数据块集合所需的数据块的个数时,只 存储数据块集合中该文件的数据块以及校验块, 能够节省存储空间和提高读 写效率。
应理解, 在本发明实施例中, 术语 "和 /或"仅仅是一种描述关联对象的 关联关系, 表示可以存在三种关系。 例如, A和 /或 B, 可以表示: 单独存在 A, 同时存在 A和 B, 单独存在 B这三种情况。 另外, 本文中字符 "/" , 一 般表示前后关联对象是一种 "或" 的关系。
本领域普通技术人员可以意识到, 结合本文中所公开的实施例描述的各 示例的单元及算法步骤, 能够以电子硬件、 计算机软件或者二者的结合来实 现, 为了清楚地说明硬件和软件的可互换性, 在上述说明中已经按照功能一 般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执 行, 取决于技术方案的特定应用和设计约束条件。 专业技术人员可以对每个 特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超 出本发明的范围。
所属领域的技术人员可以清楚地了解到, 为了描述的方便和筒洁, 上述 描述的系统、 装置和单元的具体工作过程, 可以参考前述方法实施例中的对 应过程, 在此不再赘述。
在本申请所提供的几个实施例中, 应该理解到, 所揭露的系统、 装置和 方法, 可以通过其它的方式实现。 例如, 以上所描述的装置实施例仅仅是示 意性的, 例如, 所述单元的划分, 仅仅为一种逻辑功能划分, 实际实现时可 以有另外的划分方式, 例如多个单元或组件可以结合或者可以集成到另一个 系统, 或一些特征可以忽略, 或不执行。 另外, 所显示或讨论的相互之间的 耦合或直接耦合或通信连接可以是通过一些接口、装置或单元的间接耦合或 通信连接, 也可以是电的, 机械的或其它的形式连接。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作 为单元显示的部件可以是或者也可以不是物理单元, 即可以位于一个地方, 或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或 者全部单元来实现本发明实施例方案的目的。
另外, 在本发明各个实施例中的各功能单元可以集成在一个处理单元 中, 也可以是各个单元单独物理存在, 也可以是两个或两个以上单元集成在 一个单元中。 上述集成的单元既可以采用硬件的形式实现, 也可以采用软件 功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销 售或使用时, 可以存储在一个计算机可读取存储介质中。 基于这样的理解, 本发明的技术方案本质上或者说对现有技术做出贡献的部分, 或者该技术方 案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在 一个存储介质中, 包括若干指令用以使得一台计算机设备(可以是个人计算 机, 服务器, 或者网络设备等)执行本发明各个实施例所述方法的全部或部 分步骤。 而前述的存储介质包括: U盘、 移动硬盘、 只读存储器(ROM, Read-Only Memory )、 随机存取存储器 ( RAM, Random Access Memory )、 磁碟或者光盘等各种可以存储程序代码的介质。
以上所述, 仅为本发明的具体实施方式, 但本发明的保护范围并不局限 于此, 任何熟悉本技术领域的技术人员在本发明揭露的技术范围内, 可轻易 想到各种等效的修改或替换, 这些修改或替换都应涵盖在本发明的保护范围 之内。 因此, 本发明的保护范围应以权利要求的保护范围为准。

Claims

权利要求
1. 一种存储文件的方法, 其特征在于, 包括:
确定待存储的文件的数据块的个数 τ, T为正整数;
若 T小于 N, 则按照冗余关系将所述文件组织为包括 N个数据块和 M 个校验块的数据块集合, 其中, 所述 N个数据块包括所述文件的 T个数据 块以及无效数据块, 所述无效数据块中的数据为零, N和 M为正整数; 存储所述文件的 T个数据块和所述 M个校验块。
2. 根据权利要求 1所述的方法, 其特征在于, 所述方法还包括: 记录所述 N个数据块的存储情况。
3. 根据权利要求 2所述的方法, 其特征在于, 所述记录所述 N个数据 块的存储情况, 包括:
通过位图 Bitmap标识所述 N个数据块中的每一个数据块是否被存储。
4. 根据权利要求 2所述的方法, 其特征在于, 所述记录所述 N个数据 块的存储情况, 包括:
记录被存储的所述文件的 T个数据块的总大小。
5. 根据权利要求 2至 4中任一项所述的方法, 其特征在于, 所述记录 所述 N个数据块的存储情况, 包括:
在所述文件的元数据中记录所述存储情况。
6. 根据权利要求 2至 5中任一项所述的方法, 其特征在于, 所述方法 还包括:
在读取所述文件的数据时, 获取所述存储情况;
根据所述存储情况确定所述文件被存储的 T个数据块;
读取所述 T个数据块和所述 M个校验块。
7. 一种存储文件的装置, 其特征在于, 包括:
确定模块, 用于确定待存储的文件的数据块的个数 Τ, T为正整数; 处理模块, 用于在 T小于 N的情况下按照冗余关系将所述文件组织为 包括 N个数据块和 M个校验块的数据块集合, 其中, 所述 N个数据块包括 所述文件的 T个数据块以及无效数据块, 所述无效数据块中的数据为零, N 和 M为正整数;
存储模块, 用于存储所述文件的 T个数据块和所述 M个校验块。
8. 根据权利要求 7所述的装置, 其特征在于, 所述装置还包括: 记录模块, 用于记录所述 N个数据块的存储情况。
9. 根据权利要求 8所述的装置, 其特征在于, 所述记录模块具体用于 通过位图 Bitmap标识所述 N个数据块中的每一个数据块是否被存储。
10. 根据权利要求 8所述的装置, 其特征在于, 所述记录模块具体用于 记录被存储的所述文件的 T个数据块的总大小。
11. 根据权利要求 8至 10中任一项所述的装置, 其特征在于, 所述记 录模块具体用于在所述文件的元数据中记录所述存储情况。
12. 根据权利要求 8至 11 中任一项所述的装置, 其特征在于, 所述装 置还包括:
读取模块, 用于在读取所述文件的数据时, 获取所述存储情况, 根据所 述存储情况确定所述文件被存储的 T个数据块,读取所述 T个数据块和所述 M个校验块。
PCT/CN2013/086591 2013-11-06 2013-11-06 存储文件的方法和装置 WO2015066850A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201380002592.4A CN103797455B (zh) 2013-11-06 存储文件的方法和装置
PCT/CN2013/086591 WO2015066850A1 (zh) 2013-11-06 2013-11-06 存储文件的方法和装置

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2013/086591 WO2015066850A1 (zh) 2013-11-06 2013-11-06 存储文件的方法和装置

Publications (1)

Publication Number Publication Date
WO2015066850A1 true WO2015066850A1 (zh) 2015-05-14

Family

ID=50671621

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/086591 WO2015066850A1 (zh) 2013-11-06 2013-11-06 存储文件的方法和装置

Country Status (1)

Country Link
WO (1) WO2015066850A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101308471A (zh) * 2008-05-30 2008-11-19 华为技术有限公司 一种恢复数据的方法及装置
CN101656593A (zh) * 2009-09-15 2010-02-24 中国人民解放军国防科学技术大学 前向纠错编码方法、前向纠错译码方法及其装置
US20120166909A1 (en) * 2010-12-22 2012-06-28 Schmisseur Mark A Method and apparatus for increasing data reliability for raid operations
CN102932331A (zh) * 2012-09-29 2013-02-13 南京云创存储科技有限公司 应用于分布式存储系统的超安存编解码方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101308471A (zh) * 2008-05-30 2008-11-19 华为技术有限公司 一种恢复数据的方法及装置
CN101656593A (zh) * 2009-09-15 2010-02-24 中国人民解放军国防科学技术大学 前向纠错编码方法、前向纠错译码方法及其装置
US20120166909A1 (en) * 2010-12-22 2012-06-28 Schmisseur Mark A Method and apparatus for increasing data reliability for raid operations
CN102932331A (zh) * 2012-09-29 2013-02-13 南京云创存储科技有限公司 应用于分布式存储系统的超安存编解码方法

Also Published As

Publication number Publication date
CN103797455A (zh) 2014-05-14

Similar Documents

Publication Publication Date Title
CN102937967B (zh) 数据冗余实现方法及装置
US9996557B2 (en) Database storage system based on optical disk and method using the system
US9223509B2 (en) File processing method and storage device
WO2017148242A1 (zh) 一种访问叠瓦式磁记录smr硬盘的方法及服务器
WO2014190501A1 (zh) 数据恢复方法、存储设备和存储系统
JP2010049488A (ja) ストレージシステム及びデータ管理方法
JP2009230628A5 (zh)
US10838825B2 (en) Implementing snapshot sets for consistency groups of storage volumes
WO2018120844A1 (zh) 一种差异数据备份方法和差异数据备份装置
CN104054071A (zh) 访问存储设备的方法和存储设备
US8140886B2 (en) Apparatus, system, and method for virtual storage access method volume data set recovery
TW201115326A (en) Data verification using checksum sidefile
TW201107981A (en) Method and apparatus for protecting the integrity of cached data in a direct-attached storage (DAS) system
WO2018076633A1 (zh) 一种远程数据复制方法、存储设备及存储系统
US8924642B2 (en) Monitoring record management method and device
US9213486B2 (en) Writing new data of a first block size to a second block size using a write-write mode
CN110825559A (zh) 一种数据处理方法及设备
JP5729479B2 (ja) 仮想テープ装置及び仮想テープ装置の制御方法
CN106933707B (zh) 基于raid技术的数据存储设备数据恢复方法及系统
CN103645995B (zh) 写数据的方法及装置
WO2019037587A1 (zh) 一种数据恢复方法及装置
WO2014094259A1 (zh) 存储空间对象的处理方法及设备
CN114924914B (zh) 磁盘分区表信息备份、恢复方法及系统
WO2015066850A1 (zh) 存储文件的方法和装置
CN109284270B (zh) 一种分布式文件系统存储模块的部署优化方法及装置

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 13897238

Country of ref document: EP

Kind code of ref document: A1