[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN109992197B - Data reading and writing method and device, electronic equipment and storage medium - Google Patents

Data reading and writing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN109992197B
CN109992197B CN201711484236.7A CN201711484236A CN109992197B CN 109992197 B CN109992197 B CN 109992197B CN 201711484236 A CN201711484236 A CN 201711484236A CN 109992197 B CN109992197 B CN 109992197B
Authority
CN
China
Prior art keywords
bad block
block
read
physical
electronic device
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.)
Active
Application number
CN201711484236.7A
Other languages
Chinese (zh)
Other versions
CN109992197A (en
Inventor
李扬渊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Microarray Microelectronics Corp ltd
Original Assignee
Microarray Microelectronics Corp ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Microarray Microelectronics Corp ltd filed Critical Microarray Microelectronics Corp ltd
Priority to CN201711484236.7A priority Critical patent/CN109992197B/en
Publication of CN109992197A publication Critical patent/CN109992197A/en
Application granted granted Critical
Publication of CN109992197B publication Critical patent/CN109992197B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0659Command handling arrangements, e.g. command buffers, queues, command scheduling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-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)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The embodiment of the invention provides a data reading and writing method, which comprises the following steps: acquiring a read-write operation instruction, and determining whether a physical block to be read and written is a bad block or not according to the read-write operation instruction; and if the physical block is determined to be a bad block, performing read-write operation on the storage space mapped with the physical block on the second electronic equipment. The invention realizes that the storage capacity is reduced after bad blocks are generated by the storage equipment.

Description

