WO2018086409A1 - 一种磁盘数据读写方法及装置 - Google Patents

一种磁盘数据读写方法及装置 Download PDF

Info

Publication number
WO2018086409A1
WO2018086409A1 PCT/CN2017/101628 CN2017101628W WO2018086409A1 WO 2018086409 A1 WO2018086409 A1 WO 2018086409A1 CN 2017101628 W CN2017101628 W CN 2017101628W WO 2018086409 A1 WO2018086409 A1 WO 2018086409A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
index
data
metadata
primary
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.)
Ceased
Application number
PCT/CN2017/101628
Other languages
English (en)
French (fr)
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.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology Co 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 Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to EP17870483.9A priority Critical patent/EP3540587B1/en
Priority to US16/348,248 priority patent/US11048601B2/en
Publication of WO2018086409A1 publication Critical patent/WO2018086409A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/2053Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant
    • G06F11/2094Redundant storage or storage space
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/0644Management of space entities, e.g. partitions, extents, pools
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/062Securing storage systems
    • G06F3/0622Securing storage systems in relation to access
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/2053Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant
    • G06F11/2056Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant by mirroring
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/0614Improving the reliability of storage systems
    • G06F3/0616Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/0614Improving the reliability of storage systems
    • G06F3/0619Improving the reliability of storage systems in relation to data integrity, e.g. data losses, bit errors
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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/0674Disk device
    • G06F3/0676Magnetic disk device

