Data writing method, system and device, electronic equipment and storage medium
By using the Zone UFS technology between the host and the extended storage device, the method of matching logical blocks and physical blocks by writing pointers is solved, and the writing performance of extended storage devices is improved.
Patent Information
- Application Number
- CN202510194301.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-05-23
AI Technical Summary
In Zone UFS technology, data writing instructions may be processed in parallel, resulting in data writing instructions being out of order before reaching the extended storage device, affecting the writing performance.
When sending write instructions to the extended storage device through the host, it is determined whether the physical block indicated by the write pointer in the first memory partition matches the corresponding logical block physical block. If it does not match, data is written into the physical block of the second memory partition.
When the extended storage device receives multiple data write instructions at the same time, the write instruction blockage caused by out-of-order data is avoided, and the write performance of the extended storage device is improved.
Smart Images

Figure CN120029551A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and specifically relates to a data writing method, system, device, electronic device and storage medium. Background Art
[0002] The storage system consists of a host and an extended storage device. The host issues a data write instruction to write data to the extended storage device, and the host issues a data read instruction to retrieve data from the extended storage device. In order to better manage the extended storage device, the host can use Zone Universal Flash Storage (UFS) technology.
[0003] Zone UFS requires that data be written in each zone of the host and each zone of the extended storage device in strict accordance with the ascending order of the logical block address of the host and the physical block address of the extended storage device. However, in the process of issuing data write instructions, because data write instructions may be processed in parallel, the data write instructions may be out of order before reaching the extended storage device.
[0004] Currently, in order to prevent the disorder problem in data write instructions, the queue depth of data write instructions is set to 1, that is, only one data write instruction is executed at the same time in each Zone of the extended storage device, and the write instructions of other data will be blocked. However, the above method will seriously affect the write performance of the extended storage device. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a data writing method, system, device, electronic device and storage medium to improve the writing performance of an extended storage device.
[0006] In a first aspect, an embodiment of the present application provides a data writing method, the method comprising:
[0007] Sending a first write instruction to the extended storage device through the host; the first write instruction is used to instruct to write the first data in the first logic block of the host to the first storage partition of the extended storage device;
[0008] Determine, by the host, a physical block indicated by a first write pointer in the first storage partition; the first write pointer is used to indicate a next physical block located in an occupied physical block based on a data writing order;
[0009] When the physical block indicated by the first write pointer does not match the first physical block in the first storage partition, the first data is written into the second physical block of the second storage partition of the extended storage device by the host; the first physical block corresponds to the first logical block.
[0010] In a second aspect, an embodiment of the present application provides a data writing system, the system comprising:
[0011] A host computer, the host computer comprising a plurality of logic blocks for managing data;
[0012] An extended storage device, the extended storage device comprising a first storage partition and a second storage partition, the first storage partition and the second storage partition each comprising a plurality of physical blocks for managing data, the plurality of logical blocks corresponding one-to-one to the plurality of physical blocks in the first storage partition;
[0013] The host is configured as:
[0014] Sending a first write instruction to the extended storage device, where the first write instruction is used to instruct writing first data in a first logic block of the host into a first storage partition of the extended storage device;
[0015] Determine a physical block indicated by a first write pointer in the first storage partition, wherein the first write pointer is used to indicate a physical block next to an occupied physical block based on a data writing order;
[0016] When the physical block indicated by the first write pointer does not match the first physical block in the first storage partition, the first data is written into a second physical block of the second storage partition of the extended storage device, the first physical block corresponding to the first logical block.
[0017] In a third aspect, an embodiment of the present application provides a data writing device, the device comprising:
[0018] A sending module, used for sending a first write instruction to the extended storage device through the host; the first write instruction is used for instructing to write the first data in the first logic block of the host into the first storage partition of the extended storage device;
[0019] A determination module, configured to determine, through the host, a physical block indicated by a first write pointer in the first storage partition; the first write pointer is configured to indicate a next physical block located in an occupied physical block based on a data writing order;
[0020] A write module is used to write the first data into a second physical block of a second storage partition of the extended storage device through the host when the physical block indicated by the first write pointer does not match the first physical block in the first storage partition; the first physical block corresponds to the first logical block.
[0021] In a fourth aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.
[0022] In a fifth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0023] In a sixth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0024] In a seventh aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
[0025] In an embodiment of the present application, when the host sends a first write instruction to the extended storage device to write the first data at the first logical block in the host into the first storage partition of the extended storage device, the host can determine whether the physical block indicated by the first write pointer in the first storage partition, which is used to point to the next physical block of the occupied physical block based on the data write order, matches the first physical block corresponding to the first logical block. In the case that the physical block indicated by the first write pointer does not match the first physical block, that is, when the order of data to be written in the first write instruction received by the extended storage device is disordered, the first data can be written to the second physical block of the second storage partition based on the host. In this way, when the extended storage device simultaneously receives a write instruction to write multiple data to the extended storage device, even if the order of the received data to be written is disordered, the data to be written can be written to the extended storage device based on the solution of the embodiment of the present application, without the need for the extended storage device to block the write instruction of the disordered data, thereby improving the write performance of the extended storage device. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a schematic diagram of the relationship between data managed by a host based on traditional technology and data managed by an extended storage device provided by the prior art;
[0027] Figure 2 It is a schematic diagram of the relationship between data managed by a host and data managed by an extended storage device based on Zone UFS technology provided in the prior art;
[0028] Figure 3It is a schematic diagram of a flow chart for providing data writing in the prior art;
[0029] Figure 4 is a flowchart of a data writing method provided by some embodiments of the present application;
[0030] Figure 5 is a schematic diagram of the structure of an extended storage device provided in some embodiments of the present application;
[0031] Figure 6 is a schematic diagram of a data writing process provided by some embodiments of the present application;
[0032] Figure 7 is a schematic diagram of a data writing process provided by some embodiments of the present application;
[0033] Figure 8 is a schematic diagram of a data writing process provided by some embodiments of the present application;
[0034] Fig. 9 is a schematic diagram of a data writing process provided by some embodiments of the present application;
[0035] Fig.10 is a schematic diagram of a data reading process provided by some embodiments of the present application;
[0036] Fig.11 is a flowchart of a data writing method provided by some embodiments of the present application;
[0037] Fig.12 is a schematic diagram of the structure of a data writing system shown in some embodiments of the present application;
[0038] Fig.13 is a schematic diagram of the structure of an electronic device shown in some embodiments of the present application;
[0039] Fig.14 It is a schematic diagram of the hardware structure of an electronic device shown in some embodiments of the present application. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0041] The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or N. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0042] Before introducing the technical solution of the embodiment of the present application, the background technology of the embodiment of the present application is first introduced:
[0043] The storage system of an electronic device consists of a host and an extended storage device. The host here can be but not limited to a personal computer (PC), a smart phone, a tablet computer or a personal digital assistant (PDA), etc. The extended storage device can be a device external to the host for expanding the storage space of the host, which can be but not limited to an SD card, a mobile hard disk or a USB flash drive, etc. The extended storage device can use UFS technology to manage data, so the extended storage device can also be called a UFS device.
[0044] The space where the host manages data is called the logical space, and the smallest unit for managing data is the logical block. Each logical block has a corresponding address called the logical address (LBA). The corresponding space for managing data inside the UFS device is called the physical space, and the smallest unit for managing data is called the physical block. Each physical block has a corresponding address called the physical address (PBA).
[0045] The current UFS device is equivalent to a black box to the host. In the UFS device, the storage and management of data are completely opaque. Figure 1 As shown, the host is completely unknown to the discharge locations of data 1, data 2, data 3, data 4, data 5 and data 6 written into the UFS device.
[0046] To solve Figure 1 The data storage and management in the extended storage device is completely opaque to the host. In order to better manage UFS devices, the host introduces Zone UFS technology. The extended storage device that uses Zone UFS technology can be called a ZUFS device.
[0047] Zone UFS technology aggregates the same number of physical blocks in the UFS device into a physical zone, and aggregates the logical blocks of the same data into a logical zone in the host.
[0048] like Figure 2 As shown, in the UFS device, physical blocks 21, 22, 23, 24, 25 and 26 are aggregated into physical Zone 0, wherein physical block 21 stores data 1, physical block 22 stores data 2, physical block 23 stores data 3, physical block 24 stores data 4, physical block 25 stores data 5 and physical block 26 stores data 6, that is, in the logical space of the host, logical block 201 storing data 1, logical block 202 storing data 2, logical block 203 storing data 3, logical block 204 storing data 4, logical block 205 storing data 5 and logical block 206 storing data 6 can be aggregated into logical Zone 0.
[0049] Both physical and logical zones strictly follow the order of increasing addresses for writing operations. Only one write pointer is maintained inside them to record the location of the block to be written next time. At the same time, the write pointer can only be updated in the order of increasing addresses. Because both logical and physical zones update data in the same "block address increasing" manner at the same time, it is like a mirror. When a user operates a logical address of the host, it is equivalent to directly managing the physical block address of the same offset inside the ZUFS device. Therefore, the host can indirectly control which physical block of the ZUFS device the data should be written to. In other words, each physical address corresponds to a logical address. The logical address can be understood as a directory, and the physical address can be understood as the specific content of the directory. If you want to find a certain data, you can find the corresponding data according to the directory.
[0050] Zone UFS technology requires that data be written in each zone in strict accordance with the increasing order of LBA (Logical Block Address) and PBA (Physical Block Address). However, in the process of issuing write instructions, because the instructions may be processed in parallel, this causes the write instructions to be out of order before reaching the ZUFS device. For example, refer to Figure 3 The user wants to operate the data of LBA1, the data of LBA2 and the data of LBA3, and therefore issues a write instruction for writing the data of LBA1, a write instruction for writing the data of LBA2 and a write instruction for writing the data of LBA3.
[0051] Under normal circumstances, when writing LBA1 data, LBA2 data, and LBA3 data in the ZUFS device, they should be written in the order of increasing addresses, that is, write LBA1 data first, then write LBA2 data, and finally write LBA3 data. However, the time when the write instructions for writing LBA1 data, LBA2 data, and LBA3 data arrive at the ZUFS device may be out of order, for example, the write instruction for LBA2 data may arrive first, the write instruction for writing LBA3 data may arrive second, and the write instruction for writing LBA1 data may arrive last, because in the ZUFS device, the write pointer points to the next location to be written and can only be executed in the order of increasing addresses (that is, it cannot go in reverse), so the LBA2 data will be written to the disk first, the LBA3 data will be written to the disk second, and finally the LBA1 data will be written to the ZUFS device. However, in the ZUFS device, the write pointer should point to the physical block for writing LBA1 data, and what is received now is LBA2 data. Therefore, at this time, the ZUFS device will report an error, which will cause the data of LBA1, LBA2 and LBA3 to be unable to be written into the ZUFS device. This is because once the ZUFS device reports an error, the subsequent write instructions received cannot be executed.
[0052] In order to prevent the disorder problem during the issuance of write instructions, the queue depth of the write instruction is generally set to 1 in the host scheduler (the scheduler is used to control the issuance of write instructions), that is, only one write instruction can be executed on each physical zone at the same time, and the remaining write instruction requests will be blocked by the scheduler, that is, the write instruction for writing LBA1 data is issued first, and after waiting for the LBA1 data to be written into the ZUFS device, the write instruction for writing LBA2 data is issued, and then after waiting for the LBA2 data to be written into the ZUFS device, the write instruction for writing LBA3 data is issued, and so on. That is, it is not allowed to issue multiple write instructions at the same time, which will seriously affect the write performance of the ZUFS device and reduce the write performance of the ZUFS device.
[0053] In order to solve the above problems, the embodiments of the present application provide a data writing method, system, device, electronic device and storage medium. When a host sends a first write instruction to an extended storage device to write first data at a first logical block in the host into a first storage partition of the extended storage device, the host can determine whether a physical block indicated by a first write pointer used to point to a physical block to which data is to be written next in the first storage partition matches the first physical block corresponding to the first logical block. When the physical block indicated by the first write pointer does not match the first physical block, that is, when the order of data to be written in the first write instruction received by the extended storage device is out of order, the first data can be written to the second physical block of the second storage partition based on the host. In this way, when the extended storage device simultaneously receives a write instruction to write multiple data to the extended storage device, even if the order of the received data to be written is out of order, the data to be written can be written to the extended storage device based on the solution of the embodiments of the present application, without the need for the extended storage device to block the write instruction of the out-of-order data, thereby improving the write performance of the extended storage device.
[0054] The technical solution of the embodiment of the present application can be applied to an electronic device including a host and an extended storage device, in a scenario where data is written when write instructions for multiple data are issued simultaneously.
[0055] The data writing method provided in the embodiment of the present application is described in detail below through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0056] Figure 4 It is a flow chart of a data writing method provided in an embodiment of the present application. The executor of the data writing method may be an electronic device, which may include a host and an extended storage device. The host may include multiple logical blocks for managing data; the extended storage device may include a first storage partition and a second storage partition.
[0057] The first storage partition and the second storage partition may be two storage partitions constituting the extended storage device, wherein the first storage partition may be a conventional logic unit (CLU) partition, which may be understood as a temporary storage partition. The second storage partition may be a zone logic unit (ZLU) partition, which may be understood as a partition divided based on the Zone UFS technology.
[0058] Both the first storage partition and the second storage partition may include a plurality of physical blocks for managing data, and the plurality of logical blocks correspond one-to-one to the plurality of physical blocks in the first storage partition.
[0059] refer to Figure 5The extended storage device 50 includes a first storage partition 51 and a second storage partition 52. The first storage partition 51 and the second storage partition 52 each include a plurality of physical blocks. The plurality of physical blocks in the first storage partition 51 correspond one-to-one to the plurality of logical blocks in the host.
[0060] In some embodiments of the present application, the same number of physical blocks in the first storage partition can be aggregated into a physical zone. Similarly, logical blocks of the same data in the host can be aggregated into a logical zone, so that each physical zone in the first storage partition corresponds to each logical zone in the host. For each physical block in a single physical zone, the logical block in the corresponding logical zone also corresponds to each other.
[0061] like Figure 5 As shown, the first storage partition 51 includes two physical zones, Zone 0 and Zone 1, and both Zone 0 and Zone 1 have corresponding logical zones in the host.
[0062] It should be noted that the physical blocks in the first storage partition may not be aggregated to form a physical zone, that is, all the physical blocks in the first storage partition form a physical zone separately. Whether to aggregate the same number of physical blocks in the first storage partition to form a physical zone can be set according to user needs and is not limited in the embodiments of the present application.
[0063] like Figure 4 As shown, the data writing method provided in the embodiment of the present application may include steps 410 to 430.
[0064] Step 410: Send a first write instruction to the extended storage device through the host.
[0065] The first write instruction may be an instruction sent by the host to the extended storage device to write the first data in the first logic block in the host into the first storage partition of the extended storage device.
[0066] The first logic block mentioned above may be a logic block in the host, and the first data may be data stored in the first logic block.
[0067] In some embodiments of the present application, the first write instruction may include a write instruction to write data in multiple logic blocks into the extended storage device, that is, the above-mentioned first logic block may be multiple logic blocks in the host.
[0068] refer to Figure 6The host requires that data 4 of LBA4, data 5 of LBA5 and data 6 of LBA6 in the host be written in Zone 0 of the first storage partition 61, that is, the first write instruction may include a write instruction for writing data 4 of LBA4, a write instruction for data 5 of LBA5 and a write instruction for data 6 of LBA6 in the host, and the above-mentioned LBA4, LBA5 and LBA6 are the first logical block, data 4 is the data stored in the first logical block LBA4, data 5 is the data stored in the first logical block LBA5, and data 6 is the data stored in the first logical block LBA6.
[0069] Step 420: Determine, by the host, the physical block indicated by the first write pointer in the first storage partition.
[0070] The first write pointer may be used to indicate the next physical block of the occupied physical blocks in the first storage partition based on the data writing order.
[0071] Continue to refer Figure 6 Before writing data 4 of LBA4, data 5 of LBA5 and data 6 of LBA6 in the host, that is, before the extended storage device receives the first write instruction, based on the data writing order, the physical block that has been occupied in the first storage partition 61 is the physical block with data "3" written on it. Therefore, the physical block pointed to by the first write pointer 62 is the next physical block of the physical block with data "3" written on it, that is, the first write pointer 62 points to the physical block corresponding to LBA4, that is, the position of physical block 63.
[0072] Step 430: When the physical block indicated by the first write pointer does not match the first physical block, the host writes the first data into the second physical block of the second storage partition of the extended storage device.
[0073] The first physical block may be a physical block in the first storage partition corresponding to the first logical block storing the first data in the host.
[0074] The second physical block may be any physical block in the second storage partition.
[0075] In some embodiments of the present application, when the physical block indicated by the first write pointer does not match the first physical block, the first storage partition will report an error, and the first data cannot be written to the first storage partition. The host can then write the first data to the second physical block of the second storage partition.
[0076] Continue to refer Figure 6The first write instruction sent by the host to the extended storage device is to write data 4 of LBA4, data 5 of LBA5 and data 6 of LBA6 in the host to the extended storage device. However, when the extended storage device receives the above first write instruction, it first receives the write instruction of data 5 of LBA5, then receives the write instruction of data 4 of LBA4, and finally receives the write instruction of data 6 of LBA6.
[0077] If the physical block corresponding to LBA5 in the host is physical block 64, that is, physical block 64 is the first physical block, but the physical block pointed to by the first write pointer 62 is physical block 63, that is, the physical block 63 pointed to by the first write pointer 62 is inconsistent with the physical block 64 corresponding to LBA5, then the data 5 of LBA5 can be written to the physical block 66 of the second storage partition 65.
[0078] It should be noted that the physical blocks in the second storage partition can be of two types, namely single-level cell (SLC) physical blocks and triple-level cell (TLC) physical blocks. Specifically, an SLC physical block stores 1 bit of data, and a TLC physical block stores 3 bits of data.
[0079] Since the write speed of SLC type physical blocks is much faster than that of TLC type physical blocks, some physical blocks in the second storage partition can be configured as SLC type. When writing data to the second storage partition, the data can be written into SLC type physical blocks.
[0080] Continue to refer Figure 6 , Figure 6 The physical blocks in area 651 in the second storage partition 65 can be configured as SLC type, and the physical block 66 can be an SLC type physical block, that is, the data 5 of LBA5 can be written into the SLC type physical block 66 of the second storage partition 65.
[0081] It should be noted that the type of physical blocks in the second storage partition may not be set. When the type of physical blocks in the second storage partition is not set, the type of physical blocks in the second storage partition defaults to TLC type, that is, the physical blocks in the second storage partition may also be of TLC type. In this way, the speed of writing data will be relatively slower. The specific type of physical blocks in the second storage partition can be set according to user needs and is not limited in the embodiments of the present application.
[0082] In some embodiments of the present application, after step 420, the above method may further include:
[0083] In a case where the physical block indicated by the first write pointer matches the first physical block, the first data is written into the first physical block through the host.
[0084] In some embodiments of the present application, when the physical block indicated by the first write pointer matches the first physical block, the host may directly write the first data into the first physical block.
[0085] Continuing with the above example, Figure 7 As shown, if the host issues a write instruction for data 4 of LBA4, a write instruction for data 5 of LBA5, and a write instruction for data 6 of LBA6, the write instruction for data 4 of LBA4 arrives first, then the write instruction for data 5 of LBA5 arrives, and finally the write instruction for data 6 of LBA6 arrives, that is, the write instructions for each data to be written arrive in the order issued by the host, before writing data 4 of LBA4, data 5 of LBA5, and data 6 of LBA6 in the host, the first write pointer 72 points to the physical block to which the next data is to be written, that is, the first write pointer 72 points to the position of physical block 73, if the physical block corresponding to LBA4 in the host is physical block 73 (that is, physical block 73 is the first physical block), that is, the physical block pointed to by the first write pointer 72 is consistent with the physical block corresponding to LBA4, then data 4 of LBA4 can be written to physical block 73 of the first storage partition 71.
[0086] In an embodiment of the present application, when the physical block indicated by the first write pointer matches the first physical block, the host can directly write the first data into the first physical block, thereby ensuring that the first data is written into the correct physical block, thereby improving the writing correctness of the first data.
[0087] In some embodiments of the present application, the first storage partition may further include a second write pointer, such as Figure 6 The second write pointer 67 and Figure 7 The second write pointer 78 in the physical zone can be used to point to the next physical block to be written with data. For an empty physical zone, the first write pointer and the second write pointer both point to the first physical block of the physical zone.
[0088] After the host writes the first data into the first physical block, the method may further include:
[0089] Control the first write pointer and the second write pointer to point to the third physical block through the host, and mark the storage state of the first storage partition as the first state;
[0090] The third physical block may be a physical block located after the first physical block in the first storage partition. Figure 7 As shown, the first physical block is physical block 73 and the third physical block is physical block 74 .
[0091] The first state can be used to indicate that the physical blocks corresponding to the data stored in the first storage partition all correspond to the logical blocks in the host, that is, the physical blocks of each data stored in the first storage partition are physical blocks corresponding to the logical blocks in the host, that is to say, the first storage partition is full of sequential data.
[0092] like Figure 7 As shown, physical block 73 stores data 4 of LBA4 corresponding to physical block 73, physical block 75 stores data 3 of LBA3 corresponding to physical block 75, physical block 76 stores data 2 of LBA2 corresponding to physical block 76, and physical block 77 stores data 1 of LBA1 corresponding to physical block 77. At this time, the state of the first storage partition 71 is the first state, for example, the first state may be a true state.
[0093] In some embodiments of the present application, after the host writes the first data into the first physical block, the host can control the first write pointer and the second write pointer to point to the next physical block, and mark the state of the first storage partition as the first state, that is, after the data is written to the first storage partition in sequence, the first write pointer +1 and the second write pointer +1 can be set, and the storage state of the first storage partition can be marked as true state.
[0094] Continue to refer Figure 7 In the example shown, after writing the data 4 of LBA4 into the physical block 73 of the first storage partition 71, as shown in FIG. Figure 8 As shown, the first write pointer 72 and the second write pointer 78 can be moved back one physical block, that is, the first write pointer 72 and the second write pointer 78 both point to the physical block 74, and the status of Zone 0 in the first storage partition 71 is marked as true, indicating that the data in Zone 0 in the current first storage partition 71 are all written in sequence.
[0095] In an embodiment of the present application, by maintaining two write pointers in the first storage partition, which are used to manage the offsets of normal write instructions and out-of-order write instructions respectively, out-of-order write instructions can be better managed. At the same time, after the first data is written to the first physical block through the host, the first write pointer and the second write pointer can be controlled by the host to point to the third physical block, and the storage state of the first storage partition can be marked as the first state. In this way, after the write instruction is executed, the storage state of the first storage partition can be marked according to the execution status of the write instruction, so that the storage state of the first storage partition can be intuitively viewed.
[0096] In some embodiments of the present application, after step 430, the above method may further include:
[0097] The host controls the first physical block pointed to by the first write pointer to remain unchanged, controls the second write pointer to point to the third physical block, and marks the storage state of the first storage partition as the second state.
[0098] The second state may be used to indicate that there is data in the first storage partition that should not be written, that is, data that should be written into the first storage partition is not written into the first storage partition.
[0099] like Figure 6 As shown, the data of LBA5 should be written into the physical block 64 corresponding to LBA5, but no data is written into the physical block 64. At this time, the state of Zone 0 in the first storage partition 61 is the second state, for example, the second state may be a false state.
[0100] It should be noted that, in the case where Zones are divided in the first storage partition, the state of the first storage partition may be the state of the currently operated Zone, that is, as described above Figure 6 and Figure 7 The example shown in Figure 7 In the example, the current operation is on Zone 0 in the first storage partition 71, and the state of Zone 0 in the first storage partition 71 is the first state. Figure 6 In the example, the current operation is on Zone 0 in the first storage partition 61, and the state of Zone 0 in the first storage partition 61 is the second state.
[0101] In some embodiments of the present application, after the host writes the first data into the second physical block of the second storage partition, the host can control the position of the first physical block pointed to by the first write pointer to remain unchanged, and control the second write pointer to point to the third physical block, and mark the storage status of the first storage partition as the second state, that is, when the data is not written to the first storage partition in sequence, the host can control the first write pointer to remain unchanged, but the second write pointer +1, and mark the storage status of the first storage partition as false.
[0102] Continue to refer Figure 6Before writing data 4 of LBA4, data 5 of LBA5 and data 6 of LBA6 in the host, the second write pointer 67 in the first storage partition 61 also points to the position of physical block 63. However, after writing data 5 of LBA5 to physical block 66 of the second storage partition 65, although data 4 of LBA4 is not written to physical block 63 and data 5 of LBA5 is not written to physical block 64, physical block 63 is already occupied by data 4 of LBA4 and physical block 64 is also occupied by data 5 of LBA5. Therefore, at this time, the second write pointer 67 will point to the position of physical block 68, but the first write pointer 62 still points to physical block 63 unchanged, and then the status of Zone 0 in the first storage partition 61 is marked as false, indicating that there is data in Zone 0 in the current first storage partition 61 that should not be written in sequence.
[0103] In an embodiment of the present application, after executing a write instruction by a host to write the first data to the second physical block of the second storage partition of the extended storage device, the host can control the first physical block pointed to by the first write pointer to remain unchanged, and control the second write pointer to point to the third physical block, and mark the storage status of the first storage partition as the second state. In this way, the storage status of the first storage partition can be marked according to the execution status of the write instruction, so that the storage status of the first storage partition can be intuitively viewed.
[0104] In some embodiments of the present application, after step 430, the above method may further include:
[0105] When the storage state of the first storage partition is the second state and the working state of the extended storage device is the idle working state, obtaining the first data from the second physical block through the extended storage device;
[0106] Writing the first data into the first physical block through the extended storage device;
[0107] The host controls the first write pointer to point to the third physical block, and updates the storage state of the first storage partition from the second state to the first state.
[0108] In some embodiments of the present application, when the working state of the extended storage device is an idle working state, that is, when ZUFS is in an idle working state at this time, the storage state of the first storage partition can be detected (when the first storage partition has multiple zones, the storage state of each zone in the first storage partition is detected), and when the storage state of the first storage partition is a false state, the data in the second storage partition can be moved to the first storage partition. Specifically, the extended storage device can obtain the first data from the second physical block and then write the first data to the first physical block. In this way, the first data is written to the corresponding physical block, and the host can control the first write pointer +1, that is, the first write pointer can point to the third physical block, and the storage state of the first storage partition is updated from the second state to the first state.
[0109] Continue to refer Figure 6 In the example shown, after writing data 5 of LBA5 into the physical block 66 of the second storage partition 65, if the extended storage device 60 is in an idle state at this time, the storage state of all zones in the first storage partition 61 can be detected, and the storage state of Zone 0 is detected to be false, then Fig. 9 As shown, data 5 of LBA5 is obtained from the physical block 66 of the second storage partition 65, and then the data 5 of LBA5 is written to the physical block 64 corresponding to LBA5, and then the position pointed to by the first write pointer 62 is increased by 1, that is, the physical block pointed to by the first write pointer 62 is the physical block 81, that is, the physical block 81 is the third physical block, and the storage status of Zone 0 is updated to true.
[0110] It should be noted that, in the above example, before obtaining the data 5 of LBA5 from the physical block 66 of the second storage partition 65, the data 4 of LBA4 has been written into the physical block 63 (this may be done in the same manner as the data 5 of LBA5 is moved to the physical block 64, or the data 5 of LBA5 may be moved to the physical block 64 according to the global error correction instruction, which is not limited here and the specific global error correction instruction will be introduced in detail in the subsequent embodiments), and the first write pointer 62 has also been moved to the location of the physical block 64.
[0111] In an embodiment of the present application, the out-of-order write instructions are sorted by the extended storage device, and the data of the out-of-order write instructions are moved to the corresponding physical blocks, thereby ensuring that the address of the host's logical block and the address offset of the physical block of the extended storage device are consistent.
[0112] In some embodiments of the present application, the above method may further include:
[0113] In the process of the extended storage device acquiring the first data from the second physical block, when the extended storage device receives a second write instruction sent by the host, the operation of acquiring the first data from the second physical block is interrupted by the extended storage device;
[0114] The host writes the second data to the third physical block pointed to by the second write pointer.
[0115] The second write instruction may be an instruction issued by the host to the extended storage device to write data into the extended storage device. Specifically, the data to be written in the second write instruction is different from the data to be written in the first write instruction. The second write instruction may be used to instruct to write the second data in the host into the extended storage device, where the storage location of the second data in the host is the third logical block, and the physical block corresponding to the third logical block in the extended storage device is the third physical block.
[0116] In some embodiments of the present application, during the process of the extended storage device acquiring the first data from the second physical block, that is, during the process of the extended storage device moving the data in the second storage partition to the first storage partition, if a new data write instruction issued by the host is received, the extended storage device immediately interrupts the operation of moving the first data from the second storage partition to the first storage partition, and instead starts to execute the new data write instruction, that is, writes the second data to the extended storage device.
[0117] When the host writes the second data to the extended storage device, since the first data has not yet been moved from the second storage partition to the first physical block of the first storage partition, the first write pointer still indicates the position of the first physical block, but the second data is to be stored in the third physical block, that is, the third physical block corresponding to the third logical block storing the second data in the host is inconsistent with the physical block indicated by the first write pointer, then the second data is written to the physical block after the second physical block in the second storage partition.
[0118] Continue to refer Figure 6After writing data 5 of LBA5 into physical block 66 of the second storage partition 65, in the process of moving data 5 in physical block 66 to physical block 64, if a write instruction for writing data 7 of LBA7 is received from the host, the extended storage device interrupts the process of moving data 5 in physical block 66 to physical block 64, and starts processing the write instruction for writing data 7 of LBA7. Since after writing data 5 of LBA5 into physical block 66 of the second storage partition 65, the position indicated by the first write pointer 62 has not changed and still points to the position of physical block 63, and the physical block corresponding to LBA7 is physical block 69, that is, the physical block 63 indicated by the first write pointer 62 is inconsistent with the physical block 69 corresponding to LBA7. At this time, data 7 of LBA7 needs to be written into the last two physical blocks 610 of physical block 66 of the second storage partition 65 (the physical block between physical block 66 and physical block 610 is used to store data 6 of LBA6).
[0119] In an embodiment of the present application, during the process of sorting out-of-order write instructions, if a new data write instruction is received, the sorting of the out-of-order write instructions is interrupted and the new data write instruction is executed. This ensures that the data write instruction issued by the host can quickly obtain a response from the extended storage device and will not affect the use of the host user.
[0120] In some embodiments of the present application, the above method may further include:
[0121] Sending data read instructions to the extended storage device through the host;
[0122] determining, by the host, a fourth physical block corresponding to the fourth logical block;
[0123] When the state of the first storage partition including the fourth physical block is the second state and the third data is stored in the fifth physical block of the second storage partition, the third data is obtained from the fifth physical block based on the data read instruction by the extended storage device, and the third data is sent to the fourth logical block of the host.
[0124] The data read instruction may be an instruction issued by the host to read data from the extended storage device. Specifically, the data read instruction may instruct to read the third data from the extended storage device into the fourth logic block of the host.
[0125] The third data mentioned above may be any data stored in the extended storage device.
[0126] The fourth logic block may be a logic block in the host where the third data to be read is to be stored.
[0127] The fourth physical block may be a physical block in the first storage partition of the extended storage device that corresponds to the fourth logical block.
[0128] The fifth physical block may be a physical block in the extended storage device that currently stores the third data.
[0129] In some embodiments of the present application, when the host issues a data read instruction to the extended storage device to read the third data from the physical block of the extended storage device to the fourth logical block of the host, the fourth physical block corresponding to the fourth logical block can be determined first, and then the storage state of the first storage partition including the fourth physical block can be detected. If the storage state of the first storage partition including the fourth physical block is the second state, and the third data is stored in the fifth physical block of the second storage partition, the extended storage device obtains the third data from the fifth physical block based on the data read instruction, and sends the third data to the fourth logical block of the host.
[0130] In one example, reference Fig.10 , the host sends a data read instruction to the extended storage device, and the data read instruction indicates to read the data 8 in the extended storage device into the LBA8 of the host. First, it is determined that the physical block corresponding to LBA8 in the first storage partition 91 is the physical block 92 in Zone 0, and then the storage status of Zone 0 is detected. If the storage status of Zone 0 is false, it means that Zone 0 has not been sorted into a sequential state in time. If data 8 is stored in the physical block 94 of the second storage partition 93, the extended storage device can obtain data 8 from the physical block 94 based on the data read instruction, and send data 8 to the LBA8 of the host.
[0131] In an embodiment of the present application, when the host issues a data read instruction to the extended storage device, if the storage state of the first storage partition containing the physical block corresponding to the logical block storing the data to be read is the second state, and the data to be read is stored in the second storage partition, the extended storage device can obtain the data to be read from the second storage partition based on the data read instruction and send it to the host. In this way, when the storage state of the first storage partition is the second state, the host's operation of reading data will not be affected.
[0132] In some embodiments of the present application, the above method may further include:
[0133] Send global error correction instructions to the extended storage device through the host;
[0134] Prohibit receiving commands from the host by expanding the storage device;
[0135] The fourth data is written into the first storage partition according to the global error correction instruction through the extended storage device.
[0136] The global error correction instruction may be an instruction issued by the host to the extended storage device for correcting the disordered write instructions in the extended storage device. The global error correction instruction may be used to indicate that when the second storage partition includes the fourth data to be written into the first storage partition, the fourth data is written into the first storage partition, that is, the data should normally be written into the first storage partition, but because the physical block corresponding to the data is inconsistent with the physical block pointed to by the first write pointer, the data is written into the second storage partition, so the data can be moved to the first storage partition based on the global error correction instruction.
[0137] The fourth data mentioned above may be data that should be written into the first storage partition according to a data write instruction sent by the host.
[0138] In some embodiments of the present application, when the storage system is in extreme conditions, for example, when the extended storage device of the storage system receives data in a data write instruction issued by a storage host, the data cannot be normally written into the first storage partition. In this case, the host may issue a global error correction instruction to the extended storage device, and the extended storage device may be prohibited from receiving all instructions issued by the host. Then, the extended storage device writes the fourth data into the first storage partition according to the global error correction instruction, that is, the extended storage device reorganizes the out-of-order write instructions in the second storage partition according to the global error correction instruction, and moves them to the physical block corresponding to the first storage partition.
[0139] like Figure 6 In the example shown, after writing data 5 of LBA5 into physical block 66 of the second storage partition 65, if the extended storage device is still performing other operations at this time, and if the host issues a global error correction instruction at this time, the extended storage device interrupts the operation being performed and stops receiving any instructions issued by the host, and then moves the data 5 in physical block 66 of the second storage partition 65 to physical block 64.
[0140] In the embodiment of the present application, by setting a global error correction instruction, it is ensured that the storage system can be restored to a stable state, thereby ensuring the normal writing performance of the data.
[0141] In some embodiments of the present application, before step 410, the above method may further include:
[0142] Remove the queue depth limit of data write instructions through the host;
[0143] The host divides the storage partition of the extended storage device into a first storage partition and a second storage partition, and initializes the physical blocks pointed to by the first write pointer and the second write pointer respectively.
[0144] In some embodiments of the present application, since in the prior art, the queue depth of data write instructions in the host's scheduler is set to 1, when the host is allowed to issue write instructions to write multiple data into the extended storage device, the queue depth of the data write instructions needs to be limited.
[0145] In addition, it is necessary to divide the storage partition of the extended storage device into a first storage partition and a second storage partition, and initialize the physical blocks pointed to by the first write pointer and the second write pointer respectively.
[0146] In the embodiment of the present application, the host removes the queue depth limit of the data write instruction, thereby ensuring the concurrent ability of the storage system to execute multiple data write instructions at the same time. At the same time, the storage partition of the extended storage device is divided, and the positions of the first write pointer and the second write pointer are initialized, so that if there is a disorder problem in the data write instruction, the first data can be stored in the extended storage device without blocking the disordered data write instruction, thereby improving the data write performance of the extended storage device.
[0147] In some embodiments of the present application, the host may include a scheduler, such as an mq-dealine scheduler, which may include a queue depth limit lock for data write instructions, such as blk_req_zone_write_lock.
[0148] The lifting of the queue depth restriction of the data write instruction by the host may specifically include:
[0149] Remove the queue depth limit lock for data write instructions from the host;
[0150] When the queue depth limit lock of the data write command is removed, it is determined that the queue depth limit of the data write command is released by the host.
[0151] In some embodiments of the present application, the host can remove the queue depth limit lock of the data write instruction by removing the queue depth limit lock of the data write instruction, specifically, deleting the queue depth limit lock of the data write instruction, thereby releasing the queue depth limit of the data write instruction.
[0152] In an embodiment of the present application, the host can remove the queue depth limit lock of the data write instruction, thereby lifting the queue depth limit of the data write instruction, without the need to use other external devices to lift the queue depth limit of the data write instruction, thereby saving costs.
[0153] In order to facilitate a better understanding of the data writing method provided in the embodiment of the present application, taking the first storage partition including multiple zones, the first storage partition being ZLU, the second storage partition being CLU, and the type of the physical block for storing data of out-of-order write instructions in the CLU being SLC type as an example, the data writing method provided in the embodiment of the present application is introduced in detail.
[0154] like Fig.11 As shown, the data writing method provided in the embodiment of the present application may include steps 101 to 1022.
[0155] Step 101: The host removes the queue depth restriction of the data write instruction.
[0156] Step 102: The host configures the storage partition of the extended storage device into a first storage partition and a second storage partition.
[0157] Step 103: Configure a dedicated SLC area in the CLU.
[0158] In step 103, a dedicated SLC area is configured in the CLU, which may be to configure the type of some physical blocks in the CLU as the SLC type, and the area where the physical blocks of the SLC type are aggregated is the SLC area.
[0159] Step 104: Initialize the position of the first write pointer and the position of the second write pointer.
[0160] The above steps 101 to 104 are all the initialization process of the storage system.
[0161] Step 105: The host sends a command.
[0162] In step 105, the instructions sent by the host may be of the following types: data write instructions, data read instructions, and global error correction instructions.
[0163] When the instruction sent by the host is a data write instruction, the following steps 106 to 1018 are executed.
[0164] Step 106 , determining whether the data write instruction is an out-of-order data write instruction, if so, executing step 107 , if not, executing step 1010 .
[0165] In step 106, the criterion for determining whether the data write instruction is an out-of-order data write instruction is: whether the physical block indicated by the first write pointer in the first storage partition is consistent with the physical block corresponding to the logical block in the host storing the data to be written indicated by the data write instruction, that is, whether the physical block indicated by the first write pointer in the first storage partition in the above step 420 matches the first physical block.
[0166] Step 107: Write the data into the SLC type physical block of the second storage partition.
[0167] Step 108: The position indicated by the first write pointer remains unchanged, and the position indicated by the second write pointer moves backward by one.
[0168] Step 109: The Zone state of the first storage partition is the second state.
[0169] In step 109, the Zone of the first storage partition may be a Zone that normally stores data to be written by a data write instruction.
[0170] Step 1010: Write data into the Zone of the first storage partition.
[0171] Step 1011: The positions indicated by the first write pointer and the second write pointer are both moved backward by one.
[0172] Step 1012: The Zone state of the first storage partition is the first state.
[0173] Step 1013, determine whether the extended storage device is in an idle working state, if so, execute step 1014, if not, return to execute the instruction sent by the receiving host.
[0174] Step 1014: Scan the Zone in the first storage partition that is in the second state.
[0175] Step 1015: Move the data in the SLC type physical block to the Zone.
[0176] Step 1016: The positions indicated by the first write pointer and the second write pointer are both moved backward by one.
[0177] Step 1017: Update the status of the Zone from the second status to the first status.
[0178] Step 1018, determine whether the host has issued a new instruction, if so, return to execute the instruction sent by the receiving host, if not, continue to scan the Zone in the first storage partition that is in the second state, that is, return to execute step 1014.
[0179] When the instruction sent by the host is a data read instruction, the following step 1019 is executed:
[0180] Step 1019: The storage state of the Zone containing the physical block corresponding to the data to be read is the second state, and the data is returned to the host from the SLC type physical block.
[0181] When the instruction sent by the host is a global error correction instruction, the following steps 1020 to 1022 are performed:
[0182] Step 1020: prohibit receiving instructions sent by the host.
[0183] Step 1021, traverse the data in the physical block of the SLC type, and move it to the zone whose storage state is the second state.
[0184] Step 1022: Update the storage status of the Zone.
[0185] The data writing method provided in the embodiment of the present application can be executed by a data writing system. In the embodiment of the present application, the data writing system provided in the embodiment of the present application is described by taking the data writing method executed by the data writing system as an example.
[0186] Fig.12 FIG. 1 is a schematic diagram showing a structure of a data writing system according to an exemplary embodiment. Fig.12 As shown, the data writing system 1200 may include: a host 1210 and an expansion storage device 1220 .
[0187] The host 1210 includes a plurality of logic blocks for managing data;
[0188] The extended storage device 1220 includes a first storage partition and a second storage partition. The first storage partition and the second storage partition both include a plurality of physical blocks for managing data. The plurality of logical blocks correspond one-to-one to the plurality of physical blocks in the second storage partition.
[0189] The host 1210 is configured as:
[0190] Sending a first write instruction to the extended storage device 1220, where the first write instruction is used to instruct writing the first data in the first logic block of the host into the first storage partition of the extended storage device;
[0191] Determine a physical block indicated by a first write pointer in the first storage partition, wherein the first write pointer is used to indicate a physical block next to an occupied physical block based on a data writing order;
[0192] When the physical block indicated by the first write pointer does not match the first physical block in the first storage partition, the first data is written into the second physical block of the second storage partition of the extended storage device 1220, where the first physical block corresponds to the first logical block.
[0193] In an embodiment of the present application, when the host sends a first write instruction to the extended storage device to write the first data at the first logical block in the host into the first storage partition of the extended storage device, the host can determine whether the physical block indicated by the first write pointer in the first storage partition, which is used to point to the next physical block of the occupied physical block based on the data write order, matches the first physical block corresponding to the first logical block. In the case that the physical block indicated by the first write pointer does not match the first physical block, that is, when the order of data to be written in the first write instruction received by the extended storage device is disordered, the first data can be written to the second physical block of the second storage partition based on the host. In this way, when the extended storage device simultaneously receives a write instruction to write multiple data to the extended storage device, even if the order of the received data to be written is disordered, the data to be written can be written to the extended storage device based on the solution of the embodiment of the present application, without the need for the extended storage device to block the write instruction of the disordered data, thereby improving the write performance of the extended storage device.
[0194] In some embodiments of the present application, the host 1210 is also configured to: after determining the physical block indicated by the first write pointer in the first storage partition, write the first data to the first physical block if the physical block indicated by the first write pointer matches the first physical block.
[0195] In some embodiments of the present application, the first storage partition further includes a second write pointer, and the second write pointer is used to indicate the next physical block to which data will be written;
[0196] The host 1210 is also configured to: after writing the first data to the first physical block, control the first write pointer and the second write pointer to point to the third physical block, and mark the storage state of the first storage partition as the first state, the third physical block is the next physical block of the first physical block, and the first state is used to indicate that the physical blocks corresponding to the data stored in the first storage partition all correspond to the logical blocks in the host 1210.
[0197] In some embodiments of the present application, the host 1210 is also configured to: after writing the first data to the second physical block of the second storage partition of the extended storage device 1220, control the first physical block pointed to by the first write pointer to remain unchanged, control the second write pointer to point to the third physical block, and mark the storage status of the first storage partition as a second state, wherein the second state is used to indicate that there is unwritten data in the first storage partition.
[0198] In some embodiments of the present application, the extended storage device 1220 is configured to: when the storage state of the first storage partition is the second state and the working state of the extended storage device 1220 is the idle working state, obtain the first data from the second physical block; write the first data to the first physical block;
[0199] The host 1210 is further configured to: control the first write pointer to point to the third physical block, and update the storage state of the first storage partition from the second state to the first state.
[0200] In some embodiments of the present application, the extended storage device 1220 is further configured to: in the process of obtaining the first data from the second physical block, upon receiving a second write instruction issued by the host 1210, interrupt the operation of obtaining the first data from the second physical block, wherein the second write instruction indicates that the second data in the third logical block of the host 1210 is written to the extended storage device 1220;
[0201] The host 1210 is further configured to: write the second data to the third physical block pointed to by the second write pointer, where the third physical block corresponds to the third logical block.
[0202] In some embodiments of the present application, the host 1210 is further configured to: send a data read instruction to the extended storage device 1220, the data read instruction instructing to read third data from the extended storage device 1220 to a fourth logical block of the host 1210; determine a fourth physical block corresponding to the fourth logical block;
[0203] The extended storage device 1220 is also configured to: when the storage state of the first storage partition including the fourth physical block is the second state and the third data is stored in the fifth physical block of the second storage partition, based on the data read instruction, obtain the third data from the fifth physical block and send the third data to the host 1210.
[0204] In some embodiments of the present application, the host 1210 is further configured to: send a global error correction instruction to the extended storage device 1220, the global error correction instruction instructing that when the second storage partition includes fourth data to be written to the first storage partition, the fourth data be written to the first storage partition;
[0205] The extended storage device 1220 is further configured to: prohibit receiving instructions sent by the host 1210, and write the fourth data into the first storage partition according to the global error correction instruction.
[0206] In some embodiments of the present application, the host 1210 is further configured to: before issuing the first write instruction to the extended storage device 1220, lift the queue depth limit of the data write instruction; divide the storage partition of the extended storage device 1220 into the first storage partition and the second storage partition, and initialize the physical blocks pointed to by the first write pointer and the second write pointer respectively.
[0207] In some embodiments of the present application, the host 1210 includes a scheduler, and the scheduler includes a queue depth limit lock for data write instructions;
[0208] The host 1210 is further configured to: remove the queue depth limit lock of the data write instruction; and determine that the queue depth limit of the data write instruction is released when the queue depth limit lock of the data write instruction is removed.
[0209] The data writing system in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than the terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a palmtop computer, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtualreality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personalcomputer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
[0210] The data writing system in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0211] The data writing system provided in the embodiment of the present application can achieve Figure 4 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0212] The data writing method provided in the embodiment of the present application can be executed by a data writing device. In the embodiment of the present application, the data writing device provided in the embodiment of the present application is described by taking the data writing method executed by the data writing device as an example.
[0213] The data writing device may include a sending module, a determining module and a writing module, wherein the sending module is used to send a first write instruction to the extended storage device through a host; the first write instruction is used to instruct to write the first data in the first logical block of the host to the first storage partition of the extended storage device; the determining module is used to determine the physical block indicated by the first write pointer in the first storage partition through the host; the first write pointer is used to indicate the next physical block of the occupied physical block based on the data writing order; the writing module is used to write the first data to the second physical block of the second storage partition of the extended storage device through the host when the physical block indicated by the first write pointer does not match the first physical block in the first storage partition; the first physical block corresponds to the first logical block.
[0214] The data writing device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal.
[0215] The data writing device provided in the embodiment of the present application can implement each process implemented in the above-mentioned data writing method embodiment, and will not be described again here to avoid repetition.
[0216] Alternatively, if Fig.13 As shown, an embodiment of the present application also provides an electronic device 1300, including a processor 1301 and a memory 1302, wherein the memory 1302 stores programs or instructions that can be executed on the processor 1301, and when the program or instructions are executed by the processor 1301, the various steps of the above-mentioned data writing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not repeated here.
[0217] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0218] Fig.14 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0219] The electronic device 1400 includes but is not limited to: a radio frequency unit 1401, a network module 1402, an audio output unit 1403, an input unit 1404, a sensor 1405, a display unit 1406, a user input unit 1407, an interface unit 1408, a memory 1409, and a processor 1410 and other components.
[0220] Those skilled in the art will appreciate that the electronic device 1400 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1410 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.14 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0221] Among them, the processor 1410 is used to send a first write instruction to the extended storage device through the host; the first write instruction is used to instruct to write the first data in the first logical block of the host to the first storage partition of the extended storage device; the physical block indicated by the first write pointer in the first storage partition is determined by the host; the first write pointer is used to indicate the next physical block located in the occupied physical block based on the data writing order; when the physical block indicated by the first write pointer does not match the first physical block in the first storage partition, the first data is written to the second physical block of the second storage partition of the extended storage device through the host; the first physical block corresponds to the first logical block.
[0222] In this way, when the host sends a first write instruction to the extended storage device to write the first data at the first logical block in the host into the first storage partition of the extended storage device, the host can determine whether the physical block indicated by the first write pointer in the first storage partition, which is used to point to the next physical block of the occupied physical block based on the data write order, matches the first physical block corresponding to the first logical block. In the case that the physical block indicated by the first write pointer does not match the first physical block, that is, when the order of data to be written in the first write instruction received by the extended storage device is disordered, the first data can be written to the second physical block of the second storage partition based on the host. In this way, when the extended storage device simultaneously receives a write instruction to write multiple data to the extended storage device, even if the order of the received data to be written is disordered, the data to be written can be written to the extended storage device based on the scheme of the embodiment of the present application, without the need for the extended storage device to block the write instruction of the disordered data, thereby improving the write performance of the extended storage device.
[0223] Optionally, the processor 1410 is further used to write the first data into the first physical block through the host after the physical block indicated by the first write pointer in the first storage partition is determined through the host, if the physical block indicated by the first write pointer matches the first physical block.
[0224] In this way, when the physical block indicated by the first write pointer matches the first physical block, the host can directly write the first data into the first physical block, thereby ensuring that the first data is written into the correct physical block, thereby improving the writing correctness of the first data.
[0225] Optionally, the first storage partition further includes a second write pointer, and the second write pointer is used to indicate a physical block where data will be written next;
[0226] Processor 1410 is also used to control the first write pointer and the second write pointer to point to the third physical block through the host after the first data is written into the first physical block through the host, and mark the storage state of the first storage partition as the first state, the third physical block is the next physical block of the first physical block, and the first state is used to indicate that the physical blocks corresponding to the data stored in the first storage partition all correspond to the logical blocks in the host.
[0227] In this way, by maintaining two write pointers in the first storage partition, which are used to manage the offsets of normal write instructions and out-of-order write instructions respectively, out-of-order write instructions can be better managed. At the same time, after the first data is written to the first physical block through the host, the first write pointer and the second write pointer can be controlled by the host to point to the third physical block, and the storage state of the first storage partition can be marked as the first state. In this way, after the write instruction is executed, the storage state of the first storage partition can be marked according to the execution status of the write instruction, so that the storage state of the first storage partition can be intuitively viewed.
[0228] Optionally, the processor 1410 is also used to control the first physical block pointed to by the first write pointer to remain unchanged through the host, and control the second write pointer to point to the third physical block, and mark the storage status of the first storage partition as a second status after the first data is written into the second physical block of the second storage partition of the extended storage device through the host, and the second status is used to indicate that there is unwritten data in the first storage partition.
[0229] In this way, after the host executes the write instruction to write the first data to the second physical block of the second storage partition of the extended storage device, the host can control the first physical block pointed to by the first write pointer to remain unchanged, and control the second write pointer to point to the third physical block, and mark the storage status of the first storage partition as the second state. In this way, the storage status of the first storage partition can be marked according to the execution status of the write instruction, so that the storage status of the first storage partition can be intuitively viewed.
[0230] Optionally, the processor 1410 is further used to, when the storage state of the first storage partition is the second state and the working state of the extended storage device is an idle working state, obtain the first data from the second physical block through the extended storage device; write the first data to the first physical block through the extended storage device; control the first write pointer to point to the third physical block through the host, and update the storage state of the first storage partition from the second state to the first state.
[0231] In this way, the extended storage device performs sorting of out-of-order write instructions and moves the data of the out-of-order write instructions to the corresponding physical blocks, thereby ensuring that the address of the host's logical block is consistent with the address offset of the physical block of the extended storage device.
[0232] Optionally, the processor 1410 is further configured to, during a process of obtaining the first data from the second physical block through the extended storage device, when the extended storage device receives a second write instruction issued by the host, interrupt the operation of obtaining the first data from the second physical block by the extended storage device, the second write instruction instructing to write the second data in the third logical block of the host to the extended storage device; and write the second data to the third physical block pointed to by the second write pointer through the host, the third physical block corresponding to the third logical block.
[0233] In this way, if a new data write instruction is received during the process of sorting out-of-order write instructions, the sorting of the out-of-order write instructions is interrupted and the new data write instruction is executed, thus ensuring that the data write instruction issued by the host can be quickly responded to by the extended storage device and will not affect the use of the host user.
[0234] Optionally, the processor 1410 is further used to send a data read instruction to the extended storage device through the host, the data read instruction instructing to read third data from the extended storage device to a fourth logical block of the host; determine a fourth physical block corresponding to the fourth logical block through the host; when the storage state of the first storage partition including the fourth physical block is the second state, and the third data is stored in a fifth physical block of the second storage partition, obtain the third data from the fifth physical block through the extended storage device based on the data read instruction, and send the third data to the host.
[0235] Thus, in the case where the host issues a data read instruction to the extended storage device, if the storage state of the first storage partition containing the physical block corresponding to the logical block storing the data to be read is the second state, and the data to be read is stored in the second storage partition, the extended storage device can obtain the data to be read from the second storage partition based on the data read instruction and send it to the host. In this way, it can ensure that the operation of the host reading data is not affected when the storage state of the first storage partition is the second state.
[0236] Optionally, the processor 1410 is further configured to issue a global error correction instruction to the extended storage device through the host. The global error correction instruction indicates that when the fourth data to be written to the first storage partition is included in the second storage partition, the fourth data is written to the first storage partition; the extended storage device is prohibited from receiving the instructions issued by the host through the host, and the fourth data is written to the first storage partition according to the global error correction instruction.
[0237] Thus, by setting the global error correction instruction, it is ensured that the storage system can be restored to a stable state, thereby ensuring the normal write performance of the data.
[0238] Optionally, the processor 1410 is further configured to, before issuing the first write instruction to the extended storage device through the host, release the queue depth limit of the data write instruction through the host; divide the storage partition of the extended storage device into the first storage partition and the second storage partition through the host, and initialize the physical blocks pointed to by the first write pointer and the second write pointer respectively.
[0239] Thus, by releasing the queue depth limit of the data write instruction through the host, the concurrent ability of the storage system to execute multiple data write instructions simultaneously is ensured. At the same time, the storage partition of the extended storage device is divided, and the positions of the first write pointer and the second write pointer are initialized, so that in the case of an out-of-order problem in the data write instruction, the first data can be stored in the extended storage device without blocking the out-of-order data write instruction, improving the data write performance of the extended storage device.
[0240] Optionally, the host includes a scheduler, and the scheduler includes a queue depth limit lock for the data write instruction; the processor 1410 is further configured to remove the queue depth limit lock for the data write instruction through the host; when the queue depth limit lock for the data write instruction is removed, it is determined that the queue depth limit of the data write instruction is released through the host.
[0241] Thus, by removing the queue depth limit lock for the data write instruction, the host can release the queue depth limit of the data write instruction without the need to release the queue depth limit of the data write instruction through other external devices, saving costs.
[0242] It should be understood that in the embodiment of the present application, the input unit 1404 may include a graphics processor (Graphics Processing Unit, GPU) 14041 and a microphone 14042, and the graphics processor 14041 processes the image data of the static picture or video obtained by the image capture device (such as a color camera) in the video capture mode or the image capture mode. The display unit 1406 may include a display panel 14061, and the display panel 14061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1407 includes a touch panel 14071 and at least one of other input devices 14072. The touch panel 14071 is also called a touch screen. The touch panel 14071 may include two parts: a touch detection device and a touch controller. Other input devices 14072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0243] The memory 1409 can be used to store software programs and various data. The memory 1409 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1409 may include a volatile memory or a non-volatile memory, or the memory 1409 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1409 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0244] The processor 1410 may include one or more processing units; optionally, the processor 1410 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1410.
[0245] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned data writing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0246] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0247] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned data writing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0248] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0249] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned data writing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0250] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0251] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0252] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A data writing method, characterized in that: The method comprises: Sending a first write instruction to the extended storage device through the host; the first write instruction is used to instruct to write the first data in the first logic block of the host to the first storage partition of the extended storage device; Determine, by the host, a physical block indicated by a first write pointer in the first storage partition; the first write pointer is used to indicate a next physical block located in an occupied physical block based on a data writing order; When the physical block indicated by the first write pointer does not match the first physical block in the first storage partition, the first data is written into the second physical block of the second storage partition of the extended storage device by the host; the first physical block corresponds to the first logical block.
2. The method according to claim 1, characterized in that After determining, by the host, the physical block indicated by the first write pointer in the first storage partition, the method further includes: In a case where the physical block indicated by the first write pointer matches the first physical block, the first data is written into the first physical block by the host.
3. The method according to claim 2, characterized in that The first storage partition also includes a second write pointer, where the second write pointer is used to indicate a next physical block where data will be written; After the host writes the first data into the first physical block, the method further includes: The host controls the first write pointer and the second write pointer to point to the third physical block, and marks the storage state of the first storage partition as the first state. The third physical block is the next physical block of the first physical block. The first state is used to indicate that the physical blocks corresponding to the data stored in the first storage partition all correspond to the logical blocks in the host.
4. The method according to claim 3, characterized in that After the host writes the first data into the second physical block of the second storage partition of the extended storage device, the method further includes: The host controls the first physical block pointed to by the first write pointer to remain unchanged, controls the second write pointer to point to the third physical block, and marks the storage state of the first storage partition as a second state, wherein the second state is used to indicate that there is unwritten data in the first storage partition.
5. The method according to claim 3, characterized in that: The method further comprises: When the storage state of the first storage partition is the second state and the working state of the extended storage device is the idle working state, obtaining the first data from the second physical block through the extended storage device; Writing the first data into the first physical block through the extended storage device; The host controls the first write pointer to point to the third physical block, and updates the storage state of the first storage partition from the second state to the first state.
6. The method according to claim 5, characterized in that The method further comprises: In the process of acquiring the first data from the second physical block through the extended storage device, when the extended storage device receives a second write instruction sent by the host, the extended storage device interrupts the operation of acquiring the first data from the second physical block, wherein the second write instruction instructs writing the second data in the third logical block of the host into the extended storage device; The host writes the second data to the third physical block pointed to by the second write pointer, and the third physical block corresponds to the third logical block.
7. The method according to claim 4, characterized in that The method further comprises: Sending a data read instruction to the extended storage device through the host, wherein the data read instruction instructs reading third data from the extended storage device into a fourth logic block of the host; determining, by the host, a fourth physical block corresponding to the fourth logical block; When the storage state of the first storage partition including the fourth physical block is the second state, and the third data is stored in the fifth physical block of the second storage partition, the third data is obtained from the fifth physical block based on the data read instruction by the extended storage device, and the third data is sent to the host.
8. The method according to claim 1, characterized in that The method further comprises: Sending a global error correction instruction to the extended storage device through the host, wherein the global error correction instruction indicates that when the second storage partition includes fourth data to be written into the first storage partition, the fourth data is written into the first storage partition; The extended storage device is prohibited from receiving instructions sent by the host, and the fourth data is written into the first storage partition according to the global error correction instruction.
9. The method according to claim 3, characterized in that: Before the host sends the first write instruction to the extended storage device, the method further includes: Removing the queue depth limit of the data write instruction by the host; The host divides the storage partition of the extended storage device into the first storage partition and the second storage partition, and initializes the physical blocks pointed to by the first write pointer and the second write pointer respectively.
10. The method according to claim 9, characterized in that The host includes a scheduler, and the scheduler includes a queue depth limit lock for data write instructions; The step of removing the queue depth restriction of the data write instruction by the host comprises: Removing the queue depth limit lock of the data write instruction by the host; When the queue depth limit lock of the data write instruction is removed, it is determined that the queue depth limit of the data write instruction is released by the host.
11. A data writing system, characterized in that: The system comprises: A host computer, the host computer comprising a plurality of logic blocks for managing data; An extended storage device, the extended storage device comprising a first storage partition and a second storage partition, the first storage partition and the second storage partition each comprising a plurality of physical blocks for managing data, the plurality of logical blocks corresponding one-to-one to the plurality of physical blocks in the first storage partition; The host is configured as: Sending a first write instruction to the extended storage device, where the first write instruction is used to instruct writing first data in a first logic block of the host into a first storage partition of the extended storage device; Determine a physical block indicated by a first write pointer in the first storage partition, wherein the first write pointer is used to indicate a physical block next to an occupied physical block based on a data writing order; When the physical block indicated by the first write pointer does not match the first physical block in the first storage partition, the first data is written into a second physical block of the second storage partition of the extended storage device, the first physical block corresponding to the first logical block.
12. A data writing device, characterized in that: The device comprises: A sending module, used for sending a first write instruction to the extended storage device through the host; the first write instruction is used for instructing to write the first data in the first logic block of the host into the first storage partition of the extended storage device; A determination module, configured to determine, through the host, a physical block indicated by a first write pointer in the first storage partition; the first write pointer is configured to indicate a next physical block located in an occupied physical block based on a data writing order; A write module is used to write the first data into a second physical block of a second storage partition of the extended storage device through the host when the physical block indicated by the first write pointer does not match the first physical block in the first storage partition; the first physical block corresponds to the first logical block.
13. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the method according to any one of claims 1 to 10 are implemented.
14. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.