Method and apparatus for writing data
By employing a single-threaded data writing method on solid-state drives, data storage is managed based on block status and write rate, solving the fragmentation problem in traditional methods and improving write efficiency and performance.
Patent Information
- Application Number
- CN201910987646.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-10-17
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2039-10-17
AI Technical Summary
Traditional methods of creating file systems on solid-state drives (SSDs) result in fragmentation and reduced write performance, impacting user experience.
Data is written to pre-divided solid-state drive blocks using a single thread, and the block status is marked according to the block status and write rate to avoid fragmentation.
It improves write efficiency, reduces fragmentation, and ensures stable read and write performance.
Smart Images

Figure CN110716699B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically to methods and apparatus for writing data. Background Technology
[0002] Ensuring efficient and stable SSD (Solid State Disk) write performance is a crucial aspect of storage system design. Traditionally, a file system similar to Ext4 (Fourth Extended File System) is created on the SSD, with multiple files created and concurrently written to using multiple threads. After a period of continuous writing, numerous fragments accumulate within the SSD, eventually triggering defragmentation. This leads to increased write amplification, a sharp decline in write performance, high read / write latency, and compromised read / write performance, ultimately impacting the user experience. Summary of the Invention
[0003] This application provides a method and apparatus for writing data.
[0004] In a first aspect, embodiments of this application provide a method for writing data, comprising: in response to receiving a data write instruction, determining a target block for storing data to be written from a plurality of blocks pre-divided for a solid-state drive, wherein the data write instruction includes information about the data to be written, and the solid-state drive is divided into a plurality of blocks according to striping parameters; determining the data to be written based on the information about the data to be written; and writing the data to be written into the target block using a single thread.
[0005] In some embodiments, the method further includes: marking the status of the target block according to the write rate of the target block.
[0006] In some embodiments, determining the target block for storing data from a plurality of blocks pre-divided for the solid-state drive includes: determining the target block from the plurality of blocks based on the state of each block.
[0007] In some embodiments, determining the target block for storing data from a plurality of blocks pre-divided for the solid-state drive includes: determining the target block from the plurality of blocks based on information about the data to be written.
[0008] In some embodiments, marking the status of the target block according to the write rate of the target block includes: marking the status of the target block as full in response to the target block being full; and marking the status of the target block as available in response to the target block not being full.
[0009] In some embodiments, the method further includes: after dividing the solid-state drive into multiple blocks, marking the status of the resulting multiple blocks as free; or in response to the deletion of data in a block, marking the status of the block with deleted data as free.
[0010] In some embodiments, determining the target block from the plurality of blocks based on the state of each block includes: in response to the existence of a block in an available state, selecting the block in an available state as the target block; and in response to the absence of a block in an available state, selecting a block from the blocks in an idle state as the target block.
[0011] In some embodiments, the method further includes: in response to the target block being full and the data to be written not being completely written, determining a new target block from the plurality of blocks, and writing the unwritten data into the new target block.
[0012] Secondly, embodiments of this application provide an apparatus for writing data, comprising: a target block selection unit configured to, in response to receiving a data write instruction, determine a target block for storing data to be written from a plurality of blocks pre-divided for a solid-state drive, wherein the data write instruction includes information about the data to be written, and the solid-state drive is divided into a plurality of blocks according to striping parameters; a data determination unit configured to determine the data to be written based on the information about the data to be written; and a data writing unit configured to write the data to be written into the target block using a single thread.
[0013] In some embodiments, the apparatus further includes a first status labeling unit configured to label the status of the target block according to the write rate of the target block.
[0014] In some embodiments, the target block selection unit is further configured to determine a target block from the plurality of blocks based on the state of each block.
[0015] In some embodiments, the target block selection unit is further configured to: determine a target block from the plurality of blocks based on the information of the data to be written.
[0016] In some embodiments, the first state labeling unit is further configured to: label the state of the target block as full in response to the target block being full; and label the state of the target block as available in response to the target block not being full.
[0017] In some embodiments, the above-described apparatus further includes a second status labeling unit, configured to: after dividing the solid-state drive into multiple blocks, label the status of the resulting multiple blocks as idle; or in response to the deletion of data in a block, label the status of the block whose data has been deleted as idle.
[0018] In some embodiments, the first state labeling unit is further configured to: in response to the existence of a block in an available state, select the block in the available state as the target block; in response to the absence of a block in an available state, select a block from the blocks in the idle state as the target block.
[0019] In some embodiments, the apparatus further includes a reselection unit configured to, in response to the target block being full and the data to be written not being completed, determine a new target block from the plurality of blocks and write the unwritten data into the new target block.
[0020] Thirdly, embodiments of this application provide an electronic device, including: one or more processors; and a storage device storing one or more programs thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any embodiment of the first aspect.
[0021] Fourthly, embodiments of this application provide a computer-readable medium having a computer program stored thereon that, when executed by a processor, implements the method as described in any embodiment of the first aspect.
[0022] The method and apparatus for writing data provided in the above embodiments of this application, upon receiving a data write instruction, can determine a target block for storing data from multiple blocks pre-divided for a solid-state drive (SSD). The data write instruction may include information about the data to be written, and the SSD is divided into multiple blocks based on striping parameters. Then, the data to be written is determined based on the information. Then, a single thread is used to write the data to the target block. Finally, the status of the target block is marked based on the write rate of the target block. The method of this embodiment, by partitioning the SSD and using single-threaded writing, can reduce disk fragmentation, thereby improving write efficiency. Attached Figure Description
[0023] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0024] Figure 1 This is an exemplary system architecture diagram in which one embodiment of this application can be applied;
[0025] Figure 2 This is a flowchart of one embodiment of the method for writing data according to this application;
[0026] Figure 3 This is a schematic diagram illustrating an application scenario of the method for writing data according to this application;
[0027] Figure 4 This is a flowchart of another embodiment of the method for writing data according to this application;
[0028] Figure 5 This is a schematic diagram of one embodiment of the apparatus for writing data according to this application;
[0029] Figure 6 This is a schematic diagram of the structure of a computer system suitable for implementing the electronic devices of the present application embodiments. Detailed Implementation
[0030] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.
[0031] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0032] Figure 1 An exemplary system architecture 100 is shown, in which embodiments of the method or apparatus for writing data of this application may be applied.
[0033] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0034] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social media platform software, etc.
[0035] Terminal devices 101, 102, and 103 can be either hardware or software. When terminal devices 101, 102, and 103 are hardware, they can be various electronic devices with displays, including but not limited to smartphones, tablets, e-book readers, laptops, and desktop computers. When terminal devices 101, 102, and 103 are software, they can be installed in the aforementioned electronic devices. They can be implemented as multiple software programs or software modules (e.g., to provide distributed services) or as a single software program or software module. No specific limitations are imposed here.
[0036] Server 105 can be a server that provides various services, such as a backend storage server that supports the data to be stored by terminal devices 101, 102, and 103. The backend storage server can analyze received data storage instructions and other data, and store the data to be stored on a solid-state drive.
[0037] It should be noted that a server can be either hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the server is software, it can be implemented as multiple software programs or software modules (e.g., used to provide distributed services), or as a single software program or software module. No specific limitations are made here.
[0038] It should be noted that the method for writing data provided in this application embodiment can be executed by terminal devices 101, 102, and 103, or by server 105. Accordingly, the device for writing data can be located in terminal devices 101, 102, and 103, or in server 105.
[0039] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0040] Continue to refer to Figure 2 The diagram illustrates a flow 200 of an embodiment of a method for writing data according to this application. The method for writing data in this embodiment includes the following steps:
[0041] Step 201: In response to receiving a data write command, determine the target block for storing the data to be written from a plurality of blocks pre-divided for the solid-state drive.
[0042] In this embodiment, the execution body of the method for writing data (e.g.) Figure 1The terminal devices 101, 102, 103, or server 105 shown can receive data write commands. These data write commands can be sent by the user or by other electronic devices. The data write commands can include information about the data to be written, such as storage address, size, and type. The multiple blocks partitioned for the solid-state drive (SSD) can be obtained based on band parameters. Technicians can consult the SSD's product manual to determine the band size and then divide the SSD into multiple blocks based on the band value. In some scenarios, the SSD can also be divided into multiple blocks based on integer multiples of the band value. After partitioning, the size of each block can be the same or different. For example, some blocks may be the same size as the band, while others may be twice the size of the band.
[0043] The executing entity can determine the target block for storing the data to be written from the aforementioned multiple blocks. Specifically, the executing entity can select the target block based on the size of the data to be written. Alternatively, the executing entity can select the target block based on the type of the data to be written.
[0044] In some optional implementations of this embodiment, the execution entity can determine the target block from multiple blocks based on information about the data to be written. This information may include size, type, etc.
[0045] In some optional implementations of this embodiment, the execution entity can determine the target block from multiple blocks based on the state of each block.
[0046] In this implementation, the block status can include: full, free, and available. Full indicates the block is full of data and no more data can be written. Free indicates the block is empty and can be used for data storage. Available indicates the block has partially stored data, but there is still free space available for further data storage. In some application scenarios, the executing entity can select a block in the available state as the target block to avoid fragmentation.
[0047] Step 202: Determine the data to be written based on the information of the data to be written.
[0048] After receiving a data write instruction, the executing entity can determine the data to be written based on the information included in the instruction. Specifically, the executing entity can retrieve the data to be written based on its address.
[0049] Step 203: Use a single thread to write the data to be written into the target block.
[0050] After determining the data to be written and the target block, the execution entity can use a single thread to write the data to the target block. In existing technical solutions, multiple threads are often used to store data, and each thread often randomly selects a storage address, leading to increased fragmentation. In this embodiment, however, a single thread is used to store the data to be written in the target block, thereby reducing write amplification during storage and avoiding fragmentation, thus improving storage efficiency. In some implementation scenarios, the execution entity can use a fixed thread to write data to various blocks of the solid-state drive.
[0051] In some optional implementations of this embodiment, the above method may further include Figure 2 The following steps, not shown in the diagram, are used to mark the status of the target block based on its write rate.
[0052] In this implementation, the execution entity can calculate the write rate of the target block. Specifically, the execution entity can use the ratio of the size of the data stored in the target block to the size of the target block during the write process as the write rate. Then, based on the write rate, it determines whether the target block is full, thus marking the target block's status. For example, if the write rate of the target block is 100%, the target block is full, and its status is marked as full. If the write rate of the target block is less than 100%, the target block is not full, and its status is marked as available.
[0053] In some optional implementations of this embodiment, the executing entity can mark the target block as full after determining that the target block is full. When it is determined that the target block is not full, the target block can be marked as available.
[0054] In some optional implementations of this embodiment, after dividing the solid-state drive into multiple blocks, the execution entity can mark each block as free. Alternatively, the block can be marked as free after data in the block is deleted.
[0055] In this implementation, the execution entity can indicate that the block has not been written to by marking its status as free. When selecting a target block, it can choose from the blocks in the free state.
[0056] In some optional implementations of this embodiment, the execution entity can determine the target block from multiple blocks based on the state of each block.
[0057] In this implementation, the block status can include: full, free, and available. Full indicates the block is full of data and no more data can be written. Free indicates the block is empty and can be used for data storage. Available indicates the block has partially stored data, but there is still free space available for further data storage. In some application scenarios, the executing entity can select a block in the available state as the target block to avoid fragmentation.
[0058] In some optional implementations of this embodiment, when determining the target block, the execution entity may first determine whether there is a block in an available state. If so, the block in an available state is used as the target block. If not, a block can be selected from the blocks in an idle state as the target block.
[0059] See also Figure 3 , Figure 3 This is a schematic diagram illustrating an application scenario of the method for writing data according to this embodiment. Figure 3 In this application scenario, a user stores a 12GB file on a solid-state drive (SSD). The SSD's control unit selects block 1 (16GB) from a pre-divided block set as the target block to store the file. Then, a single thread is used to write the file into the target block.
[0060] The method for writing data provided in the above embodiments of this application uses a single thread to store the data to be written in the target block, thereby reducing write amplification during storage and avoiding fragmentation, thus improving storage efficiency.
[0061] See also Figure 4 This illustrates flow 400 of another embodiment of the method for writing data according to this application. Figure 4 As shown, the method for writing data in this embodiment may include the following steps:
[0062] Step 401: In response to receiving a data write instruction, determine the target block for storing the data to be written from a plurality of blocks pre-divided for the solid-state drive.
[0063] Step 402: Determine the data to be written based on the information of the data to be written.
[0064] Step 403: Use a single thread to write the data to be written into the target block.
[0065] The principles of steps 401 to 403 are similar to those of steps 201 to 203, and will not be repeated here.
[0066] Step 404: In response to the target block being full and the data to be written not being completed, a new target block is determined from multiple blocks, and the unwritten data is written into the new target block.
[0067] In this embodiment, if the target block is full but the data to be written has not yet been completed, the execution entity can determine a new target block from multiple blocks. That is, it selects one of the multiple idle blocks as the target block. Then, the unwritten data is written into the new target block.
[0068] The method for writing data provided in the above embodiments of this application can avoid fragmentation and reduce the number of defragmentation operations by using a single thread to write data to each data block sequentially, thereby improving writing efficiency.
[0069] Further reference Figure 5 As an implementation of the methods shown in the above figures, this application provides an embodiment of a device for writing data, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0070] like Figure 5 As shown, the device 500 for writing data in this embodiment includes: a target block selection unit 501, a data determination unit 502, and a data writing unit 503.
[0071] The target block selection unit 501 is configured to, in response to receiving a data write command, determine a target block from a plurality of blocks pre-divided for the solid-state drive (SSD) for storing the data to be written. The data write command includes information about the data to be written, and the SSD is divided into multiple blocks according to striping parameters.
[0072] The data determination unit 502 is configured to determine the data to be written based on the information of the data to be written.
[0073] The data writing unit 503 is configured to use a single thread to write the data to be written into the target block.
[0074] In some optional implementations of this embodiment, the device 500 may further include Figure 5 The first state labeling unit, not shown, is configured to label the state of the target block according to the write rate of the target block.
[0075] In some optional implementations of this embodiment, the target block selection unit 501 is further configured to: determine the target block from multiple blocks based on the state of each block.
[0076] In some optional implementations of this embodiment, the target block selection unit 501 is further configured to: determine the target block from multiple blocks based on the state of each block.
[0077] In some optional implementations of this embodiment, the first state labeling unit is further configured to: label the state of the target block as full in response to the target block being full; and label the state of the target block as available in response to the target block not being full.
[0078] In some optional implementations of this embodiment, the device 500 may further include Figure 5 The second status labeling unit (not shown) is configured to: mark the status of the resulting blocks as free after the solid-state drive is divided into multiple blocks; or mark the status of the block containing the deleted data as free in response to the deletion of data in the block.
[0079] In some optional implementations of this embodiment, the first state labeling unit is further configured to: in response to the existence of a block in an available state, select the block in an available state as the target block; in response to the absence of a block in an available state, select a block from the blocks in an idle state as the target block.
[0080] In some optional implementations of this embodiment, the device 500 may further include Figure 5 The reselection unit, not shown, is configured to determine a new target block from multiple blocks in response to a target block being full or the data to be written not being completed, and to write the unwritten data into the new target block.
[0081] It should be understood that units 501 to 503 described in the device 500 for writing data are respectively related to the reference. Figure 2 The steps in the method described above correspond to those in the previous section. Therefore, the operations and features described above for the method of writing data also apply to the device 500 and the units contained therein, and will not be repeated here.
[0082] The following is for reference. Figure 6 It illustrates an electronic device suitable for implementing embodiments of the present disclosure (e.g., Figure 1 A structural diagram of the server or terminal device (600) in the system. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0083] like Figure 6As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0084] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 6 Each box shown can represent a device or multiple devices as needed.
[0085] Specifically, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by a processing device 601, it performs the functions defined in the methods of embodiments of this disclosure. It should be noted that the computer-readable medium described in embodiments of this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In embodiments of this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In embodiments of this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0086] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: in response to receiving a data write instruction, determine a target block for storing data to be written from a plurality of blocks pre-divided for the solid-state drive. The data write instruction includes information about the data to be written; the solid-state drive is divided into multiple blocks according to striping parameters; the data to be written is determined based on the information about the data to be written; and the data to be written is written to the target block using a single thread.
[0087] Computer program code for performing the operations of embodiments of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0088] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0089] The units described in the embodiments of this disclosure can be implemented in software or hardware. The described units can also be located in a processor; for example, a processor can be described as including a target block selection unit, a data determination unit, and a data writing unit. The names of these units do not necessarily limit the unit itself; for example, a data writing unit can also be described as "a unit that uses a single thread to write data to be written into a target block."
[0090] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in the embodiments of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in the embodiments of this disclosure.
Claims
1. A method for writing data, comprising: determining a target block for storing data to be written from a plurality of blocks pre-divided for a solid state disk according to a state of each block in response to receiving a data write instruction, wherein the data write instruction comprises information of the data to be written, and the solid state disk is divided into the plurality of blocks according to a stripe parameter; selecting a block in an available state as the target block in response to that there is currently a block in the available state; selecting a block in an idle state as the target block in response to that there is currently no block in the available state, determining the data to be written according to the information of the data to be written, and writing the data to be written into the target block by using a single thread, and marking a state of the target block according to a write rate of the target block; determining a new target block from the plurality of blocks in response to that the target block is full and the data to be written is not written completely, and writing the data not written into the new target block.
2. The method of claim 1, wherein, The marking of the state of the target block according to the write rate of the target block comprises: marking the state of the target block as full in response to that the target block is full; marking the state of the target block as available in response to that the target block is not full.
3. The method of claim 1, wherein, The method further comprises: marking the state of the plurality of blocks obtained after dividing the solid state disk into the plurality of blocks as idle; or marking the state of a block in which data is deleted as idle in response to that the data in the block is deleted. 4.An apparatus for writing data, comprising: a target block selecting unit configured to determine a target block for storing data to be written from a plurality of blocks pre-divided for a solid state disk according to a state of each block in response to receiving a data write instruction, wherein the data write instruction comprises information of the data to be written, and the solid state disk is divided into the plurality of blocks according to a stripe parameter; a first state marking unit configured to select a block in an available state as the target block in response to that there is currently a block in the available state, and select a block in an idle state as the target block in response to that there is currently no block in the available state; a data determining unit configured to determine the data to be written according to the information of the data to be written; a data writing unit configured to write the data to be written into the target block by using a single thread, and the first state marking unit is further configured to mark a state of the target block according to a write rate of the target block; a re-selecting unit configured to determine a new target block from the plurality of blocks in response to that the target block is full and the data to be written is not written completely, and write the data not written into the new target block.
5. The apparatus of claim 4, wherein, The first state marking unit is further configured to: mark the state of the target block as full in response to that the target block is full; mark the state of the target block as available in response to that the target block is not full.
6. The apparatus of claim 4, wherein, The apparatus further comprises a second state marking unit configured to: mark the state of the plurality of blocks obtained after dividing the solid state disk into the plurality of blocks as idle; or mark the state of a block in which data is deleted as idle in response to that the data in the block is deleted. 7.An electronic device, comprising: one or more processors; a solid state drive having stored thereon one or more programs, when the one or more programs are executed by the one or more processors, cause the one or more processors to carry out the method of any one of claims 1-3.
8. A solid state drive having stored thereon a computer program, wherein, the program, when executed by the processor, causes the processor to carry out the method of any one of claims 1-3.
Citation Information
Patent Citations
Method and device for selecting data blocks, apparatus and readable storage medium
CN109189337A
Data processing method and related equipment
CN110286858A