# Patent

## Title
Systems and methods for distributed system scanning

## Abstract

Systems and methods are provided for scanning files and directories in a distributed file system on a network of nodes. The nodes include metadata with attribute information corresponding to files and directories distributed on the nodes. In one embodiment, the files and directories are scanned by commanding the nodes to search their respective metadata for a selected attribute. At least two of the nodes are capable of searching their respective metadata in parallel. In one embodiment, the distributed file system commands the nodes to search for metadata data structures having location information corresponding to a failed device on the network. The metadata data structures identified in the search may then be used to reconstruct lost data that was stored on the failed device.

## Background
REFERENCE TO RELATED APPLICATIONS
The present disclosure relates to U.S. patent application Ser. No. 11/256,410, titled “SYSTEMS AND METHODS FOR PROVIDING VARIABLE PROTECTION,” U.S. Pat. No. 7,346,720, titled “SYSTEMS AND METHODS FOR MANAGING CONCURRENT ACCESS REQUESTS TO A SHARED RESOURCE,” U.S. patent application Ser. No. 11/255,818, titled “SYSTEMS AND METHODS FOR MAINTAINING DISTRIBUTED DATA,” U.S. patent application Ser. No. 11/256 317, titled “SYSTEMS AND METHODS FOR USING EXCITEMENT VALUES TO PREDICT FUTURE ACCESS TO RESOURCES,” and U.S. patent application Ser. No. 11/255,337, titled “SYSTEMS AND METHODS FOR ACCESSING AND UPDATING DISTRIBUTED DATA,” each filed on even date herewith and each hereby incorporated by reference herein in their entirety.
FIELD OF THE INVENTION
This disclosure relates to systems and methods for scanning files in distributed file systems.
BACKGROUND
Operating systems generally manage and store information on one or more memory devices using a file system that organizes data in a file tree. File trees identify relationships between directories, subdirectories, and files.
In a distributed file system, data is stored among a plurality of network nodes. Files and directories are stored on individual nodes in the network and combined to create a file tree for the distributed file system to identify relationships and the location of information in directories, subdirectories and files distributed among the nodes in the network. Files in distributed file systems are typically accessed by traversing the overall file tree.
Occasionally, a file system may scan a portion or all of the files in the file system. For example, the file system or a user may want to search for files created or modified in a certain range of dates and/or times, files that have not been accessed for a certain period of time, files that are of a certain type, files that are a certain size, files with data stored on a particular memory device (e.g., a failed memory device), files that have other particular attributes, or combinations of the foregoing. Scanning for files by traversing multiple file tree paths in parallel is difficult because the tree may be very wide or very deep. Thus, file systems generally scan for files by sequentially traversing the file tree. However, file systems, and particularly distributed file systems, can be large enough to store hundreds of thousands of files, or more. Thus, it can take a considerable amount of time for the file system to sequentially traverse the entire file tree.
Further, sequentially traversing the file tree wastes valuable system resources, such as the availability of central processing units to execute commands or bandwidth to send messages between nodes in a network. System resources are wasted, for example, by accessing structures stored throughout a cluster from one location, which may require significant communication between the nodes and scattered access to memory devices. The performance characteristics of disk drives, for example, vary considerably based on the access pattern. Thus, scattered access to a disk drive based on sequentially traversing a file tree can significantly increase the amount of time used to scan the file system.
SUMMARY
Thus, it would be advantageous to use techniques and systems for scanning file systems by searching metadata, in parallel, for selected attributes associated with a plurality of files. In one embodiment, content data, parity data and metadata for directories and files are distributed across a plurality of network nodes. When performing a scan of the distributed file system, two or more nodes in the network search their respective metadata in parallel for the selected attribute. When a node finds metadata corresponding to the selected attribute, the node provides a unique identifier for the metadata to the distributed file system.
According to the foregoing, in one embodiment, a method is provided for scanning files and directories in a distributed file system on a network. The distributed file system has a plurality of nodes. At least a portion of the nodes include metadata with attribute information for one or more files striped across the distributed file system. The method includes commanding at least a subset of the nodes to search their respective metadata for a selected attribute and to perform an action in response to identifying the selected attribute in their respective metadata. The subset of nodes is capable of searching their respective metadata in parallel.
In one embodiment, a distributed file system includes a plurality of nodes configured to store data blocks corresponding to files striped across the plurality of nodes. The distributed file system also includes metadata data structures stored on at least a portion of the plurality of nodes. The metadata data structures include attribute information for the files. At least two of the plurality of nodes are configured to search, at substantially the same time, their respective metadata data structures for a selected attribute.
In one embodiment, a method for recovering from a failure in a distributed file system includes storing metadata corresponding to one or more files on one or more nodes in a network. The metadata points to data blocks stored on the one or more nodes. The method also includes detecting a failed device in the distributed file system, commanding the nodes to search their respective metadata for location information corresponding to the failed device, receiving responses from the nodes, the responses identifying metadata data structures corresponding to information stored on the failed device, and accessing the identified metadata data structures to reconstruct the information stored on the failed device.
For purposes of summarizing the invention, certain aspects, advantages and novel features of the invention have been described herein. It is to be understood that not necessarily all such advantages may be achieved in accordance with any particular embodiment of the invention. Thus, the invention may be embodied or carried out in a manner that achieves or optimizes one advantage or group of advantages as taught herein without necessarily achieving other advantages as may be taught or suggested herein.



BRIEF DESCRIPTION OF THE DRAWINGS
Systems and methods that embody the various features of the invention will now be described with reference to the following drawings.
FIG. 1 illustrates an exemplary block diagram of a network according to one embodiment.
FIG. 2A illustrates an exemplary file tree including metadata data structures according to one embodiment.
FIG. 2B illustrates an inode map and an inode storage on Device A in according with FIG. 2A according to one embodiment.
FIGS. 3-5 illustrate exemplary metadata data structures for directories according to certain embodiments.
FIG. 6 illustrates an exemplary metadata data structure for a file according to one embodiment.
FIG. 7 is a flow chart of a process for scanning files and directories in a distributed file system according to one embodiment.
FIG. 8 is a flow chart of a process for recovering from a failure in a distributed file system according to one embodiment.



DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS
Systems and methods which represent one embodiment and example application of the invention will now be described with reference to the drawings. Variations to the systems and methods which represent other embodiments will also be described.
For purposes of illustration, some embodiments will be described in the context of a distributed file system. The inventors contemplate that the present invention is not limited by the type of environment in which the systems and methods are used, and that the systems and methods may be used in other environments, such as, for example, the Internet, the World Wide Web, a private network for a hospital, a broadcast network for a government agency, an internal network of a corporate enterprise, an intranet, a local area network, a wide area network, and so forth. The figures and descriptions, however, relate to an embodiment of the invention wherein the environment is that of distributed file systems. It is also recognized that in other embodiments, the systems and methods may be implemented as a single module and/or implemented in conjunction with a variety of other modules and the like. Moreover, the specific implementations described herein are set forth in order to illustrate, and not to limit, the invention. The scope of the invention is defined by the appended claims.
I. Overview
Rather than sequentially traversing a file tree searching for a particular attribute during a scan, a distributed file system, according to one embodiment, commands a plurality of network nodes to search their respective metadata for the particular attribute. The metadata includes, for example, attributes and locations of file content data blocks, metadata data blocks, and protection data blocks (e.g., parity data blocks and mirrored data blocks). Thus, two or more nodes in the network can search for files having the particular attribute at the same time.
In one embodiment, when a node finds metadata corresponding to the selected attribute, the node provides a unique identifier for a corresponding metadata data structure to the distributed file system. The metadata data structure includes, among other information, the location of or pointers to file content data blocks, metadata data blocks, and protection data blocks for corresponding files and directories. The distributed file system can then use the identified metadata data structure to perform one or more operations on the files or directories. For example, the distributed file system can read an identified file, write to an identified file, copy an identified file or directory, move an identified file to another directory, delete an identified file or directory, create a new directory, update the metadata corresponding to an identified file or directory, recover lost or missing data, and/or restripe files across the distributed file system. In other embodiments, these or other file system operations can be performed by the node or nodes that find metadata corresponding to the selected attribute.
In one embodiment, the distributed file system commands the nodes to search for metadata data structures having location information corresponding to a failed device on the network. The metadata data structures identified in the search may then be used to reconstruct lost data that was stored on the failed device.
In the following description, reference is made to the accompanying drawings, which form a part hereof, and which show, by way of illustration, specific embodiments or processes in which the invention may be practiced. Where possible, the same reference numbers are used throughout the drawings to refer to the same or like components. In some instances, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure. The present disclosure, however, may be practiced without the specific details or with certain alternative equivalent components and methods to those described herein. In other instances, well-known components and methods have not been described in detail so as not to unnecessarily obscure aspects of the present disclosure.
II. Distributed File System
FIG. 1 is an exemplary block diagram of a network 100 according to one embodiment of the invention. The network 100 comprises a plurality of nodes 102, 104, 106, 108, 110, 112 configured to communicate with each other through a communication medium 114. The communication medium 114 comprises, for example, the Internet or other global network, an intranet, a wide area network (WAN), a local area network (LAN), a high-speed network medium such as Infiniband, dedicated communication lines, telephone networks, wireless data transmission systems, two-way cable systems or customized computer interconnections including computers and network devices such as servers, routers, switches, memory storage units, or the like.
In one embodiment, at least one of the nodes 102, 104, 106, 108, 110, 112 comprises a conventional computer or any device capable of communicating with the network 114 including, for example, a computer workstation, a LAN, a kiosk, a point-of-sale device, a personal digital assistant, an interactive wireless communication device, an interactive television, a transponder, or the like. The nodes 102, 104, 106, 108, 110, 112 are configured to communicate with each other by, for example, transmitting messages, receiving messages, redistributing messages, executing received messages, providing responses to messages, combinations of the foregoing, or the like. In one embodiment, the nodes 102, 104, 106, 108, 110, 112 are configured to communicate RPC messages between each other over the communication medium 114 using TCP. An artisan will recognize from the disclosure herein, however, that other message or transmission protocols can be used.
In one embodiment, the network 100 comprises a distributed file system as described in U.S. patent application Ser. No. 10/007,003, entitled “System and Method for Providing a Distributed File System Utilizing Metadata to Track Information About Data Stored Throughout the System,” filed Nov. 9, 2001 which claims priority to application Ser. No. 60/309,803 filed Aug. 3, 2001, and U.S. patent application Ser. No. 10/714,326, filed Nov. 14, 2003, which claims priority to application Ser. No. 60/426,464, filed Nov. 14, 2002, all of which are hereby incorporated by reference herein in their entirety. For example, the network 100 may comprise an intelligent distributed file system that enables the storing of file data among a set of smart storage units which are accessed as a single file system and utilizes a metadata data structure to track and manage detailed information about each file. In one embodiment, individual files in a file system are assigned a unique identification number that acts as a pointer to where the system can find information about the file. Directories (and subdirectories) are files that list the name and unique identification number of files and subdirectories within the directory. Thus, directories are also assigned unique identification numbers that reference to where the system can find information about the directory.
In addition, the distributed file system may be configured to write data blocks or restripe files distributed among a set of smart storage units in the distributed file system wherein data is protected and recoverable if a system failure occurs.
In one embodiment, at least some of the nodes 102, 104, 106, 108, 110, 112 include one or more memory devices for storing file content data, metadata, parity data, directory and subdirectory data, and other system information. For example, as shown in FIG. 1, the node 102 includes device A, the node 106 includes device B, the node 108 includes devices C and D, the node 110 includes devices E, F, and G, and the node 112 includes device H. Advantageously, the file content data, metadata, parity data, and directory data (including, for example, subdirectory data) are distributed among at least a portion of the devices A-G such that information will not be permanently lost if one of the nodes 102, 104, 106, 108, 110, 112 and/or devices A-G fails. For example, the file content data, metadata, parity data, and/or directory data may be mirrored on two or more devices A-G or protected using a parity scheme (e.g., 2+1, 3+1, or the like).
A. Metadata
Metadata data structures include, for example, the device and block locations of the file's data blocks to permit different levels of replication and/or redundancy within a single file system, to facilitate the change of redundancy parameters, to provide high-level protection for metadata distributed throughout the network 100, and to replicate and move data in real-time. Metadata for a file may include, for example, an identifier for the file, the location of or pointer to the file's data blocks as well as the type of protection for each file, or each block of the file, the location of the file's protection blocks (e.g., parity data, or mirrored data). Metadata for a directory may include, for example, an identifier for the directory, a listing of the files and subdirectories of the directory as well as the identifier for each of the files and subdirectories, as well as the type of protection for each file and subdirectory. In other embodiments, the metadata may also include the location of the directory's protection blocks (e.g., parity data, or mirrored data). In one embodiment, the metadata data structures are stored in the distributed file system.
B. Attributes
In one embodiment, the metadata includes attribute information corresponding to files and directories stored on the network 100. The attribute information may include, for example, file size, file name, file type, file extension, file creation time (e.g., time and date), file access time (e.g., time and date), file modification date (e.g., time and date), file version, file permission, file parity scheme, file location, combinations of the foregoing, or the like. The file location may include, for example, information useful for accessing the physical location in the network of content data blocks, metadata data blocks, parity data blocks, mirrored data blocks, combinations of the foregoing, or the like. The location information may include, for example, node id, device, id, and address offset, though other location may be used.
C. Exemplary Metadata File Tree
Since the metadata includes location information for files and directories stored on the network 100, the distributed file system according to one embodiment uses a file tree comprising metadata data structures. For example, FIG. 2 illustrates an exemplary file tree 200 including metadata data structures referred to herein as “inodes.” In this example, the inodes are protected against failures by mirroring the inodes such that the inodes are stored on two devices. Thus, if a device fails, an inode on the failed device can be recovered by reading a copy of the inode from a non-failing device. An artisan will recognize that the inodes can be mirrored on more than two devices, can be protected using a parity scheme, or can be protected using a combination of methods. In one embodiment, the inodes are protected using the same level of protection as the data to which the inodes point.
As illustrated in the example in FIG. 2, the file tree 200 includes an inode 202 corresponding to a “/” directory (e.g., root directory). Referring to FIG. 1, the inode 202 for the root directory is mirrored on device D and device H. The inode 202 for the root directory points to an inode 204 (stored on devices A and G) for a directory named “dir1,” an inode 206 (stored on devices C and F) for a directory named “dir2,” and an inode 208 (stored on devices B and E) for a directory named “dir3.”
The inode 206 for directory dir2 points to an inode 210 (stored on devices D and G) for a directory named “dir4,” an inode 212 (stored on devices B and C) for a directory named “dir5,” an inode 214 (stored on devices A and E) for a directory named “dir6,” and an inode 216 (stored on devices A and B) for a file named “file1.zzz.” The inode 208 for directory dir3 points to an inode 218 (stored on devices A and F) for a file named “file2.xyz.” The inode 214 for the directory dir6 points to an inode 220 (stored on devices A and C) for a file named “file3.xxx,” an inode 222 (stored on devices B and C) for a file named “file4.xyz,” and an inode 224 (stored on devices D and G) for a file named “file5.xyz.” An artisan will recognize that the inodes shown in FIG. 2 are for illustrative purposes and that the file tree 200 can include any number inodes corresponding to files and/or directories and a variety of protection methods may be used.
FIG. 2A illustrates one embodiment of an inode map 230 and an inode storage 240 on Device A. The exemplary inode map 230 has multiple entries where the first entry 0 corresponds to inode storage entry 0, the second entry 1 corresponds to inode storage entry 1, and so forth. In the exemplary inode map 230, a 1 represents that an inode is storage in the corresponding inode storage 240, and a 0 represents that no inode is store in the corresponding inode storage 240. For example, inode map 230 entry 0 is 1, signifying that there is an inode stored in inode storage 240 entry 0. The inode for dir1 204 is stored in inode storage 0. Inode map 230 entry 1 is 0 signifying that there is no inode stored in inode storage 240 entry 1. The exemplary inode storage 240 of Device A stores inodes 204, 214, 216, 218, 220 in accordance with FIG. 2A.
D. Exemplary Metadata Data Structures
In one embodiment, the metadata data structure (e.g., inode) includes, attributes and a list of devices having data to which the particular inode points. For example, FIG. 3 illustrates an exemplary metadata data structure of the inode 202 for the root directory. The inode 202 for the root directory includes attribute information 302 corresponding to the inode 202. As discussed above, the attribute information may include, for example, size, name, type (e.g., directory and/or root directory), creation time, access time, modification time, version, permission, parity scheme, location, combinations of the foregoing, and/or other information related to the root directory. In one embodiment, the nodes 102, 104, 106, 108, 110, 112 in the network 100 include predefined location information for accessing the inode 202 of the root directory on device D and/or device H. In other embodiments, the exemplary inode 202 includes location information (not shown) pointing to its location on devices D and H. The inode 202 for the root directory also includes a list of devices used 304. As shown in FIG. 2, since the inodes 204, 206, 208 for directories dir1, dir2, and dir3 are stored on devices A, B, C, E, F and G, these devices are included in the list of devices used 304.
The inode 202 for the root directory also includes location information 306 corresponding to the directories dir1, dir2, and dir3. As shown in FIG. 3, in one embodiment, the location information 306 includes unique identification numbers (e.g., logical inode numbers) used to match the directories dir1, dir2, and dir3 to the physical storage locations of the inodes 204, 206, 208, respectively. In certain such embodiments, the distributed file system includes a data structure that tracks the unique identification numbers and physical addresses (e.g., identifying the node, device, and block offset) of the inodes 204, 206, 208 on the distributed file system. As illustrated, unique identifiers are provided for each of the directories dir1, dir2, dir3 such that a data structure may be configured, for example, to match the unique identifiers to physical addresses where the inodes 204, 206, 208, and their mirrored copies are stored. In other embodiments, the location information 306 includes the physical addresses of the inodes 204, 206, 208 or the location information includes two unique identifiers for each of the directories Dir1, dir2, and dir3 because the directories are mirrored on two devices. Various data structures that may be used to track the identification numbers are further discussed in U.S. patent application Ser. No. 11/255,8181, titled “SYSTEMS AND METHODS FOR MAINTAINING DISTRIBUTED DATA,” and U.S. patent application Ser. No. 11/255,337, titled “SYSTEMS AND METHODS FOR ACCESSING AND UPDATING DISTRIBUTED DATA,” each referenced and incorporated by reference above.
FIG. 4 illustrates an exemplary metadata data structure of the inode 206 for the directory dir2. As discussed above in relation to the inode 202 for the root directory, the inode 206 for the directory dir2 includes attribute information 402 corresponding to the inode 206 and a list of devices used 404. As shown in FIG. 2, the inode 216 for the file file1.zzz is stored on devices A and B. Further, the inodes 210, 212, 214 for the directories dir4, dir5, and dir6 are stored on devices A, B, C, D, E, and G. Thus, these devices are included in the list of devices used 404. The inode 206 for the directory dir2 also includes location information 406 corresponding to the directories dir4, dir5, dir6 and location information 408 corresponding to the file file1.zzz. As discussed above, the location information 406 points to the inodes 210, 212, 214 and the location information 408 points to the inode 216. Further, as discussed above, unique identifiers are provided for each of the directories dir4, dir5, dir6 and the file file1.zzz, however, other embodiments, as discussed above, may be used.
FIG. 5 illustrates an exemplary metadata data structure of the inode 214 for the directory dir6. As discussed above in relation to the inode 202 for the root directory, the inode 214 for the directory dir6 includes attribute information 502 corresponding to the inode 214 and a list of devices used 504. As shown in FIG. 2, the inodes 220, 222, 224 for the files are stored on devices A, B, C, D, and G. Thus, these devices are included in the list of devices used 504. The inode 214 for the directory dir6 also includes location information 506 corresponding to the files file3.xxx, file4.xyz, and file5.xyz. As discussed above, the location information 506 points to the inodes 220, 222, 224. Further, as discussed above, unique identifiers are provided for each of the files file3.xxx, file4.xyz, and file5, however, other embodiments, as discussed above, may be used.
FIG. 6 illustrates an exemplary metadata data structure of the inode 220 for the file file3.xxx. The inode 220 for the file file3.xxx includes attribute information 602 corresponding to the inode 220. For example, the attribute information 602 may include the size of file3.xxx, the name of file3.xxx (e.g., file3), the file type, the file extension (e.g., .xyz), the file creation time, the file access time, the file modification time, the file version, the file permissions, the file parity scheme, the file location, combinations of the foregoing, or the like.
The inode 220 also includes a list of devices used 604. In this example, content data blocks and parity data blocks corresponding to the file file3.xxx are striped across devices B, C, D, and E using a 2+1 parity scheme. Thus, for two blocks of content data stored on the devices B, C, D, and E, a parity data block is also stored. The parity groups (e.g., two content data blocks and one parity data block) are distributed such that each block in the parity group is stored on a different device. As shown in FIG. 6, for example, a first parity group may include a first content data block (block0) stored on device B, a second content data block (block1) stored on device C, and a first parity block. (parity0) stored on device D. Similarly, a second parity group may include a third content data block (block2) stored on device E, a fourth content data block (block3) stored on device B and a second parity data block (parity1) stored on device C.
The inode 220 for the file file3.xxx also includes location information 606 corresponding to the content data blocks (e.g., block0, block1, block2, and block3) and parity data blocks (e.g., parity0 and parity1). As shown in FIG. 6, in one embodiment, the location information 606 includes unique identification numbers (e.g., logical block numbers) used to match the content data blocks and parity data blocks to the physical storage locations of the respective data. In certain such embodiments, the distributed file system includes a table that tracks the unique identification numbers and physical addresses (e.g., identifying the node, device, and block offset) on the distributed file system. In other embodiments, the location information 606 includes the physical addresses of the content data blocks and parity data blocks. In one embodiment, the inode 220 for the file file3.xxx also includes location information 608 corresponding to one or more metadata data blocks that point to other content data blocks and/or parity blocks for the file file3.xxx.
III. Scanning Distributed File Systems
In one embodiment, the distributed file system is configured to scan a portion or all of the files and/or directories in the distributed file system by commanding nodes to search their respective metadata for a selected attribute. As discussed in detail below, the nodes can then search their respective metadata in parallel and perform an appropriate action when metadata is found having the selected attribute.
Commanding the nodes to search their respective metadata in parallel with other nodes greatly reduces the amount of time necessary to scan the distributed file system. For example, to read a file in path/dir1/fileA.xxx of a file tree (where “/” is the top level or root directory and “xxx” is the file extension of the file named fileA in the directory named dir1), the file system reads the file identified by the root directory's predefined unique identification number, searches the root directory for the name dir1, reads the file identified by the unique identification number associated with the directory dir1, searches the dir1 directory for the name fileA.xxx, and reads the file identified by the unique identification number associated with fileA.xxx.
For example, referring to FIG. 2A, sequentially traversing the file tree 200 may include reading the inode 202 corresponding to the root directory to determine the names and locations of the inodes 204, 206, 208. Then, the inode 204 corresponding to the directory dir1 may be read to determine the names and locations of any subdirectories and files that the inode 204 may point to.
After sequentially stepping through the subdirectory and file paths of the directory dir1, the inode 206 corresponding to the directory dir2 may be read to determine the names and locations of the subdirectories (e.g., dir4, dir5, and dir6) and files (e.g., file1.zzz) that the inode 206 points to. This process may then be repeated for each directory and subdirectory in the distributed file system. Since content data, metadata and parity data is spread throughout the nodes 102, 106, 108, 110, 112 in the network 100, sequentially traversing the file tree 200 requires a large number of messages to be sent between the nodes and uses valuable system resources. Thus, sequentially traversing the file tree 200 is time consuming and reduces the overall performance of the distributed file system.
However, commanding the nodes 102, 106, 108, 110, 112 to search their respective metadata in parallel, according to certain embodiments disclosed herein, reduces the number of messages sent across the network 100 and allows the nodes 102, 106, 108, 110, 112 to access their respective devices A-H sequentially.
In one embodiment, for example, one or more of the devices A-H are hard disk drives that are capable of operating faster when accessed sequentially. For example, a disk drive that yields approximately 100 kbytes/second when reading a series of data blocks from random locations on the disk drive may yield approximately 60 Mbytes/second when the data blocks are read from sequential locations on the disk drive. Thus, allowing the nodes 102, 106, 108, 110, 112 to respectively access their respective drives sequentially, rather than traversing an overall file tree for the network 100 (which repeatedly accesses small amounts of data scattered across the devices A-H), greatly reduces the amount of time used to scan the distributed file system.
The nodes 102, 106, 108, 110, 112 may perform additional processing, but the additional work is spread across the nodes 102, 106, 108, 110, 112 and reduces overall network traffic and processing overhead. For example, in one embodiment, rather than reading all the metadata from the node 102 across the network, the node 102 searches its metadata and only the metadata satisfying the search criteria is read across the network. Thus, overall network traffic and processing overhead is reduced.
FIG. 7 is a flow chart of one embodiment of a process 700 for scanning files and directories in a distributed file system according to one embodiment. Beginning at a start state 708, the process 700 proceeds to block 710. In block 710, the process 700 includes distributing content data blocks, metadata blocks and protection data blocks (e.g., parity data, and mirrored data) for files and directories across nodes in a network. For example, as discussed in detail above, content data blocks, metadata data blocks and protection data blocks are stored in nodes 102, 106, 108, 110, 112 in the network 100 shown in FIG. 1. The metadata data blocks include attribute information corresponding to files and directories stored on the network 100. The attribute information may include, for example, file size, file name, file type, file extension, file creation time (e.g., time and date), file access time (e.g., time and date), file modification date (e.g., time and date), file version, file permission, file parity scheme, file location, combinations of the foregoing, or the like.
From the block 710, the process 700 proceeds, in parallel, to blocks 712 and 714. In the block 714, file system operations are performed. The file system operations may include, for example, continuing to distribute data blocks for files and directories across the nodes in the network, writing files, reading files, restriping files, repairing files, updating metadata, waiting for user input, and the like. The distributed file system operations can be performed while the system waits for a command to scan and/or while the distributed file system performs a scan as discussed below.
In the block 712, the system queries whether to scan the distributed file system to identify the files and directories having a selected attribute. For example, the distributed file system or a user of the network 100 shown in FIG. 1 may want to search for files and/or directories created or modified in a certain range of dates and/or times, files that have not been accessed for a certain period of time, files that are of a certain type, files that are a certain size, files with data stored on a particular memory device (e.g., a failed memory device), files that have other particular attributes, or combinations of the foregoing. While the system performs the other file system operations in the block 714, the system continues to scan the distributed file system. In one embodiment, a scan will not be performed, for example, if a user has not instructed the distributed file system to scan, or the distributed file system has not determined that a scan is needed or desired (e.g., upon detecting that a node has failed).
If a scan is desired or needed, the process 700 proceeds to a block 716 where the distributed file system commands the nodes to search their respective metadata data blocks for a selected attribute. Advantageously, the nodes are capable of searching their metadata data blocks in parallel with one another. For example, the nodes 102, 106, 108, 110, 112 may each receive the command to search their respective metadata data blocks for the selected attribute. The nodes 102, 106, 108, 110, 112 can then execute the command as node resources become available. Thus, rather than waiting for each node 102, 106, 108, 110, 112 to scan its respective metadata data blocks one at a time, two or more of the nodes 102, 106, 108, 110, 112 that have sufficient node resources may search their respective metadata data blocks at the same time. It is recognized that the distributed file system may command a subset of the nodes to conduct the search.
In one embodiment, the metadata data blocks for a particular node are sequentially searched for the selected attribute. For example, a node may include a drive that is divided into a plurality of cylinder groups. The node may sequentially step through each cylinder group reading their respective metadata data blocks. In other embodiments, metadata data blocks within a particular node are also searched in parallel. For example, the node 108 includes devices C and D that can be searched for the selected attribute at the same time. The following exemplary pseudocode illustrates one embodiment of accessing metadata data blocks (e.g., stored in data structures referred to herein as inodes) in parallel:















for all devices (in parallel);









for each cylinder group;









for each inode with bit in map = 1;









read inode.










In a block 718, the distributed file system commands the nodes to perform an action in response to identifying the selected attribute in their respective metadata and proceeds to an end state 720. An artisan will recognize that the command to search for the selected attribute and the command to perform an action in response to identifying the selected attribute can be sent to the nodes using a single message (e.g., sent to the nodes 102, 106, 108, 110, 112) or using two separate messages. The action may include, for example, writing data, reading data, copying data, backing up data, executing a set of instructions, and/or sending a message to one or more of the other nodes in the network. For example, the node 102 may find one or more its inodes that point to files or directories created within a certain time range. In response, the node 102 may read the files or directories and write a backup copy of the files or directories.
In one embodiment, the action in response to identifying the attribute includes sending a list of unique identification numbers (e.g., logical inode number or “LIN”) for inodes identified as including the selected attribute to one or more other nodes. For example, the nodes 102, 106, 108, 110, 112 may send a list of LINs for their respective inodes with the selected attribute to one of the other nodes in the network 100 for processing. The node that receives the LINs may or may not have any devices. For example, the node 104 may be selected to receive the LINs from the other nodes 102, 106, 108, 110, 112 and to perform a function using the LINs.
After receiving the LINs from the other nodes 102, 106, 108, 110, 112, the node 104 reads the inodes identified by the LINs for the location of or pointers to content data blocks, metadata data blocks, and/or protection data blocks (e.g., parity data blocks and mirrored data blocks). In certain such embodiments, the node 104 also checks the identified inodes to verify that they still include the selected attribute. For example, the selected attribute searched for may be files and directories that have not been modified for more than 100 days and the node 104 may be configured to delete such files and directories. However, between the time that the node 104 receives the list of LINs and the time that the node 104 reads a particular identified inode, the particular identified inode may be updated to indicate that its corresponding file or directory has recently been modified. The node 104 then deletes only files and directories with identified inodes that still indicate that they have not been modified for more than 100 days.
While process 700 illustrates an embodiment for scanning files and directories in a distributed file system such that all devices are scanned in parallel, it is recognized that the process 700 may be used on a subset of the devices. For example, one or more devices of the distributed file system may be offline. In addition, the distributed file system may determine that the action to be performed references only a subset of the devices such that only those devices are scanned, and so forth.
A. Example Scan Transactions
High-level exemplary transactions are provided below that illustrate scanning a distributed file system according to certain embodiments. The exemplary transactions include a data backup transaction and a failure recovery transaction. An artisan will recognize from the disclosure herein that many other transactions are possible.
1. Example Data Backup Transaction
The following example illustrates how backup copies of information stored on the network 100 can be created by scanning the distributed file system to find files and directories created or modified during a certain time period (e.g., since the last backup copy was made). In this example, the node 104 is selected to coordinate the backup transaction on the distributed file system. An artisan will recognize, however, that any of the nodes can be selected to coordinate the backup transaction.
The node 104 begins the backup transaction by sending a command to the nodes 102, 106, 108, 110, 112 to search their respective metadata so as to identify inodes that point to files and directories created or modified within a certain time range. As discussed above, the exemplary nodes 102, 106, 108, 110, 112 are capable of searching their metadata in parallel with one another. After searching, the nodes 102, 106, 108, 110, 112 each send a list of LINs to the node 104 to identify their respective inodes that point to files or directories created or modified within the time range. The node 104 then accesses the identified inodes and reads locations of or pointers to content data blocks, metadata blocks, and/or protection data blocks corresponding to the files or directories created or modified within the time range. The node 104 then writes the content data blocks, metadata blocks, and/or protection data blocks to a backup location.
2. Example Failure Recovery Transaction
FIG. 8 is a flow chart of a process 800 for recovering from a failure in a distributed file system according to one embodiment. Failures may include, for example, a loss of communication between two or more nodes in a network or the failure of one or more memory devices in a node. For illustrative purposes, device B in the node 106 shown in FIG. 1 is assumed to have failed. However, an artisan will recognize that the process 800 can be used with other types of failures or non-failures. For example, the process 800 can be modified slightly to replace or upgrade a node or memory device that has not failed.
Beginning at a start state 808, the process 800 proceeds to block 810. In block 810, the process 800 detects a failed device in a distributed file system. For example, in one embodiment, the nodes 102, 106, 108, 110, 112 include a list of their own devices and share this list with the other nodes. When a device on a node fails, the node notifies the other nodes of the failure. For example, when device B fails, the node 106 sends a message to the nodes 102, 104, 108, 110, 112 to notify them of the failure.
In a block 812, the process 800 includes commanding the nodes to search their respective metadata for location information corresponding to the failed device. In one embodiment, the message notifying the nodes 102, 106, 108, 110, 112 of the failure of the device B includes the command to search for metadata identifies the location of content data blocks, metadata data blocks, and protection data blocks (e.g., parity data blocks and mirrored data blocks) that are stored on the failed device B.
After receiving the command to search metadata for location information corresponding to the failed device B, the nodes 102, 108, 110, 112 begin searching for inodes that include the failed device B in their list of devices used. For example, as discussed above in one embodiment, the inode 202 for the root directory is stored on devices D and H and includes the location of or pointers to the inodes 204, 206, 208 for the directories dir1, dir2 and dir3, respectively (see FIG. 2). Since a copy of the inode 208 for the directory dir3 is stored on the failed device B, the inode 202 for the root directory includes device B in its list of devices used 304 (see FIG. 3). Thus, the nodes 108 (for device D) and 112 (for device H) will include the LIN for the inode 202 in their respective lists of LINs that meet the search criteria. The following exemplary pseudocode illustrates one embodiment of generating a list of LINs for inodes that meet the search criteria:












for each allocated inode:









read allocated inode;



if needs_restripe (e.g., a portion of a file, a directory or









subdirectory, or a copy of the inode is located on the failed



device B);









return LIN.










Similarly, the nodes 108 (for device C) and 110 (for device F) will include the LIN for the inode 206 in their respective lists of LINS that meet the search criteria, the nodes 102 (for device A) and 110 (for device E) will include the LIN for the inode 214 in their respective lists of LINS that meet the search criteria, and the nodes 102 (for device A) and 108 (for device C) will include the LIN for the inode 220 in their respective lists of LINs that meet the search criteria. While this example returns the LIN of the inode, it is recognized that other information may be returned, such as, for example, the LIN for inode 208. In other embodiments, rather than return any identifier, the process may initiate reconstruction of the data or other related actions.
In other embodiments, the list of devices used for a particular inode includes one or more devices on which copies of the particular inode are stored. For example, FIG. 2A shows that the inode 208 is stored on devices B and E. The copy of the inode 208 on device E will list device B as used. Also, the node 110 (for device E) will include the LIN for the inode 208 in its list of LINs that meet the search criteria. Similarly, the device 102 (for device A) will include the LIN for the inode 216 in its list of LINs that meet the search criteria, and the node 108 (for device C) will include the LIN for inodes 212 and 222.
As discussed above, the nodes 102, 108, 110, 112 are capable of searching their respective metadata in parallel with one another. In one embodiment, the nodes 102, 108, 110, 112 are also configured to execute the command to search their respective metadata so as to reduce or avoid interference with other processes being performed by the node. The node 102, for example, may search a portion of its metadata, stop searching for a period of time to allow other processes to be performed (e.g., a user initiated read or write operation), and search another portion of its metadata. The node 102 may continue searching as the node's resources become available.
In one embodiment, the command to search the metadata includes priority information and the nodes 102, 108, 110, 112 are configured to determine when to execute the command in relation to other processes that the nodes 102, 108, 110, 112 are executing. For example, the node 102 may receive the command to search its metadata for the location information as part of the overall failure recovery transaction and it may also receive a command initiated by a user to read certain content data blocks. The user initiated command may have a higher priority than the command to search the metadata. Thus, the node 102 will execute the user initiated command before searching for or completing the search of its metadata for the location information corresponding to the failed device B.
In one embodiment, the nodes 102, 108, 110, 112 are configured to read their respective inodes found during the search and reconstruct the lost data (as discussed below) that the inodes point to on the failed device B. In the embodiment shown in FIG. 8, however, the nodes 102, 108, 110, 112 are configured to send their respective lists of LINs that meet the search criteria to one or more of the nodes 102, 104, 106, 108, 110, 112 that has the responsibility of reconstructing the data and restriping files across the distributed file system.
In a block 814, the process 800 includes receiving responses from the nodes that identify metadata data structures corresponding to information stored on the failed device. For example, the nodes 102, 108, 110 may send their lists of LINs to the node 112. In a block 816, the process 800 includes accessing the identified metadata data structures to reconstruct the lost information stored on the failed device and proceeds to an end state 818. For example, after receiving the lists LINs from the nodes 102, 108, 110, the node 112 may use the received LINs and any LINs that it has identified to read the corresponding inodes to determine the locations of content data blocks, metadata blocks and protection data blocks corresponding to the lost information on the failed device B.
For example, as discussed above, the node 112 in one embodiment may receive lists of LINs from the nodes 108 and 112 that include the LIN for the inode 202. The node 112 then reads the inode 202 from either the device D or the device H to determine that it includes pointers to the inode 208 for the directory dir3 stored on the failed device B (see FIG. 3). From the inode 202, the node 112 also determines that a mirrored copy of the inode 208 is stored on device E. Thus, the node 112 can restore the protection scheme of the inode 208 (e.g., maintaining a mirrored copy on another device) by reading the inode 208 from the device E and writing a copy of the inode 208 to one of the other devices A, C, D, F, G, H.
As another example, the node 112 also receives lists of LINs from the nodes 102 and 108 that include the LIN for the inode 220. The node 112 then reads the inode 220 from either the device A or the device C for the location of or pointers to content data blocks (block0 and block3) stored on the failed device B (see FIG. 6). In certain embodiments, the node 12 also verifies that the file3.xxx has not already been restriped such that block0 and block3 have already been recovered and stored on another device. For example, between the time that the node 112 receives the LIN for the inode 220 and the time that the node 112 reads the inode 220, the distributed file system may have received another command to restripe the file3.xxx.
As discussed above, the file3.xxx uses a 2+1 parity scheme in which a first parity group includes block0, block1 and parity0 and a second parity group includes block2, block3, and parity1. If needed or desired, the node 112 can recover the block0 information that was lost on the failed device B by using the pointers in the inode 220 to read the block1 content data block and the parity0 parity data block, and XORing block1 and parity0. Similarly, the node 112 can recover the block3 information that was lost on the failed device B by using the pointers in the inode 220 to read the block2 content data block and the parity1 parity data block, and XORing block2 and parity1. In one embodiment, the node 112 writes the recovered block0 and block3 to the remaining devices A, C, D, E F, G, H. In another embodiment, the node 112 can then change the protection scheme, if needed or desired, and restripe the file file3.xxx across the remaining devices A, C, D, E, F, G, H.
Thus, the distributed file system can quickly find metadata for information that was stored on the failed device B. Rather than sequentially traversing the entire file tree 200, the distributed file system searches the metadata of the remaining nodes 102, 108, 110, 112 in parallel for location information corresponding to the failed device B. This allows the distributed file system to quickly recover the lost data and restripe any files, if needed or desired.
IV. CONCLUSION
While certain embodiments of the inventions have been described, these embodiments have been presented by way of example only, and are not intended to limit the scope of the inventions. Indeed, the novel methods and systems described herein may be embodied in a variety of other forms; furthermore, various omissions, substitutions and changes in the form of the methods and systems described herein may be made without departing from the spirit of the inventions. The accompanying claims and their equivalents are intended to cover such forms or modifications as would fall within the scope and spirit of the inventions.