Definitions

  • the present application relates to the field of computer technology, and in particular, to a disk data reading and writing method and apparatus.
  • the disk is divided into two parts storage areas, which are an index area and a data area respectively, and the object data is collectively stored in the object block of the data area; the main key data and the backup key data are collectively stored in the index area.
  • the key data includes: an index of the metadata and the object data
  • the metadata includes: startup information, metadata description information, a block bitmap, a bad block bit, and an allocation information of the index.
  • the object blocks that store key data are:
  • a boot block for storing startup information, including an identifier of the metadata description block and a size of the storage space occupied by the metadata description block;
  • a metadata description block for storing metadata description information, including an identifier of a block bitmap block, an identifier of a bad block bitmap block, and an identifier of an index allocation information block, and a block bitmap block, a bad block bitmap block, and an index allocation The size of the storage space occupied by the information block;
  • a block bitmap block for storing a block bitmap, including usage information of each object block
  • the bad block bitmap block corresponds to the block bitmap block; here, if one of the object blocks is damaged, the object block may be referred to as a bad block;
  • An index allocation information block configured to store allocation information of the index, including: an identifier of each index block and a size of a storage space occupied by the index block;
  • the index block is used to store an index of the object data, including: an identifier of the object data occupying the object block and a size of the storage space occupied by the object block.
  • Read/write object data needs to read/write key data, while key data is stored in the object block of the index area.
  • the operation of key data will be concentrated.
  • the object block of the index area that is, concentrated in the area of the index area, in this case, it is easy to cause index hotspot data access, that is, it is easy to make the operation frequency of the area of the index area too high, causing damage to the disk. Reduce the life and security of the disk.
  • the embodiment of the present application discloses a disk data reading and writing method and device to increase the service life and security of the disk.
  • the embodiment of the present application discloses a disk data reading method, where the disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, and each An object block group includes: a data block storing object data; an index block storing an index of the object data; the main metadata block is located at a head of the disk; and the spare metadata block is located at a tail of the disk;
  • the at least one object block group is located between the primary metadata block and the spare metadata block; the method includes:
  • Determining the target object data according to the identifier of the target object data, the metadata in the primary metadata block, the metadata backed up in the backup metadata block, and an index in an index block in each object block group.
  • the index block includes a primary index block and an alternate index block; the primary index block is configured to store an index of the object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • the step of determining the first data block corresponding to the object data, and determining the first object block group in which the first data block is located, includes:
  • the identifier according to the target object data, the metadata in the primary metadata block, the metadata backed up in the backup metadata block, and an index in an index block in each object block group includes:
  • the preset index database is configured to store an index check value, an identifier of the data block, and a data length Corresponding relationship between the three;
  • the index check value stored in the preset index database is based on metadata in the primary metadata block, metadata backed up in the standby metadata block, and each object block group Index determination in the index block;
  • the step of reading the target object data from the first data block of the first object block group includes:
  • the embodiment of the present application further discloses a disk data writing method, where the disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group.
  • Each object block group includes: a data block storing object data, an index block storing an index of the object data; the main metadata block is located at a head of the disk; and the spare metadata block is located at a tail of the disk;
  • the at least one object block group is located between the primary metadata block and the spare metadata block; the method includes:
  • the index block includes a primary index block and an alternate index block; the primary index block is configured to store an index of the object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • the index in the index block in the first object block group, the metadata in the primary metadata block, and the spare metadata block are updated according to the identifier of the target object data.
  • the method further includes:
  • the preset index database is used to store an index check The correspondence between the value, the identifier of the data block, and the data length.
  • the embodiment of the present application further discloses a disk data reading apparatus, where the disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group.
  • Each object block group includes: a data block storing object data, an index block storing an index of the object data; the main metadata block is located at a head of the disk; and the spare metadata block is located at a tail of the disk;
  • the at least one object block group is located between the primary metadata block and the spare metadata block;
  • the device includes:
  • An instruction receiving unit configured to receive a read instruction for the target object data
  • An information determining unit configured to determine, according to the identifier of the target object data, metadata in the primary metadata block, metadata backed up in the backup metadata block, and an index in an index block in each object block group, Determining a first data block corresponding to the target object data, and determining a first object block group in which the first data block is located;
  • a data reading unit configured to read the target object data from the first data block of the first object block group.
  • the index block includes a primary index block and an alternate index block; the primary index block is configured to store an index of the object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • the information determining unit is specifically configured to:
  • a bad block determining unit configured to fail when reading metadata in the primary metadata block, or to read metadata backed up in the standby metadata block, or to read a primary index block in each object block group If the index in the failure fails or the index of the backup in the standby index block in each object block group fails to be read, the object block that failed to be read is determined as a suspected bad block, and the object data is rewritten into the suspected bad block and / or reading object data from the suspected bad block;
  • a data repairing unit configured to: if the object data is successfully written and/or read, repair the data in the suspected bad block according to the primary and backup redundant data;
  • a data overlay unit configured to: if a write and/or read object data fails, acquire a reserved block, and replace the suspected bad block; overwrite the acquired reserved block according to the primary and backup redundant data, and update the Metadata in the primary metadata block and metadata backed up in the standby metadata block.
  • the information determining unit is specifically configured to:
  • the preset index database is configured to store an index check value, an identifier of the data block, and a data length Corresponding relationship between the three;
  • the index check value stored in the preset index database is based on metadata in the primary metadata block, metadata backed up in the standby metadata block, and each object block group Index determination in the index block;
  • the data reading unit is specifically configured to:
  • the embodiment of the present application further discloses a disk data writing device, where the disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group.
  • Each object block group includes: a data block storing object data, an index block storing an index of the object data; the main metadata block is located at a head of the disk; and the spare metadata block is located at a tail of the disk;
  • the at least one object block group is located between the primary metadata block and the spare metadata block; the device includes:
  • An instruction receiving unit configured to receive a write instruction for the target object data
  • An information determining unit configured to determine, from the at least one object block group, an idle first data block, and determine a first object block group corresponding to the first data block;
  • a data writing unit configured to write the target object data into the first data block of the first object block group, and update an index in the first object block group according to the identifier of the destination object data An index in the block, metadata in the primary metadata block, and metadata backed up in the standby metadata block.
  • the index block includes a primary index block and an alternate index block; the primary index block is configured to store an index of the object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Bit Between the primary index block and the standby index block of the object block group;
  • the data writing unit is specifically configured to:
  • a bad block determining unit configured to: fail to update an index in the primary index block in the first object block group, or update an index backed up in the standby index block in the first object block group, or update the principal element
  • the object block whose update fails is determined as a suspected bad block, and the object data is rewritten into the suspected bad block and/or Or reading object data from the suspected bad block;
  • a data repairing unit configured to: if the object data is successfully written and/or read, repair the key data in the suspected bad block according to the primary and backup redundant data;
  • a data overlay unit configured to: if a write and/or read object data fails, acquire a reserved block, and replace the suspected bad block; overwrite the acquired reserved block according to the primary and backup redundant data, and update the Metadata in the primary metadata block and metadata backed up in the standby metadata block.
  • the device further includes:
  • a check value calculation unit configured to: update an index in an index block in the first object block group, metadata in the primary metadata block, and the standby metadata according to an identifier of the target object data After backing up the metadata in the block, calculating a first index check value of the identifier of the destination object data;
  • a check value storage unit configured to store, in the preset index database, the first index check value, the identifier of the first data block, and the first data length of the destination object data;
  • the index database is used to store the correspondence between the index check value, the identifier of the data block, and the data length.
  • an embodiment of the present application discloses an electronic device, including a processor, a communication interface, a memory, and a communication bus; wherein the processor, the communication interface, and the storage Communicating with each other through the communication bus;
  • the memory is configured to store an application
  • the processor is configured to implement the disk data reading method when the application stored on the memory is executed.
  • an embodiment of the present application discloses an electronic device including a processor, a communication interface, a memory, and a communication bus; wherein the processor, the communication interface, and the memory complete each other through the communication bus. Communication between
  • the memory is configured to store an application
  • the processor is configured to implement the disk data writing method when the application stored on the memory is executed.
  • an embodiment of the present application discloses an application program for implementing the foregoing disk data reading method at runtime.
  • an embodiment of the present application discloses an application program for implementing the foregoing disk data writing method at runtime.
  • the embodiment of the present application discloses a storage medium for storing an application, and the application is implemented to implement the disk data reading method.
  • the embodiment of the present application discloses a storage medium for storing an application, and the application is implemented to implement the disk data writing method.
  • the embodiment of the present application provides a disk data reading and writing method and device.
  • the disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, and each object block group includes a data block storing object data, an index block storing an index of the object data; a primary metadata block is located at a head of the disk; a spare metadata block is located at a tail of the disk; and the at least one object block group is located at the primary metadata block and the spare element
  • the key data that is, the index and
  • the main metadata and the backup metadata are scattered in different areas.
  • the operation of key data is not concentrated in one area, which reduces the probability of excessive operation frequency for one area and reduces index hot data. The chance of access increases the life and security of the disk.
  • FIG. 1 is a schematic structural diagram of a magnetic disk provided by the background art
  • FIG. 2 is a schematic flowchart of a disk data reading method according to an embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of a magnetic disk used in an embodiment of the present application.
  • FIG. 4 is a schematic structural diagram of another magnetic disk used in an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of an object block group used in an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a bad block detection process according to an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of a disk data reading apparatus according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic flowchart of a method for writing disk data according to an embodiment of the present disclosure
  • FIG. 9 is another schematic flowchart of a disk data writing method according to an embodiment of the present disclosure.
  • FIG. 10 is a schematic flowchart of a disk formatting according to an embodiment of the present application.
  • FIG. 11 is a schematic structural diagram of a disk data writing apparatus according to an embodiment of the present disclosure.
  • FIG. 12 is another schematic structural diagram of a disk data writing device according to an embodiment of the present disclosure.
  • FIG. 2 is a schematic flowchart of a disk data reading method according to an embodiment of the present disclosure.
  • the disk may include: a primary metadata block for storing metadata, and a backup element number.
  • the at least one object block group, each object block group includes: a data block storing the object data and an index block storing the index of the object data; the main metadata block is located at the head of the disk; the spare metadata block Located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block.
  • a data block is an object block; the head of the disk is the starting position of each read data on the disk, and the tail of the disk is the last position of the disk corresponding to the disk head in the disk.
  • the primary metadata and the backup metadata are scattered in different areas.
  • the operations on the key data are not concentrated in one area, which reduces the probability of operating too high for one area, and reduces the probability. Index the chance of hotspot data access, increasing disk life and security
  • the primary and backup metadata blocks may include: a boot block, a metadata description block, a block bitmap block, a bad block bitmap block, and an index allocation information block: wherein,
  • the boot block is a disk-specific key block that contains all the key information that the disk can use as a file system to store object data, that is, boot information, similar to the super block of the standard file system.
  • the boot block includes a main boot block and a standby boot block. The main boot block is at the head of the disk, and the boot block size is shifted backward from 0. The boot block is forward at the last position of the disk, that is, toward the head of the disk.
  • the offset boot block size, the contents of the primary and backup boot blocks are exactly the same, the content of the standby boot block is the backup of the content of the primary boot block, and each occupyes an object block, and the boot block stores the description information of the metadata description block, including
  • the metadata describes the identity of the block and the metadata describes the size of the storage space occupied by the block.
  • the startup block may further include a check value of all description information stored in the startup block, and the check value is used to verify whether the information in the startup block is accurate;
  • the standby boot block may also be located at a specified location as long as the specified location is not adjacent to the area where the primary metadata block is located.
  • a metadata description block for storing description information such as a block bitmap block, a bad block bitmap block, an index allocation information block, and the like, that is, an identifier of an object block storing each key information and an object block occupying each key information Information such as the size of the storage space.
  • the metadata description block may further include a check value of all description information stored by the metadata description block, the check value is used to check whether the information in the metadata description block is accurate; the metadata description block includes a main data description block.
  • the backup metadata description block the content of the spare metadata description block is a backup of the content of the main metadata description block;
  • the key information includes: a block bitmap, a bad block bitmap, an index allocation information, and the like;
  • Block bitmap block used to store the use of the object block, the disk is divided by a fixed object block size, all the information in the disk is stored in the object block, each bit in the block bitmap represents an object block Usage, "1" means used, "0” means unused; block bitmap block includes main block bitmap and spare block bitmap block, the content of the spare block bitmap block is the backup of the contents of the main block bitmap block
  • the object block may be an object block that stores key data, or an object block that stores object data, that is, a data block;
  • the size of the bad block bitmap block is the same as the block bitmap block and the block bitmap block. Each bit represents an object block. The difference is: "1" in the bad block bitmap block indicates that the object block is a bad block. , “0” indicates that the object block is a normal object block.
  • the content of the bad block bitmap block is updated only after the bad block is detected. As long as one sector is damaged in each object block, the object block is marked as a bad block; the bad block bitmap block includes the main bad block bitmap block. And preparing a bad block bitmap block, the content of the bad block bitmap block is a backup of the content of the main bad block bitmap block;
  • the index allocation information block is configured to store the object block information occupied by the index in each object block group, and each object block group has corresponding description information in the index allocation information block, and the description information describes the occupation of the primary and secondary indexes.
  • the index allocation information block may further include a check value of all the description information stored by the index allocation information block, where the check value is used to check whether the information in the index allocation information block is accurate; the index allocation information block includes the main index allocation information.
  • the block and the backup index allocation information block, and the content of the backup index allocation information block is a backup of the content of the information block for the primary index.
  • the above disk data reading method includes:
  • S202 Determine, according to the identifier of the destination object data, the metadata in the primary metadata block, the metadata backed up in the backup metadata block, and the index in the index block in each object block group, corresponding to the target object data. a first data block, and determining a first object block group in which the first data block is located;
  • the metadata in the primary metadata block is read, and the position of the index block in each object block group is determined according to the read metadata, and the position is read from the determined position.
  • Index in the index block when the metadata in the primary metadata block is incomplete and/or inaccurate, the metadata backed up in the standby metadata block is read, and the index in each object block group is determined according to the read metadata. The position of the block from which the index in the index block is read.
  • the index block in each object block group, is divided. a primary index block and a backup index block; wherein the primary index block is used to store an index of the object data, and the standby index block is used to back up the index of the object data, so that when the index in the primary index block has an error, the index block may be used according to the backup index block.
  • the index in the index repairs the index in the main index block; in addition, in order to reduce the probability of causing index hotspot data access, improve the life of the disk and the security of the object data in the disk, and facilitate the storage of data, for each object block group,
  • a primary index block in the object block group is located at a head of the object block group, and a spare index block in the object block group is located at a tail of the object block group;
  • a data block in the object block group is located at a main part of the object block group Between the index block and the standby index block.
  • the primary index and the standby index are scattered in different areas.
  • the operation of the index is not concentrated in one area, which reduces the probability of excessively operating the frequency of one area, and reduces the probability of data access of the index hotspot. , which increases the life and security of the disk.
  • each object block may be determined according to the metadata in the read primary metadata block, for example, the information in the primary index allocation information block.
  • the location of the primary index block and the standby index block in the group reading the index in the primary index block at the determined location or the index of the backup in the standby index block;
  • the metadata backed up in the spare metadata block in the tail of the disk is read, according to the metadata backed up in the read spare metadata block.
  • the information in the backup allocation information block backup determines the location of the primary index block and the standby index block in each object block group, and reads the index in the primary index block or the backup index in the determined position. index of.
  • the index read may be an index in the primary index block or an index in the standby index block. After reading the index, determining the first data block corresponding to the target object data according to the read index and the identifier of the destination object data, and determining the first object block group where the first data block is located.
  • the read index matches the identifier of the destination object data, it is determined that the data block corresponding to the read index is the first data block corresponding to the destination object data.
  • each object block group of the disk includes two object block groups, which are object block group 1 and object block group 2, and object block group 1 includes data blocks 1-8, and object block group 2 includes data blocks 9-16; if it is determined
  • the first data block where the identifier of the first data block is 4, may determine that the first object block group corresponding to the first data block is the object block group 1.
  • the size and composition of the identifier of the target object data are unknown. If the target object data is directly read according to the identifier of the destination object data, it takes a long time and resources.
  • an index database may be preset, and the index database may be used to store the correspondence between the index check value, the identifier of the data block, and the data length; here, the length of the index check value is smaller than the object.
  • the length of the identifier of the data, the index check value may be determined according to the metadata in the primary metadata block, the metadata backed up in the spare metadata block, and the index in the index block, for example, allocation of the information block or the backup index according to the primary index
  • the index stored in the information block occupies the information of the target block, determines the location of the index block, stores the identifier of the object data as an index, stores the location to the determined location, and calculates an index check value according to the index stored in the determined location;
  • the identifier of the block is the identifier of the object block storing the index check value corresponding to the object data.
  • the S202 may include:
  • S2022 Obtain an identifier of the first data block corresponding to the first index check value and a first data length from a preset index database;
  • the storage location and the data length of the destination object data are determined, and the destination object data can be accurately read, that is, the first data length can be read from the first data block of the first object block group.
  • Object data
  • the first index check value may be calculated by using the MD5 and CRC32 algorithms, that is, the first index check value of the identifier of the destination object data is calculated by using MD5_CRC32, or the destination object data is calculated by using the HASH algorithm.
  • the first index check value of the identifier is to shorten the length of the identifier of the destination object data.
  • the MD5_CRC32 is used to calculate the index check value of the identifier of the object data. If the identifier of the destination data is Key1, when the destination data is read, the MD5_CRC32 value of Key1 is calculated to be aa, if the preset index database stores ⁇ aa, 4, 132>, at this time, the identifier of the first data block can be obtained as 4, the length of the data of the destination object is obtained to be 132 Kbytes, and the first data block can be determined according to the identifier 4, combined with each object block group set in advance. The included data block determines a first object block group corresponding to the first data block, and further reads 132 Kbytes of data from the first data block 4 of the first object block group, that is, the read data length is 132 Kbytes. Destination object data.
  • S203 Read the target object data from the first data block of the first object block group.
  • reading the destination object data from the first data block of the first object block group may be: when reading the information in the index block in the first object block group, if it is determined to read The obtained information includes an index matching the identifier of the destination object data, and the data block corresponding to the index is determined to be the first data block, and the first data block is searched from the index block of the first object block group, and the first data block is read. Destination object data stored in a data block.
  • the physical distance between the data block and the index block in the object block group is smaller than the data block when there is only one object block group in the disk.
  • the physical distance from the index block can effectively shorten the seek time of the disk, as the time from the index block of the first object block group to the first data block is shortened.
  • the more the number of object block groups the more effective the effect of shortening the seek time of the disk.
  • the disk may further include: at least one reserved block; the reserved block is reserved in the disk.
  • the key data of the non-boot information cannot be read, that is, the metadata of the non-boot block information in the main metadata block is read, or the metadata of the non-start block information in the backup of the backup metadata block is read. If the failure fails, or the index in the primary index block fails to be read, or the index in the backup index block backup fails, the detection and replacement of the bad block is started, and the object block that failed to be read is determined to be a suspected bad block, and the The object data is written in the suspected bad block and/or the object data is read from the suspected bad block; if the object data is successfully written and/or read, the key in the suspected bad block is repaired according to the primary and backup redundant data.
  • a reserved block is obtained, the suspected bad block is replaced by the obtained reserved block, the obtained reserved block is overwritten according to the primary and backup redundant data, and the primary metadata is updated. Metadata in the block and metadata backed up in the spare metadata block.
  • a primary index block in the object block group is determined to be a suspected bad block, and the object data is written and/or read from the suspected bad block. If the object data is successfully written and/or read, the object may be An index in the index block of the block group, repairing the data in the suspected bad block; if the writing and/or reading of the object data fails, acquiring a reserved block and replacing the suspected bad block; according to the object block group
  • the index in the index block covers the obtained reserved block.
  • the main index block in the disk changes, and the data in the primary index allocation information block in the primary metadata block and the backup index allocation information in the spare metadata block are also updated. The data in the block.
  • S02 determining whether the disk of the bad block detection task is an available disk; if yes, executing S03; if not, ending the bad block detection task;
  • the suspected bad block is not a bad block, and the suspected bad block has a metadata error, and the suspected bad block may be repaired according to the primary and secondary redundant data. Metadata; if the writing and/or reading of the object data is unsuccessful, it may indicate that there is sector corruption in the suspected bad block, the suspected bad block is a bad block, and the suspected bad block needs to be replaced.
  • S05 Repair metadata in the suspected bad block according to the primary and backup redundant data.
  • the obtained reserved block is an unused reserved block.
  • S07 Update the acquired reserved block according to the primary and backup redundant data, and update the metadata in the primary and backup metadata blocks.
  • the index block of the object block group is damaged, the data in the index allocation information block needs to be updated; if the index allocation information block, the bad block bitmap block or the block bitmap block is damaged, the data in the metadata description block needs to be updated; If the metadata description block is corrupt, you need to update the data in the startup block information.
  • the magnetic disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data, and storing the object data Index block of the index; the primary metadata block is located at the head of the disk; the spare metadata block is located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; thus, the read-write object
  • the index in the index block, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block can be separately operated, and the key data, that is, the index and the primary metadata, and the standby metadata are dispersed in different In the area, when reading and writing object data, the operation of key data is not concentrated in one area, which reduces the probability of excessive operation frequency of one area, reduces the probability of data access of index hotspots, and increases the service life of the disk. And security.
  • FIG. 7 is a schematic structural diagram of a disk data reading apparatus according to an embodiment of the present disclosure.
  • the disk includes: a primary metadata block for storing metadata, and backup metadata. a spare metadata block, and at least one object block group, each object block group includes: a data block storing the object data, an index block storing an index of the object data; the main metadata block is located at a head of the disk; Determining that the metadata block is located at a tail of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; the device includes:
  • the instruction receiving unit 100 is configured to receive a read instruction for the target object data
  • the information determining unit 200 is configured to determine, according to the identifier of the target object data, metadata in the primary metadata block, metadata backed up in the backup metadata block, and an index in an index block in each object block group Determining a first data block corresponding to the destination object data, and determining a first object block group in which the first data block is located;
  • the data reading unit 300 is configured to read the target object data from the first data block of the first object block group.
  • the index block may include a primary index block and an alternate index block; the primary index block is configured to store an index of object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • the information determining unit 200 may specifically be used to:
  • the disk may further include: at least one reserved block;
  • the device may further include:
  • a bad block determining unit (not shown in FIG. 7) for failing to read metadata in the primary metadata block, or reading metadata backed up in the standby metadata block, or reading each
  • the index in the primary index block in an object block group fails, or the index of the backup in the standby index block in each object block group fails to be read, the block in which the read failure is determined is determined to be a suspected bad block, and the suspect is re-associated Writing object data in the bad block and/or reading the object data from the suspected bad block;
  • a data repair unit (not shown in FIG. 7), configured to repair data in the suspected bad block according to primary and backup redundant data if the object data is successfully written and/or read;
  • a data overlay unit (not shown in FIG. 7) for failing to write and/or read object data, acquiring a reserved block, and replacing the suspected bad block; and acquiring the coverage according to the primary and backup redundant data Retaining the block and updating the metadata in the primary metadata block and the metadata backed up in the standby metadata block.
  • the information determining unit 200 may be specifically configured to:
  • the preset index database is configured to store an index check value and an identifier of the data block Correspondence relationship with the data length;
  • the index check value stored in the preset index database is based on the metadata in the main metadata block, the metadata backed up in the spare metadata block, and the index in each object block group The index in the block is determined;
  • the data reading unit 300 can be specifically used to:
  • the magnetic disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data, and storing the object data Index block of the index; the primary metadata block is located at the head of the disk; the spare metadata block is located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; thus, the read-write object
  • the index in the index block, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block can be separately operated, and the key data, that is, the index and the primary metadata, and the standby metadata are dispersed in different In the area, when reading and writing object data, the operation of key data is not concentrated in one area, which reduces the probability of excessive operation frequency of one area, reduces the probability of data access of index hotspots, and increases the service life of the disk. And security.
  • FIG. 8 is a schematic flowchart of a disk data writing method according to an embodiment of the present disclosure.
  • the disk may include: a primary metadata block for storing metadata, and backup metadata.
  • a spare metadata block and at least one object block group each object block group includes: a data block storing the object data and an index block storing an index of the object data; the main metadata block is located at a head of the disk; and the spare metadata block is located at the disk The tail portion; the at least one object block group is located between the primary metadata block and the spare metadata block.
  • a data block can be understood as an object block.
  • the above disk data writing method includes:
  • S802 Determine an idle first data block from the at least one object block group, and determine a first object block group corresponding to the first data block;
  • the target block marked with a usage condition of “0” in the block bitmap may be determined as the idle first data block according to the stored primary and backup metadata, such as a block bitmap.
  • the idle first data block After determining the idle first data block, it may be determined whether the first data block is marked as a bad block by the bad block bitmap block; if not, continue to determine the first data block correspondingly.
  • the data block included in each object block group of the disk is preset, and when the first data block is determined, the first object block group corresponding to the first data block may be determined.
  • the disk includes two object block groups, which are object block group 1 and object block group 2, and object block group 1 includes data blocks 1-8, and object block group 2 includes data blocks 9-16; If the identifier of a data block is 4, it may be determined that the first object block group in which the first data block is located is the object block group 1.
  • S803 Write the target object data into the first data block of the first object block group, and update an index in the index block in the first object block group according to the identifier of the destination object data, The metadata in the primary metadata block and the metadata backed up in the standby metadata block.
  • the index block in each object block group, is divided. a primary index block and a backup index block; wherein the primary index block is used to store an index of the object data, and the standby index block is used to back up the index of the object data, so that when the index in the primary index block has an error, the index block may be used according to the backup index block.
  • the index in the index repairs the index in the main index block; in addition, in order to reduce the probability of causing index hotspot data access, improve the life of the disk and the security of the object data in the disk, and facilitate the storage of data, for each object block group,
  • a primary index block in the object block group is located at a head of the object block group, and a spare index block in the object block group is located at a tail of the object block group;
  • a data block in the object block group is located at a main part of the object block group Between the index block and the standby index block.
  • S803 may be: writing the target object data into the first data block of the first object block group, and writing the identifier of the destination object data as an index into the main index block in the first object block group, and the destination object data.
  • the identifier is written as an index into the spare index block in the first object block group, and the metadata corresponding to the first data block in the primary metadata block is updated, and the metadata corresponding to the first data block is backed up into the spare metadata block.
  • the identifier of the destination object data is used as an index, and is written into the main index block and the standby index block in the first object block group, and the main body is updated.
  • Block bitmap in the block bitmap block of the spare metadata block which makes the first data block in the block bitmap The condition is marked as "1" so that the free data block can be quickly acquired the next time the object data is written.
  • the disk may further include: at least one reserved block; the reserved block is reserved in the disk.
  • the key data of the non-boot information cannot be updated, that is, the index in the main index block in the first object block group is failed to be updated, or the index backed up in the standby index block in the first object block group is updated, or
  • the metadata of the non-starting information in the primary metadata block is failed, or the metadata of the non-starting information backed up in the spare metadata block fails, the detection and replacement of the bad block is started, and the object block whose update fails is determined to be suspected to be bad.
  • Block rewriting the object data into the suspected bad block and/or reading the object data from the suspected bad block; if the writing and/or reading of the object data is successful, repairing the suspect according to the primary and backup redundant data Key data in the bad block; if the writing and/or reading of the object data fails, a reserved block is obtained, the suspected bad block is replaced by the obtained reserved block, and the obtained reserved block is covered according to the primary and backup redundant data. And update the metadata in the primary metadata block and the backup metadata in the backup metadata block. Refer to Figure 6 for the detection and replacement process of bad blocks when critical data of non-boot information cannot be updated.
  • the size and composition of the identifier of the destination object data are unknown. If the identifier of the destination object data is directly determined, the data block in which the identifier of the destination object data is located is determined from the index stored in the index block. It will take a long time and resources.
  • an index database may be preset, and the index database may be used to store the correspondence between the index check value, the identifier of the data block and the data length; here, the index school
  • the length of the verification value is smaller than the length of the identifier of the object data
  • the index check value may be determined according to the metadata in the primary metadata block, the metadata backed up in the spare metadata block, and the index in the index block; the identifier of the data block is stored.
  • the index check value corresponds to the identifier of the object block of the object data.
  • the index in the index block in the first object block group, the metadata in the main metadata block, and the spare metadata are updated according to the identifier of the destination object data.
  • the foregoing method for writing the disk data may further include:
  • S901 Calculate a first index check value of the identifier of the destination object data.
  • the purpose of calculating the first index check value is to shorten the length of the identification of the target object data.
  • the first index check value may be calculated by using the MD5 and CRC32 algorithms, that is, the first index check value of the identifier of the target object data is calculated by using the MD5_CRC32; or the destination object data is calculated by using the HASH algorithm.
  • the first index check value of the identity is calculated by using the MD5 and CRC32 algorithms, that is, the first index check value of the identifier of the target object data is calculated by using the MD5_CRC32; or the destination object data is calculated by using the HASH algorithm.
  • the first index check value of the identifier of the destination object data is calculated by using the MD5 and CRC32 values, and the destination object data for the write command is ⁇ Key1, Value1>, the length of the destination object data is 132Kbytes, and the identifier of the destination object data For Key1, in addition, the identifier of the first data block is 4, the Value1 is written into the first data block of the first object block group, and the index in the index block in the first object block group is updated according to the identifier of the destination object data.
  • S902 Correspondly store the first index check value, the identifier of the first data block, and the first data length of the destination object data into a preset index database.
  • the disk in order to facilitate writing of the object data, the disk may be formatted before writing the data to the disk.
  • the formatting process may include:
  • the format parameters may include: a single object block size, an object block group index block number, a single index size, a reserved block size, and the like.
  • the disk may be divided into N object blocks according to a single object block size, and numbered from 0.
  • calculating the startup block information and the lower disk may be: acquiring the disk size, calculating the object block group size, calculating the description information of the metadata description block, and filling the tag information that starts formatting.
  • the calculation process of the object block group size may be:
  • the number of primary index blocks of each object block group is M (unit: number of object blocks), the size of a single index is S (unit: KB), and the number of reserved blocks is R (unit: number of object blocks), A single object block size is B (unit: KB), and the total disk size is T (unit: KB), you can get:
  • Object_Index_Num The number of data blocks that can be indexed by each index block is Object_Index_Num:
  • Each object block group contains the number of object blocks Group_Total_Object as:
  • Group_Total_Object Object_Index_Num*M+2*M;
  • the disk of size T contains the number of object block groups Group_Num is:
  • G ((T/B)-5*2-R)/Group_Total_Object
  • 5*2 indicates the number of target blocks occupied by the primary and backup metadata blocks.
  • the last object block group contains the number of object blocks:
  • the block group of the less than the object block is retained. Otherwise, don't use that space, that is,
  • recalculating the boot block information may include: filling the formatted tag information.
  • the magnetic disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data, and storing the object data Index block of the index; the primary metadata block is located at the head of the disk; the spare metadata block is located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; thus, the read-write object
  • the index in the index block, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block can be separately operated, and the key data, that is, the index and the primary metadata, and the standby metadata are dispersed in different In the area, when reading and writing object data, the operation of key data is not concentrated in one area, which reduces the probability of excessive operation frequency of one area, reduces the probability of data access of index hotspots, and increases the service life of the disk. And security.
  • FIG. 11 is a schematic structural diagram of a disk data writing apparatus according to an embodiment of the present disclosure.
  • the disk includes: a primary metadata block for storing metadata, and backup metadata. a spare metadata block, and at least one object block group, each object block group includes: a data block storing the object data, an index block storing an index of the object data; the main metadata block is located at a head of the disk; Determining that the metadata block is located at a tail of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; the device includes:
  • the instruction receiving unit 400 is configured to receive a write instruction for the target object data
  • An information determining unit 500 configured to determine, from the at least one object block group, an idle first data block, and determine a first object block group corresponding to the first data block;
  • the data writing unit 600 is configured to write the target object data into the first data block of the first object block group, and update the first object block group according to the identifier of the destination object data.
  • the index block may include a primary index block and an alternate index block; the primary index block is configured to store an index of object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • the data writing unit 600 can be specifically used to:
  • a bad block determining unit (not shown in FIG. 11) for failing to update an index in a primary index block in the first object block group, or updating an index backed up in a spare index block in the first object block group If the failure, or the update of the metadata in the primary metadata block fails, or the update of the metadata backed up in the backup metadata block fails, the object block that failed the update is determined to be a suspected bad block, and the suspected bad block is re-initiated Writing object data in the block and/or reading the object data from the suspected bad block;
  • a data repair unit (not shown in FIG. 11), configured to repair key data in the suspected bad block according to primary and backup redundant data if the object data is successfully written and/or read;
  • a data overlay unit (not shown in FIG. 11), configured to acquire a reserved block and replace the suspected bad block if the writing and/or reading of the object data fails; and obtain the coverage according to the primary and backup redundant data Retaining the block and updating the metadata in the primary metadata block and the metadata backed up in the standby metadata block.
  • the apparatus may further include:
  • the check value calculation unit 700 is configured to update an index in the index block, the metadata in the primary metadata block, and the spare element in the index block in the first object block group according to the identifier of the destination object data. After the metadata backed up in the data block, calculating a first index check value of the identifier of the destination object data;
  • the check value storage unit 800 is configured to store the first index check value, the identifier of the first data block, and the first data length of the destination object data in a preset index database;
  • the index database is used to store the correspondence between the index check value, the identifier of the data block, and the data length.
  • the magnetic disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data, and storing the object data Index block of the index; the primary metadata block is located at the head of the disk; the spare metadata block is located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; thus, the read-write object
  • the index in the index block, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block can be operated separately.
  • the key data, that is, the index and the main metadata, and the backup metadata are scattered in different areas. When reading and writing object data, the operation of key data is not concentrated in one area, which reduces the frequency of operation of an area too high. Probability reduces the chances of index hotspot data access, which in turn increases disk life and security.
  • the embodiment of the present application further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus; wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
  • the disk data reading method includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data And an index block storing an index of the object data; the primary metadata block is located at a head of the disk; the spare metadata block is located at a tail of the disk; at least one object block group is located between the primary metadata block and the spare metadata block; the method includes :
  • the destination object data is read from the first data block of the first object block group.
  • the index block includes a primary index block and a standby index block; the primary index block is used to store object data. Index, the index block is used to back up the index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • Determining, according to the identifier of the target object data, the metadata in the primary metadata block, the metadata backed up in the backup metadata block, and the index in the index block in each object block group, the first data block corresponding to the target object data, and The step of determining the first object block group in which the first data block is located includes:
  • the disk further includes: at least one reserved block; and the method further includes:
  • the data in the suspected bad block is repaired according to the primary and backup redundant data
  • a reserved block is obtained, and the suspected bad block is replaced; the obtained reserved block is overwritten according to the primary and backup redundant data, and the metadata and the preparation in the primary metadata block are updated. Metadata backed up in a metadata block.
  • determining, according to the identifier of the destination object data, the metadata in the primary metadata block, the metadata backed up in the backup metadata block, and the index in the index block in each object block group, determining the first corresponding to the target object data The steps of the data block, including:
  • the preset index database is configured to store the index check value, the identifier of the data block, and the data length Correspondence relationship;
  • the index check value stored in the preset index database is based on the main metadata block The metadata in the metadata, the metadata backed up in the spare metadata block, and the index in the index block in each object block group are determined;
  • the step of reading the destination object data from the first data block of the first object block group includes:
  • the destination data of the first data length is read from the first data block of the first object block group.
  • the magnetic disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data, and storing the object data Index block of the index; the primary metadata block is located at the head of the disk; the spare metadata block is located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; thus, the read-write object
  • the index in the index block, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block can be operated separately.
  • the key data, that is, the index and the main metadata, and the backup metadata are scattered in different areas. When reading and writing object data, the operation of key data is not concentrated in one area, which reduces the frequency of operation of an area too high. Probability reduces the chances of index hotspot data access, which in turn increases disk life and security.
  • the communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus.
  • the communication bus can be divided into an address bus, a data bus, a control bus, and the like.
  • the communication interface is used for communication between the above storage server and other devices.
  • the memory may include a RAM (Random Access Memory), and may also include NVM (Non-Volatile Memory), such as at least one disk storage.
  • the memory may also be at least one storage device located away from the aforementioned processor.
  • the processor may be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), or the like; or a DSP (Digital Signal Processing) or an ASIC (Application) Specific Integrated Circuit, FPGA (Field-Programmable Gate Array) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components.
  • CPU Central Processing Unit
  • NP Network Processor
  • DSP Digital Signal Processing
  • ASIC Application) Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • other programmable logic device discrete gate or transistor logic device, discrete hardware components.
  • the embodiment of the present application further provides an electronic device, including a processor, a communication interface, and a memory. And a communication bus; wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
  • the processor implements a disk data writing method when executing an application stored on the memory.
  • the disk data writing method includes: a primary metadata block storing metadata, a spare metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data. And an index block storing an index of the object data; the primary metadata block is located at a head of the disk; the spare metadata block is located at a tail of the disk; at least one object block group is located between the primary metadata block and the spare metadata block; the method includes :
  • the index block includes a primary index block and a backup index block; the primary index block is used to store an index of the object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • step of updating the index in the index block in the first object block group, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block according to the identifier of the destination object data including:
  • the identifier of the destination object data is written as an index into the primary index block in the first object block group, and the identifier of the destination object data is written as an index into the spare index block in the first object block group, and the number in the primary metadata block is updated.
  • the metadata corresponding to the data block is backed up, and the metadata corresponding to the first data block is backed up into the spare metadata block.
  • the disk further includes: at least one reserved block; and the method further includes:
  • the key data in the suspected bad block is repaired according to the primary and backup redundant data
  • a reserved block is obtained, and the suspected bad block is replaced; the obtained reserved block is overwritten according to the primary and backup redundant data, and the metadata and the preparation in the primary metadata block are updated. Metadata backed up in a metadata block.
  • the method further include:
  • the preset index database is configured to store the index check value, the identifier and data of the data block. Correspondence between the three lengths.
  • the magnetic disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data, and storing the object data Index block of the index; the primary metadata block is located at the head of the disk; the spare metadata block is located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; thus, the read-write object
  • the index in the index block, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block can be operated separately.
  • the key data, that is, the index and the main metadata, and the backup metadata are scattered in different areas. When reading and writing object data, the operation of key data is not concentrated in one area, which reduces the frequency of operation of an area too high. Probability reduces the chances of index hotspot data access, which in turn increases disk life and security.
  • the above communication bus may be a PCI bus or an EISA bus or the like.
  • the communication bus can be divided into an address bus, a data bus, a control bus, and the like.
  • the communication interface is used for communication between the above storage server and other devices.
  • the memory may include RAM, and may also include an NVM, such as at least one disk storage.
  • the memory may also be at least one storage device located away from the aforementioned processor.
  • the above processor may be a general-purpose processor, including a CPU, an NP, etc.; or may be a DSP, an ASIC, or FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component.
  • the embodiment of the present application further provides an application for implementing a disk data reading method at runtime.
  • the disk data reading method includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data And an index block storing an index of the object data; the primary metadata block is located at a head of the disk; the spare metadata block is located at a tail of the disk; at least one object block group is located between the primary metadata block and the spare metadata block; the method includes :
  • the destination object data is read from the first data block of the first object block group.
  • the index block includes a primary index block and a backup index block; the primary index block is used to store an index of the object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • Determining, according to the identifier of the target object data, the metadata in the primary metadata block, the metadata backed up in the backup metadata block, and the index in the index block in each object block group, the first data block corresponding to the target object data, and The step of determining the first object block group in which the first data block is located includes:
  • the disk further includes: at least one reserved block; and the method further includes:
  • the object block that failed to be read is determined to be a suspected bad block, and Writing object data to the suspected bad block and/or reading the object data from the suspected bad block;
  • the data in the suspected bad block is repaired according to the primary and backup redundant data
  • a reserved block is obtained, and the suspected bad block is replaced; the obtained reserved block is overwritten according to the primary and backup redundant data, and the metadata and the preparation in the primary metadata block are updated. Metadata backed up in a metadata block.
  • determining, according to the identifier of the destination object data, the metadata in the primary metadata block, the metadata backed up in the backup metadata block, and the index in the index block in each object block group, determining the first corresponding to the target object data The steps of the data block, including:
  • the preset index database is configured to store the index check value, the identifier of the data block, and the data length Corresponding relationship;
  • the index check value stored in the preset index database is determined according to the metadata in the primary metadata block, the metadata backed up in the backup metadata block, and the index in the index block in each object block group;
  • the step of reading the destination object data from the first data block of the first object block group includes:
  • the destination data of the first data length is read from the first data block of the first object block group.
  • the magnetic disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data, and storing the object data Index block of the index; the primary metadata block is located at the head of the disk; the spare metadata block is located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; thus, the read-write object
  • the index in the index block, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block can be operated separately.
  • the key data, that is, the index and the main metadata, and the backup metadata are scattered in different areas. When reading and writing object data, the operation of key data is not concentrated in one area, which reduces the frequency of operation of an area too high. Probability reduces the chances of index hotspot data access, which in turn increases disk life and security.
  • the embodiment of the present application further provides an application for implementing a disk data writing method at runtime.
  • the disk includes: a main element storing the metadata a data block, a spare metadata block of the backup metadata, and at least one object block group, each object block group includes: a data block storing the object data, an index block storing an index of the object data; the main metadata block is located at the head of the disk The spare metadata block is located at the end of the disk; at least one object block group is located between the primary metadata block and the spare metadata block; the method includes:
  • the index block includes a primary index block and a backup index block; the primary index block is used to store an index of the object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • step of updating the index in the index block in the first object block group, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block according to the identifier of the destination object data including:
  • the identifier of the destination object data is written as an index into the primary index block in the first object block group, and the identifier of the destination object data is written as an index into the spare index block in the first object block group, and the number in the primary metadata block is updated.
  • the metadata corresponding to the data block is backed up, and the metadata corresponding to the first data block is backed up into the spare metadata block.
  • the disk further includes: at least one reserved block; and the method further includes:
  • the key data in the suspected bad block is repaired according to the primary and backup redundant data
  • the method further include:
  • the preset index database is configured to store the index check value, the identifier and data of the data block. Correspondence between the three lengths.
  • the magnetic disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data, and storing the object data Index block of the index; the primary metadata block is located at the head of the disk; the spare metadata block is located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; thus, the read-write object
  • the index in the index block, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block can be operated separately.
  • the key data, that is, the index and the main metadata, and the backup metadata are scattered in different areas. When reading and writing object data, the operation of key data is not concentrated in one area, which reduces the frequency of operation of an area too high. Probability reduces the chances of index hotspot data access, which in turn increases disk life and security.
  • the embodiment of the present application further provides a storage medium for storing an application, and the application is implemented to implement a disk data reading method.
  • the disk data reading method includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data And an index block storing an index of the object data; the primary metadata block is located at a head of the disk; the spare metadata block is located at a tail of the disk; at least one object block group is located between the primary metadata block and the spare metadata block; the method includes :
  • the destination object data is read from the first data block of the first object block group.
  • the index block includes a primary index block and a backup index block; the primary index block is used to store an index of the object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • Determining, according to the identifier of the target object data, the metadata in the primary metadata block, the metadata backed up in the backup metadata block, and the index in the index block in each object block group, the first data block corresponding to the target object data, and The step of determining the first object block group in which the first data block is located includes:
  • the disk further includes: at least one reserved block; and the method further includes:
  • the data in the suspected bad block is repaired according to the primary and backup redundant data
  • a reserved block is obtained, and the suspected bad block is replaced; the obtained reserved block is overwritten according to the primary and backup redundant data, and the metadata and the preparation in the primary metadata block are updated. Metadata backed up in a metadata block.
  • determining, according to the identifier of the destination object data, the metadata in the primary metadata block, the metadata backed up in the backup metadata block, and the index in the index block in each object block group, determining the first corresponding to the target object data The steps of the data block, including:
  • the preset index database is configured to store the index check value, the identifier of the data block, and the data length The correspondence between the three parties; the index check value stored in the preset index database is based on the metadata in the primary metadata block, the metadata backed up in the spare metadata block, and the index in the index block in each object block group. determine;
  • the step of reading the destination object data from the first data block of the first object block group includes:
  • the destination data of the first data length is read from the first data block of the first object block group.
  • the magnetic disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data, and storing the object data Index block of the index; the primary metadata block is located at the head of the disk; the spare metadata block is located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; thus, the read-write object
  • the index in the index block, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block can be operated separately.
  • the key data, that is, the index and the main metadata, and the backup metadata are scattered in different areas. When reading and writing object data, the operation of key data is not concentrated in one area, which reduces the frequency of operation of an area too high. Probability reduces the chances of index hotspot data access, which in turn increases disk life and security.
  • the embodiment of the present application further provides a storage medium for storing an application, and the application is implemented to implement a disk data writing method.
  • the disk data writing method includes: a primary metadata block storing metadata, a spare metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data. And an index block storing an index of the object data; the primary metadata block is located at a head of the disk; the spare metadata block is located at a tail of the disk; at least one object block group is located between the primary metadata block and the spare metadata block; the method includes :
  • the index block includes a primary index block and a backup index block; the primary index block is used to store an index of the object data, and the standby index block is used to back up an index of the object data;
  • the main index block in the object block group is located at the head of the object block group, and the spare index block in the object block group is located at the end of the object block group;
  • the data block in the object block group Located between the primary index block and the standby index block of the object block group;
  • step of updating the index in the index block in the first object block group, the metadata in the primary metadata block, and the metadata backed up in the spare metadata block according to the identifier of the destination object data including:
  • the identifier of the destination object data is written as an index into the primary index block in the first object block group, and the identifier of the destination object data is written as an index into the spare index block in the first object block group, and the number in the primary metadata block is updated.
  • the metadata corresponding to the data block is backed up, and the metadata corresponding to the first data block is backed up into the spare metadata block.
  • the disk further includes: at least one reserved block; and the method further includes:
  • the key data in the suspected bad block is repaired according to the primary and backup redundant data
  • a reserved block is obtained, and the suspected bad block is replaced; the obtained reserved block is overwritten according to the primary and backup redundant data, and the metadata and the preparation in the primary metadata block are updated. Metadata backed up in a metadata block.
  • the method further include:
  • the preset index database is configured to store the index check value, the identifier and data of the data block. Correspondence between the three lengths.
  • the magnetic disk includes: a primary metadata block storing metadata, a backup metadata block of backup metadata, and at least one object block group, each object block group including: a data block storing the object data, and storing the object data
  • the index block of the index; the primary metadata block is located at the head of the disk; the number of spare elements The block is located at the end of the disk; the at least one object block group is located between the primary metadata block and the spare metadata block; thus, when reading and writing the object data, the index in the index block and the main metadata block may be separately operated.
  • the key data, that is, the index and the main metadata, and the backup metadata are scattered in different areas. When reading and writing object data, the operation of key data is not concentrated in one area, which reduces the frequency of operation of an area too high. Probability reduces the chances of index hotspot data access, which in turn increases disk life and security.
  • the disk data reading device the disk data writing device, the electronic device, the application program, and the storage medium embodiment
  • the description is relatively simple.
  • the disk data reading method shown in FIG. 2 to FIG. 6 and the disk data writing method embodiment shown in FIG. 8 to FIG. 10 may be partially described.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Quality & Reliability (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Library & Information Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Management Or Editing Of Information On Record Carriers (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)
  • Software Systems (AREA)
  • Signal Processing (AREA)

Abstract

本申请实施例公开了一种磁盘数据读写方法及装置,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块和至少一个对象块组,每一对象块组包括:存储对象数据的数据块和存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。应用本申请实施例,增加了磁盘的使用寿命和安全性。

Description

一种磁盘数据读写方法及装置
本申请要求于2016年11月8日提交中国专利局、申请号为201610979543.1发明名称为“一种磁盘数据读写方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,特别涉及一种磁盘数据读写方法及装置。
背景技术
目前,如图1所示,磁盘分为两部分存储区域,分别为索引区和数据区,对象数据集中存储在数据区的对象块中;主关键数据和备关键数据集中存储在索引区的对象块中,其中,关键数据包括:元数据和对象数据的索引,元数据包括:启动信息、元数据描述信息、块位图、坏块位和索引的分配信息。这里,存储关键数据的对象块有:
启动块,用于存储启动信息,包括元数据描述块的标识和元数据描述块占用存储空间的大小;
元数据描述块,用于存储元数据描述信息,包括块位图块的标识、坏块位图块的标识和索引分配信息块的标识,以及块位图块、坏块位图块和索引分配信息块占用存储空间的大小;
块位图块,用于存储块位图,包括每一对象块的使用情况信息;
坏块位图块与块位图块对应;这里,若对象块中有一个扇区损坏,那么该对象块可以称为坏块;
索引分配信息块,用于存储索引的分配信息,包括:每一索引块的标识和该索引块占用存储空间的大小;
索引块,用于存储对象数据的索引,包括:对象数据占用对象块的标识和该对象块占用存储空间的大小。
读取/写入对象数据都需要读取/写入关键数据,而关键数据集中存储在索引区的对象块中,当需要读取/写入对象数据时,对关键数据的操作将都集中 在索引区的对象块中,也就是,集中在索引区这一个区域中,这种情况下,容易引起索引热点数据访问,即容易使得对索引区这一个区域操作频率过高,造成磁盘的损坏,降低磁盘的使用寿命和安全性。
发明内容
本申请实施例公开了一种磁盘数据读写方法及装置,以增加磁盘的使用寿命和安全性。
为达到上述目的,本申请实施例公开了一种磁盘数据读取方法,所述磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;所述方法包括:
接收针对目的对象数据的读取指令;
根据所述目的对象数据的标识、所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组;
从所述第一对象块组的所述第一数据块中读取所述目的对象数据。
可选的,所述索引块包括主索引块和备索引块;所述主索引块用于存储对象数据的索引,所述备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
所述根据所述目的对象数据的标识、所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组的步骤,包括:
读取所述主元数据块中的元数据和/或所述备元数据块中备份的元数据, 确定每一对象块组中主索引块和备索引块的位置;
读取所确定的位置处的主索引块中的索引或备索引块中备份的索引;
根据读取到的索引和所述目的对象数据的标识,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组。
可选的,所述磁盘还包括:至少一个保留块;所述方法还包括:
当读取所述主元数据块中的元数据失败、或读取所述备元数据块中备份的元数据失败、或读取每一对象块组中主索引块中的索引失败、或读取每一对象块组中备索引块中备份的索引失败时,将读取失败的对象块确定为疑似坏块,重新向所述疑似坏块中写入对象数据和/或从所述疑似坏块中读取对象数据;
若写入和/或读取对象数据成功,根据主、备冗余数据,修复所述疑似坏块中的数据;
若写入和/或读取对象数据失败,获取一个保留块,并替换所述疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新所述主元数据块中的元数据和所述备元数据块中备份的元数据。
可选的,所述根据所述目的对象数据的标识、所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定所述目的对象数据对应的第一数据块的步骤,包括:
计算所述目的对象数据的标识的第一索引校验值;
从预设索引数据库中获取所述第一索引校验值对应的第一数据块的标识和第一数据长度;所述预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系;所述预设索引数据库中存储的索引校验值根据所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引确定;
根据所述第一数据块的标识,确定所述第一数据块;
所述从所述第一对象块组的所述第一数据块中读取所述目的对象数据的步骤,包括:
从所述第一对象块组的所述第一数据块中读取所述第一数据长度的所述目的对象数据。
为达到上述目的,本申请实施例还公开了一种磁盘数据写入方法,所述磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;所述方法包括:
接收针对目的对象数据的写入指令;
从所述至少一个对象块组中确定空闲的第一数据块,并确定所述第一数据块对应的第一对象块组;
将所述目的对象数据写入所述第一对象块组的所述第一数据块,并根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中备份的元数据。
可选的,所述索引块包括主索引块和备索引块;所述主索引块用于存储对象数据的索引,所述备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
所述根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中备份的元数据的步骤,包括:
将所述目的对象数据的标识作为索引写入所述第一对象块组中的主索引块,将所述目的对象数据的标识作为索引写入所述第一对象块组中的备索引块,更新所述主元数据块中的所述第一数据块对应的元数据,并将所述第一数据块对应的元数据备份至所述备元数据块中。
可选的,所述磁盘还包括:至少一个保留块;所述方法还包括:
当更新所述第一对象块组中主索引块中的索引失败、或更新所述第一对象块组中备索引块中备份的索引失败、或更新所述主元数据块中的元数据失败、或更新所述备元数据块中备份的元数据失败时,将更新失败的对象块确定为疑似坏块,重新向所述疑似坏块中写入对象数据和/或从所述疑似坏块中读取对象数据;
若写入和/或读取对象数据成功,根据主、备冗余数据,修复所述疑似坏块中的关键数据;
若写入和/或读取对象数据失败,获取一个保留块,并替换所述疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新所述主元数据块中的元数据和所述备元数据块中备份的元数据。
可选的,在所述根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中备份的元数据的步骤之后,所述方法还包括:
计算所述目的对象数据的标识的第一索引校验值;
将所述第一索引校验值、所述第一数据块的标识和所述目的对象数据的第一数据长度对应存储至预设索引数据库中;所述预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系。
为达到上述目的,本申请实施例还公开了一种磁盘数据读取装置,所述磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;所述装置包括:
指令接收单元,用于接收针对目的对象数据的读取指令;
信息确定单元,用于根据所述目的对象数据的标识、所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组;
数据读取单元,用于从所述第一对象块组的所述第一数据块中读取所述目的对象数据。
可选的,所述索引块包括主索引块和备索引块;所述主索引块用于存储对象数据的索引,所述备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
所述信息确定单元,具体用于:
读取所述主元数据块中的元数据和/或所述备元数据块中备份的元数据,确定每一对象块组中主索引块和备索引块的位置;
读取所确定的位置处的主索引块中的索引或备索引块中备份的索引;
根据读取到的索引和所述目的对象数据的标识,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组。
可选的,所述磁盘还包括:至少一个保留块;所述装置还包括:
坏块确定单元,用于当读取所述主元数据块中的元数据失败、或读取所述备元数据块中备份的元数据失败、或读取每一对象块组中主索引块中的索引失败、或读取每一对象块组中备索引块中备份的索引失败时,将读取失败的对象块确定为疑似坏块,重新向所述疑似坏块中写入对象数据和/或从所述疑似坏块中读取对象数据;
数据修复单元,用于若写入和/或读取对象数据成功,根据主、备冗余数据,修复所述疑似坏块中的数据;
数据覆盖单元,用于若写入和/或读取对象数据失败,获取一个保留块,并替换所述疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新所述主元数据块中的元数据和所述备元数据块中备份的元数据。
可选的,所述信息确定单元,具体用于:
计算所述目的对象数据的标识的第一索引校验值;
从预设索引数据库中获取所述第一索引校验值对应的第一数据块的标识和第一数据长度;所述预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系;所述预设索引数据库中存储的索引校验值根据所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引确定;
根据所述第一数据块的标识,确定所述第一数据块,并确定所述第一数据块所在的第一对象块组;
所述数据读取单元,具体用于:
从所述第一对象块组的所述第一数据块中读取所述第一数据长度的所述目的对象数据。
为达到上述目的,本申请实施例还公开了一种磁盘数据写入装置,所述磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;所述装置包括:
指令接收单元,用于接收针对目的对象数据的写入指令;
信息确定单元,用于从所述至少一个对象块组中确定空闲的第一数据块,并确定所述第一数据块对应的第一对象块组;
数据写入单元,用于将所述目的对象数据写入所述第一对象块组的所述第一数据块,并根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中备份的元数据。
可选的,所述索引块包括主索引块和备索引块;所述主索引块用于存储对象数据的索引,所述备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位 于该对象块组的主索引块和备索引块之间;
所述数据写入单元,具体用于:
将所述目的对象数据的标识作为索引写入所述第一对象块组中主索引块,将所述目的对象数据的标识作为索引写入所述第一对象块组中备索引块,更新所述主元数据块中的所述第一数据块对应的元数据,并将所述第一数据块对应的元数据备份至所述备元数据块中。
可选的,所述磁盘还包括:至少一个保留块;所述装置还包括:
坏块确定单元,用于当更新所述第一对象块组中主索引块中的索引失败、或更新所述第一对象块组中备索引块中备份的索引失败、或更新所述主元数据块中的元数据失败、或更新所述备元数据块中备份的元数据失败时,将更新失败的对象块确定为疑似坏块,重新向所述疑似坏块中写入对象数据和/或从所述疑似坏块中读取对象数据;
数据修复单元,用于若写入和/或读取对象数据成功,根据主、备冗余数据,修复所述疑似坏块中的关键数据;
数据覆盖单元,用于若写入和/或读取对象数据失败,获取一个保留块,并替换所述疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新所述主元数据块中的元数据和所述备元数据块中备份的元数据。
可选的,所述装置还包括:
校验值计算单元,用于在根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中的备份元数据之后,计算所述目的对象数据的标识的第一索引校验值;
校验值存储单元,用于将所述第一索引校验值、所述第一数据块的标识和所述目的对象数据的第一数据长度对应存储至预设索引数据库中;所述预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系。
为达到上述目的,本申请实施例公开了一种电子设备,包括处理器、通信接口、存储器和通信总线;其中,所述处理器、所述通信接口、所述存储 器通过所述通信总线完成相互间的通信;
所述存储器,用于存放应用程序;
所述处理器,用于执行所述存储器上所存放的应用程序时,实现上述磁盘数据读取方法。
为达到上述目的,本申请实施例公开了一种电子设备,包括处理器、通信接口、存储器和通信总线;其中,所述处理器、所述通信接口、所述存储器通过所述通信总线完成相互间的通信;
所述存储器,用于存放应用程序;
所述处理器,用于执行所述存储器上所存放的应用程序时,实现上述磁盘数据写入方法。
为达到上述目的,本申请实施例公开了一种应用程序,所述应用程序用于在运行时实现上述磁盘数据读取方法。
为达到上述目的,本申请实施例公开了一种应用程序,所述应用程序用于在运行时实现上述磁盘数据写入方法。
为达到上述目的,本申请实施例公开了一种存储介质,所述存储介质用于存储应用程序,所述应用程序被运行时实现上述磁盘数据读取方法。
为达到上述目的,本申请实施例公开了一种存储介质,所述存储介质用于存储应用程序,所述应用程序被运行时实现上述磁盘数据写入方法。
本申请实施例提供了一种磁盘数据读写方法及装置,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据,关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
附图说明
为了更清楚地说明本申请实施例或相关技术中的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为背景技术提供的一种磁盘结构示意图;
图2为本申请实施例提供的一种磁盘数据读取方法的一种流程示意图;
图3为本申请实施例使用的一种磁盘结构示意图;
图4为本申请实施例使用的另一种磁盘结构示意图;
图5为本申请实施例使用的一种对象块组结构示意图;
图6为本申请实施例提供的一种坏块检测流程示意图;
图7为本申请实施例提供的一种磁盘数据读取装置的一种结构示意图;
图8为本申请实施例提供的一种磁盘数据写入方法的一种流程示意图;
图9为本申请实施例提供的一种磁盘数据写入方法的另一种流程示意图;
图10为本申请实施例提供的一种磁盘格式化的流程示意图;
图11为本申请实施例提供的一种磁盘数据写入装置的一种结构示意图;
图12为本申请实施例提供的一种磁盘数据写入装置的另一种结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
下面通过具体实施例,对本申请进行详细说明。
参考图2,图2为本申请实施例提供的一种磁盘数据读取方法的一种流程示意图,如图3所示,该磁盘可以包括:存储元数据的主元数据块、备份元数 据的备元数据块和至少一个对象块组,每一对象块组包括:存储对象数据的数据块和存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间。这里,一个数据块即为一个对象块;磁盘的头部为磁盘中每次读取数据的起始位置,磁盘的尾部为磁盘中与磁盘头部对应的磁盘最后的位置。
这里,主元数据和备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作就不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,增加了磁盘的使用寿命和安全性
参考图4,一般的,主、备元数据块可以包括:启动块、元数据描述块、块位图块、坏块位图块和索引分配信息块:其中,
启动块是磁盘特有的关键块,包含磁盘是否能作为文件系统来存储对象数据的所有关键信息,即启动信息,类似于标准文件系统的超级块。启动块包括主启动块和备启动块,主启动块在磁盘的头部,从0开始向后偏移启动块大小,备启动块在磁盘最后的位置向前,也就是向磁盘的头部方向偏移启动块大小,主、备启动块的内容完全一样,备启动块的内容为主启动块的内容的备份,且各占用一个对象块,启动块会存储元数据描述块的描述信息,包括元数据描述块的标识及元数据描述块占用存储空间的大小等信息。启动块中还可以包括该启动块中存储的所有描述信息的校验值,该校验值用于校验启动块中的信息是否准确;
需要说明的是,备启动块也可以位于一个指定位置,只要该指定位置与主元数据块所在区域不相邻即可。
元数据描述块,用于存储块位图块、坏块位图块、索引分配信息块等描述信息,也就是,存储每个关键信息的对象块的标识和存储每个关键信息的对象块占用存储空间的大小等信息。元数据描述块中还可以包括该元数据描述块存储的所有描述信息的校验值,该校验值用于校验元数据描述块中的信息是否准确;元数据描述块包括主数据描述块和备元数据描述块,备元数据描述块的内容为主元数据描述块的内容的备份;关键信息包括:块位图、坏块位图、索引分配信息等;
块位图块,用于存储对象块的使用情况,磁盘按固定的对象块大小进行分块,磁盘中所有的信息均存储于对象块中,块位图中的每一位代表一个对象块的使用情况,“1”表示已使用,“0”表示未使用;块位图块包括主块位图和备块位图块,备块位图块的内容为主块位图块的内容的备份;这里,对象块可以为存储关键数据的对象块,也可以为存储对象数据的对象块,即数据块;
坏块位图块的大小同块位图块,和块位图块一一对应,每一位表示一个对象块,不同的是:坏块位图块中“1”表示该对象块为坏块,“0”表示该对象块为正常对象块。坏块位图块的内容只有检测到坏块之后才会更新,每个对象块中只要有一个扇区损坏,该对象块就标记为坏块;坏块位图块包括主坏块位图块和备坏块位图块,备坏块位图块的内容为主坏块位图块的内容的备份;
索引分配信息块,用于存储每个对象块组中索引占用的对象块信息,每个对象块组在索引分配信息块中都有相应的描述信息,该描述信息会描述主、备索引占用的对象块。索引分配信息块中还可以包括该索引分配信息块存储的所有描述信息的校验值,该校验值用于校验索引分配信息块中的信息是否准确;索引分配信息块包括主索引分配信息块和备索引分配信息块,备索引分配信息块的内容为主索引分配信息块的内容的备份。
上述磁盘数据读取方法包括:
S201:接收针对目的对象数据的读取指令;
S202:根据所述目的对象数据的标识、主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组;
当主元数据块中的元数据完整准确时,读取主元数据块中的元数据,根据读取到的元数据确定每一对象块组中索引块的位置,从所确定的位置处读取索引块中的索引;当主元数据块中的元数据不完整和/或不准确时,读取备元数据块中备份的元数据,根据读取到的元数据确定每一对象块组中索引块的位置,从所确定的位置处读取索引块中的索引。
在本申请的一个实施例中,为了避免因为误操作导致对象块组中的索引出现错误,而无法读取数据的问题,如图5所示,在每一对象块组中,将索引块分为主索引块和备索引块;其中,主索引块用于存储对象数据的索引,备索引块用于备份对象数据的索引,这样,当主索引块中的索引出现错误时,可以根据备索引块中的索引修复主索引块中的索引;另外,为了降低引起索引热点数据访问的几率,提高磁盘的使用寿命和磁盘中对象数据的安全性,并且便于数据的存储,对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间。
主索引、备索引分散在不同的区域中,读写对象数据时,对索引的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
当读取磁盘的头部中主元数据块中的元数据成功时,可以根据读取到的主元数据块中的元数据,例如,主索引分配信息块中的信息,确定每一对象块组中主索引块和备索引块的位置,读取所确定的位置处的主索引块中的索引或备索引块中备份的索引;
当读取到磁盘的头部中主元数据块中的元数据失败时,读取磁盘的尾部中备元数据块中备份的元数据,根据读取到的备元数据块中备份的元数据,例如,备索引分配信息块备份中的信息,确定每一对象块组中主索引块和备索引块的位置,读取所确定的位置处的主索引块中的索引或备索引块中备份的索引。
读取到的索引可以为主索引块中的索引,也可以为备索引块中的索引。读取到索引后,根据读取到的索引和目的对象数据的标识,确定目的对象数据对应的第一数据块,并确定第一数据块所在的第一对象块组。
这里,确定目的对象数据的标识后,若读取到的索引与目的对象数据的标识匹配,则确定该读取到的索引对应的数据块为目的对象数据对应的第一数据块。
另外,磁盘的每一对象块组中包括的数据块是预先设置好的,当确定了 第一数据块,也就可以确定第一数据块对应的第一对象块组。例如:磁盘中包括两个对象块组,分别为对象块组1和对象块组2,对象块组1中包括数据块1-8,对象块组2中包括数据块9-16;若确定了第一数据块,该第一数据块的标识为4,则可以确定第一数据块对应的第一对象块组为对象块组1。
在本申请的一个实施例中,目的对象数据的标识的大小和组成都是未知的,若直接根据目的对象数据的标识读取目的对象数据,将会耗费很长的时间和资源。为了减少耗费的时间和资源,可以预先设置一个索引数据库,该索引数据库可以用于存储索引校验值、数据块的标识与数据长度三者间的对应关系;这里,索引校验值长度小于对象数据的标识的长度,索引校验值可以根据主元数据块中的元数据、备元数据块中备份的元数据和索引块中的索引确定,例如:根据主索引分配信息块或备索引分配信息块中存储的索引占用对象块的信息,确定索引块的位置,将对象数据的标识作为索引,存储至该确定的位置,进而根据该确定的位置存储的索引计算出索引校验值;数据块的标识为存储该索引校验值对应对象数据的对象块的标识。
这种情况下,接收到针对目的对象数据的读取指令后,上述S202,可以包括:
S2021、计算所述目的对象数据的标识的第一索引校验值;
S2022、从预设索引数据库中获取所述第一索引校验值对应的第一数据块的标识和第一数据长度;
S2023、根据所述第一数据块的标识,确定所述第一数据块;
S2024、根据所述第一数据块,确定第一对象块组。
此时,确定了目的对象数据的存储位置和数据长度,可以准确的读取到目的对象数据,也就是,可以从第一对象块组的第一数据块中读取到第一数据长度的目的对象数据。
在本申请的一个实施例中,可以采用MD5和CRC32算法计算第一索引校验值,也就是,采用MD5_CRC32计算目的对象数据的标识的第一索引校验值,或采用HASH算法计算目的对象数据的标识的第一索引校验值,以缩短目的对象数据的标识的长度。
例如,采用MD5_CRC32计算对象数据的标识的索引校验值,若目的对象数据的标识为Key1,在读取该目的对象数据时,计算得到Key1的MD5_CRC32值为aa,若预设索引数据库中存储有<aa,4,132>,此时可以获得第一数据块的标识为4,获得目的对象数据的长度为132Kbytes,根据标识4可以确定第一数据块,结合预先设置的每一对象块组中包括的数据块,确定第一数据块对应的第一对象块组,进而从第一对象块组的第一数据块4中读取到132Kbytes的数据,也就是,读取到数据长度为132Kbytes的目的对象数据。
S203:从所述第一对象块组的所述第一数据块中读取所述目的对象数据。
在本申请的一个实施例中,从第一对象块组的第一数据块中读取目的对象数据,可以为:当读取到第一对象块组中索引块中的信息时,若确定读取到的信息中包含有与目的对象数据的标识匹配的索引,可以确定该索引对应的数据块为第一数据块,从第一对象块组的索引块寻至第一数据块,读取第一数据块中存储的目的对象数据。
这里,当磁盘中包括两个及两个以上的对象块组时,每一对象块组中,对象块组中的数据块与索引块间的物理距离小于磁盘中只有一个对象块组时数据块与索引块间的物理距离,这可以有效地缩短了磁盘的寻道时间,如上述从第一对象块组的索引块寻至第一数据块的时间缩短了。特别地,对象块组个数越多,缩短磁盘的寻道时间的效果越明显。
在本申请的一个实施例中,为了避免因磁盘长时间使用而出现坏块,降低磁盘中对象数据的安全性的问题,磁盘中还可以包括:至少一个保留块;保留块是磁盘中保留未被使用的一些对象块,这些对象块可以在非启动块的关键数据块,也就是,存储非启动信息的关键数据的主、备元数据块或对象块组中的主、备索引块损坏后进行替换。
一般的,当无法读取非启动信息的关键数据时,也就是,读取主元数据块中非启动块信息的元数据失败、或读取备元数据块备份中非启动块信息的元数据失败、或读取主索引块中的索引失败、或读取备索引块备份中的索引失败时,开始坏块的检测和替换,将读取失败的对象块确定为疑似坏块,重新向该疑似坏块中写入对象数据和/或从该疑似坏块中读取对象数据;若写入和/或读取对象数据成功,根据主、备冗余数据,修复该疑似坏块中的关键数 据;若写入和/或读取对象数据失败,获取一个保留块,由获取的保留块替换该疑似坏块,根据主、备冗余数据,覆盖所获取的保留块,并更新主元数据块中的元数据和备元数据块中备份的元数据。
例如,对象块组中一个主索引块确定为疑似坏块,重新向从该疑似坏块中写入和/或读取对象数据,若写入和/或读取对象数据成功,可以根据该对象块组中备索引块中的索引,修复该疑似坏块中的数据;若写入和/或读取对象数据失败,获取一个保留块,并替换该疑似坏块;根据该对象块组中备索引块中的索引,覆盖所获取的保留块,另外,磁盘中主索引块发生了变化,还需要更新主元数据块中主索引分配信息块中的数据和备元数据块中备索引分配信息块中的数据。
下面结合图6,说明当无法读取非启动信息的关键数据时坏块的检测和替换过程:
S01:获取坏块检测任务;
S02:判断坏块检测任务的磁盘是否为可用磁盘;如果是,执行S03;如果不是,结束本次坏块检测任务;
S03:重新向疑似坏块中写入对象数据和/或从疑似坏块中读取对象数据;
S04:判断是否写入和/或读取对象数据成功;如果是,执行S05;如果不是,执行S06;
其中,若写入和/或读取对象数据成功,则可以说明该疑似坏块不是坏块,该疑似坏块中存在元数据错误,可以根据主、备冗余数据修复该疑似坏块中的元数据;若写入和/或读取对象数据不成功,则可以说明该疑似坏块中存在扇区损坏,该疑似坏块是坏块,需要替换该疑似坏块。
S05:根据主、备冗余数据,修复该疑似坏块中的元数据;
S06:获取一个保留块,并由所获取的保留块替换该疑似坏块;
其中,所获取的保留块为未被使用的保留块。
S07:根据主、备冗余数据,覆盖所获取的保留块,更新主、备元数据块中的元数据。
一般的,如果对象块组的索引块损坏,需要更新索引分配信息块中的数据;如果索引分配信息块、坏块位图块或块位图块损坏,需要更新元数据描述块中的数据;如果元数据描述块损坏,需要更新启动块信息中的数据。
应用上述实施例,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据,关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
参考图7,图7为本申请实施例提供的一种磁盘数据读取装置的一种结构示意图,与图2相对应,所述磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;所述装置包括:
指令接收单元100,用于接收针对目的对象数据的读取指令;
信息确定单元200,用于根据所述目的对象数据的标识、所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组;
数据读取单元300,用于从所述第一对象块组的所述第一数据块中读取所述目的对象数据。
在本申请的一个实施例中,所述索引块可以包括主索引块和备索引块;所述主索引块用于存储对象数据的索引,所述备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
这种情况下,所述信息确定单元200,具体可以用于:
读取所述主元数据块中的元数据和/或所述备元数据块中备份的元数据,确定每一对象块组中主索引块和备索引块的位置;
读取所确定的位置处的主索引块中的索引或备索引块中备份的索引;
根据读取到的索引和所述目的对象数据的标识,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组。
在本申请的一个实施例中,所述磁盘还可以包括:至少一个保留块;
这种情况下,所述装置还可以包括:
坏块确定单元(图7中未示出),用于当读取所述主元数据块中的元数据失败、或读取所述备元数据块中备份的元数据失败、或读取每一对象块组中主索引块中的索引失败、或读取每一对象块组中备索引块中备份的索引失败时,将读取失败的对象块确定为疑似坏块,重新向所述疑似坏块中写入对象数据和/或从所述疑似坏块中读取对象数据;
数据修复单元(图7中未示出),用于若写入和/或读取对象数据成功,根据主、备冗余数据,修复所述疑似坏块中的数据;
数据覆盖单元(图7中未示出),用于若写入和/或读取对象数据失败,获取一个保留块,并替换所述疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新所述主元数据块中的元数据和所述备元数据块中备份的元数据。
在本申请的一个实施例中,所述信息确定单元200,具体可以用于:
计算所述目的对象数据的标识的第一索引校验值;
从预设索引数据库中获取所述第一索引校验值对应的第一数据块的标识和第一数据长度;所述预设索引数据库用于存储索引校验值、数据块的标识 与数据长度三者间的对应关系;所述预设索引数据库中存储的索引校验值根据主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引确定;
根据所述第一数据块的标识,确定所述第一数据块,并确定所述第一数据块所在的第一对象块组;
所述数据读取单元300,具体可以用于:
从所述第一对象块组的所述第一数据块中读取所述第一数据长度的所述目的对象数据。
应用上述实施例,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据,关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
参考图8,图8为本申请实施例提供的一种磁盘数据写入方法的一种流程示意图,如图3所示,该磁盘可以包括:存储元数据的主元数据块、备份元数据的备元数据块和至少一个对象块组,每一对象块组包括:存储对象数据的数据块和存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间。这里,一个数据块可以理解为一个对象块。
这种情况下,上述磁盘数据写入方法包括:
S801:接收针对目的对象数据的写入指令;
S802:从所述至少一个对象块组中确定空闲的第一数据块,并确定所述第一数据块对应的第一对象块组;
一般的,可以根据存储的主、备元数据,例如块位图,将块位图中使用情况标记为“0”的对象块确定为空闲的第一数据块。
为了保证写入对象数据成功,在确定出空闲的第一数据块后,可以通过坏块位图块判断该第一数据块是否被标记为坏块;若为否,继续确定第一数据块对应的第一对象块组;若为是,则再次重新确定空闲的第一数据块。
在本申请的一个实施例中,磁盘每一对象块组中包括的数据块是预先设置好的,当确定了第一数据块,也就可以确定第一数据块对应的第一对象块组。如:磁盘中包括两个对象块组,分别为对象块组1和对象块组2,对象块组1中包括数据块1-8,对象块组2中包括数据块9-16;若确定第一数据块的标识为4,则可以确定第一数据块所在的第一对象块组为对象块组1。
S803:将所述目的对象数据写入所述第一对象块组的所述第一数据块,并根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。
在本申请的一个实施例中,为了避免因为误操作导致对象块组中的索引出现错误,而无法读取数据的问题,如图5所示,在每一对象块组中,将索引块分为主索引块和备索引块;其中,主索引块用于存储对象数据的索引,备索引块用于备份对象数据的索引,这样,当主索引块中的索引出现错误时,可以根据备索引块中的索引修复主索引块中的索引;另外,为了降低引起索引热点数据访问的几率,提高磁盘的使用寿命和磁盘中对象数据的安全性,并且便于数据的存储,对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间。
这种情况下,S803可以为:将目的对象数据写入第一对象块组的第一数据块,将目的对象数据的标识作为索引写入第一对象块组中主索引块,将目的对象数据的标识作为索引写入第一对象块组中备索引块,更新主元数据块中的第一数据块对应的元数据,并将第一数据块对应的元数据备份至备元数据块中。例如,在目的对象数据写入第一对象块组的第一数据块后,将该目的对象数据的标识作为索引,写入第一对象块组中主索引块和备索引块中,并更新主、备元数据块中块位图块中的块位图,将块位图中第一数据块的使 用情况标记为“1”,以便于下次写入对象数据时快速地获取到空闲的数据块。
在本申请的一个实施例中,为了避免因磁盘长时间使用而出现坏块,降低磁盘中对象数据的安全性的问题,磁盘中还可以包括:至少一个保留块;保留块是磁盘中保留未被使用的一些对象块,这些对象块可以在非启动块的关键数据块,也就是,存储非启动信息的关键数据的主、备元数据块或对象块组的主、备索引块损坏后进行替换。
一般的,当无法更新非启动信息的关键数据时,也就是,更新第一对象块组中主索引块中的索引失败、或更新第一对象块组中备索引块中备份的索引失败、或更新主元数据块中非启动信息的元数据失败、或更新备元数据块中备份的非启动信息的元数据失败时,开始坏块的检测和替换,将更新失败的对象块确定为疑似坏块,重新向该疑似坏块中写入对象数据和/或从该疑似坏块中读取对象数据;若写入和/或读取对象数据成功,根据主、备冗余数据,修复该疑似坏块中的关键数据;若写入和/或读取对象数据失败,获取一个保留块,由获取的保留块替换该疑似坏块,根据主、备冗余数据,覆盖所获取的保留块,并更新主元数据块中的元数据和备元数据块中的备份元数据。当无法更新非启动信息的关键数据时坏块的检测和替换过程可参考图6。
在本申请的一个实施例中,目的对象数据的标识的大小和组成都是未知的,若直接根据目的对象数据的标识,从索引块中存储的索引中确定目的对象数据的标识所在的数据块,将会耗费很长的时间和资源。为了减少读取对象数据时耗费的时间和资源,可以预先设置一个索引数据库,该索引数据库可以用于存储索引校验值、数据块的标识与数据长度三者间的对应关系;这里,索引校验值的长度小于对象数据的标识的长度,索引校验值可以根据主元数据块中的元数据、备元数据块中备份的元数据和索引块中的索引确定;数据块的标识为存储该索引校验值对应对象数据的对象块的标识。这种情况下,参考图9,在图8的基础上,在根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据之后,上述磁盘数据写入方法还可以包括:
S901:计算所述目的对象数据的标识的第一索引校验值;
这里,计算第一索引校验值目的在于,缩短目的对象数据的标识的长度。 在本申请的一个实施例中,可以采用MD5和CRC32算法计算第一索引校验值,也就是,采用MD5_CRC32计算目的对象数据的标识的第一索引校验值;或采用HASH算法计算目的对象数据的标识的第一索引校验值。
例如,采用MD5和CRC32值计算目的对象数据的标识的第一索引校验值,写入指令针对的目的对象数据为<Key1,Value1>,该目的对象数据的长度为132Kbytes,目的对象数据的标识为Key1,另外,第一数据块的标识为4,在将Value1写入第一对象块组的第一数据块,并根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据之后,计算Key1的MD5_CRC32值,若为aa,则将<aa,4,132>存储至预设索引数据库,这样,在读取该目的对象数据<Key1,Value1>时,就可以快速地获得第一数据块的标识为4,以及该目的对象数据的数据长度为132Kbytes。
S902:将所述第一索引校验值、所述第一数据块的标识和所述目的对象数据的第一数据长度对应存储至预设索引数据库中。
在本申请的一个实施例中,为了便于写入对象数据,在向磁盘中写入数据前,可以先对磁盘进行格式化,参考图10,格式化的过程可以包括:
S11:获取格式参数;
这里,格式参数可以包括:单个对象块大小、对象块组索引块个数,单个索引大小,保留块大小等。
另外,为了便于确定对象块所属对象块组,可以按照单个对象块大小,将磁盘划分为N个对象块,并从0开始编号。
S12:判断格式化任务的磁盘是否为可用磁盘;如果是,执行S13;如果不是,结束本次磁盘格式化;
S13:计算启动块信息并下盘;
这里,计算启动块信息并下盘可以为:获取磁盘大小,计算对象块组大小,计算元数据描述块的描述信息,并填充开始格式化的标记信息。
在本申请的一个实施例中,对象块组大小的计算过程可以为:
例如,每个对象块组的主索引块个数为M(单位:对象块个数),单个索引大小为S(单位:KB),保留块个数为R(单位:对象块个数),单个对象块大小为B(单位:KB),磁盘总大小为T(单位:KB),则可以得出:
每个索引块可以索引的数据块个数Object_Index_Num为:
Object_Index_Num=B/S;
每个对象块组包含对象块个数Group_Total_Object为:
Group_Total_Object=Object_Index_Num*M+2*M;
大小为T的磁盘包含对象块组个数Group_Num为:
完整对象块组:
G=((T/B)-5*2-R)/Group_Total_Object;
其中,5*2表示主、备元数据块占用的对象块的个数。
最后一个对象块组包含对象块个数:
LAST=(T/B)-5*2-R-G*Group_Total_Object;
如果最后一个对象块组对象块个数大于主备索引需要空间,即LAST>2*M,则保留该未满对象块组。否则,不使用该空间,也就是,
Figure PCTCN2017101628-appb-000001
S14:计算元数据描述块信息并下盘;
S15:初始化块位图块信息并下盘;
磁盘中未存储任何对象数据,块位图块中对象块的使用情况都标记为“0”。
S16:初始化坏块位图块信息并下盘;
S17:计算索引分配信息块信息并下盘;
S18:初始化所有对象块组;
初始化每个对象块组时,需要初始化主备索引块信息,包括清空索引块 并写入校验值,防止数据出错。
S19:重新计算启动块信息并下盘。
这里,重新计算启动块信息可以包括:填充格式化完毕的标记信息。
应用上述实施例,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据,关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
参考图11,图11为本申请实施例提供的一种磁盘数据写入装置的一种结构示意图,与图8相对应,所述磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;所述装置包括:
指令接收单元400,用于接收针对目的对象数据的写入指令;
信息确定单元500,用于从所述至少一个对象块组中确定空闲的第一数据块,并确定所述第一数据块对应的第一对象块组;
数据写入单元600,用于将所述目的对象数据写入所述第一对象块组的所述第一数据块,并根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中备份的元数据。
在本申请的一个实施例中,所述索引块可以包括主索引块和备索引块;所述主索引块用于存储对象数据的索引,所述备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
这种情况下,所述数据写入单元600,具体可以用于:
将所述目的对象数据的标识作为索引写入所述第一对象块组中的主索引块,将所述目的对象数据的标识作为索引写入所述第一对象块组中的备索引块,更新所述主元数据块中的所述第一数据块对应的元数据,并将所述第一数据块对应的元数据备份至所述备元数据块中。
在本申请的一个实施例中,所述磁盘还可以包括:至少一个保留块;所述装置还可以包括:
坏块确定单元(图11中未示出),用于当更新所述第一对象块组中主索引块中的索引失败、或更新所述第一对象块组中备索引块中备份的索引失败、或更新所述主元数据块中的元数据失败、或更新所述备元数据块中备份的元数据失败时,将更新失败的对象块确定为疑似坏块,重新向所述疑似坏块中写入对象数据和/或从所述疑似坏块中读取对象数据;
数据修复单元(图11中未示出),用于若写入和/或读取对象数据成功,根据主、备冗余数据,修复所述疑似坏块中的关键数据;
数据覆盖单元(图11中未示出),用于若写入和/或读取对象数据失败,获取一个保留块,并替换所述疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新所述主元数据块中的元数据和所述备元数据块中备份的元数据。
在本申请的一个实施例中,参考图12,在图11的基础上,所述装置还可以包括:
校验值计算单元700,用于在根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中备份的元数据之后,计算所述目的对象数据的标识的第一索引校验值;
校验值存储单元800,用于将所述第一索引校验值、所述第一数据块的标识和所述目的对象数据的第一数据长度对应存储至预设索引数据库中;所述预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系。
应用上述实施例,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
本申请实施例还提供了一种电子设备,包括处理器、通信接口、存储器和通信总线;其中,处理器、通信接口、存储器通过通信总线完成相互间的通信;
存储器,用于存放应用程序;
处理器,用于执行存储器上所存放的应用程序时,实现磁盘数据读取方法。其中,磁盘数据读取方法中,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;至少一个对象块组位于主元数据块和备元数据块之间;该方法包括:
接收针对目的对象数据的读取指令;
根据目的对象数据的标识、主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定目的对象数据对应的第一数据块,并确定第一数据块所在的第一对象块组;
从第一对象块组的第一数据块中读取目的对象数据。
可选的,索引块包括主索引块和备索引块;主索引块用于存储对象数据 的索引,备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
根据目的对象数据的标识、主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定目的对象数据对应的第一数据块,并确定第一数据块所在的第一对象块组的步骤,包括:
读取主元数据块中的元数据和/或备元数据块中备份的元数据,确定每一对象块组中主索引块和备索引块的位置;
读取所确定的位置处的主索引块中的索引或备索引块中备份的索引;
根据读取到的索引和目的对象数据的标识,确定目的对象数据对应的第一数据块,并确定第一数据块所在的第一对象块组。
可选的,磁盘还包括:至少一个保留块;方法还包括:
当读取主元数据块中的元数据失败、或读取备元数据块中备份的元数据失败、或读取每一对象块组中主索引块中的索引失败、或读取每一对象块组中备索引块中备份的索引失败时,将读取失败的对象块确定为疑似坏块,重新向疑似坏块中写入对象数据和/或从疑似坏块中读取对象数据;
若写入和/或读取对象数据成功,根据主、备冗余数据,修复疑似坏块中的数据;
若写入和/或读取对象数据失败,获取一个保留块,并替换疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新主元数据块中的元数据和备元数据块中备份的元数据。
可选的,根据目的对象数据的标识、主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定目的对象数据对应的第一数据块的步骤,包括:
计算目的对象数据的标识的第一索引校验值;
从预设索引数据库中获取第一索引校验值对应的第一数据块的标识和第一数据长度;预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系;预设索引数据库中存储的索引校验值根据主元数据块 中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引确定;
根据第一数据块的标识,确定第一数据块;
从第一对象块组的第一数据块中读取目的对象数据的步骤,包括:
从第一对象块组的第一数据块中读取第一数据长度的目的对象数据。
应用上述实施例,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
上述通信总线可以是PCI(Peripheral Component Interconnect,外设部件互连标准)总线或EISA(Extended Industry Standard Architecture,扩展工业标准结构)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。
通信接口用于上述存储服务器与其他设备之间的通信。
存储器可以包括RAM(Random Access Memory,随机存取存储器),也可以包括NVM(Non-Volatile Memory,非易失性存储器),例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。
上述处理器可以是通用处理器,包括CPU(Central Processing Unit,中央处理器)、NP(Network Processor,网络处理器)等;还可以是DSP(Digital Signal Processing,数字信号处理器)、ASIC(Application Specific Integrated Circuit,专用集成电路)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。
本申请实施例还提供了一种电子设备,包括处理器、通信接口、存储器 和通信总线;其中,处理器、通信接口、存储器通过通信总线完成相互间的通信;
存储器,用于存放应用程序;
处理器,用于执行存储器上所存放的应用程序时,实现磁盘数据写入方法。其中,磁盘数据写入方法中,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;至少一个对象块组位于主元数据块和备元数据块之间;该方法包括:
接收针对目的对象数据的写入指令;
从至少一个对象块组中确定空闲的第一数据块,并确定第一数据块对应的第一对象块组;
将目的对象数据写入第一对象块组的第一数据块,并根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。
可选的,索引块包括主索引块和备索引块;主索引块用于存储对象数据的索引,备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据的步骤,包括:
将目的对象数据的标识作为索引写入第一对象块组中的主索引块,将目的对象数据的标识作为索引写入第一对象块组中的备索引块,更新主元数据块中的第一数据块对应的元数据,并将第一数据块对应的元数据备份至备元数据块中。
可选的,磁盘还包括:至少一个保留块;方法还包括:
当更新第一对象块组中主索引块中的索引失败、或更新第一对象块组中备索引块中备份的索引失败、或更新主元数据块中的元数据失败、或更新备 元数据块中备份的元数据失败时,将更新失败的对象块确定为疑似坏块,重新向疑似坏块中写入对象数据和/或从疑似坏块中读取对象数据;
若写入和/或读取对象数据成功,根据主、备冗余数据,修复疑似坏块中的关键数据;
若写入和/或读取对象数据失败,获取一个保留块,并替换疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新主元数据块中的元数据和备元数据块中备份的元数据。
可选的,在根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据的步骤之后,方法还包括:
计算目的对象数据的标识的第一索引校验值;
将第一索引校验值、第一数据块的标识和目的对象数据的第一数据长度对应存储至预设索引数据库中;预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系。
应用上述实施例,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
上述通信总线可以是PCI总线或EISA总线等。该通信总线可以分为地址总线、数据总线、控制总线等。
通信接口用于上述存储服务器与其他设备之间的通信。
存储器可以包括RAM,也可以包括NVM,例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。
上述处理器可以是通用处理器,包括CPU、NP等;还可以是DSP、ASIC、 FPGA或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。
本申请实施例还提供了一种应用程序,应用程序用于在运行时实现磁盘数据读取方法。其中,磁盘数据读取方法中,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;至少一个对象块组位于主元数据块和备元数据块之间;该方法包括:
接收针对目的对象数据的读取指令;
根据目的对象数据的标识、主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定目的对象数据对应的第一数据块,并确定第一数据块所在的第一对象块组;
从第一对象块组的第一数据块中读取目的对象数据。
可选的,索引块包括主索引块和备索引块;主索引块用于存储对象数据的索引,备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
根据目的对象数据的标识、主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定目的对象数据对应的第一数据块,并确定第一数据块所在的第一对象块组的步骤,包括:
读取主元数据块中的元数据和/或备元数据块中备份的元数据,确定每一对象块组中主索引块和备索引块的位置;
读取所确定的位置处的主索引块中的索引或备索引块中备份的索引;
根据读取到的索引和目的对象数据的标识,确定目的对象数据对应的第一数据块,并确定第一数据块所在的第一对象块组。
可选的,磁盘还包括:至少一个保留块;方法还包括:
当读取主元数据块中的元数据失败、或读取备元数据块中备份的元数据失败、或读取每一对象块组中主索引块中的索引失败、或读取每一对象块组中备索引块中备份的索引失败时,将读取失败的对象块确定为疑似坏块,重 新向疑似坏块中写入对象数据和/或从疑似坏块中读取对象数据;
若写入和/或读取对象数据成功,根据主、备冗余数据,修复疑似坏块中的数据;
若写入和/或读取对象数据失败,获取一个保留块,并替换疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新主元数据块中的元数据和备元数据块中备份的元数据。
可选的,根据目的对象数据的标识、主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定目的对象数据对应的第一数据块的步骤,包括:
计算目的对象数据的标识的第一索引校验值;
从预设索引数据库中获取第一索引校验值对应的第一数据块的标识和第一数据长度;预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系;预设索引数据库中存储的索引校验值根据主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引确定;
根据第一数据块的标识,确定第一数据块;
从第一对象块组的第一数据块中读取目的对象数据的步骤,包括:
从第一对象块组的第一数据块中读取第一数据长度的目的对象数据。
应用上述实施例,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
本申请实施例还提供了一种应用程序,应用程序用于在运行时实现磁盘数据写入方法。其中,磁盘数据写入方法中,磁盘包括:存储元数据的主元 数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;至少一个对象块组位于主元数据块和备元数据块之间;该方法包括:
接收针对目的对象数据的写入指令;
从至少一个对象块组中确定空闲的第一数据块,并确定第一数据块对应的第一对象块组;
将目的对象数据写入第一对象块组的第一数据块,并根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。
可选的,索引块包括主索引块和备索引块;主索引块用于存储对象数据的索引,备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据的步骤,包括:
将目的对象数据的标识作为索引写入第一对象块组中的主索引块,将目的对象数据的标识作为索引写入第一对象块组中的备索引块,更新主元数据块中的第一数据块对应的元数据,并将第一数据块对应的元数据备份至备元数据块中。
可选的,磁盘还包括:至少一个保留块;方法还包括:
当更新第一对象块组中主索引块中的索引失败、或更新第一对象块组中备索引块中备份的索引失败、或更新主元数据块中的元数据失败、或更新备元数据块中备份的元数据失败时,将更新失败的对象块确定为疑似坏块,重新向疑似坏块中写入对象数据和/或从疑似坏块中读取对象数据;
若写入和/或读取对象数据成功,根据主、备冗余数据,修复疑似坏块中的关键数据;
若写入和/或读取对象数据失败,获取一个保留块,并替换疑似坏块;根 据主、备冗余数据,覆盖所获取的保留块,并更新主元数据块中的元数据和备元数据块中备份的元数据。
可选的,在根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据的步骤之后,方法还包括:
计算目的对象数据的标识的第一索引校验值;
将第一索引校验值、第一数据块的标识和目的对象数据的第一数据长度对应存储至预设索引数据库中;预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系。
应用上述实施例,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
本申请实施例还提供了一种存储介质,存储介质用于存储应用程序,应用程序被运行时实现磁盘数据读取方法。其中,磁盘数据读取方法中,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;至少一个对象块组位于主元数据块和备元数据块之间;该方法包括:
接收针对目的对象数据的读取指令;
根据目的对象数据的标识、主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定目的对象数据对应的第一数据块,并确定第一数据块所在的第一对象块组;
从第一对象块组的第一数据块中读取目的对象数据。
可选的,索引块包括主索引块和备索引块;主索引块用于存储对象数据的索引,备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
根据目的对象数据的标识、主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定目的对象数据对应的第一数据块,并确定第一数据块所在的第一对象块组的步骤,包括:
读取主元数据块中的元数据和/或备元数据块中备份的元数据,确定每一对象块组中主索引块和备索引块的位置;
读取所确定的位置处的主索引块中的索引或备索引块中备份的索引;
根据读取到的索引和目的对象数据的标识,确定目的对象数据对应的第一数据块,并确定第一数据块所在的第一对象块组。
可选的,磁盘还包括:至少一个保留块;方法还包括:
当读取主元数据块中的元数据失败、或读取备元数据块中备份的元数据失败、或读取每一对象块组中主索引块中的索引失败、或读取每一对象块组中备索引块中备份的索引失败时,将读取失败的对象块确定为疑似坏块,重新向疑似坏块中写入对象数据和/或从疑似坏块中读取对象数据;
若写入和/或读取对象数据成功,根据主、备冗余数据,修复疑似坏块中的数据;
若写入和/或读取对象数据失败,获取一个保留块,并替换疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新主元数据块中的元数据和备元数据块中备份的元数据。
可选的,根据目的对象数据的标识、主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定目的对象数据对应的第一数据块的步骤,包括:
计算目的对象数据的标识的第一索引校验值;
从预设索引数据库中获取第一索引校验值对应的第一数据块的标识和第一数据长度;预设索引数据库用于存储索引校验值、数据块的标识与数据长 度三者间的对应关系;预设索引数据库中存储的索引校验值根据主元数据块中的元数据、备元数据块中备份的元数据和每一对象块组中索引块中的索引确定;
根据第一数据块的标识,确定第一数据块;
从第一对象块组的第一数据块中读取目的对象数据的步骤,包括:
从第一对象块组的第一数据块中读取第一数据长度的目的对象数据。
应用上述实施例,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
本申请实施例还提供了一种存储介质,存储介质用于存储应用程序,应用程序被运行时实现磁盘数据写入方法。其中,磁盘数据写入方法中,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数据块位于磁盘的尾部;至少一个对象块组位于主元数据块和备元数据块之间;该方法包括:
接收针对目的对象数据的写入指令;
从至少一个对象块组中确定空闲的第一数据块,并确定第一数据块对应的第一对象块组;
将目的对象数据写入第一对象块组的第一数据块,并根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。
可选的,索引块包括主索引块和备索引块;主索引块用于存储对象数据的索引,备索引块用于备份对象数据的索引;
对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据的步骤,包括:
将目的对象数据的标识作为索引写入第一对象块组中的主索引块,将目的对象数据的标识作为索引写入第一对象块组中的备索引块,更新主元数据块中的第一数据块对应的元数据,并将第一数据块对应的元数据备份至备元数据块中。
可选的,磁盘还包括:至少一个保留块;方法还包括:
当更新第一对象块组中主索引块中的索引失败、或更新第一对象块组中备索引块中备份的索引失败、或更新主元数据块中的元数据失败、或更新备元数据块中备份的元数据失败时,将更新失败的对象块确定为疑似坏块,重新向疑似坏块中写入对象数据和/或从疑似坏块中读取对象数据;
若写入和/或读取对象数据成功,根据主、备冗余数据,修复疑似坏块中的关键数据;
若写入和/或读取对象数据失败,获取一个保留块,并替换疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新主元数据块中的元数据和备元数据块中备份的元数据。
可选的,在根据目的对象数据的标识,更新第一对象块组中索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据的步骤之后,方法还包括:
计算目的对象数据的标识的第一索引校验值;
将第一索引校验值、第一数据块的标识和目的对象数据的第一数据长度对应存储至预设索引数据库中;预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系。
应用上述实施例,磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;主元数据块位于磁盘的头部;备元数 据块位于磁盘的尾部;上述至少一个对象块组位于主元数据块和备元数据块之间;这样,在读写对象数据时,可以分别操作索引块中的索引、主元数据块中的元数据、以及备元数据块中备份的元数据。关键数据,也就是索引和主元数据、备元数据分散在不同的区域中,读写对象数据时,对关键数据的操作不会集中在一个区域中,降低了对一个区域操作频率过高的几率,降低了索引热点数据访问的几率,进而增加了磁盘的使用寿命和安全性。
对于磁盘数据读取装置、磁盘数据写入装置、电子设备、应用程序和存储介质实施例而言,由于其基本相似于磁盘数据读取方法、磁盘数据写入方法实施例,所以描述的比较简单,相关之处参见图2-图6所示的磁盘数据读取方法和图8-图10所示的磁盘数据写入方法实施例的部分说明即可。
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
本领域普通技术人员可以理解实现上述方法实施方式中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,所述的程序可以存储于计算机可读取存储介质中,这里所称得的存储介质,如:ROM/RAM、磁碟、光盘等。
以上所述仅为本申请的较佳实施例而已,并非用于限定本申请的保护范围。凡在本申请的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本申请的保护范围内。

Claims (22)

  1. 一种磁盘数据读取方法,其特征在于,所述磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;所述方法包括:
    接收针对目的对象数据的读取指令;
    根据所述目的对象数据的标识、所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组;
    从所述第一对象块组的所述第一数据块中读取所述目的对象数据。
  2. 根据权利要求1所述的方法,其特征在于,所述索引块包括主索引块和备索引块;所述主索引块用于存储对象数据的索引,所述备索引块用于备份对象数据的索引;
    对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
    所述根据所述目的对象数据的标识、所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组的步骤,包括:
    读取所述主元数据块中的元数据和/或所述备元数据块中备份的元数据,确定每一对象块组中主索引块和备索引块的位置;
    读取所确定的位置处的主索引块中的索引或备索引块中备份的索引;
    根据读取到的索引和所述目的对象数据的标识,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组。
  3. 根据权利要求2所述的方法,其特征在于,所述磁盘还包括:至少一个保留块;所述方法还包括:
    当读取所述主元数据块中的元数据失败、或读取所述备元数据块中备份 的元数据失败、或读取每一对象块组中主索引块中的索引失败、或读取每一对象块组中备索引块中备份的索引失败时,将读取失败的对象块确定为疑似坏块,重新向所述疑似坏块中写入对象数据和/或从所述疑似坏块中读取对象数据;
    若写入和/或读取对象数据成功,根据主、备冗余数据,修复所述疑似坏块中的数据;
    若写入和/或读取对象数据失败,获取一个保留块,并替换所述疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新所述主元数据块中的元数据和所述备元数据块中备份的元数据。
  4. 根据权利要求1所述的方法,其特征在于,所述根据所述目的对象数据的标识、所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定所述目的对象数据对应的第一数据块的步骤,包括:
    计算所述目的对象数据的标识的第一索引校验值;
    从预设索引数据库中获取所述第一索引校验值对应的第一数据块的标识和第一数据长度;所述预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系;所述预设索引数据库中存储的索引校验值根据所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引确定;
    根据所述第一数据块的标识,确定所述第一数据块;
    所述从所述第一对象块组的所述第一数据块中读取所述目的对象数据的步骤,包括:
    从所述第一对象块组的所述第一数据块中读取所述第一数据长度的所述目的对象数据。
  5. 一种磁盘数据写入方法,其特征在于,所述磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;所述方法包括:
    接收针对目的对象数据的写入指令;
    从所述至少一个对象块组中确定空闲的第一数据块,并确定所述第一数据块对应的第一对象块组;
    将所述目的对象数据写入所述第一对象块组的所述第一数据块,并根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中备份的元数据。
  6. 根据权利要求5所述的方法,其特征在于,所述索引块包括主索引块和备索引块;所述主索引块用于存储对象数据的索引,所述备索引块用于备份对象数据的索引;
    对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
    所述根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中备份的元数据的步骤,包括:
    将所述目的对象数据的标识作为索引写入所述第一对象块组中的主索引块,将所述目的对象数据的标识作为索引写入所述第一对象块组中的备索引块,更新所述主元数据块中的所述第一数据块对应的元数据,并将所述第一数据块对应的元数据备份至所述备元数据块中。
  7. 根据权利要求6所述的方法,其特征在于,所述磁盘还包括:至少一个保留块;所述方法还包括:
    当更新所述第一对象块组中主索引块中的索引失败、或更新所述第一对象块组中备索引块中备份的索引失败、或更新所述主元数据块中的元数据失败、或更新所述备元数据块中备份的元数据失败时,将更新失败的对象块确定为疑似坏块,重新向所述疑似坏块中写入对象数据和/或从所述疑似坏块中读取对象数据;
    若写入和/或读取对象数据成功,根据主、备冗余数据,修复所述疑似坏块中的关键数据;
    若写入和/或读取对象数据失败,获取一个保留块,并替换所述疑似坏块; 根据主、备冗余数据,覆盖所获取的保留块,并更新所述主元数据块中的元数据和所述备元数据块中备份的元数据。
  8. 根据权利要求5所述的方法,其特征在于,在所述根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中备份的元数据的步骤之后,所述方法还包括:
    计算所述目的对象数据的标识的第一索引校验值;
    将所述第一索引校验值、所述第一数据块的标识和所述目的对象数据的第一数据长度对应存储至预设索引数据库中;所述预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系。
  9. 一种磁盘数据读取装置,其特征在于,所述磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;所述装置包括:
    指令接收单元,用于接收针对目的对象数据的读取指令;
    信息确定单元,用于根据所述目的对象数据的标识、所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组;
    数据读取单元,用于从所述第一对象块组的所述第一数据块中读取所述目的对象数据。
  10. 根据权利要求9所述的装置,其特征在于,所述索引块包括主索引块和备索引块;所述主索引块用于存储对象数据的索引,所述备索引块用于备份对象数据的索引;
    对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
    所述信息确定单元,具体用于:
    读取所述主元数据块中的元数据和/或所述备元数据块中备份的元数据,确定每一对象块组中主索引块和备索引块的位置;
    读取所确定的位置处的主索引块中的索引或备索引块中备份的索引;
    根据读取到的索引和所述目的对象数据的标识,确定所述目的对象数据对应的第一数据块,并确定所述第一数据块所在的第一对象块组。
  11. 根据权利要求10所述的装置,其特征在于,所述磁盘还包括:至少一个保留块;所述装置还包括:
    坏块确定单元,用于当读取所述主元数据块中的元数据失败、或读取所述备元数据块中备份的元数据失败、或读取每一对象块组中主索引块中的索引失败、或读取每一对象块组中备索引块中备份的索引失败时,将读取失败的对象块确定为疑似坏块,重新向所述疑似坏块中写入对象数据和/或从所述疑似坏块中读取对象数据;
    数据修复单元,用于若写入和/或读取对象数据成功,根据主、备冗余数据,修复所述疑似坏块中的数据;
    数据覆盖单元,用于若写入和/或读取对象数据失败,获取一个保留块,并替换所述疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新所述主元数据块中的元数据和所述备元数据块中备份的元数据。
  12. 根据权利要求9所述的装置,其特征在于,所述信息确定单元,具体用于:
    计算所述目的对象数据的标识的第一索引校验值;
    从预设索引数据库中获取所述第一索引校验值对应的第一数据块的标识和第一数据长度;所述预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系;所述预设索引数据库中存储的索引校验值根据所述主元数据块中的元数据、所述备元数据块中备份的元数据和每一对象块组中索引块中的索引确定;
    根据所述第一数据块的标识,确定所述第一数据块,并确定所述第一数据块所在的第一对象块组;
    所述数据读取单元,具体用于:
    从所述第一对象块组的所述第一数据块中读取所述第一数据长度的所述 目的对象数据。
  13. 一种磁盘数据写入装置,其特征在于,所述磁盘包括:存储元数据的主元数据块、备份元数据的备元数据块、和至少一个对象块组,每一对象块组包括:存储对象数据的数据块、存储对象数据的索引的索引块;所述主元数据块位于所述磁盘的头部;所述备元数据块位于所述磁盘的尾部;所述至少一个对象块组位于所述主元数据块和所述备元数据块之间;所述装置包括:
    指令接收单元,用于接收针对目的对象数据的写入指令;
    信息确定单元,用于从所述至少一个对象块组中确定空闲的第一数据块,并确定所述第一数据块对应的第一对象块组;
    数据写入单元,用于将所述目的对象数据写入所述第一对象块组的所述第一数据块,并根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中备份的元数据。
  14. 根据权利要求13所述的装置,其特征在于,所述索引块包括主索引块和备索引块;所述主索引块用于存储对象数据的索引,所述备索引块用于备份对象数据的索引;
    对于每一对象块组,该对象块组中的主索引块位于该对象块组的头部,该对象块组中的备索引块位于该对象块组的尾部;该对象块组中的数据块位于该对象块组的主索引块和备索引块之间;
    所述数据写入单元,具体用于:
    将所述目的对象数据的标识作为索引写入所述第一对象块组中主索引块,将所述目的对象数据的标识作为索引写入所述第一对象块组中备索引块,更新所述主元数据块中的所述第一数据块对应的元数据,并将所述第一数据块对应的元数据备份至所述备元数据块中。
  15. 根据权利要求14所述的装置,其特征在于,所述磁盘还包括:至少一个保留块;所述装置还包括:
    坏块确定单元,用于当更新所述第一对象块组中主索引块中的索引失败、或更新所述第一对象块组中备索引块中备份的索引失败、或更新所述主元数 据块中的元数据失败、或更新所述备元数据块中备份的元数据失败时,将更新失败的对象块确定为疑似坏块,重新向所述疑似坏块中写入对象数据和/或从所述疑似坏块中读取对象数据;
    数据修复单元,用于若写入和/或读取对象数据成功,根据主、备冗余数据,修复所述疑似坏块中的关键数据;
    数据覆盖单元,用于若写入和/或读取对象数据失败,获取一个保留块,并替换所述疑似坏块;根据主、备冗余数据,覆盖所获取的保留块,并更新所述主元数据块中的元数据和所述备元数据块中备份的元数据。
  16. 根据权利要求13所述的装置,其特征在于,所述装置还包括:
    校验值计算单元,用于在根据所述目的对象数据的标识,更新所述第一对象块组中索引块中的索引、所述主元数据块中的元数据、以及所述备元数据块中的备份元数据之后,计算所述目的对象数据的标识的第一索引校验值;
    校验值存储单元,用于将所述第一索引校验值、所述第一数据块的标识和所述目的对象数据的第一数据长度对应存储至预设索引数据库中;所述预设索引数据库用于存储索引校验值、数据块的标识与数据长度三者间的对应关系。
  17. 一种电子设备,其特征在于,包括处理器、通信接口、存储器和通信总线;其中,所述处理器、所述通信接口、所述存储器通过所述通信总线完成相互间的通信;
    所述存储器,用于存放应用程序;
    所述处理器,用于执行所述存储器上所存放的应用程序时,实现权利要求1-4任一所述的方法步骤。
  18. 一种电子设备,其特征在于,包括处理器、通信接口、存储器和通信总线;其中,所述处理器、所述通信接口、所述存储器通过所述通信总线完成相互间的通信;
    所述存储器,用于存放应用程序;
    所述处理器,用于执行所述存储器上所存放的应用程序时,实现权利要求5-8任一所述的方法步骤。
  19. 一种应用程序,其特征在于,所述应用程序用于在运行时实现权利 要求1-4任一所述的方法步骤。
  20. 一种应用程序,其特征在于,所述应用程序用于在运行时实现权利要求5-8任一所述的方法步骤。
  21. 一种存储介质,其特征在于,所述存储介质用于存储应用程序,所述应用程序被运行时实现权利要求1-4任一所述的方法步骤。
  22. 一种存储介质,其特征在于,所述存储介质用于存储应用程序,所述应用程序被运行时实现权利要求5-8任一所述的方法步骤。
PCT/CN2017/101628 2016-11-08 2017-09-13 一种磁盘数据读写方法及装置 Ceased WO2018086409A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP17870483.9A EP3540587B1 (en) 2016-11-08 2017-09-13 Disk data reading/writing method and device
US16/348,248 US11048601B2 (en) 2016-11-08 2017-09-13 Disk data reading/writing method and device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610979543.1 2016-11-08
CN201610979543.1A CN108062200B (zh) 2016-11-08 2016-11-08 一种磁盘数据读写方法及装置

Publications (1)

Publication Number Publication Date
WO2018086409A1 true WO2018086409A1 (zh) 2018-05-17

Family

ID=62109132

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/101628 Ceased WO2018086409A1 (zh) 2016-11-08 2017-09-13 一种磁盘数据读写方法及装置

Country Status (5)

Country Link
US (1) US11048601B2 (zh)
EP (1) EP3540587B1 (zh)
CN (1) CN108062200B (zh)
HU (1) HUE061107T2 (zh)
WO (1) WO2018086409A1 (zh)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111435331B (zh) * 2019-01-14 2022-08-26 杭州宏杉科技股份有限公司 存储卷写数据方法、装置、电子设备及机器可读存储介质
CN112306375B (zh) * 2019-08-01 2023-03-14 兆易创新科技集团股份有限公司 用户数据搬移的恢复方法、装置、电子设备及存储介质
CN111399762B (zh) * 2019-11-27 2021-06-18 杭州海康威视系统技术有限公司 数据存储方法、装置及存储系统
CN111382011B (zh) * 2020-02-28 2022-11-29 苏州浪潮智能科技有限公司 一种文件数据存取方法、装置和计算机可读存储介质
CN111444152A (zh) * 2020-03-30 2020-07-24 北京小米移动软件有限公司 文件系统、文件系统访问方法、电子设备及存储介质
CN111414367A (zh) * 2020-03-31 2020-07-14 中国建设银行股份有限公司 获取参数的方法和装置
CN114461455B (zh) * 2022-02-11 2025-11-21 瀚高基础软件股份有限公司 一种流复制集群的磁盘坏块修复方法及装置
CN115098032B (zh) * 2022-06-30 2025-10-03 北京金山云网络技术有限公司 集群中磁盘的踢盘处理方法、装置及存储介质
CN116541360A (zh) * 2023-05-09 2023-08-04 成都智明达电子股份有限公司 一种高速抗掉电大容量文件系统及抗掉电方法
US20250060893A1 (en) * 2023-08-15 2025-02-20 Micron Technology, Inc. Tracking latch upset events using block status data
CN117472290B (zh) * 2023-12-27 2024-03-22 苏州元脑智能科技有限公司 存储数据的修复方法、装置、系统、电子设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101814044A (zh) * 2010-04-19 2010-08-25 中兴通讯股份有限公司 元数据处理方法及装置
CN104991747A (zh) * 2015-07-30 2015-10-21 湖南亿谷科技发展股份有限公司 数据管理方法及系统
CN105224626A (zh) * 2015-09-23 2016-01-06 浪潮(北京)电子信息产业有限公司 一种分布式文件系统磁盘文件读写方法、装置和系统
CN105528053A (zh) * 2015-12-11 2016-04-27 曙光信息产业股份有限公司 分布式系统的管理方法和装置

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7873782B2 (en) * 2004-11-05 2011-01-18 Data Robotics, Inc. Filesystem-aware block storage system, apparatus, and method
US8006125B1 (en) * 2005-04-29 2011-08-23 Microsoft Corporation Automatic detection and recovery of corrupt disk metadata
CA2651757A1 (en) * 2006-05-03 2007-11-08 Data Robotics Incorporated Filesystem-aware block storage system, apparatus, and method
US9348890B2 (en) * 2011-08-30 2016-05-24 Open Text S.A. System and method of search indexes using key-value attributes to searchable metadata
WO2014091629A1 (ja) * 2012-12-14 2014-06-19 富士通株式会社 記憶装置の管理プログラム、電子装置及び記憶装置の管理方法
CN103593477A (zh) * 2013-11-29 2014-02-19 华为技术有限公司 一种哈希数据库的配置方法和装置
US9256549B2 (en) * 2014-01-17 2016-02-09 Netapp, Inc. Set-associative hash table organization for efficient storage and retrieval of data in a storage system
CN104866497B (zh) * 2014-02-24 2018-06-15 华为技术有限公司 分布式文件系统列式存储的元数据更新方法、装置、主机
CN105893188B (zh) * 2014-09-30 2018-12-14 伊姆西公司 用于加速磁盘阵列的数据重构的方法和装置
CN105117351B (zh) * 2015-09-08 2018-07-03 华为技术有限公司 向缓存写入数据的方法及装置
US9740415B2 (en) * 2015-11-17 2017-08-22 International Business Machines Corporation Object-based storage management
JP6675944B2 (ja) * 2016-07-12 2020-04-08 富士通株式会社 ファイル管理システム、ファイル管理装置およびファイル管理プログラム

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101814044A (zh) * 2010-04-19 2010-08-25 中兴通讯股份有限公司 元数据处理方法及装置
CN104991747A (zh) * 2015-07-30 2015-10-21 湖南亿谷科技发展股份有限公司 数据管理方法及系统
CN105224626A (zh) * 2015-09-23 2016-01-06 浪潮(北京)电子信息产业有限公司 一种分布式文件系统磁盘文件读写方法、装置和系统
CN105528053A (zh) * 2015-12-11 2016-04-27 曙光信息产业股份有限公司 分布式系统的管理方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3540587A4

Also Published As

Publication number Publication date
HUE061107T2 (hu) 2023-05-28
EP3540587A4 (en) 2019-11-27
EP3540587A1 (en) 2019-09-18
CN108062200B (zh) 2019-12-20
US11048601B2 (en) 2021-06-29
US20190317698A1 (en) 2019-10-17
CN108062200A (zh) 2018-05-22
EP3540587B1 (en) 2022-12-07

Similar Documents

Publication Publication Date Title
WO2018086409A1 (zh) 一种磁盘数据读写方法及装置
EP2756405B1 (en) Nonvolatile media dirty region tracking
CN109343790B (zh) 一种基于nand flash的数据存储方法、终端设备及存储介质
US10289500B2 (en) Accelerated data recovery in a storage system
CN110765076B (zh) 数据存储方法、装置、电子设备及存储介质
TWI490694B (zh) 判定資料可得性之方法及系統,以及記憶體介面
US10152416B2 (en) Buffer cache apparatus, journaling file system and journaling method for incorporating journaling features within non-volatile buffer cache
CN102722443B (zh) 闪速存储器的坏块管理方法
US10261705B2 (en) Efficient data consistency verification for flash storage
US12061557B2 (en) Method for storing L2P table, system, device, and medium
US11449261B2 (en) Low latency data mirroring in a large scale storage system
WO2018076954A1 (zh) 一种数据存储方法、装置及系统
CN110647455A (zh) 一种存储设备重启记录方法和系统
CN116301654A (zh) 数据迁移方法、装置、电子设备及存储介质
CN109597573B (zh) 管理元数据读取方法及装置
TWI407371B (zh) 嵌入式網路設備及其更新韌體的方法
CN121092373A (zh) 存储块的管理方法、装置及其存储介质
CN120653197A (zh) Ssd故障时ftl映射方法、数据恢复方法及存储设备
JP2010140155A (ja) フラッシュディスク装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17870483

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2017870483

Country of ref document: EP

Effective date: 20190611