CN111443873A - A kind of management method and device of Nand Flash memory - Google Patents
A kind of management method and device of Nand Flash memory Download PDFInfo
- Publication number
- CN111443873A CN111443873A CN202010228838.1A CN202010228838A CN111443873A CN 111443873 A CN111443873 A CN 111443873A CN 202010228838 A CN202010228838 A CN 202010228838A CN 111443873 A CN111443873 A CN 111443873A
- Authority
- CN
- China
- Prior art keywords
- data
- block
- pointer
- data block
- writing
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0614—Improving the reliability of storage systems
- G06F3/0619—Improving the reliability of storage systems in relation to data integrity, e.g. data losses, bit errors
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/064—Management of blocks
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/0644—Management of space entities, e.g. partitions, extents, pools
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0679—Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Techniques For Improving Reliability Of Storages (AREA)
Abstract
本发明涉及存储介质领域,公开了一种Nand Flash存储器的管理方法和装置。方法包括,获取存储区中入队指针指向的数据块位置,其中,储存区包括数据区和独立备份块,数据区包括至少一个数据块,入队指针指向数据区的起始数据块,出队指针指向数据区的结束数据块,独立备份块位于起始数据块之前;根据入队指针指向的数据块位置,将数据写入相应的数据块中;确认数据写入是否成功;如果数据写入成功,则分别将入队指针和出队指针向前移动一个数据块,由此能够保证数据的完整性和安全性。
The invention relates to the field of storage media, and discloses a management method and device of a Nand Flash memory. The method includes: obtaining the data block position pointed to by the queue entry pointer in the storage area, wherein the storage area includes a data area and an independent backup block, the data area includes at least one data block, the queue entry pointer points to the starting data block of the data area, and the queue is dequeued. The pointer points to the end data block of the data area, and the independent backup block is located before the starting data block; according to the position of the data block pointed to by the enqueue pointer, write the data into the corresponding data block; confirm whether the data writing is successful; if the data is written If successful, the enqueue pointer and the dequeue pointer are moved forward by one data block respectively, thereby ensuring the integrity and security of the data.
Description
技术领域technical field
本发明涉及存储介质领域,特别是涉及一种Nand Flash存储器的管理方法和装置。The present invention relates to the field of storage media, in particular to a method and device for managing a Nand Flash memory.
背景技术Background technique
在设备应用中,需要保存大量的历史记录数据(包括充电账单、操作记录、告警记录等),方便设备运营方进行数据核对和管理。In equipment applications, a large amount of historical record data (including charging bills, operation records, alarm records, etc.) needs to be saved to facilitate data verification and management by equipment operators.
目前设备中存储器件类型主要是包括:E2prom和Nand flash;E2prom属于电可擦除器件,可进行反复快速编程,但是价格昂贵,容量小,不合适保存大量记录数据;Nandflash属于非易失闪存器件,每次编程都需要按照扇区进行擦除,然后才能编程,操作速度慢,但是价格低廉,容量大,目前广泛应用于设备的记录存储。At present, the types of storage devices in the device mainly include: E2prom and Nand flash; E2prom is an electrically erasable device, which can be programmed repeatedly and quickly, but is expensive and small in capacity, which is not suitable for storing a large amount of recorded data; Nandflash is a non-volatile flash memory device , each programming needs to be erased according to the sector, and then can be programmed, the operation speed is slow, but the price is low and the capacity is large, and it is widely used in the record storage of equipment.
对于Nand flash的数据存储,具有在读写之前必须重新进行块擦除,才能进行写入的特性,就决定了会有数据丢失。For the data storage of Nand flash, it has the characteristic that block erase must be performed again before writing and writing, which determines that there will be data loss.
针对该问题传统的处理方式是在擦除之前,把块数据全部读出来,存入缓存中,等待该快擦除之后,进行写操作时,在从缓存写入块中,这样循环的进行块擦除,数据拷贝,很容易造成块损坏,而导致数据丢失,出现坏块,很容易导致数据丢失,具有极大的数据完整性和安全性风险。The traditional way to deal with this problem is to read out all the block data before erasing, store it in the cache, and wait for the fast erasing. Erasing and copying data can easily cause block damage, which leads to data loss and bad blocks, which can easily lead to data loss, which has great data integrity and security risks.
发明内容SUMMARY OF THE INVENTION
基于此,有必要针对上述技术问题,提供一种Nand Flash存储器的管理方法和装置,能够保证数据的完整性和安全性。Based on this, it is necessary to provide a management method and device for Nand Flash memory, which can ensure the integrity and security of data, in view of the above technical problems.
第一方面,本发明实施例提供了一种Nand Flash存储器的管理方法,所述方法包括:In a first aspect, an embodiment of the present invention provides a method for managing a Nand Flash memory, the method comprising:
获取存储区中入队指针指向的数据块位置,其中,所述储存区包括数据区和独立备份块,所述数据区包括至少一个数据块,所述入队指针指向所述数据区的起始数据块,出队指针指向所述数据区的结束数据块,所述独立备份块位于所述起始数据块之前;Obtain the location of the data block pointed to by the queue entry pointer in the storage area, wherein the storage area includes a data area and an independent backup block, the data area includes at least one data block, and the queue entry pointer points to the start of the data area data block, the dequeue pointer points to the end data block of the data area, and the independent backup block is located before the start data block;
根据所述入队指针指向的数据块位置,将数据写入相应的数据块中;Write data into the corresponding data block according to the data block position pointed to by the enqueue pointer;
确认数据写入是否成功;Confirm whether the data writing is successful;
如果数据写入成功,则分别将所述入队指针和所述出队指针向前移动一个数据块。If the data writing is successful, the enqueue pointer and the dequeue pointer are respectively moved forward by one data block.
在一些实施例中,所述确定数据写入是否成功,包括:In some embodiments, the determining whether the data writing is successful includes:
读取所述数据块中的数据;read the data in the data block;
若读取的数据和写入的数据一致,则确定数据写入成功;If the read data is consistent with the written data, it is determined that the data writing is successful;
若读取的数据和写入的数据不同,则确定数据写入失败。If the read data and the written data are different, it is determined that the data writing fails.
在一些实施例中,所述方法还包括:In some embodiments, the method further includes:
如果数据写入失败,则将所述入队指针向前移动一个数据块。If the data writing fails, the enqueue pointer is moved forward by one data block.
在一些实施例中,所述所述如果数据写入失败,所述方法还包括:In some embodiments, the if data writing fails, the method further includes:
获取数据写入失败的所述数据块的地址信息;Obtain the address information of the data block whose data writing fails;
将所述地址信息写入坏块检测表中,并更新所述坏块检测表。The address information is written into the bad block detection table, and the bad block detection table is updated.
在一些实施例中,所述方法还包括:In some embodiments, the method further includes:
利用所述入队指针查询所述数据区中最新写入的数据。The latest written data in the data area is queried by using the enqueue pointer.
在一些实施例中,所述方法还包括:In some embodiments, the method further includes:
利用所述出队指针查询所述数据区中最早写入的数据。The earliest written data in the data area is queried by using the dequeue pointer.
在一些实施例中,所述方法还包括:In some embodiments, the method further includes:
预先建立入队指针和出队指针,所述入队指针和所述出队指针用于查询管理;Pre-establishing an enqueue pointer and a dequeue pointer, the enqueue pointer and the dequeue pointer are used for query management;
预先建立坏块检测表,所述坏块检测表用于作为坏块的检查记录表。A bad block detection table is established in advance, and the bad block detection table is used as a check record table of bad blocks.
第二方面,本发明实施例还提供了一种Nand Flash存储器的管理装置,所述装置包括:In a second aspect, an embodiment of the present invention further provides an apparatus for managing a Nand Flash memory, the apparatus comprising:
获取模块,用于获取存储区中入队指针指向的数据块位置,其中,所述储存区包括数据区和独立备份块,所述数据区包括至少一个数据块,所述入队指针指向所述数据区的起始数据块,出队指针指向所述数据区的结束数据块,所述独立备份块位于所述起始数据块之前;An acquisition module, configured to acquire the data block position pointed to by the queue entry pointer in the storage area, wherein the storage area includes a data area and an independent backup block, the data area includes at least one data block, and the queue entry pointer points to the The starting data block of the data area, the dequeue pointer points to the ending data block of the data area, and the independent backup block is located before the starting data block;
写入模块,用于根据所述入队指针指向的数据块位置,将数据写入相应的数据块中;a writing module, for writing data into the corresponding data block according to the data block position pointed to by the queue entry pointer;
确定模块,用于确认数据写入是否成功;Confirmation module, used to confirm whether the data writing is successful;
移动模块,用于如果数据写入成功,则分别将所述入队指针和所述出队指针向前移动一个数据块。The moving module is configured to move the queue entry pointer and the queue dequeue pointer forward by one data block respectively if the data writing is successful.
第三方面,本发明实施例还提供了一种电子设备,包括:In a third aspect, an embodiment of the present invention also provides an electronic device, including:
至少一个处理器;以及,at least one processor; and,
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述Nand Flash存储器的管理方法。The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the above-mentioned method for managing a Nand Flash memory.
第四方面,本发明实施例还提供了一种非易失性计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行指令,当所述计算机可执行指令被处理器所执行时,使所述处理器执行上述Nand Flash存储器的管理方法。In a fourth aspect, an embodiment of the present invention further provides a non-volatile computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, when the computer-executable instructions are executed by a processor , causing the processor to execute the above-mentioned method for managing the Nand Flash memory.
与现有技术相比,本发明的有益效果是:区别于现有技术的情况,本发明实施例中的Nand Flash存储器的管理方法和装置,通过将Nand Flash存储器划分为数据区和独立数据区,数据区包括至少一个数据块,独立数据区包括至少一个独立备份块,通过将众多连续的数据块作为一个块队列,获取存储区中入队指针指向的数据块位置,并根据所述入队指针指向的数据块位置,将数据写入相应的数据块中,接着判断数据写入是否成功,如果数据写入成功,则分别将所述入队指针和所述出队指针向前移动一个数据块,等待下一次数据写入,由于每个数据块都是按照队列模式进行循环擦除,读写,所以数据块擦除次数均等,使得Nand Flash存储器单个坏块几率更小,由此能够保证数据的完整性和安全性。Compared with the prior art, the beneficial effects of the present invention are: different from the situation in the prior art, the management method and device of the Nand Flash memory in the embodiment of the present invention, by dividing the Nand Flash memory into a data area and an independent data area. , the data area includes at least one data block, and the independent data area includes at least one independent backup block. By using many continuous data blocks as a block queue, the position of the data block pointed to by the enqueue pointer in the storage area is obtained, and according to the enqueue The position of the data block pointed to by the pointer, write the data into the corresponding data block, and then judge whether the data writing is successful, if the data writing is successful, move the entry pointer and the dequeue pointer forward by one data respectively Block, waiting for the next data write, because each data block is cyclically erased, read and written according to the queue mode, so the number of times of data block erasure is equal, making the probability of a single bad block in Nand Flash memory smaller, which can guarantee Data integrity and security.
附图说明Description of drawings
一个或多个实施例通过与之对应的附图中的图片进行示例性说明,这些示例性说明并不构成对实施例的限定,附图中具有相同参考数字标号的元件表示为类似的元件,除非有特别申明,附图中的图不构成比例限制。One or more embodiments are exemplified by the pictures in the corresponding drawings, and these exemplifications do not constitute limitations of the embodiments, and elements with the same reference numerals in the drawings are denoted as similar elements, Unless otherwise stated, the figures in the accompanying drawings do not constitute a scale limitation.
图1是本发明一个实施例中Nand Flash存储器的管理方法的流程示意图;1 is a schematic flowchart of a management method of a Nand Flash memory in an embodiment of the present invention;
图2是本发明一个实施例中数据区和独立数据区的结构示意图;Fig. 2 is the structural representation of data area and independent data area in one embodiment of the present invention;
图3是本发明一个实施例中确定数据是否写入成功的流程示意图;3 is a schematic flow chart of determining whether data is written successfully in an embodiment of the present invention;
图4是本发明一个实施例中数据写入失败的结构示意图;4 is a schematic structural diagram of a data write failure in an embodiment of the present invention;
图5是本发明一个实施例中将地址信息写入坏块检测表中的结构示意图;5 is a schematic structural diagram of writing address information into a bad block detection table in an embodiment of the present invention;
图6是本发明一个实施例中进行数据查找的结构示意图;6 is a schematic structural diagram of performing data search in an embodiment of the present invention;
图7是本发明一个实施例中Nand Flash存储器的管理装置的结构示意图;7 is a schematic structural diagram of a management device of a Nand Flash memory in an embodiment of the present invention;
图8是本发明一个实施例中电子设备的硬件结构示意图。FIG. 8 is a schematic diagram of a hardware structure of an electronic device in an embodiment of the present invention.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
需要说明的是,如果不冲突,本发明实施例中的各个特征可以相互结合,均在本发明的保护范围之内。另外,虽然在装置示意图中进行了功能模块划分,在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于装置中的模块划分,或流程图中的顺序执行所示出或描述的步骤。再者,本发明所采用的“第一”、“第二”、“第三”等字样并不对数据和执行次序进行限定,仅是对功能和作用基本相同的相同项或相似项进行区分。It should be noted that, if there is no conflict, various features in the embodiments of the present invention can be combined with each other, which are all within the protection scope of the present invention. In addition, although the functional modules are divided in the schematic diagram of the device, and the logical sequence is shown in the flowchart, in some cases, the modules in the device may be divided differently, or the sequence shown in the flowchart may be performed. or the described steps. Furthermore, the words "first", "second" and "third" used in the present invention do not limit the data and execution order, but only distinguish the same or similar items with basically the same function and effect.
如图1所示,本发明实施例提供了一种Nand Flash存储器的管理方法,所述方法包括:As shown in FIG. 1, an embodiment of the present invention provides a method for managing a Nand Flash memory, the method includes:
步骤102,获取存储区中入队指针指向的数据块位置,其中,所述储存区包括数据区和独立备份块,所述数据区包括至少一个数据块,所述入队指针指向所述数据区的起始数据块,出队指针指向所述数据区的结束数据块,所述独立备份块位于所述起始数据块之前。
在本发明实施例中,Nand Flash存储器都是按照数据块来进行管理的,因此预先将Nand Flash存储器划分为数据区和独立数据区,如图2所示,数据区包括至少一个数据块,独立数据区包括至少一个独立备份块,数据块用于存储数据,独立备份块用作备份,可将众多连续的数据块作为一个块队列,每个数据块都是按照队列模式进行循环擦除,读写,所以数据块擦除次数均等,使得Nand Flash存储器单个坏块几率更小,有效的延长了NandFlash存储器的使用寿命。可以理解的是,在其他一些实施例中,本发明除了采用循环队列方式之外,还可以采用链表数据结构的队列方式。In the embodiment of the present invention, the Nand Flash memory is managed according to data blocks, so the Nand Flash memory is divided into a data area and an independent data area in advance. As shown in FIG. 2, the data area includes at least one data block, which is independent of The data area includes at least one independent backup block. The data block is used to store data, and the independent backup block is used for backup. Many consecutive data blocks can be used as a block queue. Each data block is cyclically erased according to the queue mode, and read Write, so the data block erase times are equal, so that the probability of a single bad block of the Nand Flash memory is smaller, effectively prolonging the service life of the Nand Flash memory. It can be understood that, in some other embodiments, in addition to the circular queue mode, the present invention may also adopt the queue mode of the linked list data structure.
由于本发明实施例采用队列循环存储的机制进行数据存储,因此,需要使用两个指针,分别为入队指针和出队指针,其中,入队指针指向数据区的起始数据块,出队指针指向数据区的结束数据块,而独立备份块位于起始数据块之前,数据区间在入队指针和出队指针之前不断的动态调整,始终保持数据的完整性。Since the embodiment of the present invention uses the queue cyclic storage mechanism for data storage, two pointers need to be used, namely the queue entry pointer and the queue dequeue pointer, wherein the queue entry pointer points to the starting data block of the data area, and the queue pointer It points to the end data block of the data area, and the independent backup block is located before the start data block, and the data interval is constantly adjusted dynamically before the enqueue pointer and the dequeue pointer, and the integrity of the data is always maintained.
步骤104,根据所述入队指针指向的数据块位置,将数据写入相应的数据块中。Step 104: Write data into the corresponding data block according to the position of the data block pointed to by the queue entry pointer.
具体地,在进行数据写入之前,首先对存储区中入队指针指向的数据块进行擦除操作,然后再根据入队指针指向的数据块位置,将数据写相应的数据块中。需要说明的是,为了使Nand Flash存储器得到充分的利用,每次写入数据时,写入数据的大小与数据块大小尽量相同。Specifically, before performing data writing, first perform an erasing operation on the data block pointed to by the queue entry pointer in the storage area, and then write data into the corresponding data block according to the position of the data block pointed to by the queue entry pointer. It should be noted that, in order to make full use of the Nand Flash memory, each time data is written, the size of the written data and the size of the data block should be the same as possible.
步骤106,确认数据写入是否成功。
具体地,当数据全部写入相应的数据块之后,为了确保数据的完整性,需要确定写入的数据是否正确,即确定数据写入是否成功。Specifically, after all data is written into the corresponding data block, in order to ensure the integrity of the data, it is necessary to determine whether the written data is correct, that is, to determine whether the data writing is successful.
步骤108,如果数据写入成功,则分别将所述入队指针和所述出队指针向前移动一个数据块。
具体地,如果数据写入成功,入队指针则自动跳到下一个数据块,等待下一次的数据写入操作,同时,出队指针也向前移动一个数据块,由此可避免循环擦除数据块的操作,降低坏块的风险,从而延长Nand Flash存储器的使用寿命。Specifically, if the data writing is successful, the enqueue pointer automatically jumps to the next data block, waiting for the next data write operation, and at the same time, the dequeue pointer also moves forward by one data block, thus avoiding cyclic erasure The operation of data blocks reduces the risk of bad blocks, thereby extending the life of Nand Flash memory.
在本发明实施例中,通过将Nand Flash存储器划分为数据区和独立数据区,数据区包括至少一个数据块,独立数据区包括至少一个独立备份块,将众多连续的数据块作为一个块队列,获取存储区中入队指针指向的数据块位置,并根据所述入队指针指向的数据块位置,将数据写入相应的数据块中,接着判断数据写入是否成功,如果数据写入成功,则分别将所述入队指针和所述出队指针向前移动一个数据块,等待下一次数据写入,由于每个数据块都是按照队列模式进行循环擦除,读写,所以数据块擦除次数均等,使得NandFlash存储器单个坏块几率更小,由此能够保证数据的完整性和安全性。In the embodiment of the present invention, by dividing the Nand Flash memory into a data area and an independent data area, the data area includes at least one data block, the independent data area includes at least one independent backup block, and many continuous data blocks are used as a block queue, Obtain the data block position pointed to by the queue entry pointer in the storage area, and write the data into the corresponding data block according to the data block position pointed to by the queue entry pointer, and then judge whether the data writing is successful, if the data writing is successful, Then move the enqueue pointer and the dequeue pointer forward by one data block and wait for the next data write. Since each data block is cyclically erased and read and written according to the queue mode, the data block is erased. The number of divisions is equal, which makes the probability of a single bad block of the NandFlash memory smaller, thereby ensuring the integrity and security of the data.
在一些实施例中,如图3所示,所述确定数据写入是否成功,包括:In some embodiments, as shown in FIG. 3 , the determining whether data writing is successful includes:
步骤302,读取所述数据块中的数据。Step 302: Read the data in the data block.
具体地,当数据全部写入相应的数据块之后,再从数据块中读取该数据。Specifically, after the data is all written into the corresponding data block, the data is read from the data block.
步骤304,若读取的数据和写入的数据一致,则确定数据写入成功。Step 304: If the read data is consistent with the written data, it is determined that the data writing is successful.
具体地,将读取到的数据与写入的数据进行比对,如果读取的数据和写入的数据一致,则说明数据正确,即数据写入成功。Specifically, the read data is compared with the written data, and if the read data is consistent with the written data, it means that the data is correct, that is, the data writing is successful.
步骤306,若读取的数据和写入的数据不同,则确定数据写入失败。
具体地,将读取到的数据与写入的数据进行比对,如果读取到的数据和写入的数据不同,即数据写入失败,说明该数据块损坏,则停止向该数据块中写入数据。Specifically, the read data is compared with the written data. If the read data is different from the written data, that is, the data writing fails, indicating that the data block is damaged, stop writing to the data block. data input.
在一些实施例中,所述方法还包括:如果数据写入失败,则将所述入队指针向前移动一个数据块。In some embodiments, the method further includes moving the enqueue pointer forward by one data block if the data writing fails.
具体地,如图4所示,如果数据写入失败,入队指针则自动跳到下一个数据块,即入队指针向前移动一个数据块。进一步的,将入队指针作为参数输入到坏块检测表中,检查入队指针指向的数据块是否损坏,如果损坏,则自动向后增加一个连续的独立块,用来补充坏块的空间,同时,入队指针自动跳到下一个数据块,出队指针向前移动一个数据块。通过坏块检测机制,即使出现了坏的数据块,通过增加独立块的方式,不会出现因为坏块而导致数据的丢失和错误,由此可保证数据的完整性和安全性。Specifically, as shown in FIG. 4 , if the data writing fails, the queue entry pointer automatically jumps to the next data block, that is, the queue entry pointer moves forward by one data block. Further, input the enqueue pointer as a parameter into the bad block detection table to check whether the data block pointed to by the enqueue pointer is damaged. At the same time, the enqueue pointer automatically jumps to the next data block, and the dequeue pointer moves forward one data block. Through the bad block detection mechanism, even if bad data blocks appear, by adding independent blocks, data loss and errors will not occur due to bad blocks, thus ensuring data integrity and security.
在一些实施例中,所述如果数据写入失败,除了将所述入队指针向前移动一个数据块之外,所述方法还包括:获取数据写入失败的所述数据块的地址信息,将所述地址信息写入坏块检测表中,并更新所述坏块检测表。In some embodiments, if the data writing fails, in addition to moving the queue pointer forward by one data block, the method further includes: acquiring address information of the data block for which the data writing fails, The address information is written into the bad block detection table, and the bad block detection table is updated.
示例性的,如图5所示,将数据写入数据块8中,如果数据写入失败,则获取数据块8的地址信息,接着将数据块8的地址信息写入到坏块检测表中,同时更新坏块检测表。Exemplarily, as shown in FIG. 5, data is written into the data block 8, if the data writing fails, the address information of the data block 8 is obtained, and then the address information of the data block 8 is written into the bad block detection table. , and update the bad block detection table.
在一些实施例中,所述方法还包括:利用所述入队指针查询所述数据区中最新写入的数据,利用所述出队指针查询所述数据区中最早写入的数据。In some embodiments, the method further includes: using the enqueue pointer to query the latest written data in the data area, and using the dequeue pointer to query the earliest written data in the data area.
具体地,如图6所示,在进行数据查找时,通过双指针即可高效的进行数据查找。如果要查找最新的数据,则通过将入队指针作为参数在数据区中查找最新的数据块,进而得到最新写入的数据,同理,若要查找最早写入的数据,则通过将出队指针作为参数在数据区中查找最旧的数据块,从而得到最早写入的数据。Specifically, as shown in FIG. 6 , when searching for data, it is possible to efficiently search for data by using double pointers. If you want to find the latest data, use the enqueue pointer as a parameter to find the latest data block in the data area, and then get the latest written data. Similarly, if you want to find the earliest written data, you can dequeue the data by dequeuing The pointer is used as a parameter to find the oldest data block in the data area, so as to get the earliest written data.
在一些实施例中,所述方法还包括:预先建立入队指针和出队指针,所述入队指针和所述出队指针用于查询管理;预先建立坏块检测表,所述坏块检测表用于作为坏块的检查记录表。In some embodiments, the method further includes: pre-establishing an enqueue pointer and a dequeue pointer, the enqueue pointer and the dequeue pointer are used for query management; pre-establishing a bad block detection table, the bad block detection The table is used as a check record table for bad blocks.
相应的,本发明实施例还提供了一种Nand Flash存储器的管理装置,如图7所示,所述装置700包括:Correspondingly, an embodiment of the present invention also provides an apparatus for managing a Nand Flash memory. As shown in FIG. 7 , the
获取模块702,用于获取存储区中入队指针指向的数据块位置,其中,所述储存区包括数据区和独立备份块,所述数据区包括至少一个数据块,所述入队指针指向所述数据区的起始数据块,出队指针指向所述数据区的结束数据块,所述独立备份块位于所述起始数据块之前;The obtaining module 702 is configured to obtain the data block position pointed to by the queue entry pointer in the storage area, wherein the storage area includes a data area and an independent backup block, the data area includes at least one data block, and the queue entry pointer points to the data block. The starting data block of the data area, the dequeue pointer points to the ending data block of the data area, and the independent backup block is located before the starting data block;
写入模块704,用于根据所述入队指针指向的数据块位置,将数据写入相应的数据块中;Writing module 704, for writing data into the corresponding data block according to the data block position pointed to by the queue entry pointer;
确定模块706,用于确认数据写入是否成功;A determination module 706, configured to confirm whether the data writing is successful;
移动模块708,用于如果数据写入成功,则分别将所述入队指针和所述出队指针向前移动一个数据块。The moving module 708 is configured to move the enqueue pointer and the dequeue pointer forward by one data block respectively if the data writing is successful.
本发明实施例提供的Nand Flash存储器的管理装置,通过获取模块获取存储区中入队指针指向的数据块位置,然后通过写入模块根据所述入队指针指向的数据块位置,将数据写入相应的数据块中,接着通过确定模块确定数据写入是否成功,如果数据写入成功,则通过移动模块分别将入队指针和出队指针向前移动一个数据块,由此能够保证数据的安全性和完整性。The management device of the Nand Flash memory provided by the embodiment of the present invention obtains the data block position pointed to by the queue entry pointer in the storage area through an acquisition module, and then writes the data according to the data block position pointed to by the queue entry pointer through the writing module. In the corresponding data block, the determination module determines whether the data writing is successful. If the data writing is successful, the moving module moves the entry pointer and the dequeue pointer forward by one data block, thereby ensuring the security of the data. sex and integrity.
可选的,在装置的其他实施例中,如图7所示,所述装置700还包括:Optionally, in other embodiments of the apparatus, as shown in FIG. 7 , the
查询模块710,用于利用所述入队指针查询所述数据区中最新写入的数据;a query module 710, configured to query the latest written data in the data area by using the queue entry pointer;
利用所述出队指针查询所述数据区中最早写入的数据。The earliest written data in the data area is queried by using the dequeue pointer.
可选的,在装置的其他实施例中,如图7所示,所述装置700还包括:Optionally, in other embodiments of the apparatus, as shown in FIG. 7 , the
建立模块712,用于预先建立入队指针和出队指针,所述入队指针和所述出队指针用于查询管理;The establishment module 712 is used for pre-establishing the enqueue pointer and the dequeue pointer, and the enqueue pointer and the dequeue pointer are used for query management;
预先建立坏块检测表,所述坏块检测表用于作为坏块的检查记录表。A bad block detection table is established in advance, and the bad block detection table is used as a check record table of bad blocks.
可选的,在装置的其他实施例中,获取模块702具体用于:Optionally, in other embodiments of the apparatus, the obtaining module 702 is specifically configured to:
获取数据写入失败的所述数据块的地址信息。Acquire address information of the data block whose data writing fails.
可选的,在装置的其他实施例中,写入模块704具体用于:Optionally, in other embodiments of the apparatus, the writing module 704 is specifically configured to:
将所述地址信息写入坏块检测表中,并更新所述坏块检测表。The address information is written into the bad block detection table, and the bad block detection table is updated.
可选的,在装置的其他实施例中,确定模块706具体用于:Optionally, in other embodiments of the apparatus, the determining module 706 is specifically configured to:
读取所述数据块中的数据;read the data in the data block;
若读取的数据和写入的数据一致,则确定数据写入成功;If the read data is consistent with the written data, it is determined that the data writing is successful;
若读取的数据和写入的数据不同,则确定数据写入失败。If the read data and the written data are different, it is determined that the data writing fails.
可选的,在装置的其他实施例中,移动模块708具体用于:Optionally, in other embodiments of the apparatus, the moving module 708 is specifically configured to:
如果数据写入失败,则将所述入队指针向前移动一个数据块。If the data writing fails, the enqueue pointer is moved forward by one data block.
需要说明的是,上述Nand Flash存储器的管理装置可执行本发明实施例所提供的Nand Flash存储器的管理方法,具备执行方法相应的功能模块和有益效果,未在NandFlash存储器的管理装置实施例中详尽描述的技术细节,可参考本发明实施例提供的NandFlash存储器的管理方法。It should be noted that the above-mentioned Nand Flash memory management device can execute the Nand Flash memory management method provided by the embodiment of the present invention, and has corresponding functional modules and beneficial effects of the execution method, which are not detailed in the embodiment of the Nand Flash memory management device. For the technical details described, reference may be made to the management method of the NandFlash memory provided by the embodiment of the present invention.
图8是本发明实施例提供的电子设备的硬件结构示意图,如图8所示,该电子设备800包括:FIG. 8 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present invention. As shown in FIG. 8 , the
一个或多个处理器802以及存储器804,图8中以一个处理器802为例。One or
处理器802和存储器804可以通过总线或者其他方式连接,图8中以通过总线连接为例。The
存储器804作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块,如本发明实施例中的Nand Flash存储器的管理方法对应的程序指令/模块(例如,附图7所示的获取模块702、写入模块704、确定模块706、移动模块708、查询模块710和建立模块712)。处理器802通过运行存储在存储器804中的非易失性软件程序、指令以及模块,从而执行电子设备的各种功能应用以及数据处理,即实现上述方法实施例的Nand Flash存储器的管理方法。The
存储器804可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储根据Nand Flash存储器的管理装置使用所创建的数据等。此外,存储器804可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。在一些实施例中,存储器804可选包括相对于处理器802远程设置的存储器,这些远程存储器可以通过网络连接至Nand Flash存储器的管理的装置。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The
所述一个或者多个模块存储在所述存储器804中,当被所述一个或者多个电子设备800执行时,执行上述任意方法实施例中的Nand Flash存储器的管理方法,例如,执行以上描述的图1中的方法步骤102至步骤108、图3中的方法步骤302至步骤306;实现图7中的模块702至712的功能。The one or more modules are stored in the
本发明实施例中的电子设备以多种形式存在,包括但不限于:The electronic devices in the embodiments of the present invention exist in various forms, including but not limited to:
(1)移动通信设备:这类设备的特点是具备移动通信功能,并且以提供话音、数据通信为主要目标。这类终端包括:智能手机(例如iPhone)、多媒体手机、功能性手机,以及低端手机等。(1) Mobile communication equipment: This type of equipment is characterized by having mobile communication functions, and its main goal is to provide voice and data communication. Such terminals include: smart phones (eg iPhone), multimedia phones, feature phones, and low-end phones.
(2)超移动个人计算机设备:这类设备属于个人计算机的范畴,有计算和处理功能,一般也具备移动上网特性。这类终端包括:PDA、MID和UMPC设备等,例如iPad。(2) Ultra-mobile personal computer equipment: This type of equipment belongs to the category of personal computers, has computing and processing functions, and generally has the characteristics of mobile Internet access. Such terminals include: PDAs, MIDs, and UMPC devices, such as iPads.
(3)便携式娱乐设备:这类设备可以显示和播放多媒体内容。该类设备包括:音频、视频播放器(例如iPod),掌上游戏机,电子书,以及智能玩具和便携式车载导航设备。(3) Portable entertainment equipment: This type of equipment can display and play multimedia content. Such devices include: audio and video players (eg iPod), handheld game consoles, e-books, as well as smart toys and portable car navigation devices.
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The device embodiments described above are only illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in One place, or it can be distributed over multiple network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
通过以上的实施方式的描述,本领域普通技术人员可以清楚地了解到各实施方式可借助软件加通用硬件平台的方式来实现,当然也可以通过硬件。本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。From the description of the above embodiments, those of ordinary skill in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and certainly can also be implemented by hardware. Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and the program is During execution, it may include the processes of the embodiments of the above-mentioned methods. The storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM) or the like.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;在本发明的思路下,以上实施例或者不同实施例中的技术特征之间也可以进行组合,步骤可以以任意顺序实现,并存在如上所述的本发明的不同方面的许多其它变化,为了简明,它们没有在细节中提供;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; under the idea of the present invention, the technical features in the above embodiments or different embodiments can also be combined, The steps may be carried out in any order, and there are many other variations of the different aspects of the invention as described above, which are not provided in detail for the sake of brevity; although the invention has been The skilled person should understand that it is still possible to modify the technical solutions recorded in the foregoing embodiments, or to perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the implementation of the present invention. scope of technical solutions.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010228838.1A CN111443873A (en) | 2020-03-27 | 2020-03-27 | A kind of management method and device of Nand Flash memory |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010228838.1A CN111443873A (en) | 2020-03-27 | 2020-03-27 | A kind of management method and device of Nand Flash memory |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN111443873A true CN111443873A (en) | 2020-07-24 |
Family
ID=71649161
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010228838.1A Pending CN111443873A (en) | 2020-03-27 | 2020-03-27 | A kind of management method and device of Nand Flash memory |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111443873A (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112035417A (en) * | 2020-09-07 | 2020-12-04 | 浙江大华技术股份有限公司 | Storage block management method, device, storage medium and electronic device |
| CN113064558A (en) * | 2021-06-04 | 2021-07-02 | 广东汇天航空航天科技有限公司 | Data storage method and device |
| CN113312207A (en) * | 2021-05-07 | 2021-08-27 | 埃森智能科技(深圳)有限公司 | Data storage method adopting ferroelectric memory and programmable logic controller thereof |
| CN113625964A (en) * | 2021-07-16 | 2021-11-09 | 浙江鸿泉电子科技有限公司 | NandFlash-based sequential storage method, electronic equipment and storage medium |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1441440A (en) * | 2002-02-27 | 2003-09-10 | 微软公司 | Regulating system and method for obtaining uniform wear in flash storage device |
| CN103514261A (en) * | 2013-08-13 | 2014-01-15 | 江苏华大天益电力科技有限公司 | Data asynchronization storage and access mechanism applied to industrial control system |
| CN105740163A (en) * | 2016-01-29 | 2016-07-06 | 山东鲁能智能技术有限公司 | Nand Flash bad block management method |
| CN106528598A (en) * | 2016-09-23 | 2017-03-22 | 华为技术有限公司 | Chain management method and physical equipment |
| CN108710531A (en) * | 2018-04-20 | 2018-10-26 | 深圳市文鼎创数据科技有限公司 | Method for writing data, device, terminal device and the storage medium of round-robin queue |
-
2020
- 2020-03-27 CN CN202010228838.1A patent/CN111443873A/en active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1441440A (en) * | 2002-02-27 | 2003-09-10 | 微软公司 | Regulating system and method for obtaining uniform wear in flash storage device |
| CN103514261A (en) * | 2013-08-13 | 2014-01-15 | 江苏华大天益电力科技有限公司 | Data asynchronization storage and access mechanism applied to industrial control system |
| CN105740163A (en) * | 2016-01-29 | 2016-07-06 | 山东鲁能智能技术有限公司 | Nand Flash bad block management method |
| CN106528598A (en) * | 2016-09-23 | 2017-03-22 | 华为技术有限公司 | Chain management method and physical equipment |
| US20180088866A1 (en) * | 2016-09-23 | 2018-03-29 | Huawei Technologies Co., Ltd. | Link management method and physical device |
| CN108710531A (en) * | 2018-04-20 | 2018-10-26 | 深圳市文鼎创数据科技有限公司 | Method for writing data, device, terminal device and the storage medium of round-robin queue |
Cited By (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112035417A (en) * | 2020-09-07 | 2020-12-04 | 浙江大华技术股份有限公司 | Storage block management method, device, storage medium and electronic device |
| CN113312207A (en) * | 2021-05-07 | 2021-08-27 | 埃森智能科技(深圳)有限公司 | Data storage method adopting ferroelectric memory and programmable logic controller thereof |
| CN113312207B (en) * | 2021-05-07 | 2023-12-05 | 埃森智能科技(深圳)有限公司 | Data storage method adopting ferroelectric memory and programmable logic controller thereof |
| CN113064558A (en) * | 2021-06-04 | 2021-07-02 | 广东汇天航空航天科技有限公司 | Data storage method and device |
| CN113064558B (en) * | 2021-06-04 | 2021-09-17 | 广东汇天航空航天科技有限公司 | Data storage method and device |
| CN113625964A (en) * | 2021-07-16 | 2021-11-09 | 浙江鸿泉电子科技有限公司 | NandFlash-based sequential storage method, electronic equipment and storage medium |
| CN113625964B (en) * | 2021-07-16 | 2024-01-26 | 浙江鸿泉电子科技有限公司 | NandFlash-based sequential storage method, electronic device and storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN111443873A (en) | A kind of management method and device of Nand Flash memory | |
| US9767035B2 (en) | Pass-through tape access in a disk storage environment | |
| US9483396B2 (en) | Control apparatus, storage device, and storage control method | |
| CN108268219B (en) | Method and device for processing IO (input/output) request | |
| CN110908927A (en) | Data storage device and method for deleting name space thereof | |
| CN109189772B (en) | File management method and system for storage medium without file system | |
| CN107480074B (en) | Caching method and device and electronic equipment | |
| CN103268201A (en) | Data storing method, storing device and reading method | |
| CN110209341B (en) | Data writing method and device and storage equipment | |
| CN102355495B (en) | Data processing method, device and system | |
| JP2013235531A (en) | Control device, storage device, and storage control method | |
| CN107025182A (en) | Non-volatile memory accelerator and access acceleration method | |
| CN111367922A (en) | A data update method and related equipment | |
| CN115639971B (en) | Data writing method, data writing device, electronic device, storage medium, and program product | |
| CN115129257A (en) | Data reading and writing method, electronic equipment and computer readable storage medium | |
| US9575883B2 (en) | Control device, storage device, and storage control method | |
| CN112181275B (en) | A data processor and a data processing method | |
| WO2017177752A1 (en) | File storage method and device | |
| CN113467698A (en) | Writing method and device based on file system, computer equipment and storage medium | |
| CN111158607A (en) | Data erasing and writing operation processing method and system, electronic equipment and storage medium | |
| CN107257281B (en) | Method, device and computer-readable storage medium for NOR FLASH storage key record | |
| CN106980685B (en) | Data processing method and data processing device | |
| US9804968B2 (en) | Storage system and data writing method | |
| CN108984432B (en) | Method and device for processing IO (input/output) request | |
| CN113918485A (en) | Method, device, equipment and storage medium for preventing flash memory data from being lost |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| RJ01 | Rejection of invention patent application after publication | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200724 |