## Claims

1. A method for identifying selected attributes in files stored in a distributed file system, the method comprising:
providing a plurality of nodes in a network, wherein each node comprises:
a processor and a memory device for locally storing data, and wherein files are distributed across the nodes such that one or more of the files are stored in the memory devices, in parts, among the plurality of nodes;
a plurality of metadata data blocks each associated with one of the files and comprising file attribute data related to the corresponding file, a file identifier, and location information for one or more content data blocks of the file, the attribute data including data indicating which nodes are used to store the file's content data blocks, the metadata data blocks distributed across the nodes and stored in the memory devices among the plurality of nodes such that, for at least one of the metadata data blocks, at least one of the content data blocks of the file associated with the metadata data block is stored on a different node than the at least one metadata data block; and
a metadata map data structure providing an indication of where metadata data blocks are stored on the respective node and comprising a plurality of entries, each of the entries corresponding to a memory location of the memory device and indicating whether a metadata data block is stored in that memory location;

instructing, by the processor of the respective node, each of the nodes that locally stores metadata data blocks to determine each memory location where a metadata data block is locally stored using the respective node's metadata map data structure, read the respective metadata data blocks, and search the locally stored metadata data blocks for files which include data blocks stored on a particular node that is unavailable such that one or more of the nodes performs at least a portion of the search in parallel with at least a portion of the search of one or more of the other nodes;
receiving from the nodes that store metadata data blocks, file identifiers related to files that include data blocks stored on the node that is unavailable;
accessing the metadata data blocks corresponding to one of the file identifiers to determine the location of at least one accessible content data block and at least one accessible parity data block corresponding to one of the files that include data blocks stored on an unavailable node;
reading the at least one accessible content data block and the at least one accessible parity data block from their respective locations in the memory devices of available nodes; and
processing the at least one accessible content data block and the at least one accessible parity data block to generate recovered data blocks corresponding to the one or more data blocks stored on the unavailable node,
wherein processing the at least one accessible content data block and the at least one accessible parity data block comprises performing an exclusive or (XOR) operation on the at least one accessible content data block and the at least one accessible parity data block.

