Method, system, computer equipment and storage medium for quickly deleting flash data

文档序号:828783 发布日期:2021-03-30 浏览:8次 中文

阅读说明:本技术 快速删除flash数据的方法、系统、计算机设备及存储介质 (Method, system, computer equipment and storage medium for quickly deleting flash data ) 是由 方利红 柳振强 包建意 李军军 杨延志 刘军 于 2020-12-17 设计创作,主要内容包括:本申请涉及一种快速删除flash数据的方法、装置、计算机设备和存储介质。其中,方法包括以下步骤:设定数据的有效标记值;将数据结合其有效标记值根据数据大小和标准扇区大小存入一个或多个连续的标准扇区内;若需要擦除该组数据时,直接修改其有效标记值的状态为无效数据。本申请技术方案在需要擦除这组数据时,直接将表征这组数据有效性的有效标记改写即可,不再需要实际擦除这组数据,运行中的时间损耗少,提高了运行效率,避免flash损坏的问题,并延长了flash的使用寿命。(The application relates to a method and a device for quickly deleting flash data, computer equipment and a storage medium. The method comprises the following steps: setting a valid flag value of the data; storing the data in combination with its valid flag value into one or more consecutive standard sectors according to the data size and the standard sector size; if the group of data needs to be erased, the state of the valid flag value is directly modified into invalid data. According to the technical scheme, when the group of data needs to be erased, the effective mark representing the validity of the group of data is directly rewritten, the group of data does not need to be actually erased, time loss in operation is low, operation efficiency is improved, the problem of flash damage is avoided, and the service life of flash is prolonged.)

1. A method for quickly deleting flash data is characterized by comprising the following steps:

setting a valid flag value of the data;

storing the data in combination with its valid flag value into one or more consecutive standard sectors according to the data size and the standard sector size;

if the group of data needs to be erased, the state of the valid flag value is directly modified into invalid data.

2. The method for rapidly deleting flash data according to claim 1, further comprising the steps of:

if the group of data needs to be rewritten, erasing the data of one or more continuous standard sectors containing the group of data;

writing new data;

the valid flag value characterizing the new data is modified.

3. The method for rapidly deleting flash data according to claim 1, wherein the data is stored in one or more continuous standard sectors according to the data size and the standard sector size in combination with the valid flag value thereof, and the method specifically comprises the following steps:

calculating the number of occupied standard sectors of the data;

the data is stored in the corresponding standard sector in combination with its valid flag value.

4. The method for rapidly deleting flash data according to claim 3, wherein the step of calculating the number of occupied standard sectors of the data specifically comprises the following steps:

setting a standard sector size of 4096;

reading the size of the data store;

n1 represents the integer part of the size of the stored information divided by the size of one standard sector, N1 ═ actual data size + 2)/4096;

n2 represents the size of the stored information divided by a standard sector size, whether there is a fractional part, if N2 has a fractional part, then N2 is 1, otherwise N2 is 0, and N2 is ((actual data size + 2)% 40961: 0);

n is N1+ N2, where N is the number of standard sectors occupied by the data.

5. A system for quickly deleting flash data, comprising:

a setting unit for setting a valid flag value of the data;

a storage unit for storing the data in combination with its valid flag value into one or more consecutive standard sectors according to the data size and the standard sector size;

and the correcting unit is used for directly modifying the state of the valid mark value of the data into invalid data when the group of data needs to be erased.

6. The system for rapidly deleting flash data according to claim 5, further comprising:

the erasing unit is used for erasing the data of one or more continuous standard sectors containing the group of data when the group of data needs to be rewritten;

a write unit for writing new data;

a modification unit for modifying the valid flag value characterizing the new data.

7. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 4 when executing the computer program.

8. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 4.

Technical Field

The present application relates to the field of data storage technologies, and in particular, to a method, a system, a computer device, and a storage medium for quickly deleting flash data.

Background

Nowadays, we have already stepped into the era of the rapid development of computer information technology,

flash chips in this time are increasingly used in a variety of computer systems of different sizes. Although the used flash chips have inconsistent storage capacity, inconsistent models and inconsistent read-write life, the flash chips are used in large quantities to achieve the consistent purpose, namely, various data information can be safely stored.

