Method and device for operating namespace of solid state disk and electronic equipment
By determining unused logical units in the solid-state drive and associating them with the namespace, the problem of low logical space utilization caused by discontinuity of logical addresses is solved, and efficient utilization of creating namespaces under discontinuity is achieved.
Patent Information
- Application Number
- CN202510465554.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-08-15
AI Technical Summary
In the prior art, the namespace of the solid-state drive needs to be continuously distributed in the logical space, resulting in the inability to create a namespace when unused logical addresses are discontinuous, resulting in low logical space utilization.
By receiving a namespace creation request, at least two target logical units that are not used in the solid state drive are determined and associated with the namespace to be created. The logical units whose logical addresses are discontinuous are used as storage space, and the identification and address mapping of these logical units are managed using an index table.
Namespaces can also be created when logical addresses are discontinuous, which improves the logical space utilization of SSDs.
Smart Images

Figure CN120491889A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of storage technology, and in particular to a method, device, electronic device, and readable storage medium for operating a namespace of a solid-state drive. Background Art
[0002] SSDs generally have multiple namespaces (NS), and each namespace can be repeatedly created and deleted by the host. In the existing technology, namespaces need to be continuously distributed in the logical space, such as Figure 1 As shown in the figure, the total capacity of the SSD is 300 (logical addresses 0-299), the capacity of namespace NSID1 is 100 (logical addresses 0-99), and the capacity of namespace NSID2 is 100 (logical addresses 150-249). The total unused logical capacity of the SSD is 100, consisting of logical addresses 100-149 and 250-299, respectively. If the host creates namespace 3 with a capacity of 100 in this situation, the logical addresses of the unused total logical capacity are discontinuous. Therefore, even if the SSD has sufficient remaining capacity, the namespace cannot be created, resulting in low logical space utilization on the SSD. Summary of the Invention
[0003] In view of this, embodiments of the present application provide a method, device, electronic device, and readable storage medium for operating a namespace of a solid-state drive, which can improve the logical space utilization of the solid-state drive.
[0004] In a first aspect, an embodiment of the present application provides a method for operating a namespace of a solid-state drive, comprising: receiving a namespace creation request; wherein the creation request includes the capacity of the namespace to be created; determining at least two unused target logical units in the solid-state drive; wherein the total capacity of the at least two target logical units is greater than or equal to the capacity of the namespace to be created, and the logical addresses of the at least two target logical units are discontinuous; and associating the at least two target logical units with the namespace to be created to serve as storage space for the namespace to be created.
[0005] According to a specific implementation method of an embodiment of the present application, determining at least two unused target logical units in the solid-state drive includes: determining at least two unused target logical units in the solid-state drive based on a first index table; wherein the first index table includes each table entry and an index number corresponding to each table entry, each index number corresponds one-to-one to each logical unit of the solid-state drive, and each table entry records the usage status of the corresponding logical unit.
[0006] According to a specific implementation of an embodiment of the present application, determining at least two unused target logical units in the solid-state drive based on a first index table includes: searching, in the first index table, for a first logical unit whose usage status is unused according to the index numbers of the table entries from large to small or from small to large; if the capacity of the first logical unit is less than the capacity of the namespace, continuing to search, in the first index table, for a second logical unit whose usage status is unused; if the sum of the capacities of the first logical unit and the second logical unit is less than the capacity of the namespace, continuing to search, in the first index table, for a logical unit whose usage status is unused, and so on, until a kth logical unit whose usage status is unused is found, and the sum of the capacities of the first to the kth logical units is greater than or equal to the capacity of the namespace, then determining the first to the kth logical units as the at least two target logical units; wherein k is an integer greater than 1.
[0007] According to a specific implementation of the embodiment of the present application, associating the at least two target logical units with the namespace to be created includes: writing identifiers of the at least two target logical units into blank entries in a second index table; and writing index numbers of the at least two target logical units in the second index table into blank entries in a third index table.
[0008] According to a specific implementation method of an embodiment of the present application, writing the identifiers of the at least two target logical units into a blank table entry of the second index table includes: determining a first blank table entry in the second index table based on the total number of logical units in the solid-state drive and the number of unused or used logical units in the solid-state drive; the first blank table entry is an entry in the second index table that is adjacent to the used table entry; writing the identifier of the first logical unit into the first blank table entry in the second index table; writing the identifier of the second logical unit into a second blank table entry in the second index table that is adjacent to the first blank table entry, and so on, until the identifier of the kth logical unit is written into the kth blank table entry in the second index table.
[0009] According to a specific implementation of the embodiment of the present application, writing the index numbers of the at least two target logical units in the second index table into blank entries in the third index table includes: writing the first index number in the second index table corresponding to the first blank entry and the number of the at least two target logical units into a blank entry in the third index table.
[0010] According to a specific implementation of an embodiment of the present application, the method further includes: receiving a data read / write request; the read / write request includes an identifier of a namespace to be read / written, a first starting logical address of the data to be read / written in the namespace to be read / written, and a data length of the data to be read / written; based on the identifier of the namespace to be read / written, the first starting logical address and the capacity of a single logical unit of the solid-state hard disk, determining a logical unit corresponding to the first starting logical address in the namespace to be read / written; wherein the capacity of each logical unit in the solid-state hard disk is the same; based on the first starting logical address, the logical unit corresponding to the first starting logical address, and the capacity of a single logical unit of the solid-state hard disk, determining a second starting logical address corresponding to the first starting logical address in the solid-state hard disk; and performing a read / write operation on the solid-state hard disk based on the second starting logical address and the data length.
[0011] According to a specific implementation method of an embodiment of the present application, the determining of the logical unit corresponding to the first starting logical address in the namespace to be read / written according to the identifier of the namespace to be read / written, the first starting logical address, and the capacity size of a single logical unit of the solid-state drive includes: determining the first table entry corresponding to the namespace to be read / written in the third index table according to the identifier of the namespace to be read / written; determining the index number of the first starting table entry in the second index table according to the index number stored in the first table entry; determining the table entry corresponding to the first starting logical address in the second index table according to the first starting logical address, the capacity size of the single logical unit of the solid-state drive, and the index number of the first starting table entry; and obtaining the identifier of the logical unit corresponding to the first starting logical address from the table entry corresponding to the first starting logical address.
[0012] According to a specific implementation of an embodiment of the present application, the method further includes: receiving a namespace deletion request; wherein the deletion request includes an identifier of the namespace to be deleted; determining a logical unit corresponding to the namespace to be deleted based on the identifier of the namespace to be deleted; and marking the usage status of the logical unit corresponding to the namespace to be deleted as unused.
[0013] According to a specific implementation method of an embodiment of the present application, determining the logical unit corresponding to the namespace to be deleted based on the identifier of the namespace to be deleted includes: determining, in the third index table, the second index number of the namespace to be deleted in the second index table based on the identifier of the namespace to be deleted; obtaining the identifier of the logical unit in the table entry corresponding to the second index number; wherein, marking the usage status of the logical unit corresponding to the namespace to be deleted as unused includes: modifying the usage status in the corresponding table entry in the first index table to unused based on the obtained identifier of the logical unit.
[0014] According to a specific implementation method of an embodiment of the present application, obtaining the identifier of the logical unit in the table item corresponding to the second index number includes: respectively obtaining the identifier of the logical unit in multiple table items corresponding to the second index number; the multiple table items include a second starting table item; the number of the multiple table items is a first number; wherein, the method also includes: in the second index table, deleting the identifier of the logical unit in the first number of consecutive table items starting from the second starting table item; in the second index table, moving the numbers of the logical units of all table items after the first number of table items in sequence to the table items that are the first number away from the table item where they are located; modifying the index number and the number of logical units in the second table item corresponding to the namespace to be deleted in the third index table to 0; subtracting the first number from the index numbers stored in each table item after the second table item in the third index table.
[0015] In a second aspect, an embodiment of the present application provides an operating device for a namespace of a solid-state drive, comprising: a first receiving module for receiving a namespace creation request; wherein the creation request includes the capacity of the namespace to be created; a first determination module for determining at least two unused target logical units in the solid-state drive; wherein the total capacity of the at least two target logical units is greater than or equal to the capacity of the namespace to be created, and the logical addresses of the at least two target logical units are discontinuous; and an association module for associating the at least two target logical units with the namespace to be created to serve as storage space for the namespace to be created.
[0016] According to a specific implementation method of an embodiment of the present application, the first determination module includes: a determination sub-module, used to determine at least two unused target logical units in the solid-state drive based on a first index table; wherein, the first index table includes each table entry and an index number corresponding to each table entry, each index number corresponds one-to-one to each logical unit of the solid-state drive, and each table entry records the usage status of the corresponding logical unit.
[0017] According to a specific implementation of an embodiment of the present application, the determination submodule includes: a first search unit, configured to search for a first logical unit in an unused state in a first index table according to the index numbers of the entries in descending order or in ascending order; a second search unit, configured to continue searching for a second logical unit in an unused state in the first index table if the capacity of the first logical unit is less than the capacity of the namespace; a determination subunit, configured to continue searching for a logical unit in an unused state in the first index table if the sum of the capacities of the first and second logical units is less than the capacity of the namespace, and so on, until a kth logical unit in an unused state is found, and the sum of the capacities of the first to kth logical units is greater than or equal to the capacity of the namespace, and then determine the first to kth logical units as the at least two target logical units; wherein k is an integer greater than 1.
[0018] According to a specific implementation of an embodiment of the present application, the association module includes: a first writing submodule, configured to write the identifiers of the at least two target logical units into blank entries in a second index table; and a second writing submodule, configured to write the index numbers of the at least two target logical units in the second index table into blank entries in a third index table.
[0019] According to a specific implementation method of an embodiment of the present application, the first writing sub-module is specifically used to: determine a first blank table entry in the second index table based on the total number of logical units in the solid-state drive and the number of unused or used logical units in the solid-state drive; the first blank table entry is an entry in the second index table that is adjacent to the used table entry; write the identifier of the first logical unit into the first blank table entry in the second index table; write the identifier of the second logical unit into the second blank table entry in the second index table that is adjacent to the first blank table entry, and so on, until the identifier of the kth logical unit is written into the kth blank table entry in the second index table.
[0020] According to a specific implementation method of an embodiment of the present application, the second writing sub-module is specifically used to: write the first index number in the second index table corresponding to the first blank table entry and the number of the at least two target logical units into a blank table entry in the third index table.
[0021] According to a specific implementation of an embodiment of the present application, the device further includes: a second receiving module for receiving a data read / write request; the read / write request includes an identifier of a namespace to be read / written, a first starting logical address of the data to be read / written in the namespace to be read / written, and a data length of the data to be read / written; a second determination module for determining, in the namespace to be read / written, a logical unit corresponding to the first starting logical address; wherein the capacity of each logical unit in the solid-state hard disk is the same; a third determination module for determining, based on the first starting logical address, the logical unit corresponding to the first starting logical address, and the capacity of a single logical unit of the solid-state hard disk, a second starting logical address in the solid-state hard disk corresponding to the first starting logical address; and a read / write operation module for performing a read / write operation on the solid-state hard disk according to the second starting logical address and the data length.
[0022] According to a specific implementation method of an embodiment of the present application, the second determination module is specifically used to: determine the first table entry corresponding to the namespace to be read / written in the third index table according to the identifier of the namespace to be read / written; determine the index number of the first starting table entry in the second index table according to the index number stored in the first table entry; determine the table entry corresponding to the first starting logical address in the second index table according to the first starting logical address, the capacity of a single logical unit of the solid-state drive, and the index number of the first starting table entry; and obtain the identifier of the logical unit corresponding to the first starting logical address from the table entry corresponding to the first starting logical address.
[0023] According to a specific implementation method of an embodiment of the present application, the device also includes: a third receiving module, used to receive a namespace deletion request; wherein the deletion request includes an identifier of the namespace to be deleted; a fourth determination module, used to determine the logical unit corresponding to the namespace to be deleted based on the identifier of the namespace to be deleted; and a marking module, used to mark the usage status of the logical unit corresponding to the namespace to be deleted as unused.
[0024] According to a specific implementation method of an embodiment of the present application, the fourth determination module includes: a determination sub-module, used to determine the second index number of the namespace to be deleted in the second index table in the third index table based on the identifier of the namespace to be deleted; an acquisition sub-module, used to obtain the identifier of the logical unit in the table item corresponding to the second index number; wherein the marking module is specifically used to: modify the usage status in the corresponding table item in the first index table to unused based on the identifier of the acquired logical unit.
[0025] According to a specific implementation method of an embodiment of the present application, the acquisition submodule is specifically used to: respectively obtain the identifiers of the logical units in the multiple table entries corresponding to the second index number; the multiple table entries include a second starting table entry; the number of the multiple table entries is a first number; wherein the device is also used to: in the second index table, delete the identifiers of the logical units in the first number of consecutive table entries starting from the second starting table entry; in the second index table, move the numbers of the logical units of all table entries after the first number of table entries to the table entries that are the first number away from the table entry itself; modify the index number and the number of logical units in the second table entry corresponding to the namespace to be deleted in the third index table to 0; subtract the first number from the index numbers stored in each table entry after the second table entry in the third index table.
[0026] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a housing, a processor, a memory, a circuit board, and a power supply circuit, wherein the circuit board is placed inside the space enclosed by the housing, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, and is used to execute the operating method of the namespace of the solid-state hard disk described in any of the aforementioned implementation methods.
[0027] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the operating method of the namespace of the solid-state drive described in any of the aforementioned implementation methods.
[0028] The method, apparatus, electronic device, and readable storage medium for operating a namespace of a solid-state drive of this embodiment receive a namespace creation request, the creation request including the capacity of the namespace to be created, then determine at least two unused target logical units in the solid-state drive, and associate the at least two target logical units, each having a total capacity greater than or equal to the capacity of the namespace to be created, with the namespace to be created, thereby making the at least two target logical units serve as storage space for the namespace to be created. The logical addresses of the at least two target logical units are discontinuous. Thus, even when the logical addresses of the at least two target logical units are discontinuous, the at least two target logical units can still serve as storage space for the namespace to be created, thereby improving logical space utilization of the solid-state drive. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0030] Figure 1 This is a schematic diagram of the logical space usage of a solid-state drive in the prior art; Figure 2 A flowchart of a method for operating a namespace of a solid-state drive provided in one embodiment of the present application; Figure 3 A schematic diagram of the logical space usage of a solid-state drive provided in one embodiment of the present application; Figure 4 A schematic diagram of the mapping relationship between the first index table, the second index table, and the third index table provided in a specific embodiment of the present application; Figure 5 A schematic diagram of the mapping relationship among the first index table, the second index table, and the third index table provided in another specific embodiment of the present application; Figure 6 A schematic diagram of the mapping relationship among the first index table, the second index table, and the third index table provided in yet another specific embodiment of the present application; Figure 7 A schematic diagram of the structure of a device for operating a namespace of a solid-state drive provided in one embodiment of the present application; Figure 8 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0031] The embodiments of the present application are described in detail below with reference to the accompanying drawings. It should be understood that the embodiments described are only a portion of the embodiments of the present application, and not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this application.
[0032] In order to enable those skilled in the art to better understand the technical concepts, implementation plans and beneficial effects of the embodiments of the present application, specific examples are described in detail below.
[0033] Figure 2 A flowchart of a method for operating a solid-state drive namespace according to an embodiment of the present application is provided. Figure 2 As shown, the method for operating the namespace of the solid-state drive of this embodiment may include: S101: Receive a namespace creation request.
[0034] The creation request includes the capacity of the namespace to be created.
[0035] The host or user sends a namespace creation request to the solid-state drive through the system interface. The request may include the capacity of the namespace to be created, for example, a request to create a namespace with a capacity of 500 GB.
[0036] S102: Determine at least two unused target logical units in the solid state drive.
[0037] In this embodiment, the total capacity of the at least two target logical units is greater than or equal to the capacity of the namespace to be created.
[0038] The multiple logic units of the solid state drive are obtained by pre-dividing the logic space of the solid state drive, and the sizes of the logic units can be equal or different.
[0039] The logical addresses of the at least two unused target logical units determined are discontinuous. For example, the at least two unused target logical units determined include A, B, and C, where the logical address of A is 0-99, the logical address of B is 250-299, and the logical address of C is 300-360, that is, the logical addresses of A, B, and C are discontinuous.
[0040] It is understood that the number of the at least two unused target logical units is the minimum number required to ensure that their total capacity is greater than or equal to the capacity of the namespace to be created. That is, if the total capacity of the at least two unused target logical units after removing any one logical unit is less than the capacity of the namespace to be created, for example, if the at least two unused target logical units include A, B, and C, and the total capacity of A, B, and C is greater than or equal to the capacity of the namespace to be created, then if any one logical unit, for example, A, is removed from A, B, and C, the total capacity of B and C will be less than the capacity of the namespace to be created.
[0041] In one embodiment, assuming the logical space of a solid-state drive is divided into multiple logical units, each with a capacity of 100 GB, the first index table may be searched for the numbers of unused logical units. For example, logical units numbered 1, 3, and 5 may be found, whose total capacity is 300 GB, less than the requested 500 GB. Continuing the search, logical units numbered 7 and 9 may be found, whose total capacity is 500 GB, thus satisfying the request.
[0042] S103: Associate at least two target logical units with the namespace to be created to serve as storage spaces of the namespace to be created.
[0043] The at least two target logical units are associated with the identifier of the namespace to be created, that is, a mapping relationship is established between the at least two target logical units and the identifier of the namespace to be created.
[0044] In this embodiment, a namespace creation request is received, the creation request including the capacity of the namespace to be created. At least two unused target logical units in the solid-state drive are then determined, and the at least two target logical units having a total capacity greater than or equal to the capacity of the namespace to be created are associated with the namespace to be created, thereby making the at least two target logical units serve as storage space for the namespace to be created. The logical addresses of the at least two target logical units are discontinuous. Thus, even when the logical addresses of the at least two target logical units are discontinuous, they can still serve as storage space for the namespace to be created, thereby improving logical space utilization of the solid-state drive.
[0045] like Figure 3 In the embodiment shown, a schematic diagram of the logical space usage of the solid state drive after using the above embodiment is provided, wherein the namespace NSID1 corresponds to logical unit 1 and logical unit 4, the namespace NSID2 corresponds to logical unit 2 and logical unit 5, and the namespace NSID3 corresponds to logical unit 3 and logical unit 6.
[0046] In a specific example, determining at least two unused target logical units in the solid state drive (S102) may include: S102a: Determine at least two unused target logical units in the solid state drive based on the first index table.
[0047] In this embodiment, the first index table includes various table entries and index numbers corresponding to the various table entries. Each index number corresponds one-to-one to each logical unit of the solid-state drive, and each table entry records the usage status of the corresponding logical unit.
[0048] The usage status can include used and unused.
[0049] Since each entry in the first index table records the usage status of the corresponding logical unit, at least two unused target logical units in the solid-state drive can be determined in the first index table.
[0050] like Figure 4 The index numbers of the entries in the first index table shown are equal to and correspond one-to-one to the numbers of the logical units of the solid-state drive. Each entry stores the usage status of the corresponding logical unit. Among them, index number 1 of the first index table corresponds to logical unit 1 (logical unit number is 1), and the entry of index number 1 records "used", indicating that the usage status of logical unit 1 is used; index number 2 corresponds to logical unit 2 (logical unit number is 2), and the entry of index number 2 stores the content "unused", indicating that the usage status of logical unit 2 is unused.
[0051] Based on the capacity of the namespace to be created, the numbers of unused logical units in the solid-state drive may be randomly searched in a preset first index table, or may be searched in a preset order. In some examples, determining at least two unused target logical units in the solid-state drive based on the first index table (S102a) may include: A1. In the first index table, search for a first logical unit whose usage status is unused according to the index numbers of the entries from large to small or from small to large.
[0052] like Figure 4 The entries of the first index table shown are distributed from top to bottom, and the numbers of the entries increase from top to bottom.
[0053] The numbers of the unused logical units may be searched in ascending order of the numbers of the entries.
[0054] A2. If the capacity of the first logical unit is smaller than the capacity of the namespace, continue searching the first index table for a second logical unit that is in an unused state.
[0055] As in Figure 4The first index table shown, in ascending order of the table item numbers, finds an unused first logical unit numbered 2, and determines whether the capacity of the first logical unit numbered 2 is greater than or equal to the capacity of the namespace to be created in the creation request. If the capacity of the first logical unit is less than the capacity of the namespace to be created, the first index table continues to search for an unused second logical unit.
[0056] A3. If the sum of the capacities of the first logical unit and the second logical unit is less than the capacity of the namespace, continue searching the first index table for unused logical units, and so on, until a kth unused logical unit is found, and the sum of the capacities of the first to kth logical units is greater than or equal to the capacity of the namespace. Then, the first to kth logical units are determined as at least two target logical units, where k is an integer greater than 1.
[0057] If the total capacity of the first logical unit and the second logical unit is less than the capacity of the namespace to be created, it is necessary to continue searching the first index table for unused logical units until the total capacity of the unused logical units is found to be greater than or equal to the capacity of the namespace to be created.
[0058] It can be understood that if the capacity of the first logical unit and the second logical unit is greater than or equal to the capacity of the namespace, the first logical unit and the second logical unit are determined as at least two target logical units.
[0059] After determining at least two target logical units, the usage status of the entry records corresponding to each target logical unit in the first index table may be marked as used.
[0060] In this embodiment, associating at least two target logical units with the namespace to be created (S103) may include: S103a: Write the identifiers of at least two target logical units into blank entries in the second index table.
[0061] Each entry in the second index table stores an identifier of a logical unit, and each entry corresponds to an index number.
[0062] After determining at least two target logical units, the identifiers of the at least two target logical units may be written into at least two blank entries of the second index table in a one-to-one correspondence.
[0063] S103b: Write the index numbers of the at least two target logical units in the second index table into the blank entries in the third index table.
[0064] Each table entry in the third index table corresponds to a namespace, and each table entry stores the index number of the logic unit corresponding to the namespace in the second index table.
[0065] The index numbers of the at least two target logical units in the second index table are written into blank entries in the third index table, thereby associating the at least two target logical units with the namespace in the third index table.
[0066] like Figure 4 In the illustrated embodiment, in the entry with index number NSID1 (namespace identifier is 1) in the third index table, the index number of the entry corresponding to the entry in the second index table is 1, and the number of corresponding entries is 2. The identifier of the logical unit stored in the entry with index number 1 in the second index table is 1, and the identifier of the logical unit stored in the entry with index number 2 in the second index table is 4. That is, the logical units corresponding to namespace 1 are numbered 1 and 4, thereby establishing an association relationship between the namespace and the logical units in the solid-state drive.
[0067] In one embodiment, writing the identifiers of at least two target logical units into blank entries of the second index table (S103a) may include: B1. Determine a first blank entry in the second index table according to the total number of logical units in the solid state drive and the number of unused or used logical units in the solid state drive.
[0068] In this embodiment, the first blank entry is an entry in the second index table that is adjacent to the entry that has been used.
[0069] like Figure 4 In the illustrated embodiment, the entry with index number 5 in the second index table is the first blank entry.
[0070] B2. Write the identifier of the first logical unit into the first blank entry in the second index table.
[0071] like Figure 5 In the illustrated embodiment, the number of the at least two target logical units is 2 and the identifiers of the target logical units are 2 and 5 respectively, and the identifier 2 of the first logical unit is written into the entry with index number 5 in the second index table.
[0072] B3. Write the identifier of the second logical unit into the second blank entry adjacent to the first blank entry in the second index table, and so on, until the identifier of the kth logical unit is written into the kth blank entry in the second index table.
[0073] like Figure 5In the embodiment shown, the index number of the blank entry adjacent to the index number 5 in the second index table is 6, and the identifier 5 of the logical unit is written into the entry with the index number 6 in the second index table.
[0074] In one embodiment, before determining the first blank entry in the second index table in step B1 based on the total number of logical units in the solid-state drive and the number of unused or used logical units in the solid-state drive, the method further includes: obtaining the number of unused logical units in the solid-state drive through a first variable.
[0075] The first variable can record the number of unused logical units in the solid state drive in real time.
[0076] In this embodiment, the number of unused logical units in the solid-state drive can be obtained more efficiently through the first variable, thereby improving the efficiency of associating the identifiers of the logical units with the namespace.
[0077] Correspondingly, in this embodiment, after determining the first blank entry in the second index table based on the total number of logical units in the solid-state drive and the number of unused or used logical units in the solid-state drive, the method of this embodiment may further include: The number of unused logical units is subtracted from the number of at least two target logical units to obtain a new number of unused logical units; and the first variable is updated using the new number of unused logical units.
[0078] The first variable is updated. When a namespace is subsequently created, the number of unused logical units in the solid-state drive can be directly obtained from the first variable, thereby improving the efficiency of subsequent namespace creation.
[0079] In some examples, writing the index numbers of the at least two target logical units in the second index table into blank entries in the third index table (S103b) may include: C1. Write the first index number in the second index table corresponding to the first blank entry and the number of at least two target logical units into a blank entry in the third index table.
[0080] like Figure 5 In the embodiment shown, the first index number corresponding to the first blank table entry is 5, and the number of at least two target logical units corresponding to the namespace to be created is 2. In this way, the index number 5 and the number 2 can be written into the blank table entry in the third index table. The index number of the blank table entry is NSID2, that is, the identifier of the namespace is 2.
[0081] It can be understood that a blank entry in the third index table corresponds to the namespace.
[0082] In a specific example, Figure 4 Based on the illustrated embodiment, the process of creating the namespace NSID2 (for example, the size of NSID2 occupies two logical units) is as follows: The first step is to access the first index table, sequentially accessing each entry in ascending order of index number, until the total capacity of unused logical units is equal to or greater than the capacity of the namespace to be created. In this case, logical units 2 and 5 are unused, and their total capacity equals the capacity of the namespace to be created, NSID2.
[0083] Step 2: By calculating 6 - 2 + 1 (6: total number of logical units in the solid-state drive; 2: current value of the first variable m), we can find that the entry with index number 5 is the first unused entry in the second index table. Then, fill the entry with index number 5 in the second index table with the identifier 2 of the logical unit, and fill the entry with index number 6 in the second index table with the identifier 5 of the logical unit. Figure 5 shown.
[0084] Step 3: Modify the content of the entry with index number 2 in the third index table to: index number = 5, number of entries = 2; where index number = 5 indicates the starting entry of namespace NSID2 in the second index table, and number of entries = 2 indicates the number of entries of namespace NSID2 in the second index table. Figure 5 shown.
[0085] Finally, the value 2 is subtracted from the variable m (2 means that NSID2 uses two logical units). In this example, the variable m = 0.
[0086] The capacity of each logical unit in the solid-state drive may be different. To improve computing efficiency and save computing resources, in one embodiment of the present application, the capacity of the multiple logical units of the solid-state drive is the same. Correspondingly, the method of this embodiment may further include: S104: Receive a data read request.
[0087] The read request in this embodiment includes an identifier of the namespace to be read, a first starting logical address of the data to be read in the namespace to be read, and a data length of the data to be read.
[0088] In such Figure 6 In the illustrated embodiment, the identifier of the namespace to be read is 2, and the first starting logical address of the data to be read in the namespace to be read is 120, where 120 represents 120 minimum read / write units in the solid state drive.
[0089] S105 : Determine a logical unit corresponding to the first starting logical address in the namespace to be read according to the identifier of the namespace to be read, the first starting logical address, and the capacity of a single logical unit of the solid state drive.
[0090] For example, the capacity of a single logical unit is 100, where 100 represents 100 minimum read / write units in the solid-state drive.
[0091] If the to-be-read namespace or the identifier of the to-be-read namespace corresponds to multiple logical units, the capacity of each logical unit is 100, and the logical starting address of the to-be-read namespace is 0, then the first starting logical address is a logical address in the to-be-read namespace starting from 0. For example, if the first starting logical address is 90, then the logical address corresponds to the first logical unit in the to-be-read namespace.
[0092] S106. Determine a second starting logical address corresponding to the first starting logical address in the solid state drive according to the first starting logical address, the logical unit corresponding to the first starting logical address, and the capacity of a single logical unit of the solid state drive.
[0093] In a specific example, the logical units of the solid-state drive are numbered sequentially (the number may be an identifier). When determining the logical unit corresponding to the first starting logical address, if the logical unit corresponding to the first starting logical address is numbered 1, then the second starting logical address is equal to the first starting logical address. If the logical unit corresponding to the first starting logical address is numbered 2, the first starting logical address is 90, and the capacity of each logical unit is 100, then the second starting logical address is 100+90=190.
[0094] S107: Perform a read operation on the solid state drive according to the second starting logical address and the data length.
[0095] Data of the data length included in the read request may be read from the second starting logical address of the solid state drive.
[0096] It can be understood that in an embodiment of performing a write operation on a solid-state hard drive, a data write request is received; the write request includes an identifier of a namespace to be written, a first starting logical address of the data to be written in the namespace to be written, and a data length of the data to be written; based on the identifier of the namespace to be written, the first starting logical address, and the capacity of a single logical unit of the solid-state hard drive, a logical unit corresponding to the first starting logical address is determined in the namespace to be written; wherein the capacity of each logical unit in the solid-state hard drive is the same; based on the first starting logical address, the logical unit corresponding to the first starting logical address, and the capacity of a single logical unit of the solid-state hard drive, a second starting logical address corresponding to the first starting logical address in the solid-state hard drive is determined; and based on the second starting logical address and the data length, a write operation is performed on the solid-state hard drive.
[0097] In some examples, determining the logical unit corresponding to the first starting logical address in the namespace to be read (S105) based on the identifier of the namespace to be read, the first starting logical address, and the capacity of a single logical unit of the solid-state drive may include: S105a: Determine, in the third index table, a first entry corresponding to the namespace to be read according to the identifier of the namespace to be read.
[0098] Since each entry in the third index table corresponds to a namespace, the first entry corresponding to the namespace to be read can be determined in the third index table according to the identifier of the namespace to be read.
[0099] S105b: Determine the index number of the first starting entry in the second index table according to the index number stored in the first entry.
[0100] Since each entry in the third index table stores the index number of the logical unit of the corresponding namespace in the second index table, the index number of the first starting entry in the second index table is determined according to the index number stored in the first entry.
[0101] S105c: Determine, according to the first starting logical address, the capacity of a single logical unit of the solid state drive, and the index number of the first starting entry, the entry in the second index table corresponding to the first starting logical address.
[0102] In some examples, the index number SEI of the first starting table entry is 1, and the index number (identifier) of the logical unit corresponding to the first starting logical address SLBA is LUN=(SLBA / NS Block Size)+SEI ( / represents the quotient). In this way, the table entry corresponding to the first starting logical address in the second index table can be determined; wherein NS Block Size is the capacity of a single logical unit of the solid-state drive.
[0103] S105d: Obtain the identifier LUID of the logical unit corresponding to the first starting logical address from the table entry corresponding to the first starting logical address.
[0104] Furthermore, the starting logical address at which the host reads data in the solid-state drive = (LUID-1) × NS BlockSize + (SLBA % NS Block Size), where % represents the remainder.
[0105] In a specific example, the host includes the namespace identifier (NSID), the starting logical address (SLBA, Start Logical Block Address) in the namespace, and the read and write length (NLB, Number of Logical Blocks) in the read command issued by the host (Note: the Logical Block Size in the read and write commands issued by the host is smaller than the above NS Block Size, and the NS Block Size is an integer multiple of the Logical Block Size).
[0106] Follow the steps below to determine the starting logical address in the SSD: Step 1: Search the third index table according to the NSID sent by the host, and obtain the start index number (SEI, Start Entry Index) in the second index table of the NSID, such as Figure 6 The index number SEI of the starting unit of the second index table corresponding to NSID1 is 1.
[0107] Step 2: The index number of the second index table (LUN, Logical Unit Number) = (SLBA / NSBlock Size) + SEI, where / represents the quotient, SEI is the starting index number in the second index table obtained in the first step, and the content of the table item corresponding to the index number is read to obtain the corresponding solid-state drive logical unit identifier LUID (LogicalUnit ID). Then, the starting logical address of the solid-state drive read and written by the host = (LUID-1) × NS Block Size + (SLBA% NS Block Size), where % represents the remainder. For example Figure 6 In the example, NS Block Size = 100, SLBA = 120, then LUN = (120 / 100 + 1) = 2. Reading the content of the unit with index number 2 in the second index table yields LUID = 4. Finally, the host reads and writes the internal starting logical address of the SSD = (4 - 1) × 100 + (120 % 100) = 320.
[0108] In practical applications, namespace operations may further include deleting a namespace. Correspondingly, in one embodiment of the present application, the method may further include: S108: Receive a namespace deletion request.
[0109] In this embodiment, the deletion request includes an identifier of the namespace to be deleted.
[0110] S109: Determine the logical unit corresponding to the namespace to be deleted according to the identifier of the namespace to be deleted.
[0111] The namespace is associated with the logical unit in the solid-state drive. Therefore, the logical unit corresponding to the namespace to be deleted can be determined according to the identifier of the namespace to be deleted.
[0112] S110: Mark the usage status of the logical unit corresponding to the namespace to be deleted as unused.
[0113] In some examples, determining the logical unit corresponding to the namespace to be deleted (S109) based on the identifier of the namespace to be deleted may include: S109a: Determine the second index number of the namespace to be deleted in the second index table in the third index table according to the identifier of the namespace to be deleted.
[0114] Each entry in the third index table stores the index number of the corresponding namespace in the second index table. In this way, the second index number of the namespace to be deleted in the second index table can be determined in the third index table according to the identifier of the namespace to be deleted.
[0115] As in Figure 6 In the embodiment shown, the identifier of the namespace to be deleted is NSID2. Then, in the third index table, it is determined that the second index numbers of the namespace to be deleted in the second index table are 3 and 4 (the index numbers are 3 and 4 obtained from the index number 3 and the number of table entries being 2).
[0116] S109b: Obtain the identifier of the logical unit in the entry corresponding to the second index number.
[0117] Each entry in the second index table stores an identifier of a logical unit. Thus, after the second index number is determined, the identifier of the logical unit can be obtained from the entry corresponding to the second index number.
[0118] As in Figure 6 In the illustrated embodiment, the identifiers of the logical units 2 and 5 are obtained from the table entry corresponding to the second index number.
[0119] In this embodiment, marking the usage status of the logical unit corresponding to the namespace to be deleted as unused (S110) may include: S110a: Modify the usage status of the corresponding entry in the first index table to unused according to the obtained identifier of the logical unit.
[0120] Each entry in the first index table records the usage status of the corresponding logical unit. The usage status of the logical unit recorded in the entry in the first index table corresponding to the obtained logical unit identifier is modified to unused, thereby deleting the namespace.
[0121] like Figure 4 In the illustrated embodiment, according to the obtained identifiers of the target logical units being 2 and 5, the usage status of the entries with index numbers 2 and 5 in the first index table is modified to unused.
[0122] To improve the efficiency of subsequent namespace creation, in some examples, obtaining the identifier of the logical unit in the entry corresponding to the second index number (S109b) in this embodiment may include: D1. Obtain identifiers of logical units in multiple entries corresponding to the second index number respectively.
[0123] In this embodiment, the plurality of entries include a second starting entry; the number of the plurality of entries is a first number; The method of this embodiment further includes: S111 . In the second index table, delete identifiers of logical units in a first number of consecutive entries starting from a second starting entry.
[0124] In such Figure 6 Based on the embodiment shown, the logical unit numbers 2 and 5 stored in the entries numbered 3 and 4 in the second index table are deleted.
[0125] S112: In the second index table, sequentially move the numbers of the logical units of all entries after the first number of entries to entries that are the first number of entries away from the entry where the logical units are located.
[0126] like Figure 6In the embodiment shown, the identifier 3 of the logic unit stored in the entries with index numbers 5 and 6 in the second index table is moved to the entry with index number 3, and the identifier 6 of the logic unit is moved to the entry with index number 4. The result is as follows: Figure 4 The second index table shown in the embodiment shown in the figure is understood to clear the entries of index numbers 5 and 6 in the second index number.
[0127] S113: Modify the index number and the number of logical units in the second entry corresponding to the namespace to be deleted in the third index table to 0.
[0128] like Figure 4 In the illustrated embodiment, the number of the starting entry in the second index table stored in the entry with index number 2 in the third index table is changed from 3 to 0, and the number of entries in the second index table of the namespace to be deleted is changed from 2 to 0.
[0129] S114: Subtract the first number from the index number of each entry after the second entry in the third index table.
[0130] In such Figure 6 In the embodiment shown, the index number stored in the entry with index number 3 in the third index table is subtracted by 2, and the result is as follows: Figure 4 The third index table in the illustrated embodiment has index number 3 for information stored therein.
[0131] In a specific example, the process of deleting NSID2 is as follows: The first step is to search the third index table, read the entry with index number 2 in the third index table, and obtain that the index number of the starting entry of the second index table used by NSID2 is 3, and the number of logical units used is 2.
[0132] The second step is to access the entries with index numbers 3 and 4 in the second index table, and obtain the values 2 and 5 in the two entries respectively.
[0133] Step 3: See Figure 4 , access the first index table and mark the entries with index numbers 2 and 5 as unused.
[0134] Step 4: Move the contents of all entries after index number 4 in the second index table up to after index number 2.
[0135] Step 5: Modify the content of the unit with index number 2 in the third index table as follows: the index number is changed to 0, the number of entries is changed to 0; the index number 5 in the entry with index number 3 in the third index table is changed to 3.
[0136] Step 6. Add the value 2 to the first variable (2: NSID2 uses two logical units), as shown in Figure 4 As shown, the number of unused logic units in the solid state drive is 2, so in this example, the first variable=2.
[0137] Figure 7 A structural diagram of an operating device for a solid-state hard disk namespace provided in an embodiment of the present application is shown as follows: Figure 7 As shown, the operating device for the namespace of the solid-state drive of this embodiment includes: a first receiving module 11, used to receive a namespace creation request; wherein the creation request includes the capacity of the namespace to be created; a first determining module 12, used to determine at least two unused target logical units in the solid-state drive; wherein the total capacity of the at least two target logical units is greater than or equal to the capacity of the namespace to be created, and the logical addresses of the at least two target logical units are discontinuous; and an associating module 13, used to associate the at least two target logical units with the namespace to be created to serve as storage space for the namespace to be created.
[0138] The device of this embodiment can be used to perform Figure 2 The technical solution of the method embodiment shown has similar implementation principles and technical effects, which will not be repeated here.
[0139] The apparatus of this embodiment receives a namespace creation request, where the creation request includes the capacity of the namespace to be created, then determines at least two unused target logical units in the solid-state drive, and associates the at least two target logical units, whose total capacity is greater than or equal to the capacity of the namespace to be created, with the namespace to be created, thereby making the at least two target logical units serve as storage space for the namespace to be created. The logical addresses of the at least two target logical units are discontinuous. Thus, even when the logical addresses of the at least two target logical units are discontinuous, they can still serve as storage space for the namespace to be created, thereby improving logical space utilization of the solid-state drive.
[0140] The device of the above embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0141] As an optional embodiment, the first determination module includes: a determination submodule, used to determine at least two unused target logical units in the solid-state drive based on a first index table; wherein the first index table includes each table entry and an index number corresponding to each table entry, each index number corresponds one-to-one to each logical unit of the solid-state drive, and each table entry records the usage status of the corresponding logical unit.
[0142] As an optional implementation, the determination submodule includes: a first search unit, configured to search for a first logical unit in an unused state in a first index table according to the index numbers of the entries in descending order or in ascending order; a second search unit, configured to continue searching for a second logical unit in an unused state in the first index table if the capacity of the first logical unit is less than the capacity of the namespace; a determination subunit, configured to continue searching for a logical unit in an unused state in the first index table if the sum of the capacities of the first and second logical units is less than the capacity of the namespace, and so on, until a kth logical unit in an unused state is found, and the sum of the capacities of the first to kth logical units is greater than or equal to the capacity of the namespace, and then determine the first to kth logical units as the at least two target logical units; wherein k is an integer greater than 1.
[0143] As an optional implementation, the association module includes: a first writing submodule, used to write the identifiers of the at least two target logical units into blank entries in the second index table; and a second writing submodule, used to write the index numbers of the at least two target logical units in the second index table into blank entries in the third index table.
[0144] As an optional implementation, the first writing submodule is specifically used to: determine a first blank entry in the second index table based on the total number of logical units in the solid-state drive and the number of unused or used logical units in the solid-state drive; the first blank entry is an entry in the second index table that is adjacent to the used entry; write the identifier of the first logical unit into the first blank entry in the second index table; write the identifier of the second logical unit into the second blank entry in the second index table that is adjacent to the first blank entry, and so on, until the identifier of the kth logical unit is written into the kth blank entry in the second index table.
[0145] As an optional implementation, the second writing submodule is specifically configured to write the first index number in the second index table corresponding to the first blank entry and the number of the at least two target logical units into a blank entry in the third index table.
[0146] As an optional embodiment, the device also includes: a second receiving module for receiving a data read / write request; the read / write request includes an identifier of a namespace to be read / written, a first starting logical address of the data to be read / written in the namespace to be read / written, and a data length of the data to be read / written; a second determining module for determining, in the namespace to be read / written, a logical unit corresponding to the first starting logical address, wherein the capacity of each logical unit in the solid-state drive is the same; a third determining module for determining, based on the first starting logical address, the logical unit corresponding to the first starting logical address, and the capacity of a single logical unit of the solid-state drive, a second starting logical address in the solid-state drive corresponding to the first starting logical address; and a read / write operation module for performing a read / write operation on the solid-state drive according to the second starting logical address and the data length.
[0147] As an optional implementation, the second determination module is specifically used to: determine, in the third index table, the first table entry corresponding to the namespace to be read / written according to the identifier of the namespace to be read / written; determine, in the second index table, the index number of the first starting table entry according to the index number stored in the first table entry; determine, in the second index table, the table entry corresponding to the first starting logical address according to the first starting logical address, the capacity size of a single logical unit of the solid-state drive, and the index number of the first starting table entry; and obtain, from the table entry corresponding to the first starting logical address, the identifier of the logical unit corresponding to the first starting logical address.
[0148] As an optional embodiment, the device also includes: a third receiving module, used to receive a namespace deletion request; wherein the deletion request includes an identifier of the namespace to be deleted; a fourth determination module, used to determine the logical unit corresponding to the namespace to be deleted based on the identifier of the namespace to be deleted; and a marking module, used to mark the usage status of the logical unit corresponding to the namespace to be deleted as unused.
[0149] As an optional implementation, the fourth determination module includes: a determination submodule, used to determine, in the third index table, the second index number of the namespace to be deleted in the second index table based on the identifier of the namespace to be deleted; an acquisition submodule, used to obtain the identifier of the logical unit in the table entry corresponding to the second index number; wherein the marking module is specifically used to: modify the usage status of the corresponding table entry in the first index table to unused based on the identifier of the acquired logical unit.
[0150] As an optional implementation, the acquisition submodule is specifically used to: respectively obtain the identifiers of the logical units in the multiple table entries corresponding to the second index number; the multiple table entries include a second starting table entry; the number of the multiple table entries is a first number; wherein the device is also used to: in the second index table, delete the identifiers of the logical units in the first number of consecutive table entries starting from the second starting table entry; in the second index table, move the numbers of the logical units of all table entries after the first number of table entries to the table entries that are the first number away from the table entry where they are located; modify the index number and the number of logical units in the second table entry corresponding to the namespace to be deleted in the third index table to 0; subtract the first number from the index numbers stored in each table entry after the second table entry in the third index table.
[0151] Figure 8 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application is shown in FIG. Figure 8 As shown, it may include: a shell 61, a processor 62, a memory 63, a circuit board 64 and a power supply circuit 65, wherein the circuit board 64 is placed inside the space enclosed by the shell 61, and the processor 62 and the memory 63 are arranged on the circuit board 64; the power supply circuit 65 is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory 63 is used to store executable program code; the processor 62 runs the program corresponding to the executable program code by reading the executable program code stored in the memory 63, and is used to execute any one of the solid-state hard disk namespace operation methods provided in the aforementioned embodiments, thereby also achieving corresponding beneficial technical effects, which have been described in detail above and will not be repeated here.
[0152] The aforementioned electronic devices exist in various forms, including but not limited to: (1) Personal computer equipment: This type of equipment belongs to the category of personal computers and has computing and processing functions.
[0153] (2) Server: A device that provides computing services. The server consists of a processor, hard disk, memory, system bus, etc. The server is similar to a general computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.
[0154] (3) Other electronic devices with data interaction functions.
[0155] Correspondingly, an embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement any of the solid-state hard disk namespace operation methods provided in the aforementioned embodiments, thereby also achieving the corresponding technical effects, which have been described in detail above and will not be repeated here.
[0156] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0157] Each embodiment in this specification is described in a related manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments.
[0158] In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0159] For the convenience of description, the above device is described as being divided into various units / modules based on their functions. Of course, when implementing this application, the functions of each unit / module can be implemented in the same or multiple software and / or hardware.
[0160] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a computer-readable storage medium, and when executed, the program can include the processes in the above-described method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0161] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A method for operating a namespace of a solid-state drive, characterized in that: include: Receiving a namespace creation request; wherein the creation request includes the capacity of the namespace to be created; Determining at least two unused target logical units in the solid-state drive; wherein a total capacity of the at least two target logical units is greater than or equal to a capacity of the namespace to be created, and logical addresses of the at least two target logical units are discontinuous; The at least two target logical units are associated with the namespace to be created to serve as storage space of the namespace to be created.
2. The method according to claim 1, characterized in that The determining of at least two unused target logical units in the solid state drive includes: Based on a first index table, at least two unused target logical units in the solid-state drive are determined; wherein the first index table includes table entries and index numbers corresponding to each table entry, each index number corresponds one-to-one to each logical unit of the solid-state drive, and each table entry records the usage status of the corresponding logical unit.
3. The method according to claim 2, characterized in that The determining, based on the first index table, at least two unused target logical units in the solid-state drive includes: In the first index table, searching for a first logical unit whose usage status is unused according to the index numbers of the entries from large to small or from small to large; If the capacity of the first logical unit is smaller than the capacity of the namespace, continue searching the first index table for a second logical unit whose usage status is unused; If the sum of the capacities of the first logical unit and the second logical unit is less than the capacity of the namespace, the first index table is continuously searched for unused logical units, and so on, until a k-th unused logical unit is found, and the sum of the capacities of the first to the k-th logical units is greater than or equal to the capacity of the namespace. In this case, the first to the k-th logical units are determined as the at least two target logical units, where k is an integer greater than 1.
4. The method according to claim 3, characterized in that Associating the at least two target logical units with the namespace to be created includes: Writing the identifiers of the at least two target logical units into blank entries in the second index table; The index numbers of the at least two target logical units in the second index table are written into blank entries in the third index table.
5. The method according to claim 4, characterized in that Writing the identifiers of the at least two target logical units into blank entries of the second index table includes: Determining a first blank entry in the second index table based on the total number of logical units in the solid-state drive and the number of unused or used logical units in the solid-state drive; the first blank entry is an entry in the second index table that is adjacent to the used entry; Writing the identifier of the first logical unit into the first blank entry in the second index table; The identifier of the second logic unit is written into the second blank entry adjacent to the first blank entry in the second index table, and so on, until the identifier of the kth logic unit is written into the kth blank entry in the second index table.
6. The method according to claim 5, characterized in that Writing the index numbers of the at least two target logical units in the second index table into blank entries in the third index table includes: The first index number in the second index table corresponding to the first blank entry and the number of the at least two target logical units are written into a blank entry in the third index table.
7. The method according to claim 4, characterized in that The method further comprises: receiving a data read / write request; the read / write request including an identifier of a namespace to be read / written, a first starting logical address of the data to be read / written within the namespace to be read / written, and a data length of the data to be read / written; Determining, in the namespace to be read / written, a logical unit corresponding to the first starting logical address based on the identifier of the namespace to be read / written, the first starting logical address, and the capacity of a single logical unit of the solid-state drive; wherein the capacity of each logical unit in the solid-state drive is the same; Determining a second starting logical address corresponding to the first starting logical address in the solid-state drive according to the first starting logical address, the logical unit corresponding to the first starting logical address, and the capacity of a single logical unit of the solid-state drive; Perform a read / write operation on the solid state drive according to the second starting logical address and the data length.
8. The method according to claim 7, characterized in that The determining, in the namespace to be read / written, a logical unit corresponding to the first starting logical address according to the identifier of the namespace to be read / written, the first starting logical address, and the capacity of a single logical unit of the solid-state drive, includes: Determining, in the third index table, a first entry corresponding to the namespace to be read / written according to the identifier of the namespace to be read / written; Determine the index number of the first starting entry in the second index table according to the index number stored in the first entry; Determining, according to the first starting logical address, the capacity of a single logical unit of the solid-state drive, and the index number of the first starting entry, an entry in the second index table corresponding to the first starting logical address; Obtain an identifier of the logical unit corresponding to the first starting logical address from the table entry corresponding to the first starting logical address.
9. The method according to claim 4, characterized in that The method further comprises: Receiving a namespace deletion request; wherein the deletion request includes an identifier of the namespace to be deleted; Determining, according to the identifier of the namespace to be deleted, a logical unit corresponding to the namespace to be deleted; The usage status of the logical unit corresponding to the to-be-deleted namespace is marked as unused.
10. The method according to claim 9, characterized in that The determining, according to the identifier of the namespace to be deleted, a logical unit corresponding to the namespace to be deleted includes: Determine, in the third index table, a second index number of the namespace to be deleted in the second index table according to the identifier of the namespace to be deleted; Obtaining an identifier of a logical unit in the entry corresponding to the second index number; The step of marking the usage status of the logical unit corresponding to the namespace to be deleted as unused includes: According to the obtained identifier of the logical unit, the usage status of the corresponding entry in the first index table is modified to unused.
11. The method according to claim 10, characterized in that The obtaining the identifier of the logical unit in the entry corresponding to the second index number includes: respectively obtaining identifiers of logical units in a plurality of entries corresponding to the second index number; the plurality of entries including a second starting entry; and the number of the plurality of entries being a first number; The method further comprises: In the second index table, delete identifiers of the logical units in the first number of consecutive entries starting from the second starting entry; In the second index table, the numbers of the logical units of all entries after the first number of entries are sequentially moved to the entries that are the first number of entries away from the entry where the logical units are located; Modify the index number and the number of logical units in the second entry in the third index table corresponding to the namespace to be deleted to 0; The first number is subtracted from the index number of each entry after the second entry in the third index table.
12. A device for operating a namespace of a solid state drive, characterized in that: include: A first receiving module is configured to receive a namespace creation request, wherein the creation request includes the capacity of the namespace to be created; a first determining module is configured to determine at least two unused target logical units in the solid-state drive; wherein the total capacity of the at least two target logical units is greater than or equal to the capacity of the namespace to be created, and the logical addresses of the at least two target logical units are discontinuous; and an associating module is configured to associate the at least two target logical units with the namespace to be created to serve as storage space for the namespace to be created.
13. An electronic device, characterized in that: The electronic device includes: a shell, a processor, a memory, a circuit board and a power supply circuit, wherein the circuit board is placed inside the space enclosed by the shell, and the processor and the memory are arranged on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs the program corresponding to the executable program code by reading the executable program code stored in the memory, and is used to execute the operating method of the namespace of the solid-state hard disk described in any one of the aforementioned claims 1-11.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the method for operating the namespace of the solid-state drive according to any one of claims 1 to 11.