2. The method of claim 1, further comprising:
restriping the recovered data blocks among available nodes.

3. The method of claim 1, wherein each of the respective nodes performs the search by sequentially traversing its memory device to read its respective metadata data blocks after determining which memory locations store metadata data blocks.

4. A system for identifying selected attributes in files stored in a distributed file system, the system comprising:
a plurality of nodes in a network, wherein each node comprises:
a processor and a memory device for locally storing data, and wherein files are distributed across the nodes such that one or more of the files are stored in the memory devices, in parts, among the plurality of nodes;
a plurality of metadata data blocks each associated with one of the files and comprising file attribute data related to the corresponding file, a file identifier, and location information for one or more content data blocks of the file, the attribute data including data indicating which nodes are used to store the file's content data blocks, the metadata data blocks distributed across the nodes and stored in the memory devices among the plurality of nodes such that, for at least one of the metadata data blocks, at least one of the content data blocks of the file associated with the metadata data block is stored on a different node than the at least one metadata data block; and
a metadata map data structure providing an indication of where metadata data blocks are stored on the respective node and comprising a plurality of entries, each of the entries corresponding to a memory location of the memory device and indicating whether a metadata data block is stored in that memory location, wherein each of the plurality of nodes are configured to:
instruct each of the nodes that locally stores metadata data blocks to determine each memory location where a metadata data block is locally stored using the respective node's metadata map data structure, read the respective metadata data blocks, and search the locally stored metadata data blocks for files which include data blocks stored on a particular node that is unavailable such that one or more of the nodes performs at least a portion of the search in parallel with at least a portion of the search of one or more of the other nodes;
receive from the nodes that store metadata data blocks, file identifiers related to files that include data blocks stored on the node that is unavailable;
access the metadata data blocks corresponding to one of the file identifiers to determine the location of at least one accessible content data block and at least one accessible parity data block corresponding to one of the files that include data blocks stored on an unavailable node;
read the at least one accessible content data block and the at least one accessible parity data block from their respective locations in the memory devices of available nodes; and
process the at least one accessible content data block and the at least one accessible parity data block to generate recovered data blocks corresponding to the one or more data blocks stored on the unavailable node by performing an exclusive—or (XOR) operation on the at least one accessible content data block and the at least one accessible parity data block.