In the inherent operation flow of the flash chip, when a user needs to delete certain data stored in the flash, the useful data needs to be read out first, then the sector where the useful data is located is erased, and finally the read data is written in. When writing is needed, the sector is still needed to be deleted, and the data needed to be stored is written again. The adoption of such a simple operation mode can cause frequent sector erasure, which results in considerable time resource consumption during the operation of erasing the whole sector, which seriously affects the response efficiency of the program and cannot bring good interactive experience to the user.

Disclosure of Invention

In view of the foregoing, it is desirable to provide a method, a system, a computer device and a storage medium for fast deleting flash data.

A method for quickly deleting flash data comprises the following steps:

setting a valid flag value of the data;

storing the data in combination with its valid flag value into one or more consecutive standard sectors according to the data size and the standard sector size;

if the group of data needs to be erased, the state of the valid flag value is directly modified into invalid data.

As an embodiment, the method further comprises the following steps:

if the group of data needs to be rewritten, erasing the data of one or more continuous standard sectors containing the group of data;

writing new data;

the valid flag value characterizing the new data is modified.

As an embodiment, the storing the data with its valid flag value into one or more consecutive standard sectors according to the data size and the standard sector size specifically includes the following steps:

calculating the number of occupied standard sectors of the data;

the data is stored in the corresponding standard sector in combination with its valid flag value.

As an implementation manner, the calculating the number of occupied standard sectors of the data specifically includes the following steps:

setting a standard sector size of 4096;

reading the size of the data store;

n1 represents the integer part of the size of the stored information divided by the size of one standard sector, N1 ═ actual data size + 2)/4096;

n2 represents the size of the stored information divided by a standard sector size, whether there is a fractional part, if N2 has a fractional part, then N2 is 1, otherwise N2 is 0, and N2 is ((actual data size + 2)% 40961: 0);

n is N1+ N2, where N is the number of standard sectors occupied by the data.

A system for fast deleting flash data, comprising:

a setting unit for setting a valid flag value of the data;

a storage unit for storing the data in combination with its valid flag value into one or more consecutive standard sectors according to the data size and the standard sector size;

and the correcting unit is used for directly modifying the state of the valid mark value of the data into invalid data when the group of data needs to be erased.

As an embodiment, further comprising:

the erasing unit is used for erasing the data of one or more continuous standard sectors containing the group of data when the group of data needs to be rewritten;

a write unit for writing new data;

a modification unit for modifying the valid flag value characterizing the new data.

A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of a method of fast deleting flash data when executing the computer program.

A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of fast deleting flash data.

According to the method, the system, the computer equipment and the storage medium for quickly deleting the flash data, when the group of data needs to be erased, the effective mark representing the validity of the group of data is directly rewritten, the group of data does not need to be actually erased, time loss in operation is low, operation efficiency is improved, the problem of flash damage is solved, and the service life of the flash is prolonged.

When the group of data needs to be used, the valid tag value of the data is read first, whether the data is valid is judged, and then whether the group of data needs to be taken is determined.

When the group of data needs to be rewritten, the memory area corresponding to the data is erased only before the data is to be written.

Drawings

FIG. 1 is a diagram of an application environment for a method for fast deleting flash data in one embodiment;

FIG. 2 is a flowchart illustrating a method for fast deleting flash data in one embodiment;

FIG. 3 is a block diagram of a system for fast deleting flash data in one embodiment;

FIG. 4 is a diagram illustrating an internal structure of a computer device according to an embodiment.

Detailed Description

In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.

The method for quickly deleting flash data provided by the application can be applied to the application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and the like, and the server 104 may be implemented by an independent server or a server cluster formed by a plurality of servers.

In one embodiment, as shown in FIG. 2, a method for fast deleting flash data is provided. The method is described as an example of the application to the terminal in fig. 1, and the method includes the following steps:

s100, setting a valid flag value of data; in the present embodiment, the valid flag value Fvalid is 0x55A a/0xAA55 (other specific values are also possible), where 0x55AA indicates that the data is valid and 0xAA55 indicates that the data is invalid.

S200, storing the data combined with the effective mark value into one or more continuous standard sectors according to the size of the data and the size of the standard sectors;

specifically, in step S200, one or more continuous standard sectors are allocated according to the data size and the standard sector size for storing the group of data, and the flow of calculating the number of standard sectors needed for storing data is as follows:

the size of a standard sector is set to be 4096 bytes, of course, other numbers of bytes can be set, and if the standard sector is of other sizes, adaptive modification can be carried out in the following calculation formula;

reading the size of the data store;

n1 represents the integer part of the size of the stored information divided by the size of a standard sector, N1 ═ actual data size +2)/4096, 4096 is the size of a standard sector;

n2 represents the size of the stored information divided by a standard sector size, whether there is a fractional part, if N2 has a fractional part, then N2 is 1, otherwise N2 is 0, and N2 is ((actual data size + 2)% 40961: 0);

n is N1+ N2, where N is the number of standard sectors occupied by the data.

After the number of the required standard sectors is obtained, the data is stored in the corresponding standard sectors in combination with the valid tag values of the data, and the data cannot be stored in a partitioned mode, so that when the size of the actual data exceeds the size of one standard sector, the actual data is stored in a plurality of continuous standard sectors to guarantee the continuity of the data.

In one embodiment, if the data size is 4098 bytes (generally, the number of bytes for which the valid flag value is set is 2, which is negligible, and only the number of standard sectors that need to be occupied is calculated according to the actual data size), then N1 is 1, N2 is 1, and N is 2, so the data needs to occupy two consecutive standard sectors to store the data.

S300, if the group of data needs to be erased, the state of the valid flag value is directly modified into invalid data.

After the valid flag value of the data is modified, the data state is an invalid state when the data is read next time, that is, the data is erased by default.

When the storage space is insufficient or the data is required to be stored in the standard sector area, the data in the standard sector area of the area is rewritten. The specific step S400 of rewriting data is as follows:

erasing data of one or more consecutive standard sectors containing the set of data;

writing new data;

the valid flag value characterizing the new data is modified.

In the erasing process, the number and the position of the standard sectors occupied by the data during storage can be directly read, or the number of the standard sectors occupied by the data can be obtained through a calculation mode (the same as the flow of calculating the number of the standard sectors required by the stored data), and the data stored in the sectors can be erased after corresponding information is obtained.

In one embodiment, as shown in fig. 3, a system for quickly deleting flash data includes a setting unit 1, a storage unit 2, and a modification unit 3, where the setting unit 1 is configured to set a valid flag value of data; the storage unit 2 is used for storing the data combined with the valid mark value thereof into one or more continuous standard sectors according to the data size and the standard sector size; the modification unit 3 is used for directly modifying the valid flag value of the group of data if the group of data needs to be erased.

In addition to the above units, the device also comprises an erasing unit 4, a writing unit 5 and a modifying unit 6, wherein the erasing unit is used for erasing the data of one or more continuous standard sectors containing the group of data if the group of data needs to be rewritten; the writing unit is used for writing new data; the modification unit is adapted to modify a valid flag value characterizing the new data.

For the specific limitations of the above system, reference may be made to the limitations of the method above, which are not described herein again. The various modules in the above-described apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.

In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 4. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer equipment is used for storing the data of the human face living body detection method based on the infrared image. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to realize a human face living body detection method based on infrared images.

Those skilled in the art will appreciate that the architecture shown in fig. 4 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.

In one embodiment, there is provided a computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:

s100, setting a valid flag value of data; in the present embodiment, the valid flag value Fvalid is 0x55A a/0xAA55 (other specific values are also possible), where 0x55AA indicates that the data is valid and 0xAA55 indicates that the data is invalid.

S200, storing the data combined with the effective mark value into one or more continuous standard sectors according to the size of the data and the size of the standard sectors;

specifically, in step S200, one or more continuous standard sectors are allocated according to the data size and the standard sector size for storing the group of data, and the flow of calculating the number of standard sectors needed for storing data is as follows:

the size of a standard sector is set to be 4096 bytes, of course, other numbers of bytes can be set, and if the standard sector is of other sizes, adaptive modification can be carried out in the following calculation formula;

reading the size of the data store;

n1 represents the integer part of the size of the stored information divided by the size of a standard sector, N1 ═ actual data size +2)/4096, 4096 is the size of a standard sector;

n2 represents the size of the stored information divided by a standard sector size, whether there is a fractional part, if N2 has a fractional part, then N2 is 1, otherwise N2 is 0, and N2 is ((actual data size + 2)% 40961: 0);

n is N1+ N2, where N is the number of standard sectors occupied by the data.

