Sector attribute automatic detection method, device, equipment and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- YEESTOR MICROELECTRONICS CO LTD
- Filing Date
- 2022-07-19
- Publication Date
- 2026-06-30
Smart Images

Figure CN115167774B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of storage technology, and in particular to a method, apparatus, device, and storage medium for automatic sector attribute detection. Background Technology
[0002] The TRIM command, commonly used in SSDs, deletes data within a specific logical range. If TRIM is performed on a 4K base-weighted array, the corresponding mapping table (the aforementioned mapping between host logical addresses and Nand Flash addresses) can be directly invalidated. Subsequent reads of this logical segment will then return all 0s or all 1s because the invalid mapping table will return the data. However, if the host is operating on data larger than 4K base-weighted data, the data must first be read, and the corresponding sector data filled with all 0s or all 1s before being written back to ensure that subsequent logical reads do not result in data errors. Alternatively, an additional memory module can be used to record the TRIM / WRITE ZERO attributes of each sector. Querying this memory module will reveal the status of the corresponding sector and retrieve the correct data.
[0003] For commands like Trim or Write zero that can modify sector data, handling these is relatively straightforward. However, for Writeunc commands, data modification is not possible. It's necessary to mark the sector the host is about to operate on as being in an Unc state to ensure correct logical read responses later. This requires an additional RAM block to record the UNC attributes of each sector, ensuring that the host's settings for the sectors being operated on are consistent with the SSD's management algorithm in this situation.
[0004] However, processing non-4K aligned or non-4K base data requires more memory to manage data sector attributes, and the firmware needs to perform additional attribute table lookups during access. Operations on configurable sector data attributes also require additional data setting overhead. Summary of the Invention
[0005] The main objective of this invention is to solve the problems that existing data processing methods, which are not 4K aligned or 4K base, require more memory to manage data sector attributes, and require additional firmware overhead for querying attribute tables during access, as well as additional data setting overhead for configurable sector data attribute operations.
[0006] The first aspect of this invention provides a method for automatic sector attribute detection, comprising:
[0007] Configure the sector identifier in the source data;
[0008] Record the attributes of each sector in the source data in the sector identifier to obtain the identifier data, wherein the sector attributes include unc status and normal status;
[0009] The identification data is stored in flash memory;
[0010] Based on the records in the sector identifier, the pre-configured master controller identifies the attributes of the sector read by the external host and feeds back the data or attributes of the corresponding sector to the host.
[0011] Furthermore, in a second implementation of the first aspect of the present invention, configuring the sector identifier in the source data includes:
[0012] Add multiple bit values to the MD area in the source data;
[0013] The multiple bit values are matched with each sector in the source data.
[0014] Furthermore, in a third implementation of the first aspect of the present invention, the source data is 4KB of data, which is divided into 8 sectors of 512 bytes each, and 8 bit values are added to the MD area corresponding to the 8 sectors.
[0015] Furthermore, in a fourth implementation of the first aspect of the present invention, the step of recording the attributes of each sector in the source data in the sector identifier to obtain the identifier data includes:
[0016] The attributes of each sector in the source data are described and identified.
[0017] If the sector is identified as being in a normal state, no operation is performed, wherein the bit value is 0 by default;
[0018] If the sector is identified as being in an ununc state, then the bit value corresponding to the sector is converted to 1.
[0019] Furthermore, in a fifth implementation of the first aspect of the present invention, the step of pre-setting the main controller to identify the attributes of the sector read by the external host based on the record in the sector identifier, and feeding back the data or attributes corresponding to the sector to the host, includes:
[0020] The host reads each of the eight sectors in the identification data one by one, and the master controller is preset to detect the eight bit values at the same time.
[0021] If the bit value corresponding to the sector is detected to be 0, the sector is determined to be in a normal state, and the data in the sector is fed back to the host.
[0022] If the bit value corresponding to the sector is detected to be 1, the sector is determined to be in an unc state. The unc state is then fed back to the host, and the host stops reading subsequent sectors.
[0023] Furthermore, in a sixth implementation of the first aspect of the invention, before configuring the sector identifier in the source data, the method further includes:
[0024] Determine if the current environment is a 4K operation;
[0025] If so, then no action is taken;
[0026] If not, proceed with the step of configuring the sector identifier in the source data.
[0027] A second aspect of the present invention provides an apparatus for automatic sector attribute detection, the apparatus comprising:
[0028] The configuration module is used to configure the sector identifier in the source data;
[0029] The recording module is used to record the attributes of each sector in the source data in the sector identifier to obtain the identifier data, wherein the attributes of the sector include unc status and normal status.
[0030] A register module is used to store the identification data in flash memory;
[0031] The feedback module is used to identify the attributes of the sector read by the external host based on the records in the sector identifier, and to feed back the data or attributes of the corresponding sector to the host.
[0032] A third aspect of the present invention provides a device for automatic sector attribute detection, the device comprising: a memory and at least one processor, the memory storing instructions, and the memory and the at least one processor being interconnected via a line;
[0033] The at least one processor invokes the instructions in the memory to cause the device to perform the above-described method for automatic sector attribute detection.
[0034] A fourth aspect of the present invention provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the above-described method for automatic sector attribute detection.
[0035] The beneficial effects of this invention are as follows: Sector identifiers are configured in the source data, and the attributes of each sector in the source data are recorded in the sector identifier to obtain identifier data. The attributes of the sector include unc state and normal state. The identifier data is stored in flash memory. Based on the records in the sector identifier, the master controller identifies the attributes of the sector read by the external host and feeds back the data or attributes corresponding to that sector to the host. By configuring sector identifiers in the source data, unnecessary memory usage and additional firmware overhead are reduced during non-4K aligned or non-4K base data processing. Attached Figure Description
[0036] Figure 1 This is a schematic diagram of the first embodiment of the method for automatic sector attribute detection in this invention;
[0037] Figure 2 This is a schematic diagram of a second embodiment of the method for automatic sector attribute detection in this invention;
[0038] Figure 3 This is a third embodiment of the method for automatic sector attribute detection in this invention. Figure 1 ;
[0039] Figure 4 This is a third embodiment of the method for automatic sector attribute detection in this invention. Figure 2 ;
[0040] Figure 5 This is a schematic diagram of the fourth embodiment of the method for automatic sector attribute detection in this invention;
[0041] Figure 6 This is a schematic diagram of the fifth embodiment of the method for automatic sector attribute detection in this invention;
[0042] Figure 7 This is a schematic diagram of one embodiment of the device for automatic sector attribute detection in this invention.
[0043] Figure 8 This is a schematic diagram of one embodiment of the device for automatic sector attribute detection in this invention. Detailed Implementation
[0044] This invention provides a method, system, device, equipment, and storage medium for automatic sector attribute detection.
[0045] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” or “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0046] For ease of understanding, the specific process of the embodiments of the present invention is described below. Please refer to [link / reference]. Figure 1-6 One embodiment of the method for automatic sector attribute detection in this invention includes:
[0047] 101. Configure the sector identifier in the source data;
[0048] In this embodiment, to avoid unnecessary memory usage and the addition of mapping tables, the present invention limits the sector attributes in the source data with a simple identifier, and configures the data limited by the identifier in the source data, either at the beginning or the end, so that while reading the source data, the sector identifier can be detected to quickly determine the attributes of each sector in the source data.
[0049] Furthermore, step 101 can also be performed as follows:
[0050] 1011. Add multiple bit values to the MD area in the source data;
[0051] 1012. Match multiple bit values with each sector in the source data.
[0052] In this embodiment, the source data is 4KB of data, which is divided into 8 sectors of 512 bytes each. 8 bit values are added to the corresponding 8 sectors in the MD area.
[0053] In steps 1011-1012, the suffix MD area of the source data is metadata. The metadata includes PI-MD used to verify whether the data transmission path is faulty, as well as other verification MDs. The sector identifier added here is a value after PI-MD, specifically composed of 8 bits. Each of the 8 bits corresponds to the attribute of 8 sectors in the source data in sequence. Therefore, each data segment only adds 8 bits of verification data to the suffix, effectively avoiding the traditional method of using a large amount of memory space to manage the attributes of data sectors separately, improving response speed and making full use of memory space.
[0054] 102. Record the attributes of each sector in the source data in the sector identifier to obtain the identifier data, where the sector attributes include unc status and normal status;
[0055] In this embodiment, the sector attributes in the source data need to be read out in advance, and the attributes of each sector need to be confirmed one by one. Alternatively, the attributes of a certain sector need to be manually adjusted. The sector identifier can only be used to determine whether it is the corresponding attribute, but cannot determine what the attribute is.
[0056] Furthermore, step 102 can also be performed as follows:
[0057] 1021. Describe and identify the attributes of each sector in the source data;
[0058] 1022. If the sector is identified as being in a normal state, no operation is performed. The default bit value is 0.
[0059] 1023. If the identified sector is in an ununc state, then convert the bit value corresponding to the sector to 1.
[0060] 103. Store the identification data in flash memory;
[0061] In steps 1021-1023 and step 103, the unc state needs to be processed. Therefore, when it is necessary to adjust the attribute of a certain sector to the unc state, the corresponding bit value in the sector identifier is adjusted from 0 to 1 to represent that the attribute of the sector corresponding to the bit value is the unc state. After the adjustment, the identifier data is obtained. In order to make the next read faster, the identifier data is stored in the flash memory, i.e., in the Nand Flash.
[0062] 104. Based on the records in the sector identifier, the master controller is pre-configured to identify the attributes of the sector read by the external host and feed back the data or attributes of the corresponding sector to the host.
[0063] In this embodiment, the main controller receives the instruction from the host to read data from the flash memory and sends the data path back to the host for reading. At the same time, the main controller also needs to read the sector identifier during the host's data reading process.
[0064] Furthermore, step 104 can also be performed as follows:
[0065] 1041. The host reads each of the eight sectors in the identification data one by one, and the master controller is preset to detect the eight bit values at the same time;
[0066] 1042. If the bit value corresponding to the sector is detected to be 0, the sector is determined to be in a normal state, and the data in the sector is fed back to the host.
[0067] 1043. If the bit value corresponding to the sector is detected to be 1, the sector is determined to be in the unc state. The unc state is fed back to the host, and the host stops reading subsequent sectors.
[0068] In steps 1041-1043, the host directly reads the identification data from the flash memory. While reading each sector in the identification data one by one, the built-in main controller HW also starts to detect the sector identifier of the MD area after the identification data, checking whether the corresponding bit value is 1. If the bit value corresponding to the data read is 0, then the attribute of the sector is normal and no other special attributes are attached. Therefore, the corresponding sector data is fed back to the host. If the bit value corresponding to the previous sector read by the host is 1, then the attribute of the sector has a special identifier attached. In this embodiment, the special identifier is the unc state. At this time, the unc state is fed back to the host, and the host also stops reading subsequent sectors.
[0069] Furthermore, prior to step 101, the following can also be performed:
[0070] 1001. Determine if the current environment is a 4K operation;
[0071] 1002. If so, then no action is taken;
[0072] 1003. If not, proceed with the step of configuring the sector identifier in the source data.
[0073] The execution steps 1001-1003 are configured in the hardware. The hardware determines whether the current storage environment supports 4K alignment and whether to enable execution step 1003. This makes the method more flexible and avoids continuing to configure sector identifiers when the system is not 4K aligned, thus avoiding unnecessary use of identifier memory resources.
[0074] In this embodiment, sector identifiers are configured in the source data, and the attributes of each sector in the source data are recorded in the sector identifiers to obtain identifier data. The attributes of the sectors include ununc state and normal state. The identifier data is stored in flash memory. Based on the records in the sector identifiers, the master controller is preset to identify the attributes of the sectors read by the external host and feed back the data or attributes of the corresponding sectors to the host. By configuring sector identifiers in the source data, unnecessary memory occupation and additional firmware overhead are reduced under non-4K aligned or non-4K base data processing.
[0075] The method for automatic sector attribute detection in this embodiment of the invention has been described above. The apparatus for automatic sector attribute detection in this embodiment of the invention is described below. Please refer to [link / reference]. Figure 6 One embodiment of the device for automatic sector attribute detection in this invention includes:
[0076] Configuration module 201 is used to configure the sector identifier in the source data;
[0077] The recording module 202 is used to record the attributes of each sector in the source data in the sector identifier to obtain the identifier data, wherein the sector attributes include unc status and normal status.
[0078] Register module 203 is used to store identification data in flash memory;
[0079] Feedback module 204 is used to identify the attributes of the sector read by the external host based on the records in the sector identifier, and to feed back the data or attributes of the corresponding sector to the host.
[0080] In another embodiment of the automatic sector attribute detection device of the present invention, the automatic sector attribute detection device includes:
[0081] Configuration module 201 is used to configure the sector identifier in the source data;
[0082] The recording module 202 is used to record the attributes of each sector in the source data in the sector identifier to obtain the identifier data, wherein the sector attributes include unc status and normal status.
[0083] Register module 203 is used to store identification data in flash memory;
[0084] Feedback module 204 is used to identify the attributes of the sector read by the external host based on the records in the sector identifier, and to feed back the data or attributes of the corresponding sector to the host.
[0085] Specifically, the following can also be executed before the configuration module 201:
[0086] Determine if the current environment is a 4K operation;
[0087] If so, then no action is taken;
[0088] If not, proceed with the step of configuring the sector identifier in the source data.
[0089] Specifically, the configuration module 201 can also perform the following:
[0090] Add multiple bit values to the MD area in the source data;
[0091] Match multiple bit values with each sector in the source data.
[0092] Specifically, the recording module 202 can also perform the following:
[0093] Describe and identify the attributes of each sector in the source data;
[0094] If the sector is identified as being in a normal state, no action is taken, where the bit value is 0 by default;
[0095] If the sector is identified as being in an ununc state, then the bit value corresponding to that sector is converted to 1.
[0096] Specifically, the feedback module 204 can also perform the following:
[0097] The host reads each of the eight sectors in the identification data one by one, and the master controller is preset to detect the eight bit values at the same time.
[0098] If the bit value corresponding to the sector is detected to be 0, the sector is determined to be in a normal state, and the data in the sector is fed back to the host.
[0099] If the bit value corresponding to the sector is detected to be 1, the sector is determined to be in an unc state. The unc state is then fed back to the host, and the host stops reading subsequent sectors.
[0100] In this embodiment, sector identifiers are configured in the source data, and the attributes of each sector in the source data are recorded in the sector identifiers to obtain identifier data. The sector attributes include ununc state and normal state. The identifier data is stored in flash memory. Based on the records in the sector identifiers, the master controller is preset to identify the attributes of the sector read by the external host and feed back the corresponding data or attributes to the host. By configuring sector identifiers in the source data, unnecessary memory occupation and additional firmware overhead are reduced under non-4K aligned or non-4K base data processing.
[0101] The above is attached Figure 7The device for automatic sector attribute detection in this embodiment of the invention is described in detail from the perspective of modular functional entities. The device for automatic sector attribute detection in this embodiment of the invention is described in detail below from the perspective of hardware processing.
[0102] Appendix Figure 8 This is a schematic diagram of the structure of a sector attribute automatic detection device 300 provided in an embodiment of the present invention. The sector attribute automatic detection device 300 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 310 (e.g., one or more processors) and a memory 320, and one or more storage media 330 (e.g., one or more mass storage devices) storing application programs 333 or data 332. The memory 320 and storage media 330 can be temporary or persistent storage. The program stored in the storage media 330 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the sector attribute automatic detection device 300. Furthermore, the processor 310 may be configured to communicate with the storage media 330 and execute the series of instruction operations in the storage media 330 on the sector attribute automatic detection device 300.
[0103] The device 300 for automatic sector attribute detection may also include one or more power supplies 340, one or more wired or wireless network interfaces 350, one or more input / output interfaces 360, and / or one or more operating systems 331, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will understand that... Figure 4 The illustrated device structure for automatic sector attribute detection does not constitute a limitation on the device for automatic sector attribute detection. It may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.
[0104] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when the instructions are executed on a computer, cause the computer to perform the steps of the method and system for automatically detecting the sector attributes.
[0105] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system, device, or unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0106] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0107] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for automatic sector attribute detection, characterized in that, include: Configure the sector identifier in the source data; Record the attributes of each sector in the source data in the sector identifier to obtain the identifier data, wherein the sector attributes include unc status and normal status; The identification data is stored in flash memory; Based on the records in the sector identifier, the pre-configured main controller identifies the attributes of the sector read by the external host and feeds back the data or attributes of the corresponding sector to the host. The step of configuring sector identifiers in the source data includes: Add multiple bit values to the MD area in the source data; Match the multiple bit values with each sector in the source data; The source data is 4KB of data, which is divided into 8 sectors of 512 bytes each. The MD area adds 8 bit values to the corresponding 8 sectors. The step of recording the attributes of each sector in the source data in the sector identifier to obtain the identifier data includes: The attributes of each sector in the source data are described and identified. If the sector is identified as being in a normal state, no operation is performed, wherein the bit value is 0 by default; If the sector is identified as being in an ununc state, then the bit value corresponding to the sector is converted to 1; The step of pre-setting the main controller to identify the attributes of the sector read by the external host based on the record in the sector identifier, and feeding back the data or attributes of the corresponding sector to the host, includes: The host reads each of the eight sectors in the identification data one by one, and the master controller is preset to detect the eight bit values at the same time. If the bit value corresponding to the sector is detected to be 0, the sector is determined to be in a normal state, and the data in the sector is fed back to the host. If the bit value corresponding to the sector is detected to be 1, the sector is determined to be in an unc state. The unc state is then fed back to the host, and the host stops reading subsequent sectors.
2. The method for automatic sector attribute detection according to claim 1, characterized in that, Before configuring the sector identifier in the source data, the method further includes: Determine if the current environment is a 4K operation; If so, then no action is taken; If not, proceed with the step of configuring the sector identifier in the source data.
3. A device for automatic sector attribute detection, characterized in that, The device for automatic sector attribute detection includes: The configuration module is used to configure the sector identifier in the source data; The recording module is used to record the attributes of each sector in the source data in the sector identifier to obtain the identifier data, wherein the attributes of the sector include unc status and normal status. A register module is used to store the identification data in flash memory; The feedback module is used to identify the attributes of the sector read by the external host based on the records in the sector identifier, and to feed back the data or attributes of the corresponding sector to the host. The step of configuring sector identifiers in the source data includes: Add multiple bit values to the MD area in the source data; Match the multiple bit values with each sector in the source data; The source data is 4KB of data, which is divided into 8 sectors of 512 bytes each. The MD area adds 8 bit values to the corresponding 8 sectors. The step of recording the attributes of each sector in the source data in the sector identifier to obtain the identifier data includes: The attributes of each sector in the source data are described and identified. If the sector is identified as being in a normal state, no operation is performed, wherein the bit value is 0 by default; If the sector is identified as being in an ununc state, then the bit value corresponding to the sector is converted to 1; The step of pre-setting the main controller to identify the attributes of the sector read by the external host based on the record in the sector identifier, and feeding back the data or attributes of the corresponding sector to the host, includes: The host reads each of the eight sectors in the identification data one by one, and the master controller is preset to detect the eight bit values at the same time. If the bit value corresponding to the sector is detected to be 0, the sector is determined to be in a normal state, and the data in the sector is fed back to the host. If the bit value corresponding to the sector is detected to be 1, the sector is determined to be in an unc state. The unc state is then fed back to the host, and the host stops reading subsequent sectors.
4. A device for automatic sector attribute detection, characterized in that, The device for automatic sector attribute detection includes: a memory and at least one processor, wherein the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor invokes the instructions in the memory to cause the device for automatic sector attribute detection to perform the method for automatic sector attribute detection as described in claim 1 or 2.
5. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the method for automatic sector attribute detection as described in claim 1 or 2.