WO2014166446A1 - 文件访问处理方法、系统及计算机存储介质 - Google Patents

文件访问处理方法、系统及计算机存储介质 Download PDF

Info

Publication number
WO2014166446A1
WO2014166446A1 PCT/CN2014/076906 CN2014076906W WO2014166446A1 WO 2014166446 A1 WO2014166446 A1 WO 2014166446A1 CN 2014076906 W CN2014076906 W CN 2014076906W WO 2014166446 A1 WO2014166446 A1 WO 2014166446A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
small
preprocessing
interface
access
Prior art date
Application number
PCT/CN2014/076906
Other languages
English (en)
French (fr)
Inventor
邹同亮
缪敬
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2014166446A1 publication Critical patent/WO2014166446A1/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/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • G06F3/0632Configuration or reconfiguration of storage systems by initialisation or re-initialisation of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0659Command handling arrangements, e.g. command buffers, queues, command scheduling

Definitions

  • the present invention relates to computer storage technology, and more particularly to a file access processing method, system and computer storage medium. Background technique
  • the technical implementation is mainly divided into symmetric and non-symmetric.
  • the former uses techniques such as consistent hashing to allow each node in the storage system to store files and metadata (mainly the distribution of files on nodes).
  • a node's downtime does not affect access to a file.
  • the asymmetric distributed file system has a special metadata server, which has a simple logical structure and is easy to manage. In particular, access to files in the same directory is more efficient.
  • the well-known open source distributed file system includes Hadoop Distributed File System (HDFS, Hadoop Distributed File System), lustre, etc.
  • the small file is packaged into a large file for storage.
  • the packaged file consists of two parts: index and storage.
  • the index part records the original directory structure and file status.
  • the disadvantage of this solution is that once a large file is created, it cannot be modified. Adding large files is not supported. To add and tamper files, you must repackage the small files.
  • the Sequence file consists of a series of binary key/values. If key is a small file name, value is the file content. This scheme supports the consolidation of batch small files into one large file. Writer, Reader and Sequence File Sorter classes are provided to support writing, reading and sorting of small files in large files. This scheme supports access to small files in large files without restricting access operations. The number of users and the number of files accessed, support for large file appends (Send) to write small files, and support for three-level document compression for large files (including: no compression, file level, block level).
  • Embodiments of the present invention provide a file access processing method, system, and computer storage medium, which can improve response performance of distributed file system file access.
  • An embodiment of the present invention provides a file access processing method, including:
  • the corresponding file access pre-processing interface is invoked according to the type of the file access instruction to obtain pre-processing information of the file access;
  • Accessing the processing interface by calling a standard file corresponding to the file access pre-processing interface, and performing access processing according to the pre-processing information.
  • the corresponding file access preprocessing interface is invoked according to the type of the file access instruction to obtain the file access preprocessing information, including:
  • the small file is created, and the small file is merged into the large file according to the layout information, and the obtained large file combined with the small file is used as the pre-processing information.
  • the file access pre-processing interface includes: a pre-processing interface for creating a small file; the method further includes: creating a small file by calling the small file before the setting of the layout information of the small file a pre-processing interface of the file, determining whether the created small file needs to be merged into the large file for optimization, and if necessary, performing the operation of establishing the layout information; otherwise, accessing the pre-processing interface corresponding to the file access Standard file access processing interface, creating small files.
  • the party The law also includes:
  • the large file is created when the large file does not exist.
  • the establishing the layout information for storing the small file in the large file includes: dividing the large file into blocks by using the pre-processing interface for creating the small file;
  • layout information of the small file where the layout information includes: global description information, an index node table, an index node description table, and a block description table.
  • the merging the small file into the large file according to the layout information includes: assigning a directory item to the small file according to the layout information, where the directory item includes a file name and an index node;
  • the small file is merged into the large file according to a directory entry allocated for the small file.
  • the determining whether the created small file needs to be merged into a large file for optimization includes:
  • the file access pre-processing interface includes: a pre-processing interface for reading and writing small files; correspondingly, when the type of the file access instruction is a small file for reading and writing, the corresponding file is called according to the file access instruction type
  • the pre-processing interface obtains pre-processing information for file access, including:
  • Searching for the directory entry corresponding to the small file by calling the pre-processing interface for reading and writing the small file, and searching for the block corresponding to the small file in the large file according to the index node found in the directory entry Obtaining block information of the found block, and using the acquired block information as the pre-processing information.
  • the invoking the standard file access processing interface corresponding to the file access pre-processing interface, and performing access processing according to the pre-processing information includes: The processing interface is accessed by calling a standard file corresponding to the file pre-processing interface, and the small file in the found block is read and written according to the acquired block information.
  • the method further includes: determining, by using the pre-processing interface for reading and writing the small file, whether the small file that needs to be read or written is an optimized file, and if so, Then, an operation of searching for a directory entry corresponding to the small file is performed; otherwise, a standard file access processing interface corresponding to the file pre-processing interface is invoked for access processing.
  • the embodiment of the invention further provides a distributed file system, comprising: an interface definition module, a pre-processing module and a processing module;
  • the interface definition module is configured to define a file access pre-processing interface
  • the pre-processing module is configured to, when receiving the file access instruction, invoke a corresponding file access pre-processing interface according to the type of the file access instruction to obtain pre-processing information of the file access;
  • the processing module is configured to invoke a standard file access processing interface corresponding to the file pre-processing interface, and perform access processing according to the pre-processing information.
  • the file access pre-processing interface includes: a pre-processing interface for creating a small file; the pre-processing module includes: a merging unit and a layout information establishing unit;
  • the layout information establishing unit is configured to: when the type of the file access instruction is received to create a small file, by calling a standard file access processing interface corresponding to the file access preprocessing interface, establishing a small storage in the large file Layout information of the file;
  • the merging unit is configured to create a small file, and merge the small file into the large file according to the layout information, and use the obtained large file combined with the small file as the preprocessing information. .
  • the file access pre-processing interface includes: a pre-processing interface for creating a small file; the pre-processing module further includes: a first optimization determining unit, configured to determine, by calling the pre-processing interface that creates the small file, whether to merge the created small file into the large file for optimization, if necessary, triggering the layout information establishing unit The layout information is created; otherwise, the processing module is triggered to create a small file by calling the standard file access processing interface corresponding to the file access pre-processing interface.
  • the system further includes: a large file determining module and a large file creating module; the large file determining module configured to determine whether the large file exists; if yes, triggering the large file creating module to create the large File; otherwise, the layout information establishing unit is triggered to establish layout information.
  • the layout information establishing unit is further configured to divide the large file into blocks by using the pre-processing interface for creating a small file; and establishing, in the large file, the layout information of the small file;
  • the layout information includes: global description information, an inode table, an inode description table, and a block description table.
  • the merging unit is further configured to allocate a directory item to the small file according to the layout information, where the directory item includes a file name and an index node; according to the directory item allocated for the small file, the small file is Merge into the large file.
  • the first optimization determining unit is further configured to determine whether the created small file needs to be merged into the large file for optimization according to the size of the directory or the small file where the small file needs to be created.
  • the file access pre-processing interface includes: a pre-processing interface for reading and writing small files; the pre-processing module further includes:
  • the first search processing unit is configured to: when the type of the file access instruction received is a small file read/write file, the directory entry corresponding to the small file is searched by calling the pre-processing interface for reading and writing the small file; a second search processing unit, configured to search for a block corresponding to the small file in the large file according to an index node found in the directory entry, acquire block information of the found block, and obtain the obtained block Information is used as the pre-processing information.
  • the processing module is further configured to access a processing interface by calling a standard file corresponding to the file pre-processing interface, and reading and writing a small file in the found block according to the acquired block information.
  • the preprocessing module further includes:
  • the second optimization determining unit is configured to determine whether the small file to be read or written is an optimized file by calling the pre-processing interface for reading and writing the small file, and if yes, triggering the first search processing unit to perform the searching The operation of the directory entry corresponding to the small file; otherwise, the processing module is triggered to invoke the standard file access processing interface corresponding to the file pre-processing interface for access processing.
  • the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the file access processing method described above.
  • the pre-processing is performed before the file access processing, and then the access processing is performed according to the pre-processed information by calling the standard file access interface, and the standard pre-processing interface is replaced by the customized pre-processing interface to implement the customized pre-processing interface.
  • the function can realize the processing of file access without any modification to the standard interface in the existing distributed file system; the implementation is easy and more versatile, and the processing performance of small file access can be significantly improved.
  • FIG. 1 is a flowchart 1 of an implementation of a file access processing method according to an embodiment of the present invention
  • FIG. 2 is a flowchart 2 of an implementation of a file access processing method according to an embodiment of the present invention
  • FIG. 3 is a file access processing according to an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram 1 of a distributed file system according to an embodiment of the present invention
  • FIG. 5 is a schematic structural diagram 1 of a pre-processing module 42 in a distributed file system according to an embodiment of the present invention
  • FIG. 6 is a schematic structural diagram 2 of a pre-processing module 42 in a distributed file system according to an embodiment of the present invention
  • FIG. 7 is a schematic structural diagram 2 of a distributed file system according to an embodiment of the present invention
  • FIG. 8 is a schematic structural diagram 3 of a preprocessing module 42 in a distributed file system according to an embodiment of the present invention
  • FIG. 9 is a schematic structural diagram 4 of a pre-processing module 42 in a distributed file system according to an embodiment of the present invention. detailed description
  • the embodiment of the invention describes a file access processing method, as shown in FIG. 1 , including the following steps:
  • Step 101 Define a file access preprocessing interface.
  • Step 102 When receiving the file access instruction, obtain the file access pre-processing information by calling a file access pre-processing interface corresponding to the type of the file access instruction.
  • Step 103 Access a processing interface by calling a standard file corresponding to the file access pre-processing interface, and perform access processing according to the pre-processing information, that is, responding to the file access instruction.
  • the pre-processing interface is used to access the pre-processing interface, and the file access is pre-processed, so that the small file optimization or other file access processing can be implemented without modifying the upper-layer access interface, and the embodiment of the present invention is implemented.
  • the technical solution does not require any changes to the existing distributed file system, and is more achievable and versatile than the existing methods modified at the distributed file system level.
  • the types of access instructions described in the embodiments of the present invention mainly include: creating a small file, opening a small file, reading and writing a small file, and deleting a small file.
  • the file access pre-processing interface described in the embodiment of the present invention may include: a pre-processing interface for creating a small file, a pre-processing interface for opening a small file, a pre-processing interface for reading and writing small files, and deleting a small file. Preprocessing interface.
  • the file access processing includes the following steps:
  • Step 201 Determine whether the created small file needs to be merged into the large file by calling the pre-processing interface that creates the small file, that is, optimize the small file, if necessary, execute step 202; otherwise, execute step 206.
  • Step 202 Detect whether the large file exists, if yes, perform step 204; otherwise, perform step 203.
  • Step 203 Create the large file.
  • Step 204 Establish layout information for storing the small file in the large file, create a small file, and merge the created small file into the large file according to the layout information.
  • Step 205 Access the processing interface by calling a standard file corresponding to the file pre-processing interface, and perform access processing according to the pre-processing information, and the process ends.
  • the pre-processing information includes: information of the large file after merging the small file.
  • Step 206 Create a small file by calling the standard file access processing interface corresponding to the file access preprocessing interface, and the process ends.
  • the operation between the existing standard interface and the distributed file system, and the replacement of the upper layer access interface by the pre-processing interface does not require any modification to the existing distributed file system, so the implementation is easier, More general.
  • the solution described in the embodiment of the present invention may be implemented for a process.
  • the technical solution described in the embodiment of the present invention may be omitted to avoid introducing optimization. Affects the performance of other processes.
  • step 201 it is determined whether the created small file needs to be merged into a large file, that is, the small file is optimized, including: determining the need to create the small file according to the size of the directory or the small file to be created. Small files are merged into large files for optimization.
  • step 204 the layout information for storing the small file is established in the large file, including:
  • layout information for storing the small file in the large file, where the layout information includes: global description information, an index node table, an index node description table, and a block description table;
  • the global description information (also referred to as a super block) includes a size of a block (ie, a block obtained by dividing a large file), a data block (ie, a block storing data), an occupancy of an index node, and a root directory location;
  • the index node table is composed of a series of index nodes of the same size, each index node describes information of a block in which small file data is located, and other file information, such as creation time, size, and the like;
  • An index node description table for describing the use of the index node
  • step 204 the small file is merged into the large file according to the layout information, including:
  • the small file is merged into the large file according to the assigned directory entry.
  • the directory recorded in the embodiment of the present invention is also regarded as a file or a directory file, and the content in the directory is a directory entry.
  • the length of the directory entry may be expanded to save the file name, the index node, and the index node type ( Such as files or directories).
  • the directory entries are placed according to the algorithm.
  • the commonly used algorithms are B+ tree, hash table, hash tree, and so on.
  • the directory file and the index node closest to the storage location where the small file parent directory is located can be preferentially assigned to the small file to improve the pre-read hit ratio. It is also possible to cache partial directory entries, inodes, file data, and periodically age to reduce disk access.
  • the small file access processing includes the following steps:
  • Step 301 Determine whether the small file to be read or written is an optimized file (that is, whether it is merged with the large file) by calling a pre-processing interface for reading and writing a small file. If yes, go to step 302; otherwise, go to step 304. .
  • Step 302 Find block information of a block in which the small file is located.
  • Searching for the directory entry corresponding to the small file by calling the pre-processing interface for reading and writing the small file, and searching for the block corresponding to the small file in the large file according to the index node found in the directory item, Get the block information of the found block, that is, the pre-processing information of the file access.
  • Step 303 Access the processing interface by calling a standard file corresponding to the file pre-processing interface, and read and write the small file in the found block according to the found block information.
  • Step 304 Directly invoke a standard file access processing interface corresponding to the file pre-processing interface to perform access processing.
  • the directory entry corresponding to the file is first found, and then the index node is found, the block recorded in the index node is released, and the block description table is updated; the index node is released. Update the inode table to the directory entry The directory entry corresponding to the optimized small file is deleted from the file.
  • the above processing also involves the management of small file handles.
  • the file handle is the means of the application operation file. The handle needs to distinguish between the handles of the non-optimized access, so that when the application operates, it can decide whether to go through the normal access process or the optimized access process.
  • the file operation interfaces defined in this embodiment include create, close, write, read, unlink, sync, fstat and other APIs.
  • the POSIX file operation interface defined in the small file optimization mainly includes create, close, write, read, unlink, sync, fstat and other APIs.
  • the above interface is compiled into a small file optimization dynamic library. When the process starts, it is prior to the standard.
  • the dynamic library libc of the POSIX file operation interface loads the small file optimization dynamic library, so that when the process wants to access the file, the small file is used to optimize the above API in the dynamic library. Initialization is also completed before running the process to prepare for small file access.
  • Initialization includes: Obtaining the function pointer of the above API in libc for use in optimizing the dynamic library; Obtaining the file descriptor (FD, in the current system) The maximum value of File Descriptor ), the FD generated by the small file optimization module is greater than the maximum value of the system FD to distinguish it from the regular file access; the configuration information is read into the memory, the configuration information includes rules for judging small file optimization, and other parameters, including Whether large files are created are new or copied, large files are dynamically growing, cache size, delayed write time and size, and so on.
  • the create operation first allocates a directory entry for the file, and needs to be stored according to certain rules for quick search. It also needs to allocate FD for small files, and establish information such as FD index fd and index node relationship, file read and write position, and so on. After the completion of the return FD for the upper application, the application can use FD to perform various and conventional POSIX-like file operations.
  • the FD will be passed from the application layer to the Linux kernel, so it is possible to determine whether the small file is an access-optimized file according to the FD, thereby obtaining a small file.
  • the above small file access processing method can not only improve the file access speed of the distributed file system, but also does not involve the operating system kernel, nor does it involve the implementation mechanism of the distributed file system, which can effectively reduce the development difficulty and has a good Universality.
  • the embodiment of the invention further describes a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used for the file access processing method shown in any of the figures of FIG. 1 to FIG. .
  • the embodiment of the present invention further describes a distributed file system, as shown in FIG. 4, comprising: an interface definition module 41, a pre-processing module 42 and a processing module 43;
  • the interface definition module 41 is configured to define a file access pre-processing interface
  • the pre-processing module 42 is configured to, when receiving a file access instruction, invoke a corresponding file access pre-processing interface according to the type of the file access instruction to obtain pre-processing information of the file access;
  • the processing module 43 is configured to invoke a standard file access processing interface corresponding to the file pre-processing interface, and perform access processing according to the pre-processing information.
  • the file access preprocessing interface includes: a preprocessing interface for creating a small file;
  • the pre-processing module 42 includes: a merging unit 421 and a layout information establishing unit 422;
  • the layout information establishing unit 422 is configured to: when the type of the file access instruction is received to create a small file, establish a storage in the large file by calling a standard file access processing interface corresponding to the file access preprocessing interface. Layout information of small files;
  • the merging unit 421 is configured to create a small file, and merge the small file into the large file according to the layout information, and use the obtained large file combined with the small file as the pre-processing information.
  • the file access pre-processing interface includes: a pre-processing interface for creating a small file;
  • the pre-processing module 42 further includes:
  • the first optimization determining unit 423 is configured to determine, by calling the pre-processing interface that creates the small file, whether the created small file needs to be merged into the large file for optimization, and if necessary, triggering the setting of the layout information.
  • the unit 422 establishes the layout information; otherwise, the processing module 43 is triggered to create a small file by calling the standard file access processing interface corresponding to the file access pre-processing interface.
  • the system further includes: a large file determining module 44 and a large file creating module 45;
  • the large file determining module 44 is configured to determine whether the large file exists. If yes, the large file creating module 45 is triggered to create the large file; otherwise, the layout information establishing unit 422 is triggered to establish layout information.
  • the layout information establishing unit 422 is further configured to divide the large file into blocks by using the pre-processing interface for creating a small file; and establishing a layout for storing the small file in the large file.
  • the layout information includes: global description information, an index node table, an index node description table, and a block description table.
  • the merging unit 421 is further configured to allocate a directory entry for the small file according to the layout information, where the directory entry includes a file name and an index node; according to the directory entry allocated for the small file, The small file is merged into the large file.
  • the first optimization determining unit 423 is further configured to determine, according to the size of the directory or the small file where the small file needs to be created, whether to merge the created small file into the large file for optimization. .
  • the file access pre-processing interface includes: a pre-processing interface for reading and writing small files; as shown in FIG. 8, the pre-processing module 42 includes:
  • the first search processing unit 424 is configured to: when the type of the file access instruction received is a small file read/write file, the directory entry corresponding to the small file is searched by calling the pre-processing interface for reading and writing the small file;
  • the second search processing unit 425 is configured to search for the block corresponding to the small file in the large file according to the index node found in the directory item, acquire block information of the found block, and obtain the obtained block information.
  • Block information is used as the pre-processing information.
  • the processing module 43 is further configured to: access a processing file by calling a standard file corresponding to the file pre-processing interface, and perform small file in the found block according to the acquired block information. Read and write.
  • the pre-processing module 42 further includes:
  • the second optimization determining unit 426 is configured to determine whether the small file to be read or written is an optimized file by calling the pre-processing interface for reading and writing the small file, and if yes, triggering the first search processing unit 424 to perform the search. The operation of the directory entry corresponding to the small file; otherwise, the processing module 43 is triggered to invoke a standard file access processing interface corresponding to the file pre-processing interface. Perform access processing.
  • the embodiment of the invention further describes a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the file access processing method shown in any one of FIG. 1 to FIG. .
  • the distributed file system is disposed on multiple servers, and the interface definition module 41, the pre-processing module 42 and the processing module 43 can be processed by a central processing unit (CPU) in a server.
  • CPU central processing unit
  • DSP Digital Signal Processor
  • FPGA Field Programmable Gate Array
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of a hardware embodiment, a software embodiment, or an embodiment of a combination of software and hardware. Moreover, the invention can be embodied in the form of a computer program product embodied on one or more computer usable storage media (including but not limited to disk storage and optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps that are configured to implement the functions specified in one or more blocks of the flowchart or in a block or blocks of the flowchart.

Landscapes

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

Abstract

一种文件访问处理方法、系统及计算机存储介质;所述方法包括:定义文件访问预处理接口;当接收到文件访问指令时,根据所述文件访问指令的类型调用对应的文件访问预处理接口,以获取文件访问的预处理信息;通过调用与所述文件访问预处理接口对应的标准文件访问处理接口,并根据所述预处理信息进行访问处理。

Description

文件访问处理方法、 系统及计算机存储介质 技术领域
本发明涉及计算机存储技术, 尤其涉及一种文件访问处理方法、 系统 及计算机存储介质。 背景技术
目前互连网中信息产生的速度日益提高, 特别是近年移动互连网的飞 速发展, 智能手机的广泛应用, 每天都在产生海量的图片、 短信、 微信等 小文件, 因此对海量小文件的快速存取、 分析有着重要的现实意义, 一方 面方便用户保存信息和分享, 另一方面可以帮助网络运营公司、 手机制造 商吸引客户, 从中提取有用信息, 实现增值服务。
对于海量的文件存储, 利用目前的磁盘阵列技术实现不但成本高昂, 在规模、 性能上无法实现动态的线性扩容。 目前, 能动态扩容、 按需分配 存储资源的分布式文件系统应运而生, 技术实现上主要分为对称式和非对 称式。 前者使用一致性哈希等技术, 让存储系统中的每个节点都能存储文 件和元数据(主要是文件在节点的分布信息), 一个节点的宕机不会影响对 某个文件的访问。 非对称式分布文件系统有专门的元数据服务器, 逻辑结 构简单, 便于管理, 特别是对同一目录下文件的访问更为高效, 为目前分 布式文件系统主流方式,著名的开源分布式文件系统包括 Hadoop分布式文 件系统( HDFS, Hadoop Distributed File System )、 lustre等。
目前开源的分布式文件系统难以能满足对海量小文件访问的性能需 求, 由于分布式文件系统为确保数据一致性、 数据位置信息分配, 在一次 访问中往往需要服务器内部节点间和服务器与客户端间进行多次交互, 中 间还会导致一些对磁盘的随机访问, 这样使得小文件的访问性能低于本地 访问小文件的性能, 相关技术通常釆用合并、 緩存、 预取来减少节点间、 服务器和客户端的交互, 变随机访问为顺序访问, 减少访问磁盘的访问次 数, 从而提升性能。 其中比较典型的方案有:
方案 1, Hadoo 归档 ( HAR, Hadoop Archives )
将小文件打包成一个大文件进行存储, 打包后的文件由索引和存储两 大部分组成, 索引部分记录了原有的目录结构和文件状态; 该方案缺点在 于一旦创建大文件就不能修改, 也不支持对大文件进行追加操作, 要做增 加和爹改文件必须对小文件重新打包。
方案 2, Hadoo 序列文件 ( Sequeues File )
Sequence file由一系列的二进制 key/value组成, 如果 key为小文件名, value 则为文件内容, 该方案支持将批量小文件合并成一个大文件。 提供 Writer, Reader和 Sequence File Sorter类以支持对大文件中的小文件进行写、 读和排序操作; 该方案支持对大文件中的小文件的进行存取操作, 且不限 制进行存取操作的用户数量、 以及存取文件的数量, 支持对大文件追加 ( Append )写入小文件, 支持对大文件进行三级文档压缩(包括: 不压缩、 文件级、 块级别)。
该方案缺点在于需要在分布式文件系统内部实现, 需要专用的应用程 序编程接口 ( API, Application Programming Interface )来提供访问支持, 并 且需要上层应用改动, 无法应用于其它分布式文件系统。
相关技术中, 小文件优化都和分布式文件系统紧密相关, 通常直接在 分布式文件系统上进行改造, 改动复杂, 随着分布式文件系统的更新, 需 要做相应的改动, 工作量大;
且在一种分布式文件系统优化的方案无法直接应用于为其它类型的分 布式文件系统。 而且, 由于为了将小文件访问和一般的文件访问进行区分, 还需要专用的 API支持, 这会导致已有的 API无法使用, 或者要对已有的 API进行修改后, 工作量大, 实施成本高。 发明内容
本发明实施例提供一种文件访问处理方法、 系统及计算机存储介质, 能够提升分布式文件系统文件访问的响应性能。
本发明实施例的技术方案是这样实现的:
本发明实施例提供一种文件访问处理方法, 包括:
定义文件访问预处理接口;
当接收到文件访问指令时, 根据所述文件访问指令的类型调用对应的 文件访问预处理接口, 以获取文件访问的预处理信息;
通过调用与所述文件访问预处理接口对应的标准文件访问处理接口, 并根据所述预处理信息进行访问处理。
其中, 相应地, 当文件访问指令的类型为创建小文件时, 所述根据该 文件访问指令的类型调用对应的文件访问预处理接口, 以获取文件访问预 处理信息, 包括:
通过调用与所述文件访问预处理接口对应的标准文件访问处理接口, 在大文件中建立存放所述 ' j、文件的布局信息;
创建所述小文件, 并根据所述布局信息将所述小文件合并到所述大文 件, 将所得到的与所述小文件合并后的大文件, 作为所述预处理信息。
其中, 所述文件访问预处理接口包括: 创建小文件的预处理接口; 所 述在所述大文件中建立存放所述小文件的布局信息之前, 所述方法还包括: 通过调用所述创建小文件的预处理接口, 判断是否需要将创建的小文 件合并到所述大文件以进行优化, 如果需要, 则执行所述建立布局信息的 操作; 否则, 通过调用所述文件访问预处理接口对应的标准文件访问处理 接口, 创建小文件。
其中, 在所述大文件中建立存放所述小文件的布局信息之前, 所述方 法还包括:
判断所述大文件是否存在;
在所述大文件不存在时创建所述大文件。
其中, 所述在所述大文件中建立存放小文件的布局信息, 包括: 利用所述创建小文件的预处理接口将所述大文件等分为块;
建立在所述大文件中存放所述小文件的布局信息, 所述布局信息包括: 全局描述信息、 索引节点表、 索引节点描述表以及块描述表。
其中, 所述根据所述布局信息将小文件合并到所述大文件, 包括: 根据所述布局信息为所述小文件分配目录项, 所述目录项包括文件名 和索引节点;
根据为所述小文件分配的目录项, 将所述小文件合并到所述大文件。 其中, 所述判断是否需要将创建的小文件合并到大文件以进行优化, 包括:
根据需要创建的小文件所在的目录或者小文件的大小, 判断是否需要 将所创建的小文件合并到所述大文件以进行优化。
其中, 所述文件访问预处理接口包括: 读写小文件的预处理接口; 相应地, 当所述文件访问指令的类型为读写小文件时, 所述根据该文 件访问指令类型调用对应的文件预处理接口获取文件访问的预处理信息, 包括:
通过调用所述读写小文件的预处理接口, 查找所述小文件对应的目录 项, 根据在所述目录项中查找到的索引节点查找所述小文件在所述大文件 中所对应的块, 获取所查找到块的块信息, 将所获取的块信息作为所述预 处理信息。
其中, 所述调用与所述文件访问预处理接口对应的标准文件访问处理 接口, 并根据所述预处理信息进行访问处理, 包括: 通过调用与所述文件预处理接口对应的标准文件访问处理接口, 并根 据所获取的块信息, 对所查找到的块中的小文件进行读写。
其中, 所述查找所述小文件对应的目录项之前, 所述方法还包括: 通过调用所述读写小文件的预处理接口, 判断需要读写的小文件是否 为优化的文件, 如果是, 则执行查找所述小文件对应的目录项的操作; 否 则, 调用与所述文件预处理接口对应的标准文件访问处理接口进行访问处 理。
本发明实施例还提供一种分布式文件系统, 包括: 接口定义模块、 预 处理模块和处理模块;
所述接口定义模块, 配置为定义文件访问预处理接口;
所述预处理模块, 配置为当接收到文件访问指令时, 根据所述文件访 问指令的类型调用对应的文件访问预处理接口, 以获取文件访问的预处理 信息;
所述处理模块, 配置为调用与所述文件预处理接口对应的标准文件访 问处理接口, 并根据所述预处理信息进行访问处理。
其中, 所述文件访问预处理接口包括: 创建小文件的预处理接口; 所述预处理模块包括: 合并单元和布局信息建立单元;
所述布局信息建立单元, 配置为当接收到文件访问指令的类型为创建 小文件时, 通过调用与所述文件访问预处理接口对应的标准文件访问处理 接口, 在所述大文件中建立存放小文件的布局信息;
所述合并单元, 配置为创建小文件, 并根据所述布局信息将所述小文 件合并到所述大文件, 将所得到的与所述小文件合并后的大文件, 作为所 述预处理信息。
其中, 所述文件访问预处理接口包括: 创建小文件的预处理接口; 所述预处理模块还包括: 第一优化判断单元, 配置为在通过调用所述创建小文件的预处理接口, 判断是否需要将创建的小文件合并到所述大文件以进行优化, 如果需要, 则触发所述布局信息建立单元建立布局信息; 否则, 触发所述处理模块通 过调用所述文件访问预处理接口对应的标准文件访问处理接口, 创建小文 件。
其中, 所述系统还包括: 大文件判断模块和大文件创建模块; 所述大文件判断模块, 配置为判断所述大文件是否存在; 如果存在, 则触发所述大文件创建模块创建所述大文件; 否则, 触发所述布局信息建 立单元建立布局信息。
其中, 所述布局信息建立单元, 还配置为利用所述创建小文件的预处 理接口将所述大文件等分为块; 建立在所述大文件中存放所述小文件的布 局信息;
所述布局信息包括: 全局描述信息、 索引节点表、 索引节点描述表以 及块描述表。
其中, 所述合并单元, 还配置为根据所述布局信息为所述小文件分配 目录项, 所述目录项包括文件名和索引节点; 根据为所述小文件分配的目 录项, 将所述小文件合并到所述大文件。
其中, 所述第一优化判断单元, 还配置为根据需要创建的小文件所在 的目录或者小文件的大小, 判断是否需要将所创建的小文件合并到所述大 文件以进行优化。
其中, 所述文件访问预处理接口包括: 读写小文件的预处理接口; 所述预处理模块还包括:
第一查找处理单元, 配置为接收到的文件访问指令的类型为读写小文 件时, 通过调用所述读写小文件的预处理接口, 查找所述小文件对应的目 录项; 第二查找处理单元, 配置为根据在所述目录项中查找到的索引节点查 找所述小文件在所述大文件中所对应的块, 获取所查找到块的块信息, 将 所获取的块信息作为所述预处理信息。
其中, 所述处理模块, 还配置为通过调用与所述文件预处理接口对应 的标准文件访问处理接口, 并根据所获取的块信息, 对所查找到的块中的 小文件进行读写。
其中, 所述预处理模块还包括:
第二优化判断单元, 配置为通过调用所述读写小文件的预处理接口, 判断需要读写的小文件是否为优化的文件, 如果是, 则触发所述第一查找 处理单元执行查找所述小文件对应的目录项的操作; 否则, 触发所述处理 模块调用与所述文件预处理接口对应的标准文件访问处理接口进行访问处 理。
本发明实施例还提供一种计算机存储介质, 所述计算机存储介质中存 储有计算机可执行指令, 所述计算机可执行指令用于执行以上所述的文件 访问处理方法。
本发明实施例中, 在文件访问处理之前进行预处理, 然后通过调用标 准文件访问接口根据预处理的信息进行访问处理, 通过自定义的预处理接 口替代标准接口, 以自定义的预处理接口实现功能, 无需对已有分布式文 件系统中标准接口作任何改造即可实现对文件访问的处理; 实施容易, 也 更为通用, 能显著提升小文件访问的处理性能。 附图说明
图 1为本发明实施例记载的文件访问处理方法的实现流程图一; 图 2为本发明实施例记载的文件访问处理方法的实现流程图二; 图 3为本发明实施例记载的文件访问处理方法的实现流程图三; 图 4为本发明实施例记载的分布式文件系统的结构示意图一; 图 5为本发明实施例记载的分布式文件系统中预处理模块 42的结构示 意图一;
图 6为本发明实施例记载的分布式文件系统中预处理模块 42的结构示 意图二;
图 7为本发明实施例记载的分布式文件系统的结构示意图二; 图 8为本发明实施例记载的分布式文件系统中预处理模块 42的结构示 意图三;
图 9为本发明实施例记载的分布式文件系统中预处理模块 42的结构示 意图四。 具体实施方式
下面通过具体实施方式结合附图对本发明作进一步详细说明。
本发明实施例记载了一种文件访问处理方法, 如图 1 所示, 包括以下 步骤:
步骤 101 : 定义文件访问预处理接口。
步骤 102: 当接收到文件访问指令时, 通过调用与所述文件访问指令的 类型对应的文件访问预处理接口, 获取文件访问预处理信息。
步骤 103:通过调用与所述文件访问预处理接口对应的标准文件访问处 理接口, 并根据所述预处理信息进行访问处理, 即响应文件访问指令。
本发明实施例中利用自定义的文件访问预处理接口, 对文件访问进行 预处理, 从而不需要对上层访问接口进行改动, 就能实现小文件优化或者 其他文件访问的处理, 实施本发明实施例的技术方案, 不需要对已有分布 式文件系统作任何改动, 与已有的在分布式文件系统层面修改的方法比较 有更强的可实现性、 通用性。
本发明实施例记载的访问指令的类型主要包括: 创建小文件、 打开小 文件、 读写小文件以及删除小文文件。 针对访问指令的类型, 本发明实施例中记载的文件访问预处理接口可 以包括: 创建小文件的预处理接口、 打开小文件的预处理接口、 读写小文 件的预处理接口以及删除小文件的预处理接口。
如图 2所示, 当接收到访问指令的类型为创建小文件时, 文件访问处 理包括以下步骤:
步骤 201 : 通过调用创建小文件的预处理接口, 判断是否需要将创建的 小文件合并到大文件, 即对小文件进行优化, 如果需要, 则执行步骤 202; 否则, 执行步骤 206。
步骤 202: 检测所述大文件是否存在, 如果存在, 则执行步骤 204; 否 则, 执行步骤 203。
步骤 203: 创建所述大文件。
步骤 204: 在所述大文件中建立存放小文件的布局信息, 创建小文件, 并根据所述布局信息将所创建的小文件合并到所述大文件。
合并小文件后的大文件作为文件访问的预处理信息, 供后续进行访问 处理。
步骤 205:通过调用与所述文件预处理接口对应的标准文件访问处理接 口, 并根据所述预处理信息进行访问处理, 流程结束。
所述预处理信息包括: 合并所述小文件后的所述大文件的信息。
步骤 206:通过调用所述文件访问预处理接口对应的标准文件访问处理 接口创建小文件, 流程结束。
本发明实施例中, 在已有的标准接口与分布式文件系统之间进行操作, 通过预处理接口替换上层访问接口, 不需要对已有分布式文件系统作任何 改造, 因此实施更容易, 也更为通用。 另外, 本发明实施例记载的方案可 以针对进程实施, 对于不需要使用分布式文件系统的进程、 以及不需要合 并文件的进程, 可以不釆用本发明实施例记载的技术方案, 避免引入优化 对其它进程性能造成影响。
作为一个实施方式, 步骤 201 中判断是否需要将创建的小文件合并到 大文件, 即进行小文件优化, 包括: 根据需要创建的小文件所在的目录或 者小文件的大小, 判断是否需要将创建的小文件合并到大文件进行优化。
作为一个实施方式, 步骤 204 中在所述大文件中建立存放小文件的布 局信息, 包括:
利用所述创建小文件的预处理接口将所述大文件等分为块;
建立在所述大文件中存放小文件的布局信息, 所述布局信息包括: 全 局描述信息、 索引节点表、 索引节点描述表以及块描述表; 其中,
所述全局描述信息(又称为超级块), 包括块(即大文件等分后得到的 块) 的大小、 数据块(即存储数据的块)和索引节点的占用情况、 根目录 位置;
所述索引节点表由一系列大小相同的索引节点组成, 每个索引节点描 述一个小文件数据所在的块的信息, 以及其它文件信息, 如创建时间、 大 小等;
索引节点描述表, 用于描述索引节点使用情况;
块描述表, 用于描述块的使用情况;
相应地, 步骤 204 中根据所述布局信息将小文件合并到所述大文件, 包括:
根据所述布局信息为所述小文件分配目录项, 所述目录项包括文件名 和索引节点;
根据所分配的目录项将所述小文件合并到所述大文件。
本发明实施例中所记载的目录也视为文件或目录文件, 目录中的内容 为目录项, 实际应用中, 可以将目录项的长度进行拓展, 以保存文件名、 索引节点、 索引节点类型 (如文件还是目录)。 为了加快访问在文件创建时 会根据釆用算法放置目录项, 常用的算法有 B+树、 hash表、 hash树等。 在 为小文件分配目录项、 索引节点时, 可以优先为小文件分配距离小文件父 目录所在的存储位置最近的目录项、 索引节点, 以提高预读取命中率。 另 外还可以緩存部分目录项、 索引节点、 文件数据, 并定期老化, 以减少磁 盘访问。
作为一个实施方式, 如图 3 所示, 当接收到的访问指令类型为读写小 文件时, 小文件访问处理包括以下步骤:
步骤 301 : 通过调用读写小文件的预处理接口, 判断需要读写的小文件 是否为优化的文件(即是否与大文件进行了合并),如果是,则执行步骤 302; 否则, 执行步骤 304。
步骤 302: 查找所述小文件所在块的块信息。
通过调用所述读写小文件的预处理接口, 查找所述小文件对应的目录 项, 根据在所述目录项中查找到的索引节点, 查找所述小文件在大文件中 所对应的块, 获取所查找到块的块信息, 即文件访问的预处理信息。
步骤 303:通过调用与所述文件预处理接口对应的标准文件访问处理接 口, 并根据所查找到的块信息, 对所查找到的块中的小文件进行读写。
步骤 304:直接调用与所述文件预处理接口对应的标准文件访问处理接 口进行访问处理。
当所接收到访问指令的类型为打开优化小文件时, 可以通过超级块找 到根目录的目录文件, 再从目录文件中逐级找下级目录, 最终找到小文件 或小文件所在目录。 为小文件分配句柄, 建立句柄和索引节点的关系, 并 緩存文件访问的相关信息, 比如文件当前读写位置。
作为一个实施方式, 当所接收到访问指令的访问类型为删除优化小文 件时, 首先找到文件对应的目录项, 进而找到索引节点, 释放索引节点内 记录的块, 更新块描述表; 释放索引节点, 更新索引节点表, 再到目录项 文件中删除该优化小文件对应的目录项。
以上处理中还涉及到小文件句柄的管理, 文件句柄是应用程序操作文 件手段, 句柄需要区分与非优化访问的句柄, 这样当应用操作时才能决定 走正常访问流程还是优化的访问流程。
本实施例中定义的文件操作接口包括 create, close, write, read, unlink, sync, fstat等 API。
下面以 linux环境下对可移植操作系统接口(POSIX, Portable Operating System Interface )进行替换为例,对本发明实施例记载的技术方案进行说明。
在小文件优化中定义的 POSIX文件操作接口, 主要包括 create, close, write, read, unlink, sync, fstat等 API, 把上述接口编译成小文件优化动 态库, 当进程启动时, 先于标准的 POSIX文件操作接口所在动态库 libc加 载小文件优化动态库, 这样当进程要访问文件时就会调用小文件优化动态 库中的上述 API。在运行进程运行前还要完成初始化, 以准备为小文件访问 进行优化, 初始化包括: 获得上述 API在 libc中的函数指针, 以便在优化 动态库中使用; 获得当前系统中文件描述符(FD, File Descriptor ) 的最大 值, 小文件优化模块生成的 FD大于系统 FD最大值, 以区别于常规文件访 问; 读取配置信息到内存, 配置信息包括判断小文件优化的规则, 以及其 它一些参数, 包括大文件的创建是新建还是拷贝、 大文件是否动态增长、 緩存大小、 延迟写入时间和大小等。
对于 create这样的创建文件操作,当进程访问文件时首先调用小文件优 化动态库中的 POSIX接口; 然后判断是否需要优化, 如果不需要优化, 则 调用 libc中相应标准接口处理后返回, 如果需要优化进入以下处理流程: 根据文件所在目录、 文件大小等规则来判断是否需要将小文件合并到 大文件, 以及合并的大文件的路径; 如果要合并入的大文件不存在, 需要 动态创建, 一般选取从一个模板文件拷贝布局信息, 加快大文件的建立速 度, 建立后还需要为大文件分配相应空间, 分配空间的过程可以和为小文 件索引节点等信息过程同步进行。 create操作首先要为文件分配目录项, 为 快速查找需要按一定规则存放; 还要为小文件分配 FD, 并建立以 FD为索 引 fd和索引节点关系、文件读写位置等信息等。完成后为上层应用返回 FD, 应用就可以用 FD来进行各种和常规 POSIX—样的文件操作。
对于其它如 write、 read等操作, 由于文件(小文件或大文件) 已经打 开, 会有 FD从应用层传递到 Linux内核, 因此可以根据 FD判定小文件是 否为访问优化的文件, 进而获得小文件对应的大文件, 以及小文件的索引 节点信息、 读写位置等相关信息。 根据索引节点信息可以获得文件内容位 置信息, 再根据当前读写位置信息完成读写操作。
利用上述小文件访问处理方法不但可以提高分布式文件系统小文件 访问速度, 且所有实现都不涉及操作系统内核, 也不涉及分布式文件系统 的实现机制, 可以有效降低开发难度, 并具有很好的通用性。
本发明实施例还记载了一种计算机存储介质, 所述计算机存储介质中 存储有计算机可执行指令, 所述计算机可执行指令用于图 1至图 3任一附 图所示的文件访问处理方法。
本发明实施例还记载了一种分布式文件系统, 如图 4所示, 包括: 接 口定义模块 41、 预处理模块 42和处理模块 43;
所述接口定义模块 41, 配置为定义文件访问预处理接口;
所述预处理模块 42, 配置为当接收到文件访问指令时, 根据所述文件 访问指令的类型调用对应的文件访问预处理接口, 以获取文件访问的预处 理信息;
所述处理模块 43, 配置为调用与所述文件预处理接口对应的标准文件 访问处理接口, 并根据所述预处理信息进行访问处理。
其中, 所述文件访问预处理接口包括: 创建小文件的预处理接口; 作为一个实施方式, 如图 5所示, 所述预处理模块 42包括: 合并单元 421和布局信息建立单元 422;
所述布局信息建立单元 422,配置为当接收到文件访问指令的类型为创 建小文件时, 通过调用与所述文件访问预处理接口对应的标准文件访问处 理接口, 在所述大文件中建立存放小文件的布局信息;
所述合并单元 421, 配置为创建小文件, 并根据所述布局信息将所述小 文件合并到所述大文件, 将所得到的与所述小文件合并后的大文件, 作为 所述预处理信息。
作为一个实施方式, 所述文件访问预处理接口包括: 创建小文件的预 处理接口;
如图 6所示, 在图 5所示预处理模块 42的基础上, 所述预处理模块 42 还包括:
第一优化判断单元 423,配置为在通过调用所述创建小文件的预处理接 口, 判断是否需要将创建的小文件合并到所述大文件以进行优化, 如果需 要, 则触发所述布局信息建立单元 422建立布局信息; 否则, 触发所述处 理模块 43 通过调用所述文件访问预处理接口对应的标准文件访问处理接 口, 创建小文件。
作为一个实施方式, 如图 7所示, 在图 4所示分布式文件系统的基础 上, 所述系统还包括: 大文件判断模块 44和大文件创建模块 45;
所述大文件判断模块 44, 配置为判断所述大文件是否存在; 如果存在, 则触发所述大文件创建模块 45创建所述大文件; 否则, 触发所述布局信息 建立单元 422建立布局信息。
作为一个实施方式, 所述布局信息建立单元 422,还配置为利用所述创 建小文件的预处理接口将所述大文件等分为块; 建立在所述大文件中存放 所述小文件的布局信息; 所述布局信息包括: 全局描述信息、 索引节点表、 索引节点描述表以 及块描述表。
作为一个实施方式, 所述合并单元 421, 还配置为根据所述布局信息为 所述小文件分配目录项, 所述目录项包括文件名和索引节点; 根据为所述 小文件分配的目录项, 将所述小文件合并到所述大文件。
作为一个实施方式, 所述第一优化判断单元 423,还配置为根据需要创 建的小文件所在的目录或者小文件的大小, 判断是否需要将所创建的小文 件合并到所述大文件以进行优化。
作为一个实施方式, 所述文件访问预处理接口包括: 读写小文件的预 处理接口; 如图 8所示, 所述预处理模块 42包括:
第一查找处理单元 424,配置为在接收到的文件访问指令的类型为读写 小文件时, 通过调用所述读写小文件的预处理接口, 查找所述小文件对应 的目录项;
第二查找处理单元 425,配置为根据在所述目录项中查找到的索引节点 查找所述小文件在所述大文件中所对应的块, 获取所查找到块的块信息, 将所获取的块信息作为所述预处理信息。
作为一个实施方式, 所述处理模块 43, 还配置为通过调用与所述文件 预处理接口对应的标准文件访问处理接口, 并根据所获取的块信息, 对所 查找到的块中的小文件进行读写。
作为一个实施方式, 如图 9所示, 在图 8所示的预处理模块 42的基础 上, 所述预处理模块 42还包括:
第二优化判断单元 426, 配置为通过调用所述读写小文件的预处理接 口, 判断需要读写的小文件是否为优化的文件, 如果是, 则触发所述第一 查找处理单元 424执行查找所述小文件对应的目录项的操作; 否则, 触发 所述处理模块 43调用与所述文件预处理接口对应的标准文件访问处理接口 进行访问处理。
本发明实施例还记载一种计算机存储介质, 所述计算机存储介质中存 储有计算机可执行指令, 所述计算机可执行指令用于执行图 1至图 3任一 附图所示的文件访问处理方法。
实际应用中, 所述分布式文件系统设置于多个服务器上, 所述接口定 义模块 41、预处理模块 42和处理模块 43可由服务器中的中央处理器( CPU, Central Processing Unit )、 数字信号处理器(DSP, Digital Signal Processor ) 或现场可编程门阵列 (FPGA, Field Programmable Gate Array ) 实现。
本实施例的系统详细的工作过程可以参考上述图 1至图 3 中关于文件 访问处理方法的描述。
本发明实施例中, 不但可以提高分布式文件系统小文件访问速度, 且 所有实现都不涉及操作系统内核, 不涉及分布式文件系统的实现机制, 可 以有效降低开发难度, 并具有很好的通用性。
本领域内的技术人员应明白, 本发明的实施例可提供为方法、 系统、 或计算机程序产品。 因此, 本发明可釆用硬件实施例、 软件实施例、 或结 合软件和硬件方面的实施例的形式。 而且, 本发明可釆用在一个或多个其 中包含有计算机可用程序代码的计算机可用存储介质 (包括但不限于磁盘 存储器和光学存储器等 )上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、 设备(系统)、 和计算机程序 产品的流程图和 /或方框图来描述的。 应理解可由计算机程序指令实现流程 图和 /或方框图中的每一流程和 /或方框、以及流程图和 /或方框图中的流程和 /或方框的结合。 可提供这些计算机程序指令到通用计算机、 专用计算机、 嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器, 使得 通过计算机或其他可编程数据处理设备的处理器执行的指令产生配置为实 现在流程图一个流程或多个流程和 /或方框图一个方框或多个方框中指定的 功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理 设备以特定方式工作的计算机可读存储器中, 使得存储在该计算机可读存 储器中的指令产生包括指令装置的制造品, 该指令装置实现在流程图一个 流程或多个流程和 /或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备 上, 使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机 实现的处理, 从而在计算机或其他可编程设备上执行的指令提供配置为实 现在流程图一个流程或多个流程和 /或方框图一个方框或多个方框中指定的 功能的步骤。
以上所述仅是本发明的优选实施方式, 应当指出, 对于本技术领域的 普通技术人员来说, 在不脱离本发明原理的前提下, 还可以做出若干改进 和润饰, 这些改进和润饰也应视为本发明的保护范围。 工业实用性 本发明实施例中, 当接收到文件访问指令时, 根据该文件访问指令的 类型调用对应的文件访问预处理接口获取文件访问预处理信息; 调用与所 述文件预处理接口对应的标准文件访问处理接口根据所述预处理信息进行 访问处理; 能够提升分布式文件系统小文件访问的响应性能。

Claims

权利要求书
1、 一种文件访问处理方法, 包括:
定义文件访问预处理接口;
当接收到文件访问指令时, 根据所述文件访问指令的类型调用对应的 文件访问预处理接口, 以获取文件访问的预处理信息;
通过调用与所述文件访问预处理接口对应的标准文件访问处理接口, 并根据所述预处理信息进行访问处理。
2、 如权利要求 1所述的文件访问处理方法, 其中, 当文件访问指令的 类型为创建小文件时, 所述根据该文件访问指令的类型调用对应的文件访 问预处理接口, 以获取文件访问预处理信息, 包括:
通过调用与所述文件访问预处理接口对应的标准文件访问处理接口, 在大文件中建立存放所述 ' j、文件的布局信息;
创建所述小文件, 并根据所述布局信息将所述小文件合并到所述大文 件, 将所得到的与所述小文件合并后的大文件, 作为所述预处理信息。
3、 如权利要求 2所述的文件访问处理方法, 其中, 所述文件访问预处 理接口包括: 创建小文件的预处理接口;
相应地, 所述在所述大文件中建立存放所述小文件的布局信息之前, 所述方法还包括:
通过调用所述创建小文件的预处理接口, 判断是否需要将创建的小文 件合并到所述大文件以进行优化, 如果需要, 则执行所述建立布局信息的 操作; 否则, 通过调用所述文件访问预处理接口对应的标准文件访问处理 接口, 创建小文件。
4、 如权利要求 2所述的文件访问处理方法, 其中, 在所述大文件中建 立存放所述小文件的布局信息之前, 所述方法还包括:
判断所述大文件是否存在; 在所述大文件不存在时创建所述大文件。
5、 如权利要求 3所述的文件访问处理方法, 其中, 所述在所述大文件 中建立存放小文件的布局信息, 包括:
利用所述创建小文件的预处理接口将所述大文件等分为块;
建立在所述大文件中存放所述小文件的布局信息, 所述布局信息包括: 全局描述信息、 索引节点表、 索引节点描述表以及块描述表。
6、 如权利要求 2至 5任一项所述的文件访问处理方法, 其中, 所述根 据所述布局信息将小文件合并到所述大文件, 包括:
根据所述布局信息为所述小文件分配目录项, 所述目录项包括文件名 和索引节点;
根据为所述小文件分配的目录项, 将所述小文件合并到所述大文件。
7、 如权利要求 3所述的文件访问处理方法, 其中, 所述判断是否需要 将创建的小文件合并到大文件以进行优化, 包括:
根据需要创建的小文件所在的目录或者小文件的大小, 判断是否需要 将所创建的小文件合并到所述大文件以进行优化。
8、 如权利要求 1所述的文件访问处理方法, 其中, 所述文件访问预处 理接口包括: 读写小文件的预处理接口;
相应地, 当所述文件访问指令的类型为读写小文件时, 所述根据该文 件访问指令类型调用对应的文件预处理接口获取文件访问的预处理信息, 包括:
通过调用所述读写小文件的预处理接口, 查找所述小文件对应的目录 项, 根据在所述目录项中查找到的索引节点查找所述小文件在所述大文件 中所对应的块, 获取所查找到块的块信息, 将所获取的块信息作为所述预 处理信息。
9、 如权利要求 8所述的文件访问处理方法, 其中, 所述调用与所述文 件访问预处理接口对应的标准文件访问处理接口, 并根据所述预处理信息 进行访问处理, 包括:
通过调用与所述文件预处理接口对应的标准文件访问处理接口, 并根 据所获取的块信息, 对所查找到的块中的小文件进行读写。
10、 如权利要求 8或 9所述的文件访问处理方法, 其中, 所述查找所 述小文件对应的目录项之前, 所述方法还包括:
通过调用所述读写小文件的预处理接口, 判断需要读写的小文件是否 为优化的文件, 如果是, 则执行查找所述小文件对应的目录项的操作; 否 则, 调用与所述文件预处理接口对应的标准文件访问处理接口进行访问处 理。
11、 一种分布式文件系统, 包括: 接口定义模块、 预处理模块和处理 模块;
所述接口定义模块, 配置为定义文件访问预处理接口;
所述预处理模块, 配置为当接收到文件访问指令时, 根据所述文件访 问指令的类型调用对应的文件访问预处理接口, 以获取文件访问的预处理 信息;
所述处理模块, 配置为调用与所述文件预处理接口对应的标准文件访 问处理接口, 并根据所述预处理信息进行访问处理。
12、 如权利要求 11所述的分布式文件系统, 其中, 所述预处理模块包 括: 合并单元和布局信息建立单元;
所述布局信息建立单元, 配置为当接收到文件访问指令的类型为创建 小文件时, 通过调用与所述文件访问预处理接口对应的标准文件访问处理 接口, 在所述大文件中建立存放小文件的布局信息;
所述合并单元, 配置为创建小文件, 并根据所述布局信息将所述小文 件合并到所述大文件, 将所得到的与所述小文件合并后的大文件, 作为所 述预处理信息。
13、 如权利要求 12所述的分布式文件系统, 其中, 所述文件访问预处 理接口包括: 创建小文件的预处理接口;
所述预处理模块还包括:
第一优化判断单元, 配置为在通过调用所述创建小文件的预处理接口, 判断是否需要将创建的小文件合并到所述大文件以进行优化, 如果需要, 则触发所述布局信息建立单元建立布局信息; 否则, 触发所述处理模块通 过调用所述文件访问预处理接口对应的标准文件访问处理接口, 创建小文 件。
14、 如权利要求 12所述的分布式文件系统, 其中, 所述系统还包括: 大文件判断模块和大文件创建模块;
所述大文件判断模块, 配置为判断所述大文件是否存在; 如果存在, 则触发所述大文件创建模块创建所述大文件; 否则, 触发所述布局信息建 立单元建立布局信息。
15、 如权利要求 13所述的分布式文件系统, 其中,
所述布局信息建立单元, 还配置为利用所述创建小文件的预处理接口 将所述大文件等分为块; 建立在所述大文件中存放所述小文件的布局信息; 所述布局信息包括: 全局描述信息、 索引节点表、 索引节点描述表以 及块描述表。
16、 如权利要求 12至 15任一项所述的分布式文件系统, 其中, 所述合并单元, 还配置为根据所述布局信息为所述小文件分配目录项, 所述目录项包括文件名和索引节点; 根据为所述小文件分配的目录项, 将 所述小文件合并到所述大文件。
17、 如权利要求 13所述的分布式文件系统, 其中,
所述第一优化判断单元, 还配置为根据需要创建的小文件所在的目录 或者小文件的大小, 判断是否需要将所创建的小文件合并到所述大文件以 进行优化。
18、 如权利要求 11所述的分布式文件系统, 其中, 所述文件访问预处 理接口包括: 读写小文件的预处理接口;
所述预处理模块还包括:
第一查找处理单元, 配置为接收到的文件访问指令的类型为读写小文 件时, 通过调用所述读写小文件的预处理接口, 查找所述小文件对应的目 录项;
第二查找处理单元, 配置为根据在所述目录项中查找到的索引节点查 找所述小文件在所述大文件中所对应的块, 获取所查找到块的块信息, 将 所获取的块信息作为所述预处理信息。
19、 如权利要求 18所述的分布式文件系统, 其中,
所述处理模块, 还配置为通过调用与所述文件预处理接口对应的标准 文件访问处理接口, 并根据所获取的块信息, 对所查找到的块中的小文件 进行读写。
20、 如权利要求 18或 19所述的分布式文件系统, 其中, 所述预处理 模块还包括:
第二优化判断单元, 配置为通过调用所述读写小文件的预处理接口, 判断需要读写的小文件是否为优化的文件, 如果是, 则触发所述第一查找 处理单元执行查找所述小文件对应的目录项的操作; 否则, 触发所述处理 模块调用与所述文件预处理接口对应的标准文件访问处理接口进行访问处 理。
21、 一种计算机存储介质, 所述计算机存储介质中存储有计算机可执 行指令, 所述计算机可执行指令用于执行权利要求 1至 10任一项所述的文 件访问处理方法。
PCT/CN2014/076906 2013-07-10 2014-05-06 文件访问处理方法、系统及计算机存储介质 WO2014166446A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310289242.2 2013-07-10
CN201310289242.2A CN104281414B (zh) 2013-07-10 2013-07-10 分布式文件系统及其小文件访问方法

Publications (1)

Publication Number Publication Date
WO2014166446A1 true WO2014166446A1 (zh) 2014-10-16

Family

ID=51688958

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/076906 WO2014166446A1 (zh) 2013-07-10 2014-05-06 文件访问处理方法、系统及计算机存储介质

Country Status (2)

Country Link
CN (1) CN104281414B (zh)
WO (1) WO2014166446A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105630810A (zh) * 2014-10-30 2016-06-01 曙光信息产业股份有限公司 一种对于海量小文件在分布式存储系统中上载的方法
CN109451069A (zh) * 2018-12-29 2019-03-08 江苏鼎峰信息技术有限公司 基于分布式存储的网络数据文件库存储及查询方法

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106293490A (zh) * 2015-05-12 2017-01-04 中兴通讯股份有限公司 数据存储、读取的方法、装置及系统
CN106682003B (zh) * 2015-11-06 2019-09-20 中国电信股份有限公司 分布式存储命名空间的路径分割映射方法和装置
CN105404691A (zh) * 2015-12-14 2016-03-16 曙光信息产业股份有限公司 一种文件存储的方法及装置
KR101736406B1 (ko) * 2016-05-30 2017-05-29 주식회사 인피니플럭스 데이터 복제 방법 및 그 장치
CN107480039B (zh) * 2017-09-22 2020-12-04 郑州云海信息技术有限公司 一种分布式存储系统的小文件读写性能测试方法及装置
CN109947703A (zh) * 2017-11-09 2019-06-28 北京京东尚科信息技术有限公司 文件系统、文件存储方法、存储装置和计算机可读介质
CN108133151B (zh) * 2018-02-08 2020-07-28 北京指掌易科技有限公司 文件加密装置、文件处理方法及移动终端设备
CN109918354B (zh) * 2019-03-01 2022-11-04 浪潮商用机器有限公司 一种基于hdfs的磁盘定位方法、装置、设备及介质
CN112860641A (zh) * 2021-01-29 2021-05-28 西藏宁算科技集团有限公司 基于hadoop的小文件存储方法及其装置

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515267A (zh) * 2008-02-19 2009-08-26 北京新岸线网络技术有限公司 网络媒体智能编目系统
US20090265339A1 (en) * 2006-04-12 2009-10-22 Lonsou (Beijing) Technologies Co., Ltd. Method and system for facilitating rule-based document content mining
CN102567312A (zh) * 2011-12-30 2012-07-11 北京理工大学 一种基于分布式并行计算框架的机器翻译方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090265339A1 (en) * 2006-04-12 2009-10-22 Lonsou (Beijing) Technologies Co., Ltd. Method and system for facilitating rule-based document content mining
CN101515267A (zh) * 2008-02-19 2009-08-26 北京新岸线网络技术有限公司 网络媒体智能编目系统
CN102567312A (zh) * 2011-12-30 2012-07-11 北京理工大学 一种基于分布式并行计算框架的机器翻译方法

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105630810A (zh) * 2014-10-30 2016-06-01 曙光信息产业股份有限公司 一种对于海量小文件在分布式存储系统中上载的方法
CN109451069A (zh) * 2018-12-29 2019-03-08 江苏鼎峰信息技术有限公司 基于分布式存储的网络数据文件库存储及查询方法

Also Published As

Publication number Publication date
CN104281414A (zh) 2015-01-14
CN104281414B (zh) 2018-07-06

Similar Documents

Publication Publication Date Title
WO2014166446A1 (zh) 文件访问处理方法、系统及计算机存储介质
US11422898B2 (en) Efficient creation of multiple retention period based representations of a dataset backup
US10140461B2 (en) Reducing resource consumption associated with storage and operation of containers
US11836112B2 (en) Path resolver for client access to distributed file systems
JP2019194882A (ja) ファーストクラスデータベース要素としての半構造データの実装
US20170277435A1 (en) Managing storage space based on multiple dataset backup versions
US9747321B2 (en) Providing a content preview
US10261996B2 (en) Content localization using fallback translations
US10909086B2 (en) File lookup in a distributed file system
US10169348B2 (en) Using a file path to determine file locality for applications
US11347681B2 (en) Enhanced reading or recalling of archived files
Chen et al. Big data storage
WO2021226822A1 (zh) 日志写入方法、装置、电子设备以及存储介质
US11157456B2 (en) Replication of data in a distributed file system using an arbiter
Mukhopadhyay et al. Addressing name node scalability issue in Hadoop distributed file system using cache approach
US10606805B2 (en) Object-level image query and retrieval
US20220269657A1 (en) Cache indexing using data addresses based on data fingerprints
US11681653B2 (en) Namespace representation and enhanced browsability for replicated file systems
CN113095778A (zh) 通过多个邮箱在通信应用中进行海量数据管理的架构
JP2020502605A (ja) プレースホルダーを介したコンテンツ管理システムの履歴コンテンツアイテムへのアクセス
US20180276290A1 (en) Relevance optimized representative content associated with a data storage system
US10146791B2 (en) Open file rebalance
US11989159B2 (en) Hybrid snapshot of a global namespace
US9535926B2 (en) Reducing transaction operations using deferred operations
Prabavathy et al. Multi-index technique for metadata management in private cloud storage

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

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

Country of ref document: EP

Kind code of ref document: A1