Index node allocation method, data processing device and computer-readable medium
AssigneeQnap Systems, Inc.
InventorTsu-Yu Wu
Life of this patent
Estimating the term…
Abstract
An index node (inode) allocation method, a corresponding data processing device and a corresponding computer-readable medium are provided. The method is applicable to a file system and includes the following steps: allocating a range including a plurality of consecutive inodes to a directory in the file system when a directory order mode is already activated, wherein files in the directory are sorted according to hash values of the files; dividing the range of inodes into a plurality of sub-regions; and when a new file is created in the directory, selecting one of the sub-regions according to a hash value of the new file, so as to allocate an inode in the selected sub-region to the new file.
Claims9
An index node allocation method for speeding up a directory traversal, applicable to a directory traversal system installed in a data processing device and executed by a processor of the data processing device, the index node allocation method comprising the steps of:
- activating a directory order mode when a total number of inodes used by files in a directory in the directory traversal system is greater than a preset threshold value;
- allocating a first range comprising a plurality of consecutive inodes to the directory when the directory order mode is already activated, wherein each of the consecutive inodes is configured to store metadata of one of the files in the directory;
- dividing the first range into a plurality of first sub-regions of consecutive inodes, wherein the files in the directory are sorted according to tail numbers of hash values of the files, and wherein the tail number of each of the files in the directory is a remainder obtained by dividing the hash value of the file by a total number of the first sub-regions;
- gathering previously scattered inodes of the files into the first sub-regions so that inodes of the files with the same tail number are located in the same first sub-region of consecutive inodes;
- selecting one of the first sub-regions according to a tail number of a hash value of a new file when the new file is created in the directory to allocate a first inode of the selected one of the first sub-regions for use by the new file;
- and
- allocating a second range comprising a plurality of consecutive inodes for use by the files in the directory when all inodes of any one of the first sub-regions have been allocated for use by the files in the directory.
A data processing device, comprising a processor for executing an index node allocation method for speeding up a directory traversal in a directory traversal system installed in the data processing device, wherein the index node allocation method comprises:
- activating a directory order mode when a total number of inodes used by files in a directory in the directory traversal system is greater than a preset threshold value;
- allocating a first range comprising a plurality of consecutive inodes to the directory when the directory order mode is already activated, wherein each of the consecutive inodes is configured to store metadata of one of the files in the directory;
- dividing the first range into a plurality of sub-regions of consecutive inodes, wherein the files in the directory are sorted according to tail numbers of hash values of the files, and wherein the tail number of each of the files in the directory is a remainder obtained by dividing the hash value of the file by a total number of the sub-regions;
- gathering previously scattered inodes of the files into the sub-regions so that inodes of the files with the same tail number are located in the same sub-region of consecutive inodes;
- selecting one of the sub-regions according to a tail number of a hash value of a new file when the new file is created in the directory to allocate an inode of the selected one of the sub-regions for use by the new file;
- and
- allocating a second range comprising a plurality of consecutive inodes for use by the files in the directory when all inodes of any one of the sub-regions have been allocated for use by the files in the directory.
A non-transitory computer-readable storage medium, storing instructions for controlling a processor of a data processing device for executing an index node allocation method for speeding up a directory traversal in a directory traversal system installed in the data processing device, wherein the index node allocation method comprises:
- activating a directory order mode when a total number of inodes used by files in a directory in the directory traversal system is greater than a preset threshold value;
- allocating a first range comprising a plurality of consecutive inodes to the directory when the directory order mode is already activated, wherein each of the consecutive inodes is configured to store metadata of one of the files in the directory;
- dividing the first range into a plurality of sub-regions of consecutive inodes, wherein the files in the directory are sorted according to tail numbers of hash values of the files, and wherein the tail number of each of the files in the directory is a remainder obtained by dividing the hash value of the file by a total number of the sub-regions;
- gathering previously scattered inodes of the files into the sub-regions so that inodes of the files with the same tail number are located in the same sub-region of consecutive inodes;
- selecting one of the sub-regions according to a tail number of a hash value of a new file when the new file is created in the directory to allocate an inode of the selected one of the sub-regions for use by the new file;
- and
- allocating a second range comprising a plurality of consecutive inodes for use by the files in the directory when all inodes of any one of the sub-regions have been allocated for use by the files in the directory.
Dependencies are inferred from the claim text.