Data reading and writing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a data reading and writing method and apparatus, an electronic device, and a storage medium.
Background
In the flash memory technology, a memory chip is managed by taking a block as a unit, and because the existing process cannot ensure that the flash memory is continuously and reliably in the life cycle, the flash memory chip can generate bad blocks when the flash memory chip leaves a factory or in the running process.
Bad blocks generated when the flash memory chip leaves a factory and running bad blocks generated in running are marked and recorded in a bad block recording table. The existing flash memory data reading and writing method can replace a bad block with a good block so as to prevent data reading and writing errors caused by the bad block. Therefore, the storage capacity of the existing storage device such as a U disk and a solid state disk applying the flash memory technology is continuously reduced along with the continuous increase of bad blocks in the use process, so that the actual capacity of the storage device is smaller than the nominal capacity.
Disclosure of Invention
The invention provides a data reading and writing method and device, electronic equipment and a storage medium, which are used for avoiding the reduction of storage capacity after a storage device generates a bad block.
In a first aspect, an embodiment of the present invention provides a data reading and writing method, including:
acquiring a read-write operation instruction, and determining whether a physical block to be read and written is a bad block according to the read-write operation instruction;
and if the physical block is determined to be a bad block, performing read-write operation on a storage space mapped with the physical block on the second electronic equipment.
Optionally, performing a read-write operation on a physical block mapped with the physical block on the second electronic device, includes:
sending a first communication instruction and the bad block number of the physical block to the second electronic device, wherein the first communication instruction is used for instructing the second electronic device to read and write a storage space on the second electronic device corresponding to the bad block number according to a bad block mapping table;
the bad block mapping table comprises a mapping relation between a bad block number and a storage space of the second electronic device.
Optionally, the read-write operation instruction includes a logical address of the read-write operation;
determining whether the physical block to be read and written is a bad block according to the read and write operation instruction, including:
converting the logical address into a physical address according to a logical address and physical address mapping table;
and determining whether the physical block corresponding to the physical address is a bad block.
Optionally, after determining whether the physical block corresponding to the physical address is a bad block, the method further includes:
if the physical block corresponding to the physical address is not a bad block, updating the reading and writing frequency information of the physical block;
and if the reading and writing times of the physical block reach a threshold value, marking the physical block as a bad block, updating a bad block recording table, and simultaneously sending an instruction for updating a bad block mapping table to the second electronic equipment.
Optionally, before performing the read-write operation on the storage space mapped to the physical block on the second electronic device, the method further includes:
and mapping the bad block to the storage space of the second electronic equipment through a bad block record table.
Optionally, mapping the bad block to a storage space of the second electronic device through a bad block record table, including:
sending a device identifier and a bad block number to the second electronic device, wherein the device identifier and the bad block number are used for indicating the second electronic device to establish or update a bad block mapping table;
the bad block mapping table comprises a mapping relation between a bad block number and a storage space of the second electronic device.
In a second aspect, an embodiment of the present invention further provides a data reading and writing apparatus, including:
the bad block determining module is used for acquiring a read-write operation instruction and determining whether a physical block to be read and written is a bad block or not according to the read-write operation instruction;
and the read-write operation module is used for performing read-write operation on the storage space mapped with the physical block on the second electronic equipment if the physical block is determined to be a bad block.
Optionally, the read-write operation module includes:
the communication unit is used for sending a first communication instruction and the bad block number of the physical block to the second electronic equipment, wherein the first communication instruction is used for indicating the second electronic equipment to read and write the storage space on the second electronic equipment corresponding to the bad block number according to a bad block mapping table;
the bad block mapping table comprises a mapping relation between a bad block number and a storage space of the second electronic device.
Optionally, the read-write operation instruction includes a logical address of the read-write operation;
the read-write operation module comprises:
the address translation unit is used for translating the logical address into a physical address according to a logical address and a physical address mapping table;
and the bad block determining unit is used for determining whether the physical block corresponding to the physical address is a bad block.
Optionally, the read-write operation module further includes:
the reading and writing times updating unit is used for converting the logical address into a physical address according to a logical address and a physical address mapping table, and updating the reading and writing times information of the physical block if the physical block corresponding to the physical address is not a bad block;
and the bad block mapping table updating unit is used for marking the physical block as a bad block if the reading and writing times of the physical block reach a threshold value, updating a bad block recording table and sending an instruction for updating the bad block mapping table to the second electronic equipment.
Optionally, the data reading and writing device further includes:
and the storage space mapping module is used for mapping the bad block to the storage space of the second electronic equipment through the bad block record table before performing read-write operation on the storage space mapped with the physical block on the second electronic equipment.
Optionally, the storage space mapping module is specifically configured to send a device identifier and a bad block number to the second electronic device, and is configured to instruct the second electronic device to establish or update a bad block mapping table;
the bad block mapping table comprises a mapping relation between a bad block number and a storage space of the second electronic device.
In a third aspect, an embodiment of the present invention further provides an electronic device, including:
one or more processors;
a memory for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the data reading and writing method according to the above embodiments.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the data reading and writing method described in the foregoing embodiment.
The embodiment of the invention determines whether the physical block to be read and written is a bad block or not according to the read-write operation instruction by acquiring the read-write operation instruction; if the physical block is determined to be a bad block, performing read-write operation on the storage space mapped with the physical block on the second electronic device, and performing read-write operation on the storage space mapped with the bad block corresponding to the bad block, so that the problem that the storage capacity of the existing storage device is continuously reduced as the bad blocks are continuously increased in the using process of the storage device is solved, and the storage capacity is prevented from being reduced after the storage device generates the bad blocks.
Drawings
Fig. 1 is a flowchart of a data read/write method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a data interaction provided in an embodiment of the present invention;
FIG. 3 is a schematic diagram of another data interaction provided by the embodiment of the present invention;
FIG. 4 is a flowchart of another data reading/writing method according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of another data interaction provided in the embodiment of the present invention;
FIG. 6 is a diagram illustrating a one-to-one relationship between a bad block and an IP address of a network server according to an embodiment of the present invention;
FIG. 7 is a diagram illustrating a one-to-many relationship between a bad block and an IP address of a network server according to an embodiment of the present invention;
FIG. 8 is a diagram illustrating a one-to-many relationship between a bad block and an IP address of a network server according to an embodiment of the present invention;
fig. 9 is a flowchart of another data reading and writing method according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a data reading/writing apparatus according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
The embodiment is applicable to the case of data reading and writing, the data reading and writing method provided in this embodiment may be executed by a first electronic device, specifically, may be executed by a data reading and writing apparatus in the first electronic device, and the first electronic device may be any flash memory device.
Fig. 1 is a flowchart of a data read/write method according to an embodiment of the present invention, and referring to fig. 1, the method specifically includes the following steps:
s110: acquiring a read-write operation instruction, and determining whether a physical block to be read and written is a bad block or not according to the read-write operation instruction;
the read-write operation instruction comprises a data reading instruction or a data writing instruction and a logical address of the read-write operation, and the physical block to be read and written is determined according to the logical address of the read-write operation. If the physical block is a bad block, mapping the bad block in a bad block record table, and determining whether the physical block to be read and written is a bad block according to the bad block record table.
S120: and if the physical block is determined to be a bad block, performing read-write operation on the storage space mapped with the physical block on the second electronic equipment.
And if the physical block to be read and written is a bad block, performing read-write operation on the physical block mapped on the second electronic equipment through the communication interface. In this embodiment, the second electronic device communicates with the first electronic device executing the method, where the communication mode may be a USB (Universal Serial Bus) Interface, an SPI (Serial Peripheral Interface), a VGA (Video Graphics Array) Interface, infrared, bluetooth, WIFI (WIreless-Fidelity, WIreless network), and the like, the second electronic device may be a computer or a network server, and the first electronic device may be any flash memory device, such as a USB disk and a mobile phone. Taking the second electronic device as a server, taking the first electronic device executing the method as a mobile phone as an example, the first electronic device and the second electronic device communicate through WIFI, and a data interaction schematic diagram of the first electronic device and the second electronic device is shown in fig. 2, where fig. 2 is a data interaction schematic diagram provided by an embodiment of the present invention, where the first electronic device 100 includes a first memory 101, and the second electronic device 200 includes a second memory 201. Illustratively, if the read-write operation instruction acquired by the first electronic device 100 is "read out picture 1", the read-write operation instruction is mapped to a storage space 102 in the first memory 102 of the first electronic device 100, where the storage space 102 stores picture 1, and the storage space 102 includes a plurality of physical blocks for storing picture 1, if the physical blocks are not bad blocks, data stored in the physical blocks is read out, and if the storage space has bad blocks 103, data stored in a physical block 202 on the second electronic device 200, which is mapped to the bad blocks 103, is read, and the read data is transmitted to the first electronic device 100 through the communication interface, so that the operation of "reading picture 1" is completed.
In this embodiment, for example, the second electronic device may be a computer, and a first electronic device executing the method communicates with the computer through a USB interface, and a data interaction diagram of the first electronic device is shown in fig. 3, where fig. 3 is another data interaction diagram provided in the embodiment of the present invention, where the first electronic device 110 includes a logical block, a physical block, and a bad block record table, where the logical block and the physical block have a mapping relationship, and the bad block record table records a bad block, for example, a bad block number corresponding to the physical block. In this embodiment, the first electronic device 110 obtains a read-write operation instruction, where the read-write operation instruction includes a logical address of a read-write operation, and exemplarily, if a logical block number corresponding to the logical address included in the read-write operation instruction is "5", a physical block number of a physical block to be subjected to the read-write operation is "5" according to a mapping relationship between the logical block and the physical block, since the physical block with the physical block number of "5" is marked as a bad block and is stored in a bad block record table, the physical block with the physical block number of "5" is mapped into a physical block with a physical block number of "8" on the second electronic device 120 through the bad block record table, and the second electronic device 120 performs the read-write operation on the physical block with the physical block number of "8" on the second electronic device 120 according to the read-write operation instruction.
The embodiment of the invention determines whether the physical block to be read and written is a bad block or not according to the read-write operation instruction by acquiring the read-write operation instruction; if the physical block is determined to be a bad block, performing read-write operation on the storage space mapped with the physical block on the second electronic device, and performing read-write operation on the storage space mapped with the bad block, so that when the bad block appears on the first electronic device, the bad block is mapped to the storage space of the second electronic device instead of being replaced by a new physical block, and the read-write operation on the bad block is corresponding to the read-write operation on the storage space mapped with the bad block of the second electronic device, and the storage capacity on the first electronic device does not change, thereby solving the problem that the storage capacity of the existing storage device can be continuously reduced along with the continuous increase of the bad block in the using process, and avoiding the reduction of the storage capacity after the storage device generates the bad block.
Fig. 4 is a flowchart of another data reading and writing method according to an embodiment of the present invention, and referring to fig. 4, the data reading and writing method specifically includes the following steps:
s210: acquiring a read-write operation instruction;
s220: the read-write operation instruction comprises a logic address of the read-write operation; converting the logical address into a physical address according to the logical address and a physical address mapping table;
the logical address refers to an address code unrelated to hardware, the physical address refers to an actual hardware address of data in the memory chip, and the logical address and physical address mapping table records the mapping relationship between the logical address and the physical address.
S230: and determining whether the physical block corresponding to the physical address is a bad block.
S240: if the physical block is determined to be a bad block, mapping the bad block to a storage space of the second electronic device through a bad block record table, wherein the storage space comprises a device identifier and a bad block number which are sent to the second electronic device and used for indicating the second electronic device to establish or update a bad block mapping table; the bad block mapping table comprises a mapping relation between a bad block number and a storage space of the second electronic equipment;
the device identifier is a unique identifier of a first electronic device executing the method, the first electronic device can communicate with a plurality of second electronic devices, and a bad block mapping table in the second electronic device stores mapping relationships between bad block numbers in the plurality of first electronic devices and a storage space of the second electronic device, so that the device identifier of the first electronic device needs to be sent to establish or update the bad block mapping table, and the mapping relationship between the bad block in the first electronic device and the storage space of the second electronic device is determined.
S250: and sending a first communication instruction and the bad block number of the physical block to the second electronic equipment, wherein the first communication instruction is used for instructing the second electronic equipment to read and write the storage space on the second electronic equipment corresponding to the bad block number according to the bad block mapping table.
In this embodiment, taking the second electronic device as a network server and the first electronic device as a mobile phone as an example, the first electronic device executing the method communicates with the second electronic device through a network (TCP/IP protocol), referring to fig. 5, fig. 5 is a schematic diagram of another data interaction provided by an embodiment of the present invention, the first electronic device 210 executing the method includes a logical block, a physical block, and a bad block record table, where the logical block and the physical block have a mapping relationship, and a bad block is recorded in the bad block record table, the second electronic device 220 includes a bad block mapping table, a logical block, and a physical block, where the bad block mapping table maps a bad block on the first electronic device 210 to a logical address of a physical block of the second electronic device 220, and specifically, the first electronic device 210 obtains a read-write operation instruction, where the read-write operation instruction includes a logical address of a read-write operation; according to the logical address and physical address mapping table, the logical address is converted into the physical address, for example, if the logical block number corresponding to the logical address is "3", the physical block number corresponding to the converted physical address is "3" according to the logical address and physical address mapping table, and since the physical block with the physical block number of "3" is marked as a bad block, the physical block can be determined as a bad block, and the bad block number corresponding to the physical block number of "3" is "2" by searching the bad block recording table. Taking the device identifier of the first electronic device 210 as "0" as an example, the device identifier "0" and the bad block number "2" are sent to the second electronic device 220, the second electronic device 220 establishes or updates a bad block mapping table, so that a mapping relationship between the device identifier "0" and the bad block number "2" and a storage space of the second electronic device is established in the bad block mapping table, and in fig. 5, the device identifier "0" and the bad block number "2" correspond to a logical block with a logical block number "8" in the second electronic device 220 as an example. After the mapping relationship between the bad block mapping tables is established, the first electronic device 210 sends a first communication instruction and the bad block number "2" of the physical block to the second electronic device 220, the first communication instruction includes the device identifier of the first electronic device 210, the first communication instruction instructs the second electronic device 220 to search the bad block mapping table, a logical block with a logical block number "8" in the second electronic device 220 corresponding to the device identifier of "0" and the bad block number of "2" is obtained, according to the mapping relationship between the logical block and the physical block in the second electronic device 220, the physical block number "9" corresponding to the logical block with the logical block number "8" is obtained, and the first communication instruction instructs to perform read-write operation on the physical block with the physical block number "9".
The embodiment of the invention obtains the read-write operation instruction; the read-write operation instruction comprises a logic address of the read-write operation; converting the logical address into a physical address according to the logical address and a physical address mapping table; determining whether a physical block corresponding to the physical address is a bad block; if the physical block is determined to be a bad block, sending a device identifier and a bad block number to the second electronic device, and indicating the second electronic device to establish or update a bad block mapping table; the bad block mapping table comprises a mapping relation between a bad block number and a storage space of the second electronic equipment; the method comprises the steps of sending a first communication instruction and a bad block number of a physical block to a second electronic device, wherein the first communication instruction is used for instructing the second electronic device to read and write a storage space on the second electronic device corresponding to the bad block number according to a bad block mapping table, and the read and write operation of the bad block is corresponded to the storage space mapped with the bad block to carry out the read and write operation, so that the problem that the storage capacity of the existing storage device is continuously reduced along with the continuous increase of the bad blocks in the using process of the existing storage device is solved, and the effect of avoiding the reduction of the storage capacity after the storage device generates the bad blocks is achieved.
It should be noted that a plurality of second electronic devices may be provided, and taking the second electronic device as a network server as an example, the bad block may establish a mapping relationship with the network server through the IP address of the network server, and the mapping relationship between the bad block and the IP address of the network server may be selected as a one-to-one relationship, see fig. 6, where fig. 6 is a schematic diagram of a one-to-one relationship between the bad block and the IP address of the network server provided in the embodiment of the present invention. The mapping relationship between the bad block and the IP address of the network server can be selected as a one-to-many relationship, see fig. 7, and fig. 7 is a schematic diagram of a one-to-many relationship between the bad block and the IP address of the network server according to an embodiment of the present invention. The mapping relationship between the bad block and the IP address of the network server can be selected as a many-to-one relationship, referring to fig. 8, and fig. 8 is a schematic diagram of a one-to-many relationship between the bad block and the IP address of the network server according to an embodiment of the present invention. The same bad block can be mapped to different network servers, and different bad blocks can also be mapped to the same network server. If the IP address of the network server is dynamic, the address table of the network server is also dynamic, for example, if the domain name of the network server is mapped by the bad block, the real IP address of the network server mapped by the bad block can be obtained by the DNS server.
Fig. 9 is a flowchart of another data reading and writing method according to an embodiment of the present invention, and referring to fig. 9, on the basis of the foregoing embodiments, the data reading and writing method specifically includes the following steps:
s310: acquiring a read-write operation instruction;
s320: the read-write operation instruction comprises a logic address of the read-write operation; converting the logical address into a physical address according to the logical address and a physical address mapping table;
s330: determining whether a physical block corresponding to the physical address is a bad block, if so, executing S370, otherwise, executing S340;
s340: updating the reading and writing frequency information of the physical block;
s350: determining whether the read-write times of the physical block reach a threshold value, if so, executing S360, otherwise, executing 380;
s360: marking the physical block as a bad block, updating a bad block record table, and sending an instruction for updating a bad block mapping table to the second electronic equipment;
s370: and performing read-write operation on the storage space mapped with the physical block on the second electronic equipment.
S380: and performing read-write operation on the physical block according to the read-write operation instruction.
On the basis of the foregoing embodiments, the present embodiment determines whether the read-write frequency of the physical block reaches a threshold by updating the read-write frequency information of the physical block, and if the read-write frequency reaches the threshold, marks the physical block as a bad block, and updates a bad block mapping table on the second electronic device, so that the bad block mapping table of the second electronic device is updated in time after the bad block is generated. The problem that the storage capacity of the existing storage equipment can be continuously reduced along with the continuous increase of the bad blocks in the use process is solved, and the reduction of the storage capacity of the storage equipment after the bad blocks are generated is avoided.
Fig. 10 is a schematic structural diagram of a data reading and writing apparatus according to an embodiment of the present invention, where the data reading and writing apparatus according to an embodiment of the present invention can execute a data reading and writing method according to any embodiment of the present invention, and has corresponding beneficial effects of the execution method. Referring to fig. 10, the data reading and writing apparatus includes:
a bad block determining module 410, configured to obtain a read-write operation instruction, and determine whether a physical block to be read and written is a bad block according to the read-write operation instruction;
and the read-write operation module 420 is configured to perform a read-write operation on the storage space mapped with the physical block on the second electronic device if the physical block is determined to be a bad block.
Optionally, the read/write operation module 420 includes:
the communication unit 421 is configured to send a first communication instruction and a bad block number of a physical block to the second electronic device, where the first communication instruction is used to instruct the second electronic device to read and write a storage space on the second electronic device corresponding to the bad block number according to the bad block mapping table;
the bad block mapping table comprises a mapping relation between the bad block number and the storage space of the second electronic equipment.
Optionally, the read-write operation instruction includes a logical address of the read-write operation;
the read/write operation module 420 includes:
an address translation unit 422, configured to translate a logical address into a physical address according to the logical address and the physical address mapping table;
and a bad block determination unit 423, configured to determine whether the physical block corresponding to the physical address is a bad block.
Optionally, the read/write operation module 420 further includes:
a read-write frequency updating unit 424, configured to update the physical block read-write frequency information if the physical block corresponding to the physical address is not a bad block after determining whether the physical block corresponding to the physical address is a bad block;
and a bad block mapping table updating unit 425, configured to mark the physical block as a bad block if the number of times of reading and writing the physical block reaches a threshold, update the bad block recording table, and send an instruction to update the bad block mapping table to the second electronic device.
Optionally, the data reading and writing device further includes:
the storage space mapping module 430 is configured to map the bad block to the storage space of the second electronic device through the bad block record table before performing read-write operation on the storage space mapped to the physical block on the second electronic device.
Optionally, the storage space mapping module 430 is specifically configured to send the device identifier and the bad block number to the second electronic device, and is configured to instruct the second electronic device to establish or update the bad block mapping table;
the bad block mapping table comprises a mapping relation between the bad block number and the storage space of the second electronic equipment.
In this embodiment, by setting that the data reading and writing apparatus includes a bad block determining module 410 and a reading and writing operation module 420, the bad block determining module 410 is configured to obtain a reading and writing operation instruction, and determine whether a physical block to be read and written is a bad block according to the reading and writing operation instruction; the read-write operation module 420 is configured to perform a read-write operation on the storage space mapped to the physical block on the second electronic device if it is determined that the physical block is a bad block. The method and the device realize that the read-write operation of the bad block is corresponding to the storage space mapped with the bad block, solve the problem that the storage capacity of the existing storage equipment is continuously reduced along with the continuous increase of the bad block in the use process, and avoid the reduction of the storage capacity after the storage equipment generates the bad block.
Fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. The electronic equipment can comprise the data reading and writing device provided by any embodiment of the invention. As shown in fig. 11, the electronic device specifically includes: one or more processors 510, one processor 510 being illustrated in FIG. 11; the memory 520 is used for storing one or more programs, and when the one or more programs are executed by the one or more processors 510, the one or more processors 510 implement the data reading and writing method according to any embodiment of the present invention. The processor 510 and the memory 520 may be connected by a bus or other means, such as the bus connection shown in FIG. 11.
The memory 520, which is a computer-readable storage medium, may be used to store software programs, computer-executable programs, and modules, such as program instructions corresponding to the data reading and writing method in the embodiment of the present invention (for example, receiving a reading and writing operation instruction sent by the second electronic device and performing reading and writing operation on a storage space mapped with the physical block on the second electronic device). The processor 510 executes various functional applications of the terminal and data processing, i.e., implements the above-described data read/write method, by executing software programs, instructions, and modules stored in the memory 520.
The memory 520 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 520 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the memory 520 may further include memory located remotely from the processor 510, which may be connected to the terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program (or referred to as computer-executable instructions) is stored, where the computer program is used for executing a data reading and writing method when executed by a processor, and the method includes:
receiving a read-write operation instruction sent by the second electronic equipment, and determining whether a physical block to be read and written is a bad block or not according to the read-write operation instruction;
and if the physical block is determined to be a bad block, performing read-write operation on the storage space mapped with the physical block on the second electronic equipment.
Of course, the computer-readable storage medium provided in the embodiments of the present invention has computer-executable instructions that are not limited to the operations of the method described above, and may also perform related operations in the data reading and writing method provided in any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly can be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention or portions thereof contributing to the prior art may be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention. It should be noted that, in the embodiment of the above search apparatus, each included unit and module are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, the specific names of the functional units are only for the convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A method for reading and writing data, comprising:
acquiring a read-write operation instruction, and determining whether a physical block to be read and written is a bad block or not according to the read-write operation instruction;
if the physical block is determined to be a bad block, performing read-write operation on a storage space mapped with the physical block on second electronic equipment;
before performing the read-write operation on the storage space mapped with the physical block on the second electronic device, the method further includes: mapping the bad block to a storage space of the second electronic device through a bad block record table;
wherein, the mapping the bad block to the storage space of the second electronic device through the bad block record table includes: sending a device identifier and a bad block number to the second electronic device, wherein the device identifier and the bad block number are used for indicating the second electronic device to establish or update a bad block mapping table; the bad block mapping table comprises a mapping relation between the bad block number and a storage space of the second electronic equipment; the device identifier is a unique identification of the first electronic device.
2. The method according to claim 1, wherein performing read/write operations on the storage space mapped to the physical block on the second electronic device includes:
and sending a first communication instruction and the bad block number of the physical block to the second electronic equipment, wherein the first communication instruction is used for instructing the second electronic equipment to read and write the storage space on the second electronic equipment corresponding to the bad block number according to a bad block mapping table.
3. A method according to claim 1, wherein the read/write operation command includes a logical address of the read/write operation;
determining whether the physical block to be read and written is a bad block according to the read and write operation instruction, including:
converting the logical address into a physical address according to a logical address and physical address mapping table;
and determining whether the physical block corresponding to the physical address is a bad block.
4. The data reading and writing method according to claim 3, wherein after determining whether the physical block corresponding to the physical address is a bad block, further comprising:
if the physical block corresponding to the physical address is not a bad block, updating the information of the reading and writing times of the physical block;
and if the reading and writing times of the physical block reach the threshold value, marking the physical block as a bad block, updating a bad block recording table, and simultaneously sending an instruction for updating a bad block mapping table to the second electronic equipment.
5. A data reading and writing apparatus, comprising:
the bad block determining module is used for acquiring a read-write operation instruction and determining whether a physical block to be read and written is a bad block or not according to the read-write operation instruction;
the read-write operation module is used for performing read-write operation on a storage space mapped with the physical block on the second electronic equipment if the physical block is determined to be a bad block;
the storage space mapping module is used for mapping the bad block to the storage space of the second electronic device through a bad block record table before the read-write operation is carried out on the storage space mapped with the physical block on the second electronic device;
the storage space mapping module is specifically configured to send a device identifier and a bad block number to the second electronic device, and is configured to instruct the second electronic device to establish or update a bad block mapping table; the bad block mapping table comprises a mapping relation between the bad block number and a storage space of the second electronic equipment; the device identifier is a unique identification of the first electronic device.
6. The data reading and writing device according to claim 5, wherein the reading and writing operation module includes:
and the communication unit is used for sending a first communication instruction and the bad block number of the physical block to the second electronic equipment, wherein the first communication instruction is used for indicating the second electronic equipment to read and write the storage space on the second electronic equipment corresponding to the bad block number according to the bad block mapping table.
7. The data reading and writing apparatus according to claim 5, wherein the reading and writing operation command includes a logical address of the reading and writing operation;
the read-write operation module comprises:
the address conversion unit is used for converting the logical address into a physical address according to a logical address and a physical address mapping table;
and the bad block determining unit is used for determining whether the physical block corresponding to the physical address is a bad block.
8. The data reading/writing apparatus according to claim 7, wherein the reading/writing operation module further includes:
a read-write frequency updating unit, configured to update the physical block read-write frequency information if the physical block corresponding to the physical address is not a bad block after determining whether the physical block corresponding to the physical address is a bad block;
and the bad block mapping table updating unit is used for marking the physical block as a bad block if the reading and writing times of the physical block reach a threshold value, updating a bad block recording table and sending an instruction for updating the bad block mapping table to the second electronic equipment.
9. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the data reading and writing method of any one of claims 1 to 4.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method for reading and writing data according to any one of claims 1 to 4.
CN201711484236.7A 2017-12-29 2017-12-29 Data reading and writing method and device, electronic equipment and storage medium Active CN109992197B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711484236.7A CN109992197B (en) 2017-12-29 2017-12-29 Data reading and writing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711484236.7A CN109992197B (en) 2017-12-29 2017-12-29 Data reading and writing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109992197A CN109992197A (en) 2019-07-09
CN109992197B true CN109992197B (en) 2022-08-26