After the number of the required standard sectors is obtained, the data is stored in the corresponding standard sectors in combination with the valid tag values of the data, and the data cannot be stored in a partitioned mode, so that when the size of the actual data exceeds the size of one standard sector, the actual data is stored in a plurality of continuous standard sectors to guarantee the continuity of the data.

In one embodiment, if the data size is 4098 bytes (generally, the number of bytes for which the valid flag value is set is 2, which is negligible, and only the number of standard sectors that need to be occupied is calculated according to the actual data size), then N1 is 1, N2 is 1, and N is 2, so the data needs to occupy two consecutive standard sectors to store the data.

S300, if the group of data needs to be erased, the state of the valid flag value is directly modified into invalid data.

After the valid flag value of the data is modified, the data state is an invalid state when the data is read next time, that is, the data is erased by default.

When the storage space is insufficient or the data is required to be stored in the standard sector area, the data in the standard sector area of the area is rewritten. The specific step S400 of rewriting data is as follows:

erasing data of one or more consecutive standard sectors containing the set of data;

writing new data;

the valid flag value characterizing the new data is modified.

In the erasing process, the number and the position of the standard sectors occupied by the data during storage can be directly read, or the number of the standard sectors occupied by the data can be obtained through a calculation mode (the same as the flow of calculating the number of the standard sectors required by the stored data), and the data stored in the sectors can be erased after corresponding information is obtained.

In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:

s100, setting a valid flag value of data; in the present embodiment, the valid flag value Fvalid is 0x55A a/0xAA55 (other specific values are also possible), where 0x55AA indicates that the data is valid and 0xAA55 indicates that the data is invalid.

S200, storing the data combined with the effective mark value into one or more continuous standard sectors according to the size of the data and the size of the standard sectors;

specifically, in step S200, one or more continuous standard sectors are allocated according to the data size and the standard sector size for storing the group of data, and the flow of calculating the number of standard sectors needed for storing data is as follows:

the size of a standard sector is set to be 4096 bytes, of course, other numbers of bytes can be set, and if the standard sector is of other sizes, adaptive modification can be carried out in the following calculation formula;

reading the size of the data store;

n1 represents the integer part of the size of the stored information divided by the size of a standard sector, N1 ═ actual data size +2)/4096, 4096 is the size of a standard sector;

n2 represents the size of the stored information divided by a standard sector size, whether there is a fractional part, if N2 has a fractional part, then N2 is 1, otherwise N2 is 0, and N2 is ((actual data size + 2)% 40961: 0);

n is N1+ N2, where N is the number of standard sectors occupied by the data.

After the number of the required standard sectors is obtained, the data is stored in the corresponding standard sectors in combination with the valid tag values of the data, and the data cannot be stored in a partitioned mode, so that when the size of the actual data exceeds the size of one standard sector, the actual data is stored in a plurality of continuous standard sectors to guarantee the continuity of the data.

In one embodiment, if the data size is 4098 bytes (generally, the number of bytes for which the valid flag value is set is 2, which is negligible, and only the number of standard sectors that need to be occupied is calculated according to the actual data size), then N1 is 1, N2 is 1, and N is 2, so the data needs to occupy two consecutive standard sectors to store the data.

S300, if the group of data needs to be erased, the state of the valid flag value is directly modified into invalid data.

After the valid flag value of the data is modified, the data state is an invalid state when the data is read next time, that is, the data is erased by default.

When the storage space is insufficient or the data is required to be stored in the standard sector area, the data in the standard sector area of the area is rewritten. The specific step S400 of rewriting data is as follows:

erasing data of one or more consecutive standard sectors containing the set of data;

writing new data;

the valid flag value characterizing the new data is modified.

In the erasing process, the number and the position of the standard sectors occupied by the data during storage can be directly read, or the number of the standard sectors occupied by the data can be obtained through a calculation mode (the same as the flow of calculating the number of the standard sectors required by the stored data), and the data stored in the sectors can be erased after corresponding information is obtained.

It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), enhanced SD RAM (ESDRAM), synchronous Link (Synchlink)

Dram (sldram), Rambus (Rambus) direct ram (rdram), direct memory bus dynamic ram (drdram), and memory bus dynamic ram (rdram), among others.

The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.

The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

10页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:降低SSD平均功耗的方法、装置、计算机设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类