5. The system of claim 4, wherein each of the plurality of nodes is further configured to:
restripe the recovered data blocks among available nodes.

6. The system of claim 4, wherein each of the respective nodes performs the search by sequentially traversing its memory device to read its respective metadata data blocks after determining which memory locations store metadata data blocks.

7. A computer readable medium storing program code that, in response to execution by a processor of one of a plurality of nodes in a network, causes the processor to perform operations for identifying selected attributes in files stored in a distributed file system, the operations comprising:
instructing, by a processor of one of a plurality of nodes in a network wherein each node comprises:
a processor and a memory device for locally storing data, and wherein files are distributed across the nodes such that one or more of the files are stored in the memory devices, in parts, among the plurality of nodes; and
a plurality of metadata data blocks each associated with one of the files and comprising file attribute data related to the corresponding file, a file identifier, and location information for one or more content data blocks of the file, the attribute data including data indicating which nodes are used to store the file's content data blocks, the metadata data blocks distributed across the nodes and stored in the memory devices among the plurality of nodes such that, for at least one of the metadata data blocks, at least one of the content data blocks of the file associated with the metadata data block is stored on a different node than the at least one metadata data block; and
a metadata map data structure providing an indication of where metadata data blocks are stored on the respective node and comprising a plurality of entries, each of the entries corresponding to a memory location of the memory device and indicating whether a metadata data block is stored in that memory location,

