The present application claims priority to Chinese Patent Application No. 2017114774425, filed on Dec. 29, 2017 and entitled “METHOD OF USING KV STORAGE DEVICE TO PROVID FILE SYSTEM AND FILE SYSTEM THEREOF”, and Chinese Patent Application No. 2017114746603, filed on Dec. 29, 2017 and entitled “KV STORAGE DEVICE FOR PROVIDING LOGICAL KEYS AND METHOD THEREOF”, which are incorporated herein by reference in their entirety.
The present application relates to a KV storage device, and in particular, to a KV storage device and a method of using a KV storage device to provide a file system.
NAND flash memory, phase change memory, Ferroelectric RAM (FeRAM), Magnetic Random Access Memory (MRAM), Resistive Random Access Memory (RRAM), etc. are common NVMs.
The interface 103 can be adapted to exchange data with the host by means of, for example, SATA, IDE, USB, PCIE, NVMe, SAS, the Ethernet, a fiber channel and the like.
The control component 104 is configured to control data transmission among the interface 103, the NVM chip 105 and the DRAM 110, and is further configured for storage management, mapping from a logical address of the host to a physical address of the flash memory, erasure leveling, bad block management, and the like. The control component 104 can be implemented in multiple ways such as software, hardware, firmware, or a combination thereof. For example, the control component 104 may be a Field-programmable gate array (FPGA), an Application Specific Integrated Circuit (ASIC), or a combination thereof. The control component 104 may also include a processor or a controller, and the software is executed in the processor or controller to manipulate the hardware of the control component 104 to process Input/Output (IO) commands. The control unit 104 may also be coupled to the DRAM 110 and can access data of the DRAM 110. The DRAM may store an FTL table and/or cached data of the IO commands.
The control component 104 includes a flash memory interface controller (or called a media interface controller or a flash memory channel controller). The flash memory interface controller is coupled to the NVM chip 105, and issues a command to the NVM chip 105 by means of following the interface protocol of the NVM chip 105 to operate the NVM chip 105, and receives the command execution result output from the NVM chip 105. Known NVM chip interface protocols include “Toggle”, “ONFI”, and the like.
A memory target is one or more logic units (LUN, Logic UNit) sharing a Chip Enable (CE) signal in a NAND flash memory package. The NAND flash memory package may include one or more dies. Typically, the logic unit corresponds to a single die. The logic unit may include multiple planes. The multiple planes in the logic unit can be accessed in parallel, and the multiple logic units in the NAND flash memory chip can execute commands and report status independently of each other.
Data is usually stored and read on the storage medium in pages. However, the data is erased in blocks. A block (also called a physical block) includes multiple pages. The pages (called physical pages) on the storage medium have a fixed size, for example, 17,664 bytes. The physical pages may also have other sizes.
In the solid-state storage device, a Flash Translation Layer (FTL) is used to maintain mapping information from a logical address to a physical address. The logical address constitutes a storage space of the solid-state storage device as perceived by upper-layer software such as an operating system. The physical address is an address used for accessing a physical storage unit of the solid-state storage device. In the related art, an intermediate address form can also be used to implement address mapping. For example, the logical address is mapped to the intermediate address, and then the intermediate address is further mapped to the physical address.
A table structure which stores the mapping information from the logical address to the physical address is called an FTL table. The FTL table is important metadata in the solid-state storage device. Generally, data items of the FTL table record address mapping relationships in the solid-state storage device in units of data pages.
The FTL table includes multiple FTL table entries (or called table items). In one case, each FTL table entry records the corresponding relationship between one logical page address and one physical page. In another case, each FTL table entry records the corresponding relationship between multiple consecutive logical page addresses and multiple consecutive physical pages. In yet another case, each FTL table entry records the corresponding relationship between the logical block address and the physical block address. In still another case, the FTL table records the mapping relationship between the logical block address and the physical block address, and/or the mapping relationship between the logical page address and the physical page address.
In “DFTL: A Flash Translation Layer Employing Demand-based Selective Caching of Page-level Address Mappings”, an improved FTL table method and the application thereof in a solid-state storage device are disclosed, and the entire text thereof can be obtained from http://www.cse.psu.edu/˜buul/papers/ps/dftl-asplos09.pdf.
A storage device that supports a Key-Value (Key-Data, also referred to as “KV”) storage model provides a key-based read operation (Get (Key)) and write operation (Put (Key, Value)). In order to execute the write operation, the host provides a key (Key) and data (Value) to the storage device to write the data into the storage device, and takes the key as an index of the written data. In order to execute the read operation, the host provides a key to the storage device, and the storage device finds data according to the key and provides the data to the host. Therefore, in the KV storage system, the key is the index used for accessing the data, and the data (Value) is the accessed data. Generally, neither of the lengths of the key and the data is a fixed length. Moreover, optionally, in order to reduce complexity, the lengths of the key and/or the data may have a specified range.
For some KV storage devices, the length of the key provided by the host is variable, and the length of the data is also variable. The key serves as the index of the FTL table. The key is taken as an index to query the FTL table to obtain a corresponding address. The FTL table may be realized by various data structures such as arrays, link tables, and trees. Optionally, performing a hash calculation on the variable-length key to obtain a fixed-length hash key (for example, 4 bytes/8 bytes), which is taken as the index of the FTL table.
Operations provided by a KV storage device include, for example, a read operation (Get (Key)), a write operation (Put (Key, Value)), and a delete operation (Delete (Key)). However, there are other operation requirements for the data in applications, including, but not limited to, a modification operation for the key itself, copy operations for the key and its data, a query (or read) operation for the key and its data belonging to a certain range, and the like. These operations are difficult to be provided by the KV storage devices in the prior art. The file system provides mappings from, for example, file names to addresses of storage devices. By using KV storage devices, file system services can be provided more efficiently.
According to a first aspect of the present application, provided is a first method of using a KV storage device to provide a file system according to the first aspect of the present application, including: acquiring a file system path of a file system object to be accessed; acquiring a key (K) corresponding to the file system path; and accessing a value (V) corresponding to the key (K) in a KV storage device by using the key (K), wherein the value is an object corresponding to the file system path in the file system.
According to the first method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a second method of using a KV storage device to provide a file system according to the first aspect of the present application, wherein the file system maintains a sorted table, and acquires the key (K) corresponding to the file system path through the sorted table.
According to the first method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a third method of using a KV storage device to provide a file system according to the first aspect of the present application, wherein the KV storage device provides a sorted table, and the file system obtains the key (K) corresponding to the file system path by accessing the sorted table of the KV storage device.
According to the first or second method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a fourth method of using a KV storage device to provide a file system according to the first aspect of the present application, wherein the KV storage device provides the sorted table with a storage service of <key (K), value (V)>, wherein the file system path recorded in an entry of the sorted table is used as the key (K) of the KV storage device, and the key corresponding to the file system path recorded in the entry of the sorted table is used as the value (V) of the KV storage device.
According to one of the first to third methods of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a fifth method of using a KV storage device to provide a file system according to the first aspect of the present application, wherein the object of the file system includes file content and directory content; the directory content includes keys (K) and names of subdirectories contained in the directory, and keys (K) and names of files contained therein; and the method further includes: acquiring a first directory where the to-be-accessed file system object is located by means of the file system path; and accessing the directory content of the first directory from the KV storage device through the key (K) of the first directory, and acquiring the key (K) of the file system object to be accessed from the directory content of the first directory.
According to one of the first to third methods of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a sixth method of using a KV storage device to provide a file system according to the first aspect of the present application, wherein the object of the file system include file content, directory metadata, and directory attribute content; the directory metadata includes keys (K) of subdirectories contained in the directory, and keys (K) of files contained therein; the directory metadata includes names of the subdirectories contained in the directory and names of the files contained therein; and the method further includes: acquiring a first directory where the file system object to be accessed is located by means of the file system path; acquiring a key of the directory metadata of the first directory and a key of a directory attribute of the first directory through the key (K) of the first directory; and accessing the directory metadata and the directory attribute of the first directory from the KV storage device to acquire the key (K) of the file system object to be accessed.
According to the fifth or sixth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a seventh method of using a KV storage device to provide a file system according to the first aspect of the present application, wherein the object of the file system is stored in the KV storage device as the value (V).
According to the fifth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is an eighth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to creating a file in the file system, assigning a key (K) for the KV storage device to the file to be created, and recording the key (K) assigned to the file to be created and the name of the file to be created in the directory content of the first directory.
According to the fifth or eighth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a ninth method of using a KV storage device to provide a file system according to the first aspect of the present application, including in response to modifying the name of the file system object in the file system, updating the name of the file system object to be modified recorded in the directory content of the first directory.
According to the fifth, eighth or ninth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a tenth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to deleting a directory in the file system, deleting all subdirectories of the directory to be deleted, acquiring the keys (K) of all files contained in the directory to be deleted from the content of the directory of the directory to be deleted, using the acquired keys (K) to delete the corresponding file content from the KV storage device, and delete an entry corresponding to the directory to be deleted recorded in the content of the directory of the first directory.
According to one of the fifth and eighth to tenth methods of using a KV storage device to provide a file system according to the first aspect of the present application, provided is an eleventh method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to reading a file in the file system, querying an entry corresponding to the name of the file to be read in the directory content of the first directory, acquiring the key (K) of the file to be read from the entry, and reading the corresponding file content from the KV storage device according to the acquired key (K).
According to the sixth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a twelfth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to creating a file in the file system, assigning a key (K) for the KV storage device to the file to be created, recording the key (K) assigned to the file to be created in the directory metadata of the first directory, and recording the name of the file to be created in the directory attribute content of the first directory.
According to the sixth or twelfth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a thirteenth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to modifying the name of the file system object in the file system, updating the name of the file system object to be modified recorded in the directory attribute content of the first directory.
According to the sixth, twelfth or thirteenth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a fourteenth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to deleting a directory in the file system, deleting all subdirectories of the directory to be deleted, acquiring the keys (K) of all files contained in the directory to be deleted from the directory metadata of the directory to be deleted, using the acquired keys (K) to delete the corresponding file content from the KV storage device, and delete an entry corresponding to the directory to be deleted recorded in the directory metadata and the directory attribute content of the first directory.
According to one of the sixth and twelfth to fourteenth methods of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a fifteenth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to reading a file in the file system, querying an entry corresponding to the name of the file to be read in the directory attribute content and the directory metadata of the first directory, acquiring the key (K) of the file to be read from the entry, and reading the corresponding file content from the KV storage device according to the acquired key (K).
According to one of the fifth to fifteenth methods of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a sixteenth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: compared with the acquisition of the first directory, the key (K) of the file system object to be accessed is obtained first through the sorted table.
According to the sixth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a seventeenth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to modifying the name of the file system object, locking the entry corresponding to the file system path associated with the file system object to be modified in the sorted table.
According to the sixth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is an eighteenth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to modifying the name of the file system object, locking the sorted table.
According to the seventeenth or eighteenth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a nineteenth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: updating the file system path of one or more entries associated with the modified file system object recorded in the sorted table.
According to the nineteenth method of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a twentieth method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to the completion of the update of the sorted table, releasing the added lock.
According to one of the seventeenth to twentieth methods of using a KV storage device to provide a file system according to the first aspect of the present application, provided is a twenty-first method of using a KV storage device to provide a file system according to the first aspect of the present application, further including: in response to accessing the object of the file system, if the file system path of the object to be accessed is locked in the file system, accessing the first directory from the KV storage device to obtain the key (K) of the file system object to be accessed.
According to a second aspect of the present application, provided is a first file system according to the second aspect of the present application, including a program stored in a computer readable medium, wherein when the program is executed by a processor, one of the first to twenty-first method of using a KV storage device to provide a file system according to the first aspect of the present application is implemented.
According to the first file system according to the second aspect of the present application, provided is a second file system according to the second aspect of the present application, wherein the second file system is coupled to the KV storage device.
According to the first file system according to the second aspect of the present application, provided is a third file system according to the second aspect of the present application, wherein the second file system is implemented on the KV storage device.
According to a third aspect of the present application, provided is a first method for a KV storage device according to the third aspect of the present application, including: receiving a logical key (LK) for accessing a KV storage device; acquiring a physical key (PK) corresponding to the logical key (LK); and querying an address translation table to obtain an address corresponding to the physical key (PK), wherein a value (V) corresponding to the logical key (LK) is stored in the address.
According to the first method for a KV storage device according to the third aspect of the present application, provided is a second method for a KV storage device according to the third aspect of the present application, wherein a first table of the KV storage device is queried to acquire the physical key (PK) corresponding to the logical key (LK).
According to the second method for a KV storage device according to the third aspect of the present application, provided is a third method for a KV storage device according to the third aspect of the present application, wherein the first table is a sorted table.
According to the third method for a KV storage device according to the third aspect of the present application, provided is a fourth method for a KV storage device according to the third aspect of the present application, wherein the sorted table is implemented with a prefix tree.
According to one of the first to third methods for a KV storage device according to the third aspect of the present application, provided is a fifth method for a KV storage device according to the third aspect of the present application, wherein performing a hash calculation on the physical key (PK) to obtain a hash key (HPK); and accessing a hash table with the hash key (HPK) as an index, to obtain the address corresponding to the physical key (PK).
According to the fifth method for a KV storage device according to the third aspect of the present application, provided is a sixth method for a KV storage device according to the third aspect of the present application, wherein the first hash table is queried according to a first part (HPK1) of the hash key; and if the entry corresponding to the first part (HPK1) of the hash key in the first hash table records a physical address corresponding to the value (V) of the logical key (LK), first data is read from a storage medium according to the physical address.
According to the sixth method for a KV storage device according to the third aspect of the present application, provided is a seventh method for a KV storage device according to the third aspect of the present application, wherein if the entry corresponding to the first part (HPK1) of the hash key in the first hash table records the address of a second hash table, the second hash table is queried according to a second part (HPK2) of the hash key.
According to the sixth or seventh method for a KV storage device according to the third aspect of the present application, provided is an eighth method for a KV storage device according to the third aspect of the present application, wherein if the first part (HPK1) of the hash key has no corresponding entry in the first hash table, it indicates that the logical key (LK) does not exist in the KV storage device.
According to one of the sixth to eighth methods for a KV storage device according to the third aspect of the present application, provided is a ninth method for a KV storage device according to the third aspect of the present application, wherein the length of the first part (HPK1) of the hash key is less than the length of the hash key (HPK); and the length of the second part (HPK1) of the hash key is less than the length of the hash key (HK).
According to one of the sixth to ninth methods for a KV storage device according to the third aspect of the present application, provided is a tenth method for a KV storage device according to the third aspect of the present application, wherein the first data is stored at the address; a first key (Kp) is acquired from the first data; and if the first key (Kp) matches the logical key (LK) or the physical key (K), the value (V) acquired from the first data is adopted to respond to the logical key (LK) used to access the KV storage device.
According to the seventh method for a KV storage device according to the third aspect of the present application, provided is an eleventh method for a KV storage device according to the third aspect of the present application, further including: if the entry corresponding to the second part (HPK2) of the hash key in the second hash table records the physical address corresponding to the value (V) of the logical key (LK), the second data is read from the storage medium according to the physical address.
According to one of the seventh to eleventh methods for a KV storage device according to the third aspect of the present application, provided is a twelfth method for a KV storage device according to the third aspect of the present application, further including: acquiring the length of the first key (Kp) from the entry corresponding to the first part (HPK1) of the hash key in the first hash table, and comparing the length of the first key (Kp) with the length of the logical key (LK) or the physical key (K) to identify whether or not the first key (Kp) matches the logical key (LK) or the physical key (K).
According to one of the first to twelfth methods for a KV storage device according to the third aspect of the present application, provided is a thirteenth method for a KV storage device according to the third aspect of the present application, wherein in response to writing the value (V) corresponding to the logical key (LK) into the KV storage device, if the physical key (PK) corresponding to the logical key (LK) is not found in the first table, the physical key (PK) is assigned to the logical key, an entry is added to the first table to record that the logical key (LK) corresponds to the assigned physical key (PK), and an address is assigned to the assigned physical key (PK); and an entry is added to the address translation table to record the physical key (PK) and the assigned address, and the value (V) corresponding to the logical key (LK) is written at the assigned address.
According to the thirteenth method for a KV storage device according to the third aspect of the present application, provided is a fourteenth method for a KV storage device according to the third aspect of the present application, wherein in response to instructing the KV storage device to modify the logical key (LK), an entry corresponding to the logical key (LK) is found in the first table, and the entry is modified to record the modified new logical key.
According to the fourteenth method for a KV storage device according to the third aspect of the present application, provided is a fifteenth method for a KV storage device according to the third aspect of the present application, wherein if the entry corresponding to the logical key (LK) is not found in the first table, it indicates that an error occurs.
According to one of the thirteenth to fifteenth methods for a KV storage device according to the third aspect of the present application, provided is a sixteenth method for a KV storage device according to the third aspect of the present application, wherein in response to instructing the KV storage device to copy the value (V) corresponding to the logical key (LK), a first physical key (PK) corresponding to the logical key (LK) is found in the first table, and an entry is added to the first table to record that the new logical key corresponds to the first physical key (PK).
According to one of the thirteenth to sixteenth methods for a KV storage device according to the third aspect of the present application, provided is a seventeenth method for a KV storage device according to the third aspect of the present application, wherein in response to instructing the KV storage device to read all values of a logical key range (LK_R), the physical key (PK) corresponding to one or more logical keys (LK) falling within the logical key range (LK_R) is found in the first table; and for each obtained physical key (PK), the address translation table is queried to obtain the address corresponding to the physical key (PK), and the value (V) corresponding to the logical key (LK) is read from the address.
According to a fourth aspect of the present application, provided is a first KV storage device according to the fourth aspect of the present application, including a control component and a non-volatile storage medium, wherein the control component executes the first to seventeenth methods for a KV storage device according to the third aspect of the present application.
According to the fifth aspect of the present application, provided is a first method for a KV storage device according to fifth aspect of the present application, including: receiving a key (K) for accessing a KV storage device; acquiring a sorted index for the key (K); acquiring a first hash table from a sorted table according to the sorted index; hashing the key to obtain a hash key (HK); querying the first hash table according to a first part (HK1) of the hash key; and if an entry corresponding to the first part (HK1) of the hash key in the first hash table records a physical address of a value (V) to be accessed by a read operation, reading first data from a storage medium according to the physical address.
According to the first method for a KV storage device according to the fifth aspect of the present application, provided is a second method for a KV storage device according to the fifth aspect of the present application, wherein the sorted index is acquired from a request for accessing the KV storage device, the sorted index is generated from the key (K), or the sorted index is assigned to the key (K).
According to the first or second method for a KV storage device according to the fifth aspect of the present application, provided is a third method for a KV storage device according to the fifth aspect of the present application, further including: to write the value (V) corresponding to the key (K) to the KV storage device, if the sorted index does not exist in the sorted table, adding an entry to the sorted table to record the sorted index and the address of a newly created first hash table, and recording the first part (HK1) of the hash key and the logical address or physical address assigned for recording the value (V) in the newly created first hash table.
According to one of the first to third methods for a KV storage device according to the fifth aspect of the present application, provided is a fourth method for a KV storage device according to the fifth aspect of the present application, further including: in response to instructing the KV storage device to read all values of a key range (K_R), acquiring the sorted index for the key range (K_R); acquiring one or more first hash tables falling within the key range (K_R) from the sorted table according to the sorted index; and for each first hash table, acquiring each entry of the first hash table, and if the entry records the physical address of a value (V) to be accessed, reading the first data from the storage medium according to the physical address.
According to the fourth method for a KV storage device according to the fifth aspect of the present application, provided is a fifth method for a KV storage device according to the fifth aspect of the present application, wherein for each first hash table, the first hash table is queried according to a first part (HK1) of the hash key (HK) matching the key range (K_R); and if the entry corresponding to the first part (HK1) of the hash key in the first hash table records the physical address corresponding to the value (V) to be accessed by a read operation, the data is read from the storage medium according to the physical address.
According to a sixth aspect of the present application, provided is a first KV storage device according to the sixth aspect of the present application, including a control component and a non-volatile storage medium, wherein the control component executes the first to fifth methods for a KV storage device according to the fifth aspect of the present application.
To describe the technical solutions in the embodiments of the present application or in the prior art more clearly, the accompanying drawings required for describing the embodiments or the prior art are briefly introduced below. Apparently, the accompanying drawings in the following description show merely some embodiments recited in the present application, and a person of ordinary skill in the art can also derive other accompanying drawings from these accompanying drawings.
The technical solutions in the embodiments of the present application are clearly and fully described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are merely some of the embodiments of the present application, but not all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by a person skilled in the art without involving an inventive effort shall fall within the scope of protection of the present application.
According to the storage device in the embodiment of the present application, two types of keys are provided or used to provide more data operation capabilities. The two types of keys used are called logical keys and physical keys, and the latter is also referred to as “keys” for short if there is no confusion. The logical keys correspond one-to-one to the physical keys. As an example, the logical key is, for example, a web page address (such as, www.abc.com/foo.html), a path of a file system (such as, /root/dirl/a.txt), or a logical address in a storage protocol of the prior art (such as, NVMe Protocol). Moreover, the physical key is in the form of a key that is convenient for the storage device to process. For example, the physical key is a Universally Unique Identifier (UUID) having a specified length. Preferably, the physical key has a designated length. As another example, the physical key is the result of hashing the logical key. Still optionally, the physical key is a key used by a KV storage device in the prior art. The Chinese patent application with application No. 201711392 529.2 provides a KV storage device, which is incorporated in the present application in its entirety.
Referring to
The sorted table records the corresponding relationship between the logical keys and the physical keys (marked as “keys” in
The KV FTL records the corresponding relationship between the physical keys (marked as “keys” in
According to the KV storage device of the embodiment of
Optionally, according to the KV storage device of the embodiment of the present application, in addition to providing the host with an operation interface similar to the KV storage device in the prior art (for example, read operation (Get (logical key)), write operation (Put (logical key, Value)) and/or delete operation (Delete (logical key))), operations such as accessing the physical key are further provided, for example, reading the physical key (GetKey (logical key), in response to this operation, the KV storage device outputs the physical key corresponding to the logical key recorded in the sorted table).
The KV storage device according to the embodiment shown in
The operation interface provided by the KV storage device according to the embodiment shown in
If the logical key (LK) already exists in the sorted table (322), the sorted table is queried to obtain the physical key (PK) corresponding to the logical key (LK), and the data (V) corresponding to the queried physical key (PK) is updated (329).
To update the data (V) corresponding to the physical key (PK) (329), for example, to assign a new physical address to the queried physical key (PK), the queried physical key (PK) and the newly assigned physical address are recorded in the KV FTL, and the data (V) is written to the assigned new physical address. Optionally, a new logical address is assigned to the queried physical key (PK), and the value of the assigned new logical address is updated to the data (V) to be written according to the update approach of the storage device in the prior art. Still optionally, according to the update approach of the KV storage device in the prior art, the corresponding data (V) is written to the newly generated physical key (PK).
If the unmodified logical key (LK_S) exists in the sorted table (332), the unmodified logical key (LK_S) in the sorted table is updated to the modified logical key (LK_D) (334).
If the logical key (LK_S) to be copied exists in the sorted table (352), a physical key (PK) corresponding to the logical key (LK_S) to be copied is acquired from the sorted table; a new sorted table entry is generated, which records the corresponding relationship between the new logical key (LK_D) and the acquired physical key (PK) corresponding to the logical key (LK_S) to be copied; and the newly generated sorted table entry is added to the sorted table (354). Moreover, optionally, the newly generated sorted table entry is added to the sorted table, and the entries in the sorted table are still sorted according to logical keys.
In one implementation mode, the processes shown in
Referring to
The sorted table includes multiple entries, and each entry records the corresponding relationship between the sorted index and a base address of one of the L1 hash tables. The multiple entries of the sorted table are sorted according to the sorted index. Therefore, according to the sorted index or its prefix, the corresponding L1 hash table can be queried from the sorted table quickly and efficiently.
In one implementation mode, the KV storage device according to the embodiment of
According to the embodiment of
Take a host issuing a read operation interface command (Get (key, sorted index)) to a KV storage device as an example. To read data corresponding to the same key (K), the host acquires the key (K) (410) to be read, generates a sorted index corresponding to the key (K) or acquires the sorted index (SK) corresponding to the same key (K) (415), and issues a read operation interface command to the KV storage device. The key (K) and the sorted index (SK) are indicated in the read operation interface command.
The KV storage device receives the key (K) and the sorted index (SK) (420) in the read operation interface command, queries a sorted table by using the sorted index (SK), and obtains a corresponding L1 hash table according to the obtained L1 hash table address (425). Moreover, the L1 hash table is queried using the key in the read operation interface command to obtain a corresponding logical address or physical address (430), which is used to access the storage device. Data is read from the logical address/or physical address, and is provided to the host as a response to the read operation interface command. Optionally, the L1 hash table is the FTL of a KV storage device in the prior art.
As another example, the host sends a write operation interface command (Put (key, sorted index, data)) to the KV storage device. The host acquires the key (K) to be read, and generates a sorted index for the key (K) or acquires a sorted index corresponding to the key (K). And the host provides the key (K) and the sorted index (SK) to the KV storage device by using the write operation interface command. The KV storage device receives the key and the sorted index in the write operation interface command, queries the sorted table by using the sorted index, and obtains the corresponding L1 hash table according to the obtained L1 hash table address. Moreover, said device queries the L1 hash table by using the key in the write operation interface command to obtain the corresponding logical address or physical address, and writes the data indicated by the write operation interface command thereto. If a record corresponding to the sorted index is not found in the sorted table, or a record corresponding to the key is not found in the L1 hash table, it indicates that the key to be written does not exist in the KV storage device, and the record corresponding to the sorted index is added to the sorted table, and the record corresponding to the key is added to the L1 hash table. Moreover, when needed, a new L1 hash table is also generated.
In another implementation mode, the operation interface command provided by the KV storage device according to the embodiment of
The host sends the key range (also denoted as K_R) to be accessed and the sorted index (SK) to the KV storage device. The KV storage device accesses the sorted table according to the sorted index (SK), and obtains addresses of one or more L1 hash tables therefrom (470). For example, according to the node hit by the sorted index (SK), the L1 hash table addresses recorded by all the child nodes of the node in the sorted table are obtained. For each acquired hash table, the logical addresses or physical addresses recorded in all the entries matching the key range (K_R) are acquired therefrom (480), and the logical addresses or physical addresses are accessed, from example, reading data therefrom. In one example, the L1 hash table is traversed to obtain each key therein, and the logical addresses or physical addresses are obtained from the entries matching the same key range (K_R).
An NVM chip of the KV storage device (also refer to
Taking physical pages as an example, the data block shown in
For example, the physical page indicated by “header 1” in
Optionally, multiple <key, value> pairs are recorded in the physical page. Take the physical page indicated by “header 2” as an example, wherein “key 2” and “value 2” recorded therein are a pair, and “key 3” and “value 3” are another pair. Moreover, each pair of <key 2, value 2> and <key 3, value 3> is addressed according to “header 2”.
Still optionally, if the sum of the lengths of the header field, key (Key) and value (Value) of a physical page (such as the physical page indicated by “header 3” in
The physical pages indicated by “header 4” and “header 5” are physical pages with consecutive physical addresses, and key 5 and “value 5” are the key (Key) and value (Value) provided by the host when writing data. Because “value 5” exceeds the capacity value of the physical page, the physical page indicated by “header 4” records key 5 and a part of value 5 provided by the host. The remaining part of “value 5” is recorded in the physical page indicated by “header 5”. “Header 4” and “header 5” of the header field are used to indicate the starting addresses and/or lengths of “key 5” and “value 5” in the physical page. Optionally, the number of physical pages occupied (the number is 2) is also recorded in the header field.
Optionally, still referring to the physical pages indicated by “header 4” and “header 5” in
Continuing to refer to
In an alternative implementation mode, the key (K) provided by the host or the user is taken as RK, and a sorted index (SK) corresponding to RK is additionally obtained or generated. For example, a part of RK is intercepted as the sorted index (SK). In this implementation mode, RK is the same as the key (K).
Still referring to
The sorted table includes multiple entries, and each entry records the corresponding relationship between the sorted index (SK) and the base address of one of the L1 hash tables. The multiple entries of the sorted table are sorted according to the sorted index. Therefore, according to the sorted index or its prefix, the corresponding L1 hash table can be queried from the sorted table quickly and efficiently.
One or more L1 hash tables are provided. The L1 hash table is indexed by a part HRK1 of the hash key (HRK). For example, entries of the L1 hash table are obtained by taking HRK1 as an offset value in the L1 hash table. The entries of the L1 hash table record the logical addresses/physical addresses of the data blocks or the addresses of a conflict table.
One or more conflict tables are provided. The entries of the L1 hash table record the addresses of the conflict tables, so that the conflict tables can be addressed according to the entries of the L1 hash table. (Each) conflict table is indexed by a key (K). The entries of the conflict table record the physical page (or data unit) addresses of the data blocks.
In an alternative implementation mode, one or more L2 hash tables are provided. The entries of the L1 hash table optionally record the addresses of the L2 hash table, so that the L2 hash table can be addressed according to the entries of the L1 hash table. (Each) L2 hash table is indexed by a part HRK2 of the hash key (HRK). For example, entries of the L2 hash table are obtained by taking HRK2 as an offset value in the L2 hash table. The entries of the L2 hash table record the physical addresses/logical addresses of the data blocks or the addresses of the conflict table.
Each entry of the conflict table is indexed by a sorted index (SK), and the value of the entry is the address of the L1 hash table. As an example, the sorted index (SK) is used as an index to access the sorted table, to obtain a sorted table entry that matches the sorted index (SK). Referring to
A designed hash calculation is performed on RK to obtain a hash key (HRK). Each entry of the L1 hash table is indexed by a part (HRK1) of the hash key (HRK), and the value of the entry is the logical address/physical address of the data block or the conflict table address. As an example, the entry of the L1 hash table is accessed by taking HRK1 as the address or offset value. If the entry of the L1 hash table records the physical address/logical address of the data block, the address indicates the storage location of a <key (K), data (V)> pair in an NVM storage medium.
Understandably, the index HRK1 of the L1 hash table is different from the hash key (HRK). Moreover, HRK1 is not in a one-to-one correspondence to the hash key (HRK), but multiple hash keys (HRK) can all correspond to the same HRK1. Therefore, according to the <key (K), data (V)> accessed by HRK1 from the physical address/logical address of the data block indexed by the L1 hash table, there is a certain probability that it does not correspond to the RK that is accessed by the host/user and is used to generate the hash key (HRK), resulting in the occurrence of an error. In some cases, the probability of occurrence of such an error is extremely small, and this error can be accepted by the technical standards followed by users or solid-state storage devices. In other cases, this error cannot be accepted, and it is also necessary to compare whether the key (K) accessed from the physical address/logical address of the data block indexed by the L1 hash table is the same as the combination of the RK to be accessed by the user and the sorted index (SK) to identify whether the error has occurred.
If the entry of the L1 hash table records a conflict table address, the address indicates the location of one of the conflict tables associated with the entry in a memory. Therefore, the entry of the conflict table is also associated with HRK1.
For example, referring to
Each entry of the conflict table is indexed by RK, and the value of the entry is the physical address/logical address of the data block.
According to the embodiment shown in
Optionally, the L1 hash table has a designated size (for example, 1 KB-4 MB), and the number of entries in the conflict table is not limited. Still optionally, the sizes of the L1 hash table and the conflict table are selected to make the tables easy to be accessed by an operating system or a Memory Management Unit (MMU), and/or easy to be stored in an NVM storage medium.
In a still alternative implementation mode, the solid-state storage device includes multiple address translation systems as shown in
According to
The sort index (SK) is used to query the sort table, to obtain a corresponding L1 hash table according to the obtained L1 hash table address. (720) Moreover, a part HRK1 of the hash key (HRK) obtained from a read operation interface command is used to query the L1 hash table (725). If there is no entry corresponding to the hash key part HRK1 in the L1 hash table, it indicates that the key (K) corresponding to the read operation interface command does not exist.
The L1 hash table entry obtained using HRK1 is accessed. If the L1 hash table entry indicates that there is no conflict (730), then the logical address or physical address is recorded in the L1 hash table entry, the logical address or physical address is accessed (739), and the read data is regarded as the data corresponding to the same key (K). Optionally, the key (Kp) is also acquired from the read data, and it is compared whether the key (Kp) is the same as the key (K). If the key (Kp) is the same as the key (K), the value stored in association with the key (Kp) in the NVM storage medium is the value corresponding to the same key (K), and the value is taken as the result of the read operation. If the key (Kp) is different from the key (K), then the value stored in association with the key (Kp) in the NVM storage medium is not the value corresponding to the same key (K), thus it indicates that the value corresponding to the same key (K) does not exist in the solid-state storage device.
If the L1 hash table entry obtained by HRK1 indicates that there is a conflict (730), what is recorded in the L1 hash table entry is the address of the conflict table, the conflict table is acquired using this address, and the conflict table is inquired using RK (735) to obtain the conflict table entry. The logical address or physical address is recorded in the conflict table entry, the logical address or physical address is accessed (737), and the read data is regarded as the data corresponding to the same key (K). Optionally, the key (Kp) is also acquired from the read data, and it is compared whether the key (Kp) is the same as the key (K). If the key (Kp) is the same as the key (K), the value stored in association with the key (Kp) in the NVM storage medium is the value corresponding to the same key (K), and the value is taken as the result of the read operation. If the key (Kp) is different from the key (K), then the value stored in association with the key (Kp) in the NVM storage medium is not the value corresponding to the same key (K), thus it indicates that the value corresponding to the same key (K) does not exist in the solid-state storage device.
In an alternative implementation model, the index of the conflict table is the key (K), and in step 735, the conflict table is queried using the key (K).
According to
The sorted table is accessed according to the sorted index (SK) to obtain addresses of one or more L1 hash tables therefrom (750). For example, according to the node hit by the sorted index (SK), the L1 hash table addresses recorded by all the child nodes of the node in the sorted table are obtained. For each acquired L1 hash table, the hash key part HSK1 corresponding to all keys (K) matching the same key range (K_R) is used to access the L1 hash table (755) to obtain a hash table entry.
For each entry obtained from each L1 hash table, it is identified whether there is a conflict (760). If the L1 hash table entry indicates that there is no conflict (760), the logical address or physical address is recorded in the L1 hash table entry, the logical address or physical address is accessed (769), and the read data is taken as the same key (K). If the L1 hash table entry indicates that there is a conflict (760), the address of the conflict table is recorded in the L1 hash table entry, a conflict table is acquired using the address, RK corresponding to the hash key part HRK1 that hits the entry of the L1 hash table is used to the conflict table (765) to obtain the conflict table entry. The logical address or physical address is recorded in the conflict table entry, the logical address or physical address is accessed (737), and the read data is regarded as the data corresponding to the same key (K).
In one example, as an alternative to step 755, each L1 hash table is traversed to obtain a part key HRK1 recorded by each entry therein, and the logical address or physical address is acquired from the entry where the component key HRK1 that matches the key range (K_R) is located. If the entries of the L1 hash table conflict, the logical address/physical address is obtained from all the entries recorded in the corresponding conflict table, and the data is read.
In another example, as an alternative to step 755, each L1 hash table is traversed to acquire all the entries therein, and physical addresses/logical addresses or the physical addresses/logical addresses in all the entries of the conflict table corresponding thereto are acquired from each L1 hash table entry. Moreover, data is acquired from the physical address/logical address as a response to the range query operation interface command.
According to
The sorted index (SK) is used to query a sorted table (774). If there is no entry in the sorted table that matches the sorted index (SK) (776), a new L1 hash table is created, a new entry that matches the sorted index (SK) is added to the sorted table, and a base address of the newly created L1 hash table is recorded in a new sort table entry. Moreover, a physical address/logical address is assigned for the data to be written, and a record is added to the newly created L1 hash table. The added record is indexed by a part HSK1 of the hash key (HSK), and takes the assigned physical address/logical address as a value (778). The data corresponding to the write operation interface command is also written to the assigned physical address/logical address.
If the sorted index (SK) matches the entry of the sorted table (776), the base address of the L1 hash table is acquired from the matched entry, and the hash key part HRK1 is used to query the L1 hash table (780).
If there is no entry corresponding to the hash key part HRK1 in the L1 hash table (782), it indicates that the key (K) corresponding to the write operation interface command does not exist. The L1 hash table is updated (784), an entry is added to the L1 hash table, the added entry is indexed by the hash key part HRK1, and the assigned physical address/logical address is recorded in the entry. Moreover, data is written to the newly assigned physical address/logical address.
If a partial key HRK1 exists in the L1 hash table (782), whether the partial key HRK1 conflicts in the L1 hash table is further identified (786). If there is no conflict, the data is written to the newly assigned physical address/logical address; the address recorded in the L1 hash table entry indexed by the partial key HRK1 is updated to the newly assigned physical address/logical address (788); and if the partial key HRK1 has a conflict in the L1 hash table (786), the address of the conflict table is acquired according to the L1 hash table entry indexed by the partial key HRK1, and the conflict table is queried using RK (790). If an entry indexed by RK is found in the conflict table (792), the entry is updated with the assigned physical address/logical address (796). If the entry indexed by RK does not exist in the conflict table (792), an entry that is indexed by RK and uses the assigned physical address/logical address as a value is added to the conflict table (794).
A host is coupled with a KV storage device. The KV storage device provides a key (K)-based access interface to the host. The KV storage device is, for example, a KV storage device in the prior art, or a KV storage device according to an embodiment of the present application. The host includes a file system configured to use the KV storage device and provide a file system service to a user or an application.
The file system uses a file system path to describe a file or a directory. Moreover, file system services such as reading a file, writing a file, deleting a file, creating a directory, deleting a directory, and modifying a path are provided. The file system provides file system interfaces. The file system interfaces include, for example, a read file interface, a write file interface, a create file interface, a delete file interface, a file rename interface, a create directory interface, a delete directory interface, directory rename interface, a copy file or directory interface, a create file or directory link interface, and the like. The file system is accessed through the file system interface.
Optionally, the file system is provided by the KV storage device. For example, a program that implements the file system is run on a CPU of the KV storage device, and a file system interface is provided to the host coupled to the KV storage device.
Taking the file system path of the file as an example, said path includes a full path and file name of a directory where the file is located. The full path and file name of the directory where the file is located are stitched to obtain the file system path for the file. For the directory, the file system path thereof is the full path of the directory. Both the directory and the file are objects of the file system. The file system includes a unique root directory.
For example, the root directory is denoted as “/”, the file system path of the directory starts with the root directory and includes the path of parent directories at all levels of the directory. The directory with the file system path being “/abc” is a subdirectory of a root directory “/”. The directory with the file system path being “/abc/hello” is a subdirectory of the subdirectory “abc” of the root directory “/”.
According to the embodiment of
As an example, the sorted table is provided by the host as a part of the file system. The file system uses the file system path to query the sorted table, to obtain the key (or UUID) corresponding to the file system path, and uses the key to access the KV storage device.
A value (V) corresponding to the key (K) is recorded in the KV storage device. For the key obtained through the file system path of the file, the value thereof is the content of the file. Optionally, the value also includes attribute information of the file. Still optionally, for the key (K) obtained through the file system path of the file, two or more keys (such as, K and K−1) are generated. In the KV storage device, the value corresponding to the file is obtained through the key (K), and the attribute information corresponding to the same file is obtained through the key (K−1). For the key obtained through the file system path of the directory, the value recorded in the KV storage device is the content of the directory, including, for example, attribute information including file names or directory names of all files and subdirectories in a directory that is this directory.
The KV storage device records the key (K) and the corresponding value (V). The key is, for example, UUID, and the value is file content or directory content. For example, the value corresponding to the key UUID100 is the content of the root directory, the value corresponding to the key UUID 101 is the content of subdirectory 1, the value corresponding to UUID200 is the content of file 1, and the value corresponding to the key UUID201 is the content of file 2.
The content of the root directory is the value corresponding to the key UUID100 recorded in the KV storage device. The content of the root directory includes multiple records, and each record describes the attribute information including file names or directory names of all files and subdirectories in a directory that is the root directory. The content of the root directory in
Understandably, for each subdirectory and each file contained in the root directory, a corresponding record is provided in the content of the root directory. The content of the directory “dummy” is the value corresponding to the key UUID 101 recorded in the KV storage device. The content of the root directory includes multiple records, and each record describes the attribute information including file names or directory names of all files and subdirectories in a directory that is this subdirectory. The content of the subdirectory “dummy” in
Understandably, for each subdirectory and each file contained in the subdirectory “dummy”, a corresponding record is provided in the content of the subdirectory.
In step 1112, if the directory does not exist, the file system indicates to the user or the application that an error occurs (1119) because the directory to be accessed does not exist. If the directory exists, the UUID of the directory is obtained, and the UUID is used to access the KV storage device to obtain the directory content (1114). The file name of a file to be read is used to search for records in the directory content obtained in step 1114 to identify whether a record associated with the file name of the file to be read is recorded in the directory content (1116). If the file to be read is not found in step 1116, it is indicated to the user or the file system that the file to be read does not exist (1119). If the record corresponding to the file to be read is found in step 1116, the UUID of the file to be read is obtained from the records, and the UUID is used to read the KV storage device, so as to read the content of the file to be read (1118).
A file modification service provided by the file system is processed in a similar process as shown in
A file creation service provided by the file system is processed in a similar process as shown in
If the directory content to be deleted indicates that the directory to be deleted also includes subdirectories and/or files, each subdirectory and file is deleted (1167). For example, to delete the subdirectories, the process from step 1160 is repeated; and to delete the files, the process shown in
The file renaming service is implemented in a manner similar to that in
The KV storage device records the key (K) and the corresponding value (V). The key is, for example, UUID, and the value is file content, directory metadata content, or directory attribute content. For example, the value corresponding to the key UUID 100 is metadata content of a root directory, the value corresponding to the key UUID 101 is the metadata content of subdirectory 1, the value corresponding to UUID 200 is the content of file 1, the value corresponding to the key UUID 201 is the content of file 2, the value corresponding to the key UUID 101+P is the attribute of subdirectory 1, and the value corresponding to UUID 200 is the attribute of file 1. According to the embodiment of
The metadata content of the root directory is the value corresponding to the key UUID 100 recorded in the KV storage device. The root directory metadata content includes multiple records, and each record describes each key (UUID) of all files and subdirectories of the directory that is the root directory. The metadata content of the root directory in
In the directory metadata according to the embodiment of
Understandably, for each subdirectory and each file contained in the root directory, a corresponding record is provided in the metadata content of the root directory.
The metadata content of the directory “dummy” is the value corresponding to the key UUID 101 recorded in the KV storage device. The directory metadata content includes multiple records, and each record describes each UUID of all files and subdirectories where the directory is located. The metadata content of the subdirectory “dummy” in
The directory attribute content of the directory “dummy” is the value corresponding to, for example, the key UUID 101 recorded in the KV storage device. The directory attribute content records its own name (“dummy”), its own type “directory”, its own related attributes, creation date, permissions, and the like. Optionally, the directory attribute content also records the UUIDs (UUID list) of the directories where one or more links pointing to itself are located in the file system. Optionally, in the directory attribute content, the name of the directory where the user is located is also recorded.
Optionally, there is no need to record the corresponding UUID in each entry of the directory attribute content, and the corresponding UUID is obtained by jointly querying the directory metadata content. For example, the records in the directory metadata content correspond one-to-one to the entries in the directory attribute content in order; thus the corresponding record in the directory metadata content is accessed according to the serial number of the record of the directory attribute content to obtain the corresponding UUID.
According to the file system shown in
To read a file from the file system according to the embodiment of
To identify whether the directory exists, the file system obtains the metadata content of the parent directory of the directory, and obtains the UUIDs of all objects contained in the parent directory from the metadata content of the parent directory. Moreover, the key (UUID+P) of the attribute content of the corresponding object is generated for each UUID, UUID+P is used to access the KV storage device to obtain the attribute content of the corresponding object, and whether the attribute content is the attribute content of the directory whose existence is to be identified is identified from the attribute content. If the attribute content of the directory whose existence is to be identified is found, it is determined that the directory exists. If the directory whose existence is to be identified is still not found even the attribute content of all the objects contained in the parent directory is traversed, it is determined that the directory does not exist.
Moreover, starting from the root directory, whether the parent directories of the directory to be accessed exist is identified by searching for the attribute content of the objects contained in the parent directories of the directory where the file is located step by step. The UUID of the root directory is, for example, known.
If the directory where the file to be accessed is located does not exist, the file system indicates to the user or the application that an error occurs because the file to be accessed does not exist. If the directory where the file to be accessed is located exists, the UUIDs of all the objects contained in the directory are acquired, and the key (UUID+P) of the attribute content of the corresponding object is generated for each UUID, the UUID+P is used to access the KV storage device to obtain the attribute content of the corresponding object, and whether the attribute content is the attribute content of the file to be accessed is identified from the attribute content.
If the attribute content of the file to be accessed is found, the UUID of the file to be accessed is obtained, and the KV storage device is accessed according to the UUID of the file to be accessed to read the content of file to be read.
To delete a file from the file system according to the embodiment of
If the directory where the file to be accessed is located does not exist, the file system indicates to the user or the application that an error occurs because the file to be accessed does not exist. If the directory where the file to be accessed is located exists, the UUIDs of all the objects contained in the directory are acquired, and the key (UUID+P) of the attribute content of the corresponding object is generated for each UUID, the UUID+P is used to access the KV storage device to obtain the attribute content of the corresponding object, and whether the attribute content is the attribute content of the file to be deleted is identified from the attribute content.
If the attribute content of the file to be deleted is found, the UUID of the file to be deleted is obtained, and the KV storage device is accessed according to the UUID of the file to be deleted to delete the content of file to be read.
To rename a directory from the file system according to the embodiment of
If the parent directory does not exist, the file system indicates to the user or application that an error occurs. If the parent directory exists, the UUIDs of all the objects contained in the parent directory are acquired, and the key (UUID+P) of the attribute content of the corresponding object is generated for each UUID, the UUID+P is used to access the KV storage device to obtain the attribute content of the corresponding object, and whether the attribute content is the attribute content of the file to be renamed is identified from the attribute content.
If the attribute content of the directory to be renamed is found, the file name recorded therein is modified to the new file name to complete the directory renaming operation.
According to the embodiments described above, those skilled in the art would easily obtain the implementation mode of performing operations, such as file modification, link creation, link deletion, directory creation, directory deletion, and directory content listing, by the file system according to the embodiment of
Referring to
A sorted table is further maintained in the host running the file system, and the sorted table records the corresponding relationship between any file system path existing in the file system and the key (for example, UUID) used for the KV storage device. Through the sorted table, the file system path serving as the logical key is mapped to the key (UUID). Therefore, to access the file system (file content, directory metadata content, directory attribute content or file attribute content), according to the file system path, the UUID corresponding to the file system path can be quickly searched from the sorted table, the UUID corresponding to the file system path can be quickly queried from the sorted table according to the file system path to find the directory where the target object to be accessed located without traversing the file system, and the directory is further traversed to obtain the process of obtaining the UUID of the object to be accessed. According to the file system path of the object to be accessed, the file system path of the directory where the object to be accessed is located can also be easily obtained, and the UUID corresponding to the file system path of the directory where the object to be accessed is located can also be quickly obtained from the sorted table. The sorted table is maintained by the host running the file system. The file system accesses the KV storage device according to the acquired UUID, in order to access the file content, directory attribute content, or file attribute content of the accessed file system.
Furthermore, for operations that cause modification of the file system path (such as, file or directory renaming), a flag (for example, locking) is set for the sorted table to indicate that the sorted table node corresponding to the modified file or directory is to be modified, and also to indicate the sorted table nodes corresponding to all the sub-directories of the directory to be modified. When accessing the sorted table, if the visited node is set with a flag, the file system is traversed according to the to-be-accessed file system path according to the method shown in the embodiment of
In one implementation mode, the KV storage device provides a sorted table service that can be accessed by the file system of the host. The file system path is used as the key to access the KV storage system (or the key of the sorted table service), and the UUID of the node in the accelerator table is used as the value of the KV storage system (or the value corresponding to the file system path provided by the sorted table service).
The file system running on the host accesses the sorted table by means of the KV storage device. To access the file system (file content, directory metadata content, directory attribute content or file attribute content), the file system path is provided to the sorted table service of the KV storage device. The sorted table service of the KV storage device outputs the UUID corresponding to the file system path as a response, thereby finding the directory where the target object to be accessed is located without traversing the file system, and the directory is further traversed to obtain the process of obtaining the UUID of the object to be accessed.
The file system running on the host accesses the file content, directory metadata content, directory attribute content, or file attribute content in the manner provided in the embodiment shown in
Furthermore, in response to the operation of creating a file or creating a directory, the file system further adds an entry to the sorted table, and the added entry records the corresponding relationship between the file system path of the created file or directory and the newly assigned UUID. The UUID may be assigned by the file system or the KV storage device.
Furthermore, in response to the operation of writing a file, the file system acquires the UUID corresponding to the file system path from the sorted table, and updates the value corresponding to the UUID in the KV storage device. Moreover, optionally, the attribute information of the updated file corresponding to, for example, “UUID+P” recorded in the KV storage device is further updated.
Still furthermore, in response to the operation of modifying the file name, the file system further modifies the entry in the sorted table to find an entry corresponding to the file system path corresponding to the unmodified file name from the sorted table, and updates the file system path thereof.
Still furthermore, in response to the operation of modifying the directory name, the file system modifies the entries in the sorted table corresponding to the modified directory, and further modifies the entries of all objects contained in the modified directory in the sorted table. For example, for the subdirectory “dummy!” of the root directory, the full path is “/dummy”, which includes a subdirectory “dummy1/” and a file “dummy1.txt”. In response to the name of the subdirectory “dummy!” being modified to “dummyNew!”, in addition to modifying its own records in the sorted table, the records of the subdirectory “dummy1/” and the file “dummy1.txt” in the sort table are also modified, because the file system path has changed. Because there are lots of entries to be modified in the sorted table, a period of time is required for processing, and before the modification is completed, the sorted table does not respond to the access to the modified entries. For example, in response to an entry of a sorted table to be modified, the sorted table is locked, or the modified entry of the sorted table is locked, thereby preventing access to the entry of the sorted table that is being modified. Moreover, the file system traverses the file system (the directory metadata content and directory attribute content) according to the to-be-accessed file system path according to the method shown in the embodiment of
In another implementation mode, the KV storage device provides a sorted table service in the form of <key, value>. The file system path of the entry in the sorted table is used as the key to access the KV storage system, and the UUID of the entry in the sorted table is used as the value of the KV storage system.
Still optionally, the KV storage device implements the sorted table by using a prefix tree.
According to the embodiments of the present application, further provided is a solid-state storage device. The device includes a controller and a non-volatile memory chip, wherein the controller executes any one of the processing methods provided by the embodiments of the present application.
According to the embodiments of the present application, further provided is a program stored on a readable medium, wherein when the program is run by a controller of a solid-state storage device, the solid-state storage device executes any one of the processing methods according to the embodiments of the present application.
Although the preferred embodiments of the present application have been described, those skilled in the art benefiting from the underlying inventive concept can make additional alterations and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as encompassing the preferred embodiments and all the alterations and modifications falling within the scope of the present application. Apparently, those skilled in the art can make various changes and variations to the present application without departing from the spirit and the scope of the present application. In this way, if these changes and variations of the present application fall within the scope of the claims of the present invention and equivalent technologies thereof, the present application is also intended to include these changes and variations.
Number | Date | Country | Kind |
---|---|---|---|
201711474660.3 | Dec 2017 | CN | national |
201711477442.5 | Dec 2017 | CN | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2018/093285 | 6/28/2018 | WO | 00 |