Family

ID=67111270

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711484236.7A Active CN109992197B (en) 2017-12-29 2017-12-29 Data reading and writing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109992197B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112416810A (en) * 2020-11-10 2021-02-26 深圳宏芯宇电子股份有限公司 Storage-level storage device, data operation method thereof and electronic equipment
CN112948173A (en) * 2021-02-02 2021-06-11 湖南国科微电子股份有限公司 Data recovery method, device, equipment and medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107085534A (en) * 2017-03-30 2017-08-22 联想(北京)有限公司 A kind of information processing method and electronic equipment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101593157B (en) * 2008-05-27 2011-03-16 中兴通讯股份有限公司 Bad block management (BBM) method and device for Nand Flash
CN101777013A (en) * 2009-01-12 2010-07-14 成都市华为赛门铁克科技有限公司 Solid state disk and data read-write method
US9442840B2 (en) * 2012-12-19 2016-09-13 Qualcomm Incorporated Virtual boundary codes in a data image of a read-write memory device
KR20160003530A (en) * 2014-07-01 2016-01-11 삼성전자주식회사 An internal storage, an external storage capable of communicationg with the same, and data processing system including the same
KR20170099018A (en) * 2016-02-22 2017-08-31 에스케이하이닉스 주식회사 Memory system and operation method for the same

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107085534A (en) * 2017-03-30 2017-08-22 联想(北京)有限公司 A kind of information processing method and electronic equipment