each of the nodes that locally stores metadata data blocks to determine each memory location where a metadata data block is locally stored using the respective node's metadata map data structure, read the respective metadata data blocks, and search the locally stored metadata data blocks for files which include data blocks stored on a particular node that is unavailable such that one or more of the nodes performs at least a portion of the search in parallel with at least a portion of the search of one or more of the other nodes;
receiving from the nodes that store metadata data blocks, file identifiers related to files that include data blocks stored on the node that is unavailable;
accessing the metadata data blocks corresponding to one of the file identifiers to determine the location of at least one accessible content data block and at least one accessible parity data block corresponding to one of the files that include data blocks stored on an unavailable node;
reading the at least one accessible content data block and the at least one accessible parity data block from their respective locations in the memory devices of available nodes; and
processing the at least one accessible content data block and the at least one accessible parity data block to generate recovered data blocks corresponding to the one or more data blocks stored on the unavailable node,
wherein processing the at least one accessible content data block and the at least one accessible parity data block comprises performing an exclusive—or (XOR) operation on the at least one accessible content data block and the at least one accessible parity data block.

8. The computer-readable medium of claim 7, wherein the program code is further configured to cause the processor to perform operations comprising:
restriping the recovered data blocks among available nodes.

9. The computer-readable medium of claim 7, wherein each of the respective nodes performs the search by sequentially traversing its memory device to read its respective metadata data blocks after determining which memory locations store metadata data blocks.