Also Published As

Publication number Publication date
CN109992197A (en) 2019-07-09

Similar Documents

Publication Publication Date Title
US10754869B2 (en) Managing data format of data received from devices in an internet of things network
CN103607428B (en) A kind of method and apparatus for accessing shared drive
KR20150091663A (en) System comprising multi channel memory and operating method for the same
CN110266763B (en) Method, system and storage medium for implementing block chain network interconnected across network segments
CN108881227B (en) Operation control method and device of remote whiteboard system and remote whiteboard system
CN110719345B (en) Virtual machine MAC address generation method, system, equipment and computer medium
CN114338594B (en) ARP (Address resolution protocol) response-substituting method, device, equipment and storage medium in Kubernetes environment
CN110297608B (en) Data processing method, device and storage medium
CN105335309A (en) Data transmission method and computer
WO2021128903A1 (en) Method and system for accelerating reading of information of field replace unit, device and medium
CN106126374A (en) Method for writing data, method for reading data and device
CN104468368A (en) Method and device for allocating BGP neighbors
CN109992197B (en) Data reading and writing method and device, electronic equipment and storage medium
CN106170757A (en) A kind of date storage method and device
CN109446147B (en) Data interaction method of network storage device and pcie device
CN112463055B (en) Method, system, equipment and medium for optimizing and using L2P table of solid state disk
CN108268216A (en) Data processing method, device and server
CN112422485B (en) Communication method and device of transmission control protocol
CN111064786A (en) Account identifier management method and device
CN105144073A (en) Removable storage device identity and configuration information
CN104077374A (en) Method and device for achieving internet protocol (IP) disk file storage
CN113923061B (en) GPU network communication method based on intelligent network card, medium and equipment
CN105765542A (en) Method for accessing files, distributed storage system and storage node
CN109995678A (en) Message transmitting method and device
CN110045929B (en) Mounting point management method and related device

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
GR01 Patent grant
GR01 Patent grant