WO2021143049A1 - 一种读写方法、装置和电子设备及可读存储介质 - Google Patents
一种读写方法、装置和电子设备及可读存储介质 Download PDFInfo
- Publication number
- WO2021143049A1 WO2021143049A1 PCT/CN2020/098034 CN2020098034W WO2021143049A1 WO 2021143049 A1 WO2021143049 A1 WO 2021143049A1 CN 2020098034 W CN2020098034 W CN 2020098034W WO 2021143049 A1 WO2021143049 A1 WO 2021143049A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- read
- write
- instruction
- information
- registry
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/061—Improving I/O performance
-
- G—PHYSICS
- G11—INFORMATION STORAGE
- G11C—STATIC STORES
- G11C7/00—Arrangements for writing information into, or reading information out from, a digital store
- G11C7/10—Input/output [I/O] data interface arrangements, e.g. I/O data control circuits, I/O data buffers
- G11C7/1051—Data output circuits, e.g. read-out amplifiers, data output buffers, data output registers, data output level conversion circuits
- G11C7/1069—I/O lines read out arrangements
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/061—Improving I/O performance
- G06F3/0613—Improving I/O performance in relation to throughput
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0655—Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0655—Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
- G06F3/0659—Command handling arrangements, e.g. command buffers, queues, command scheduling
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/067—Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0674—Disk device
- G06F3/0676—Magnetic disk device
-
- G—PHYSICS
- G11—INFORMATION STORAGE
- G11C—STATIC STORES
- G11C7/00—Arrangements for writing information into, or reading information out from, a digital store
- G11C7/10—Input/output [I/O] data interface arrangements, e.g. I/O data control circuits, I/O data buffers
- G11C7/1078—Data input circuits, e.g. write amplifiers, data input buffers, data input registers, data input level conversion circuits
- G11C7/1096—Write circuits, e.g. I/O line write drivers
Definitions
- This application relates to the field of reading and writing technology, and in particular to a reading and writing method, a reading and writing device, electronic equipment and a computer-readable storage medium.
- the network storage host is a computer system, including CPU, motherboard, memory, hard disk and other hardware, on which the Linux operating system runs.
- the network storage host can read and write to the hard disk, but cannot write when reading the hard disk, and cannot read when writing to the hard disk. That is to say: the same address space of the hard disk cannot be read and written at the same time. Therefore, shared resource protection is required for hard disks.
- the commonly used method is rwlock read-write lock, which is a set of standard methods provided by Linux, that is, using this method, read and write can be mutually exclusive, in case the same address space is read and written at the same time, resulting in data inconsistency.
- the Linux standard resource lock rwlock processes reads and writes sequentially, that is, if the write operation is performed first, even if there are more reads, the client's read operation must wait for the write operation to complete, which is likely to cause more read operations. delay.
- the purpose of this application is to provide a reading and writing method, a reading and writing device, an electronic device and a computer readable storage medium, which can improve the efficiency of reading and writing processing.
- the specific plan is as follows:
- This application provides a method of reading and writing, including:
- the write instruction is executed based on the write strategy.
- the determining the write strategy corresponding to the write instruction according to the read information in the registry includes:
- the first write strategy is determined; if the read information does not exist, the second write strategy is determined;
- the executing the write instruction based on the write strategy includes:
- the method before the receiving the write instruction, the method further includes:
- each of the read instructions includes the read information
- the read information corresponding to the target read instruction is deleted from the registry, and the data in the area corresponding to the next read instruction is executed based on the next read instruction.
- the read operation is completed until all the read instructions corresponding to the read information in the registry are completed.
- the method further includes:
- the read information does not exist in the registry, the data in the temporary memory that has completed the execution of the write instruction is written back to the area corresponding to the write instruction.
- the registration table further includes: pointing information corresponding to each of the read information, wherein the pointing information refers to the next read information from the current read information;
- the judging whether the read information exists in the registry every first preset time interval includes:
- determining the second write strategy includes:
- the determining the write strategy corresponding to the write instruction according to the read information in the registry includes:
- the executing the write instruction based on the write strategy includes:
- the read information includes: the address of the read data, the length of the read data, the time stamp of the read data, and the ID of the read data;
- the execution process of the read operation includes:
- Every second preset time interval judging whether the read time length of the data read of the read operation exceeds a preset threshold based on the time stamp of the read data;
- the data reading operation is stopped, the corresponding reading information in the registry is deleted, and the reading operation is determined to be completed.
- the method further includes:
- Every third preset time interval judging whether the write duration of the write operation corresponding to the current write instruction is greater than the preset write time threshold
- the writing operation is stopped and a warning message is issued.
- This application provides a reading and writing device, including:
- the write command receiving module is used to receive the write command
- the write strategy determination module is used to determine the write strategy corresponding to the write instruction according to the read information in the registry, where the read information is that when the read instruction is received, the information corresponding to the read instruction is stored in the State the information in the registration form;
- the write instruction execution module is configured to execute the write instruction based on the write strategy.
- This application provides an electronic device, including:
- Memory used to store computer programs
- the processor is used to implement the steps of the above-mentioned reading and writing method when the computer program is executed.
- the present application provides a computer-readable storage medium with a computer program stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned reading and writing method are realized.
- This application provides a read and write method, including: receiving a write instruction; determining a write strategy corresponding to the write instruction according to the read information in the registry, where the read information is the information corresponding to the read instruction after the read instruction is received Information stored in the registry; execute write commands based on write strategies.
- this application will register the read information in the registry when the read instruction is executed. Before executing the write instruction, determine the write strategy corresponding to the write instruction according to the read information in the registry, based on the write strategy Execute write instructions to improve the efficiency of read and write processing.
- This application also provides a read-write device, an electronic device, and a computer-readable storage medium, all of which have the above-mentioned beneficial effects, and will not be repeated here.
- FIG. 1 is a flowchart of a method for reading and writing according to an embodiment of the application
- FIG. 2 is a schematic diagram of the information structure in a registration form provided by an embodiment of the application.
- FIG. 3 is a schematic flowchart of another reading and writing method provided by an embodiment of the application.
- FIG. 4 is a schematic flowchart of another reading and writing method provided by an embodiment of the application.
- FIG. 5 is a schematic structural diagram of a read-write device provided by an embodiment of the application.
- FIG. 1 is a flowchart of a reading and writing method provided by an embodiment of the application, which specifically includes:
- This embodiment is based on a network storage host, where the network storage host includes hardware such as a CPU, a motherboard, a memory, and a hard disk, and runs a Linux operating system.
- the network storage host includes hardware such as a CPU, a motherboard, a memory, and a hard disk, and runs a Linux operating system.
- the purpose of this step is to receive a write command. It can be understood that the write command includes: a write address, that is, an area corresponding to the write command.
- S120 Determine a write strategy corresponding to the write instruction according to the read information in the registry.
- the read information is the information that stores the information corresponding to the read instruction in the registry after receiving the read instruction.
- FIG. 2 is a schematic diagram of the information structure in a registration table provided by an embodiment of the application; reading the information registration table is implemented using a singly linked list.
- the method of determining the write strategy corresponding to the write instruction according to the read information in the registry may be to determine whether the read information exists in the registry, and if so, Determine the first write strategy. If it does not exist, determine the second write strategy.
- the first write strategy is: read the area corresponding to the write command to the temporary memory, and execute the write command in the temporary memory until all the information is read After the corresponding read operation is executed, and there is no read information in the registry, all data in the temporary memory is written back to the area corresponding to the write instruction.
- the second write strategy is: execute the write instruction in the area corresponding to the write instruction.
- the method of determining the write strategy corresponding to the write instruction according to the read information in the registry may be to determine whether there is target read information with a priority greater than a preset priority threshold in the registry; if If the target read information exists, the third write strategy is determined. If the target read information does not exist, the fourth write strategy is determined.
- the third write strategy is: read out the area corresponding to the write instruction to the temporary memory and store it in the temporary memory. Execute the write instruction in the process; execute the read operation corresponding to the target read information. When all the read operations corresponding to the target read information are executed, all data in the temporary memory is written back to the area corresponding to the write instruction.
- the fourth write strategy is : Execute the write command in the area corresponding to the write command.
- the method of determining the write strategy corresponding to the write instruction according to the read information in the registry may be to determine the priority of the first read information in the registry and compare the priority And the priority of the write command. If the priority of the write command is greater than the priority of the first read message, the fifth write strategy is determined. If the priority of the write command is lower than the priority of the first read message, then the fifth write strategy is determined.
- the sixth write strategy, the fifth write strategy is: execute the write instruction in the area corresponding to the write instruction, the sixth write strategy is: read the area corresponding to the write instruction to the temporary memory, execute the write instruction in the temporary memory, and execute the The read operation corresponding to the first read information.
- the first read information is deleted, and then the next read information is used as the new first read information, and the first read information in the registry is determined.
- the priority step when the priority corresponding to the first read message is less than the priority of the write command, all data in the temporary memory is written back to the area corresponding to the write command.
- step S130 further includes: every third preset time interval, judging whether the write duration of the write operation corresponding to the current write instruction is greater than the preset write time threshold; if it is greater than the preset write time threshold, stop writing Operate, and issue a warning message.
- this step it is judged every third preset time interval whether the write duration of the write operation corresponding to the current write instruction is greater than the preset write time threshold.
- the purpose is to limit the write duration within a certain range to ensure subsequent write and read operations The high-efficiency completion. If it is greater than the preset write time threshold, the write operation is stopped and a warning message is issued, and if it is less than the preset small time threshold, the write operation is continued.
- this embodiment sets up a registry to register read information in the registry when executing a read instruction. Before executing the write instruction, determine the write strategy corresponding to the write instruction based on the read information in the registry. The write strategy executes the write command and improves the efficiency of read and write processing.
- FIG. 3 is a schematic flowchart of another reading and writing method provided by an embodiment of the application, including:
- the method further includes: receiving a read instruction, each read instruction including read information; sequentially storing the read information in the registry; performing a read operation on the data in the target area based on the target read instruction; After the execution is completed, the read information corresponding to the target read instruction is deleted from the registry, and the data in the area corresponding to the next read instruction is read based on the next read instruction, until the read information corresponding to the read information in the registry is completed All read instructions.
- the read information includes: the address of the read data, the length of the read data, the time stamp of the read data, the ID of the read data, and the pointing information.
- Address is the address of the read data
- Length is the length of the read data
- Timestamp is the timestamp of the read data
- Name is the ID of the read data
- NEXT is the pointing information, used to point to the next read information, so that the string together forms a single-phase linked list.
- each read information in the registry is at least 56 bytes.
- the read information can also include Priority, that is, the operation priority, which is used to determine whether the write can be performed. Operation, at this time, the memory size of a read message in the registry is 57 bytes.
- the read instruction When at least one read instruction is received (the read instruction may be received simultaneously or sequentially), the corresponding read information is sequentially stored in the registry.
- S320 Determine whether there is read information in the registry.
- the read information is the information that stores the information corresponding to the read instruction in the registry after receiving the read instruction.
- the registry includes read information. It can be understood that each read information corresponds to a read instruction. When the read instruction is completed, the read information in the registry is deleted. Therefore, the read information in the registry is all unprocessed. Read information. If there is read information in the registry, step S330 is executed, and if there is no read information in the registry, step S350 is executed.
- Reading the information registry is implemented using a singly linked list. After the read operation A corresponding to the read instruction corresponding to the read information A is executed, the read operation B corresponding to the read information B is executed; after the read operation B is executed, the read operation C corresponding to the read information C is executed; when the read operation is completed After C, execute the read operation D corresponding to the read information D; after the read operation D is executed, execute the read operation E corresponding to the read information E; after executing the read operation E, execute the write operation corresponding to the write instruction.
- the read instruction when there is the first read message in the registry, and the read command corresponding to the read message is not completed, a write command is received, and the area corresponding to the write command is read to the temporary memory at this time, and in the temporary memory Execute the write instruction, and when the first read instruction is not completed, if the second read instruction is received, the read information corresponding to the second read instruction will be stored in the registry.
- delete In the corresponding read information in the registry execute the second read instruction until there is no read information in the registry, and write the data corresponding to the write instruction in the temporary memory back to the area corresponding to the write instruction. It can be understood that the read instruction Before the completion of the complete execution, a write instruction is received again, the write instruction waits, and the write instruction is executed after the previous write instruction completes the write operation.
- the write instruction in the temporary memory after executing the write instruction in the temporary memory, it also includes: every first preset time interval, judging whether there is read information in the registry; if the read information does not exist in the registry, the execution of the write instruction in the temporary memory is completed The data is written back to the area corresponding to the write command.
- the registration table also includes: pointing information corresponding to each read information, where the pointing information points to the next read information from the current read information; correspondingly, every first preset time interval, it is judged whether the registration table is Existing read information includes: judging whether the last pointing information in the registry is empty every first preset time interval; correspondingly, if there is no read information, then determining the second write strategy, including: if it is empty, then Determine the second write strategy.
- the pointing information has a size of 4 bytes, pointing to the next read information, and strung together to form a singly linked list, the registry. It is understandable that when the write command is received, it is judged whether there is read information in the registry. The specific judgment method can be to judge whether the last pointing information in the registry is empty. If it is empty, it means that there is no read later. Information registration.
- the second write strategy is determined, and the data area corresponding to the hard disk can be written directly; if it is not empty, the first write strategy is determined, and the corresponding area of the hard disk is read into the temporary memory, and the data in it is modified, that is, read out
- the area corresponding to the write instruction is to the temporary memory, and the write instruction is executed in the temporary memory.
- the last point in the registry is checked every first preset time interval, which is 50ms. Whether the information is empty, until it is empty to indicate that the read information is not locked, then all the data in the temporary memory is written back to the area corresponding to the write command.
- each read information in the registry can be printed, where the read information includes: the address of the read data, the length of the read data, the time stamp of the read data, and the ID of the read data is the initiator. Name, in which, according to the timestamp, you can get information such as read start time and read duration.
- the present invention provides a technical method for designing a Linux read priority hard disk protection lock on a network storage host. This method is divided into three parts: data structure, read operation processing, and write operation processing, which can improve the processing efficiency of read-first write-latency applications.
- the data structure is the processing flow of each read information in the registry.
- the flow of the method for reading and writing includes: setting a register of information, and when receiving a read command to perform a read operation, registering the information in the register means storing the read information corresponding to the read command in the register; receiving the write command ,
- When performing a write operation when there is still read information in the registry, first read the hard disk content, that is, first read the area corresponding to the write instruction to the temporary memory, and execute the write instruction in the temporary memory, and then determine whether the registry is If there is read information, if there is no read operation, it means that there is no read operation and write to the hard disk; if there is, there is a read operation occupying the hard disk, and the write operation must wait until there is no read operation before writing to the hard disk.
- this embodiment sets up a registry to register the read information in the registry when executing the read instruction. Before executing the write instruction, if the read information does not exist in the registry, the write instruction is directly executed. If there is read information in the table, the operation waits, and the write instruction is executed in the temporary memory. When there are read and write instructions at the same time, the demand for fast read is met, and the processing efficiency of read instructions is improved.
- FIG. 4 is a schematic flowchart of another reading and writing method provided by an embodiment of the application, including:
- S420 Determine whether there is target read information with a priority greater than a preset priority threshold in the registry.
- the read information is sequentially stored in the registry, and the read information includes: the address of the read data, the length of the read data, the time stamp of the read data, the ID of the read data, and the operation priority. Set the corresponding priority for each read operation. When the priority is greater than the preset priority threshold, the target read information needs to be executed first. When the target read information exists in the registry, step S430 is executed, and when the target read information does not exist in the registry, the write instruction is executed in the area corresponding to the write instruction.
- the read information is the information that stores the information corresponding to the read instruction in the registry after receiving the read instruction.
- this embodiment provides setting priorities for read operations, which can prioritize the completion of read operations corresponding to read information with a priority greater than the preset priority threshold, ensuring that the customer's read operations can be completed efficiently
- the read information includes: the address of the read data, the length of the read data, the timestamp of the read data, and the ID of the read data; correspondingly, the execution process of the read operation includes: every second preset Set the time interval, based on the time stamp of the read data to determine whether the read time of the data read of the read operation exceeds the preset threshold; if it exceeds the preset threshold, stop the data read operation and delete the corresponding read information in the registry To confirm the completion of the read operation.
- This embodiment does not limit the second preset time interval, and may be 50 ms.
- the time stamp can determine the read duration of the read data. When the read duration exceeds a preset threshold, the read unlocks, the read instruction is no longer executed, and the read instruction is determined to be completed. This embodiment does not limit the read duration, which may be 500 ms. Further, when the reading time exceeds a preset threshold, an alarm can also be issued. This embodiment does not limit the alarm mode, and the user can customize the setting.
- Read management thread There is a read management thread globally, which polls every second preset time interval of 50ms to view each read information in the entire registry. If the read time corresponding to the read information exceeds the set global read time threshold Threshold.
- the preset threshold (this value can be set, the default is 500ms), an alarm will be issued, and the read operation will be unlocked, and the read operation is not allowed to be locked indefinitely.
- the read information corresponding to the target read instruction is deleted from the registry, and the data in the area corresponding to the next read instruction is read based on the next read instruction, until the registry is completed All read instructions in.
- the reading and writing device described below and the reading and writing method described above can be referred to each other.
- FIG. 5 is a kind of reading and writing device provided by an embodiment of the application.
- the structure diagram of the read-write device including:
- the write instruction receiving module 510 is configured to receive the write instruction
- the write strategy determination module 520 is configured to determine the write strategy corresponding to the write instruction according to the read information in the registry, where the read information is the information corresponding to the read instruction is stored in the registry after the read instruction is received;
- the write instruction execution module 530 is configured to execute the write instruction based on the write strategy.
- the write strategy determination module 520 includes:
- the judging unit is used to judge whether there is read information in the registry
- the write strategy determination unit is configured to determine the first write strategy if there is read information; if there is no read information, determine the second write strategy;
- the write instruction execution module 530 includes:
- the first execution unit is used to read out the area corresponding to the write instruction to the temporary memory based on the first write strategy, and execute the write instruction in the temporary memory, until all read operations corresponding to the read information are executed, and the registry There is no read information in the memory, and all data in the temporary memory is written back to the area corresponding to the write command;
- the second execution unit is configured to execute the write instruction in the area corresponding to the write instruction based on the second write strategy.
- it further includes:
- the read instruction receiving module is used to receive read instructions, and each read instruction includes read information
- the storage module is used to sequentially store the read information in the registry
- the read module is used to perform a read operation on the data in the target area based on the target read instruction
- the delete and data read module is used to delete the read information corresponding to the target read instruction from the registry after the read operation is completed, and read the data in the area corresponding to the next read instruction based on the next read instruction Operate until all the read instructions corresponding to the read information in the registry are completed.
- it further includes:
- the judging module is used for judging whether there is read information in the registry every first preset time interval
- the write module is used to write back the data of the executed write instruction in the temporary memory to the area corresponding to the write instruction if there is no read information in the registry.
- the registry further includes: pointing information corresponding to each read information, where the pointing information points to the next read information from the current read information;
- the judgment module includes:
- the judging unit is used for judging whether the last pointing information in the registration table is empty every first preset time interval
- the writing strategy determination unit includes:
- the write strategy determination subunit is used to determine the second write strategy if it is empty.
- the write strategy determination module 520 includes:
- a judging unit for judging whether there is target read information with a priority greater than a preset priority threshold in the registry
- the third write strategy determination unit is configured to determine the third write strategy if there is target read information
- the write instruction execution module includes:
- the first write unit is configured to read out the area corresponding to the write instruction to the temporary memory based on the third write strategy, and execute the write instruction in the temporary memory;
- the second writing unit is used to perform a read operation corresponding to the target read information, and when all the read operations corresponding to the target read information are executed, all data in the temporary memory is written back to the area corresponding to the write instruction.
- the read information includes: the address of the read data, the length of the read data, the time stamp of the read data, and the ID of the read data;
- the execution process of the read operation includes:
- the read duration judgment module is configured to judge whether the read duration of the data read of the read operation exceeds the preset threshold based on the time stamp of the read data every second preset time interval;
- the read operation execution module is used to stop the data reading operation if the preset threshold is exceeded, delete the corresponding read information in the registry, and confirm the completion of the read operation.
- it further includes:
- the writing duration judging module is used for judging whether the write duration of the write operation corresponding to the current write instruction is greater than the preset write time threshold every third preset time interval;
- the write operation stop and warning module is used to stop the write operation and send a warning message if it is greater than the preset write time threshold.
- the following introduces an electronic device provided by an embodiment of the present application.
- the electronic device described below and the reading and writing method described above can be referred to each other.
- This embodiment provides an electronic device, including:
- Memory used to store computer programs
- the processor is used to implement the steps of the above-mentioned reading and writing method when the computer program is executed.
- the following introduces a computer-readable storage medium provided by an embodiment of the present application.
- the computer-readable storage medium described below and the read-write method described above can be referred to each other.
- This embodiment provides a computer-readable storage medium, and a computer program is stored on the computer-readable storage medium.
- the computer program is executed by a processor, the steps of the above-mentioned reading and writing method are realized.
- the steps of the method or algorithm described in the embodiments disclosed in this document can be directly implemented by hardware, a software module executed by a processor, or a combination of the two.
- the software module can be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or all in the technical field. Any other known storage media.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Storage Device Security (AREA)
- Techniques For Improving Reliability Of Storages (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
一种读写方法、装置和电子设备及可读存储介质,该方法包括:接收到写指令;根据注册表中的读信息确定与写指令对应的写策略,其中,读信息是当接收到读指令后,将读指令对应的信息存储至注册表中的信息;基于写策略执行写指令。可见,本申请通过设置注册表,在执行读指令时,将在所述注册表中注册读信息,执行写指令前,根据注册表中的读信息确定与写指令对应的写策略,基于写策略执行写指令,提高读写处理效率。
Description
本申请要求于2020年01月17日提交中国专利局、申请号为202010052597.X、发明名称为“一种读写方法、装置和电子设备及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及读写技术领域,特别涉及一种读写方法、读写装置、电子设备和计算机可读存储介质。
网络存储主机是一个计算机系统,包括CPU、主板、内存、硬盘等硬件,上面运行Linux操作系统。网络存储主机可以对硬盘进行读写,读硬盘的时候不能写,写硬盘的时候不能读,也就是说:读写硬盘相同地址空间不能同时进行,如果同时进行,硬盘内的数据将不统一,所以针对硬盘要进行共享资源保护。常用的方法是rwlock读写锁,这是Linux提供的一套标准方法,即使用这套方法,读和写可以进行互斥,以防对相同地址空间同时进行读和写,导致数据不统一。
但是在网络存储主机中,要求读硬盘优先,写硬盘延后。多个客户端连接网络存储主机后,对硬盘的读要求延迟小,需要立即回复,读一般比写快的多;而对硬盘写的响应要求不高。Linux标准资源锁rwlock对读和写的处理是依次进行,也即,若写操作先进行,即便有再多读客户端的读操作都要等待写操作完成后才能进行,易造成较多的读操作延迟。
因此,如何提供一种解决上述技术问题的方案是本领域技术人员目前需要解决的问题。
发明内容
本申请的目的是提供一种读写方法、读写装置、电子设备和计算机可读存储介质,能够提高读写处理效率。其具体方案如下:
本申请提供一种读写方法,包括:
接收到写指令;
根据注册表中的读信息确定与所述写指令对应的写策略,其中,所述读信息是当接收到读指令后,将所述读指令对应的信息存储至所述注册表中的信息;
基于所述写策略执行所述写指令。
可选的,所述根据注册表中的读信息确定与所述写指令对应的写策略,包括:
判断所述注册表是否存在所述读信息;
若存在所述读信息,则确定第一写策略;若不存在所述读信息,则确定第二写策略;
对应的,所述基于所述写策略执行所述写指令,包括:
基于所述第一写策略,读出与所述写指令对应的区域至临时内存,且在所述临时内存中执行所述写指令,直至当所有所述读信息对应的读操作执行完成后,且所述注册表中不存在所述读信息,将所述临时内存中的所有数据写回与所述写指令对应的区域;
或,基于所述第二写策略,在与所述写指令对应的区域执行所述写指令。
可选的,所述接收到写指令之前,还包括:
接收到所述读指令,每个所述读指令包括所述读信息;
依次将所述读信息存储至所述注册表中;
基于目标读指令对目标区域的数据执行所述读操作;
当所述读操作执行完成后,将与所述目标读指令对应的读信息从所述注册表中删除,并基于下一个读指令对与所述下一个读指令对应的区域的数据执行所述读操作,直至完成所述注册表中的所述读信息对应的所有所述读指令。
可选的,所述在所述临时内存中执行所述写指令之后,还包括:
每隔第一预设时间间隔,判断所述注册表是否存在所述读信息;
若所述注册表不存在所述读信息,则将所述临时内存中的执行完成所述写指令的数据写回与所述写指令对应的区域。
可选的,所述注册表还包括:与每个所述读信息对应的指向信息,其中,所述指向信息是由当前的读信息指向下一个读信息;
对应的,所述每隔第一预设时间间隔,判断所述注册表是否存在所述读信息,包括:
每隔所述第一预设时间间隔判断所述注册表中的最后一个指向信息是否为空;
对应的,所述若不存在所述读信息,则确定第二写策略,包括:
若为空,则确定所述第二写策略。
可选的,所述根据注册表中的读信息确定与所述写指令对应的写策略,包括:
判断所述注册表是否存在优先级大于预设优先级阈值的目标读信息;
若存在所述目标读信息,则确定第三写策略;
对应的,所述基于所述写策略执行所述写指令,包括:
基于所述第三写策略,读出与所述写指令对应的区域至临时内存,且在所述临时内存中执行所述写指令;
执行与所述目标读信息对应的读操作,当所有的所述目标读信息对应的读操作执行完成后,将所述临时内存中的所有数据写回与所述写指令对应的区域。
可选的,所述读信息包括:读取数据的地址、读取数据的长度、读取数据的时间戳、读取数据的ID;
对应的,所述读操作的执行过程,包括:
每隔第二预设时间间隔,基于读取数据的时间戳判断所述读操作的数据读取的读时长是否超过预设阈值;
若超过所述预设阈值,则停止所述数据读取的操作,并删除所述注册表中相应的读信息,确定完成所述读操作。
可选的,所述基于所述写策略执行所述写指令之后,还包括:
每隔第三预设时间间隔,判断当前写指令对应的写操作的写时长是否大于预设写时间阈值;
若大于所述预设写时间阈值,则停止写操作,并发出警示信息。
本申请提供一种读写装置,包括:
写指令接收模块,用于接收到写指令;
写策略确定模块,用于根据注册表中的读信息确定与所述写指令对应的写策略,其中,所述读信息是当接收到读指令后,将所述读指令对应的信息存储至所述注册表中的信息;
写指令执行模块,用于基于所述写策略执行所述写指令。
本申请提供一种电子设备,包括:
存储器,用于存储计算机程序;
处理器,用于执行所述计算机程序时实现如上述读写方法的步骤。
本申请提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上述读写方法的步骤。
本申请提供一种读写方法,包括:接收到写指令;根据注册表中的读信息确定与写指令对应的写策略,其中,读信息是当接收到读指令后,将读指令对应的信息存储至注册表中的信息;基于写策略执行写指令。
可见,本申请通过设置注册表,在执行读指令时,将在所述注册表中注册读信息,执行写指令前,根据注册表中的读信息确定与写指令对应的写策略,基于写策略执行写指令,提高读写处理效率。
本申请同时还提供了一种读写装置、一种电子设备和计算机可读存储介质,均具有上述有益效果,在此不再赘述。
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。
图1为本申请实施例提供的一种读写方法的流程图;
图2为本申请实施例提供的一种注册表中的信息结构示意图;
图3为本申请实施例提供的另一种读写方法的流程示意图;
图4为本申请实施例提供的另一种读写方法的流程示意图;
图5为本申请实施例所提供的一种读写装置的结构示意图。
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
相关技术中Linux标准资源锁rwlock对读和写的处理是依次进行,也即,若写操作先进行,即便有再多读客户端的读操作都要等待写操作完成后才能进行,易造成较多的读操作延迟。基于上述技术问题,本实施例提供一种读写方法,具体请参考图1,图1为本申请实施例提供的一种读写方法的流程图,具体包括:
S110、接收到写指令。
本实施例基于网络存储主机,其中,网络存储主机包括:CPU、主板、内存、硬盘等硬件,运行Linux操作系统。
本步骤的目的是接收到写指令,可以理解的是,写指令包括:写地址也即与写指令对应的区域。
S120、根据注册表中的读信息确定与写指令对应的写策略。
其中,读信息是当接收到读指令后,将读指令对应的信息存储至注册表中的信息。
参考图2,图2为本申请实施例提供的一种注册表中的信息结构示意图;读信息注册表使用单向链表实现。
本实施例不对写策略进行限定,在一种可实现的实施方式中,根据注册表中的读信息确定与写指令对应的写策略的方式可以是判断注册表中是否存在读信息,如果存在,则确定第一写策略,如果不存在,则确定第二写策略,第一写策略是:读出与写指令对应的区域至临时内存,且在临时 内存中执行写指令,直至当所有读信息对应的读操作执行完成后,且注册表中不存在读信息,将临时内存中的所有数据写回与写指令对应的区域,第二写策略是:在与写指令对应的区域执行写指令。
在另一种可实现的实施方式中,根据注册表中的读信息确定与写指令对应的写策略的方式,可以是判断注册表是否存在优先级大于预设优先级阈值的目标读信息;若存在目标读信息,则确定第三写策略,若不存在目标读信息,则确定第四写策略,其中,第三写策略是:读出与写指令对应的区域至临时内存,且在临时内存中执行写指令;执行与目标读信息对应的读操作,当所有的目标读信息对应的读操作执行完成后,将临时内存中的所有数据写回与写指令对应的区域,第四写策略是:在与写指令对应的区域执行写指令。
在另一种可实现的实施方式中,根据注册表中的读信息确定与写指令对应的写策略的方式,可以是对确定注册表中的第一个读信息的优先级,比较该优先级与写指令的优先级的大小,若写指令的优先级大于第一个读信息的优先级,则确定第五写策略,若写指令的优先级小于第一个读信息的优先级,则确定第六写策略,第五写策略是:在与写指令对应的区域执行写指令,第六写策略是:读出与写指令对应的区域至临时内存,在临时内存中执行写指令,执行与第一个读信息对应的读操作,当该读操作完成后,删除第一个读信息,然后下一个读信息作为新的第一个读信息,执行确定注册表中的第一个读信息的优先级的步骤,当第一个读信息对应的优先级小于写指令的优先级时,将临时内存中的所有数据写回与写指令对应的区域。
S130、基于写策略执行写指令。
进一步的,在步骤S130之后,还包括:每隔第三预设时间间隔,判断当前写指令对应的写操作的写时长是否大于预设写时间阈值;若大于预设写时间阈值,则停止写操作,并发出警示信息。
本步骤中,每隔第三预设时间间隔判断当前写指令对应的写操作的写时长是否大于预设写时间阈值,目的是将写时长限定在一定范围内,保证后续的写操作和读操作的高效率完成。如果大于预设写时间阈值,停止写操作,发出警示信息,若小于预设小时间阈值,则继续执行写操作。
基于上述技术方案,本实施例通过设置注册表,在执行读指令时,将在注册表中注册读信息,执行写指令前,根据注册表中的读信息确定与写指令对应的写策略,基于写策略执行写指令,提高读写处理效率。
基于上述实施例,请参考图3,图3为本申请实施例提供的另一种读写方法的流程示意图,包括:
S310、接收到写指令。
进一步的,在步骤S310之前,还包括:接收到读指令,每个读指令包括读信息;依次将读信息存储至注册表中;基于目标读指令对目标区域的数据执行读操作;当读操作执行完成后,将与目标读指令对应的读信息从注册表中删除,并基于下一个读指令对与下一个读指令对应的区域的数据执行读操作,直至完成注册表中的读信息对应的所有读指令。
具体的,读信息包括:读取数据的地址、读取数据的长度、读取数据的时间戳、读取数据的ID、指向信息,具体请参考表1,其中,Address为读取数据的地址,Length为读取数据的长度,Timestamp为读取数据的时间戳,Name为读取数据的ID,NEXT为指向信息,用于指向下一个读信息,以使串起来形成单相链表。
表1读信息
可以理解的是,每一个读信息在注册表中的内存大小至少为56字节,在一些可实现的实施方式中,读信息还可以包括Priority,即操作优先级,用于判断是否可以执行写操作,此时,一个读信息在注册表中的内存大小为57字节。
当接收到至少一个读指令时(读指令可以是同时接收到,可以是依次接收到),依次将对应的读信息存储至注册表中。
S320、判断注册表是否存在读信息。
其中,读信息是当接收到读指令后,将读指令对应的信息存储至注册表中的信息。其中,注册表中包括读信息,可以理解的是,每一个读信息对应一个读指令,当读指令完成后,删除注册表中的读信息,因此,注册表中的读信息是所有未处理完成的读信息。若注册表存在读信息,则执行步骤S330,若注册表不存在读信息,则执行步骤S350。
请参考图2,读信息注册表使用单向链表实现。在执行完成读信息A对应的读指令对应的读操作A后,执行读信息B对应的读操作B;当执行完读操作B后,执行读信息C对应的读操作C;当执行完读操作C后,执行读信息D对应的读操作D;当执行完读操作D后,执行读信息E对应的读操作E;当执行完读操作E后,执行写指令对应的写操作。
S330、若存在读信息,则确定第一写策略。
S340、基于第一写策略,读出与写指令对应的区域至临时内存,且在临时内存中执行写指令,直至当所有读信息对应的读操作执行完成后,且注册表中不存在读信息,将临时内存中的所有数据写回与写指令对应的区域。
读出与写指令对应的区域至临时内存,在临时内存中执行写执行。可以理解的是,在接收到写指令的同时或者之前或者之后,接收到读指令,将与读指令对应的读信息存储至注册表中,此时,当执行完成注册表中所有的预读信息对应的读指令之后,再执行写指令。
例如,当注册表中存在第一个读信息时,并且未完成该读信息对应的读指令,接收到一个写指令,此时读出与写指令对应的区域至临时内存,且在临时内存中执行写指令,同时第一个读指令未完成时,接收到第二个读指令,则将第二个读指令对应的读信息存储至注册表中,当第一个读指令执行完成后,删除在注册表中对应的读信息,执行第二读指令,直至注册表中没有读信息后,将临时内存中与写指令对应的数据写回与写指令对应的区域,可以理解的是,在读指令并未完全执行完成之前,再次接收到 一个写指令,则该写指令等待,当上一个写指令完成写操作后,再执行该写指令。
进一步的,在临时内存中执行写指令之后,还包括:每隔第一预设时间间隔,判断注册表是否存在读信息;若注册表不存在读信息,则将临时内存中的执行完成写指令的数据写回与写指令对应的区域。
进一步的,注册表还包括:与每个读信息对应的指向信息,其中,指向信息是由当前的读信息指向下一个读信息;对应的,每隔第一预设时间间隔,判断注册表是否存在读信息,包括:每隔第一预设时间间隔判断注册表中的最后一个指向信息是否为空;对应的,若不存在读信息,则确定第二写策略,包括:若为空,则确定第二写策略。
其中,指向信息,大小为4字节,指向下一个读信息,串起来形成一个单向链表即注册表。可以理解的是,当接收到写指令后,判断注册表中是否还有读信息,具体的判断方法可以是判断注册表中的最后一个指向信息是否为空,如果为空,则说明后面没有读信息注册。这时,则确定第二写策略,可以直接进行硬盘对应数据区域写操作;如果不为空,确定第一写策略,则读出硬盘对应区域到临时内存中,修改其中数据,即执行读出与写指令对应的区域至临时内存,且在临时内存中执行写指令,当在临时内存中完成写指令的操作后,每隔第一预设时间间隔即50ms查看一次注册表中的最后一个指向信息是否为空,直到为空说明没有读信息锁住,则临时内存中的所有数据写回与写指令对应的区域。
S350、若不存在读信息,则确定第二写策略。
S360、基于第二写策略,在与写指令对应的区域执行写指令。
进一步的,还包括:接收查询指令;基于查询指令查询注册表中的读信息。可以理解的是,通过查询命令,可以打印注册表中各个读信息,其中读信息包括:读取数据的地址、读取数据的长度、读取数据的时间戳、读取数据的ID即发起者名称,其中,依据时间戳可以得到读开始时间、读持续时间等信息。
本发明提出一种网络存储主机上Linux读优先硬盘保护锁的设计技术方法。此方法共分为三部分:数据结构、读操作处理、写操作处理,能够提高读优先写延后应用处理效率,其中数据结构即注册表中的各个读信息 处理流程。该读写方法的流程包括:设置一张信息的注册表,接收到读指令进行读操作时,向注册表中注册信息即向该注册表中存储于读指令对应的读信息;接收到写指令,执行写操作时,当注册表中还存在读信息时,先读出硬盘内容即先读出与写指令对应的区域至临时内存,且在临时内存中执行写指令,然后判断注册表中是否有读信息,如果没有,说明没有读操作,进行写硬盘;如果有,说明有读操作在占用硬盘,写操作必须等待,直到没有读操作后,才能写硬盘。
基于上述技术方案,本实施例通过设置注册表,在执行读指令时,将在注册表中注册读信息,执行写指令前,若注册表中不存在读信息,则直接执行写指令,若注册表中存在读信息,则操作等待,在临时内存中执行写指令,在同时存在读写指令的时候,满足了快速读的需求,提高了读指令处理效率。
基于上述实施例,请参考图4,图4为本申请实施例提供的另一种读写方法的流程示意图,包括:
S410、接收到写指令。
S420、判断注册表是否存在优先级大于预设优先级阈值的目标读信息。
其中,依次将读信息存储至注册表中,读信息包括:读取数据的地址、读取数据的长度、读取数据的时间戳、读取数据的ID、操作优先级。对每一个读操作设置对应的优先级。当优先级大于预设优先级阈值时,则该目标读信息需要优先执行。当注册表中存在目标读信息时,执行步骤S430,当注册表中不存在目标读信息时,则在与写指令对应的区域执行写指令。
S430、若存在目标读信息,则确定第三写策略。
其中,读信息是当接收到读指令后,将读指令对应的信息存储至注册表中的信息。
S440、基于第三写策略,读出与写指令对应的区域至临时内存,且在临时内存中执行写指令。
S450、执行与目标读信息对应的读操作,当所有的目标读信息对应的读操作执行完成后,将临时内存中的所有数据写回与写指令对应的区域。
基于上述技术方案,本实施例提供对读操作设置优先级,可以优先完成优先级大于预设优先级阈值的读信息对应的读操作,保证客户的读操作能够高效率完成
基于上述实施例,读信息包括:读取数据的地址、读取数据的长度、读取数据的时间戳、读取数据的ID;对应的,读操作的执行过程,包括:每隔第二预设时间间隔,基于读取数据的时间戳判断读操作的数据读取的读时长是否超过预设阈值;若超过预设阈值,则停止数据读取的操作,并删除注册表中相应的读信息,确定完成读操作。
本实施例不对第二预设时间间隔进行限定,可以是50ms。时间戳能够判断读取数据的读时长,当读时长超过预设阈值时,读解锁,不再执行该读指令,确定该读指令完成。本实施例不对读时长进行限定,可以是500ms。进一步的,当读时长超过预设阈值时,还可以进行报警,本实施例不对报警的方式进行限定,用户可自定义设置。
申请读信息的内存,把读取数据的地址、读取数据的长度、读取数据的时间戳、读者名字构成读信息,然后将读信息插入到单向链表即注册表中,此过程就是读Lock,读锁住。依据读指令对硬盘数据进行读取。当数据读取完毕后,删除注册表中对应读信息,释放曾经申请的内存,此过程就是读Unlock,读解锁。读管理线程:全局有一个读管理线程,每隔即第二预设时间间隔50ms轮询一次,查看整个注册表中各个读信息,如果读信息对应的读时长超过设置的全局读时长门限Threshold即预设阈值(此值可设,默认500ms),则进行报警,并把此读操作进行Unlock,不允许读操作无限期锁住。
当数据读取完成后,将与目标读指令对应的读信息从注册表中删除,并基于下一个读指令对与下一个读指令对应的区域的数据进行数据读取的步骤,直至完成注册表中的所有读指令。
下面对本申请实施例提供的一种读写装置进行介绍,下文描述的读写装置与上文描述的读写方法可相互对应参照,参考图5,图5为本申请实施例所提供的一种读写装置的结构示意图,包括:
写指令接收模块510,用于接收到写指令;
写策略确定模块520,用于根据注册表中的读信息确定与写指令对应的写策略,其中,读信息是当接收到读指令后,将读指令对应的信息存储至注册表中的信息;
写指令执行模块530,用于基于写策略执行写指令。
在一些具体的实施例中,写策略确定模块520,包括:
判断单元,用于判断注册表是否存在读信息;
写策略确定单元,用于若存在读信息,则确定第一写策略;若不存在读信息,则确定第二写策略;
对应的,写指令执行模块530,包括:
第一执行单元,用于基于第一写策略,读出与写指令对应的区域至临时内存,且在临时内存中执行写指令,直至当所有读信息对应的读操作执行完成后,且注册表中不存在读信息,将临时内存中的所有数据写回与写指令对应的区域;
第二执行单元,用于基于第二写策略,在与写指令对应的区域执行写指令。
在一些具体的实施例中,还包括:
读指令接收模块,用于接收到读指令,每个读指令包括读信息;
存储模块,用于依次将读信息存储至注册表中;
读取模块,用于基于目标读指令对目标区域的数据执行读操作;
删除与数据读取模块,用于当读操作执行完成后,将与目标读指令对应的读信息从注册表中删除,并基于下一个读指令对与下一个读指令对应的区域的数据执行读操作,直至完成注册表中的读信息对应的所有读指令。
在一些具体的实施例中,还包括:
判断模块,用于每隔第一预设时间间隔,判断注册表是否存在读信息;
写模块,用于若注册表不存在读信息,则将临时内存中的执行完成写指令的数据写回与写指令对应的区域。
在一些具体的实施例中,注册表还包括:与每个读信息对应的指向信息,其中,指向信息是由当前的读信息指向下一个读信息;
对应的,判断模块,包括:
判断单元,用于每隔第一预设时间间隔判断注册表中的最后一个指向信息是否为空;
对应的,写策略确定单元,包括:
写策略确定子单元,用于若为空,则确定第二写策略。
在一些具体的实施例中,写策略确定模块520,包括:
判断单元,用于判断注册表是否存在优先级大于预设优先级阈值的目标读信息;
第三写策略确定单元,用于若存在目标读信息,则确定第三写策略;
对应的,写指令执行模块,包括:
第一写单元,用于基于第三写策略,读出与写指令对应的区域至临时内存,且在临时内存中执行写指令;
第二写单元,用于执行与目标读信息对应的读操作,当所有的目标读信息对应的读操作执行完成后,将临时内存中的所有数据写回与写指令对应的区域。
在一些具体的实施例中,读信息包括:读取数据的地址、读取数据的长度、读取数据的时间戳、读取数据的ID;
对应的,读操作的执行过程,包括:
读时长判断模块,用于每隔第二预设时间间隔,基于读取数据的时间戳判断读操作的数据读取的读时长是否超过预设阈值;
读操作执行模块,用于若超过预设阈值,则停止数据读取的操作,并删除注册表中相应的读信息,确定完成读操作。
在一些具体的实施例中,还包括:
写时长判断模块,用于每隔第三预设时间间隔,判断当前写指令对应的写操作的写时长是否大于预设写时间阈值;
写操作停止与警示模块,用于若大于预设写时间阈值,则停止写操作,并发出警示信息。
由于读写装置部分的实施例与读写方法部分的实施例相互对应,因此读写装置部分的实施例请参见读写方法部分的实施例的描述,这里暂不赘述。
下面对本申请实施例提供的一种电子设备进行介绍,下文描述的电子设备与上文描述的读写方法可相互对应参照。
本实施例提供一种电子设备,包括:
存储器,用于存储计算机程序;
处理器,用于执行计算机程序时实现如上述读写方法的步骤。
由于电子设备部分的实施例与读写方法部分的实施例相互对应,因此电子设备部分的实施例请参见读写方法部分的实施例的描述,这里暂不赘述。
下面对本申请实施例提供的一种计算机可读存储介质进行介绍,下文描述的计算机可读存储介质与上文描述的读写方法可相互对应参照。
本实施例提供一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现如上述读写方法的步骤。
由于计算机可读存储介质部分的实施例与读写方法部分的实施例相互对应,因此计算机可读存储介质部分的实施例请参见读写方法部分的实施例的描述,这里暂不赘述。
说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。
专业人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于 随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。
以上对本申请所提供的一种读写方法、读写装置、电子设备及计算机可读存储介质进行了详细介绍。本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想。应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以对本申请进行若干改进和修饰,这些改进和修饰也落入本申请权利要求的保护范围内。
Claims (11)
- 一种读写方法,其特征在于,包括:接收到写指令;根据注册表中的读信息确定与所述写指令对应的写策略,其中,所述读信息是当接收到读指令后,将所述读指令对应的信息存储至所述注册表中的信息;基于所述写策略执行所述写指令。
- 根据权利要求1所述的读写方法,其特征在于,所述根据注册表中的读信息确定与所述写指令对应的写策略,包括:判断所述注册表是否存在所述读信息;若存在所述读信息,则确定第一写策略;若不存在所述读信息,则确定第二写策略;对应的,所述基于所述写策略执行所述写指令,包括:基于所述第一写策略,读出与所述写指令对应的区域至临时内存,且在所述临时内存中执行所述写指令,直至当所有所述读信息对应的读操作执行完成后,且所述注册表中不存在所述读信息,将所述临时内存中的所有数据写回与所述写指令对应的区域;或,基于所述第二写策略,在与所述写指令对应的区域执行所述写指令。
- 根据权利要求2所述的读写方法,其特征在于,所述接收到写指令之前,还包括:接收到所述读指令,每个所述读指令包括所述读信息;依次将所述读信息存储至所述注册表中;基于目标读指令对目标区域的数据执行所述读操作;当所述读操作执行完成后,将与所述目标读指令对应的读信息从所述注册表中删除,并基于下一个读指令对与所述下一个读指令对应的区域的数据执行所述读操作,直至完成所述注册表中的所述读信息对应的所有所述读指令。
- 根据权利要求2所述的读写方法,其特征在于,所述在所述临时内存中执行所述写指令之后,还包括:每隔第一预设时间间隔,判断所述注册表是否存在所述读信息;若所述注册表不存在所述读信息,则将所述临时内存中的执行完成所述写指令的数据写回与所述写指令对应的区域。
- 根据权利要求4所述的读写方法,其特征在于,所述注册表还包括:与每个所述读信息对应的指向信息,其中,所述指向信息是由当前的读信息指向下一个读信息;对应的,所述每隔第一预设时间间隔,判断所述注册表是否存在所述读信息,包括:每隔所述第一预设时间间隔判断所述注册表中的最后一个指向信息是否为空;对应的,所述若不存在所述读信息,则确定第二写策略,包括:若为空,则确定所述第二写策略。
- 根据权利要求1所述的读写方法,其特征在于,所述根据注册表中的读信息确定与所述写指令对应的写策略,包括:判断所述注册表是否存在优先级大于预设优先级阈值的目标读信息;若存在所述目标读信息,则确定第三写策略;对应的,所述基于所述写策略执行所述写指令,包括:基于所述第三写策略,读出与所述写指令对应的区域至临时内存,且在所述临时内存中执行所述写指令;执行与所述目标读信息对应的读操作,当所有的所述目标读信息对应的读操作执行完成后,将所述临时内存中的所有数据写回与所述写指令对应的区域。
- 根据权利要求2至6任一项所述的读写方法,其特征在于,所述读信息包括:读取数据的地址、读取数据的长度、读取数据的时间戳、读取数据的ID;对应的,所述读操作的执行过程,包括:每隔第二预设时间间隔,基于读取数据的时间戳判断所述读操作的数据读取的读时长是否超过预设阈值;若超过所述预设阈值,则停止所述数据读取的操作,并删除所述注册表中相应的读信息,确定完成所述读操作。
- 根据权利要求1所述的读写方法,其特征在于,所述基于所述写策略执行所述写指令之后,还包括:每隔第三预设时间间隔,判断当前写指令对应的写操作的写时长是否大于预设写时间阈值;若大于所述预设写时间阈值,则停止写操作,并发出警示信息。
- 一种读写装置,其特征在于,包括:写指令接收模块,用于接收到写指令;写策略确定模块,用于根据注册表中的读信息确定与所述写指令对应的写策略,其中,所述读信息是当接收到读指令后,将所述读指令对应的信息存储至所述注册表中的信息;写指令执行模块,用于基于所述写策略执行所述写指令。
- 一种电子设备,其特征在于,包括:存储器,用于存储计算机程序;处理器,用于执行所述计算机程序时实现如权利要求1至8任一项所述读写方法的步骤。
- 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至8任一项所述读写方法的步骤。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US17/793,454 US11868620B2 (en) | 2020-01-17 | 2020-06-24 | Read-write method and apparatus, electronic device, and readable memory medium |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010052597.X | 2020-01-17 | ||
CN202010052597.XA CN111261206B (zh) | 2020-01-17 | 2020-01-17 | 一种读写方法、装置和电子设备及可读存储介质 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2021143049A1 true WO2021143049A1 (zh) | 2021-07-22 |
Family
ID=70950732
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2020/098034 WO2021143049A1 (zh) | 2020-01-17 | 2020-06-24 | 一种读写方法、装置和电子设备及可读存储介质 |
Country Status (3)
Country | Link |
---|---|
US (1) | US11868620B2 (zh) |
CN (1) | CN111261206B (zh) |
WO (1) | WO2021143049A1 (zh) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111261206B (zh) * | 2020-01-17 | 2022-03-08 | 苏州浪潮智能科技有限公司 | 一种读写方法、装置和电子设备及可读存储介质 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2006244191A (ja) * | 2005-03-04 | 2006-09-14 | Fujitsu Ltd | 計算機管理プログラム、管理対象計算機制御プログラム、計算機管理装置、管理対象計算機、計算機管理システム、計算機管理方法、管理対象計算機制御方法 |
US20120151110A1 (en) * | 2010-12-14 | 2012-06-14 | Richard Pointon | Process-safe read/write locks |
CN105550567A (zh) * | 2015-12-09 | 2016-05-04 | 国云科技股份有限公司 | 一种Windows虚拟机USB设备读写权限管控方法 |
CN109388645A (zh) * | 2017-08-11 | 2019-02-26 | 腾讯科技(深圳)有限公司 | 指令执行方法、指令执行装置及存储介质 |
CN111261206A (zh) * | 2020-01-17 | 2020-06-09 | 苏州浪潮智能科技有限公司 | 一种读写方法、装置和电子设备及可读存储介质 |
Family Cites Families (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6466932B1 (en) * | 1998-08-14 | 2002-10-15 | Microsoft Corporation | System and method for implementing group policy |
CN1232909C (zh) * | 2003-09-29 | 2005-12-21 | 港湾网络有限公司 | 路由器流量管理芯片缓存管理实现方法与系统 |
US20050289143A1 (en) * | 2004-06-23 | 2005-12-29 | Exanet Ltd. | Method for managing lock resources in a distributed storage system |
US7562180B2 (en) * | 2006-03-28 | 2009-07-14 | Nokia Corporation | Method and device for reduced read latency of non-volatile memory |
JP5066209B2 (ja) * | 2010-03-18 | 2012-11-07 | 株式会社東芝 | コントローラ、データ記憶装置、及びプログラム |
US10296517B1 (en) * | 2011-06-30 | 2019-05-21 | EMC IP Holding Company LLC | Taking a back-up software agnostic consistent backup during asynchronous replication |
US10754710B1 (en) * | 2012-06-20 | 2020-08-25 | Amazon Technologies, Inc. | Transactional watch mechanism |
US9952788B2 (en) * | 2015-09-29 | 2018-04-24 | Cnex Labs, Inc. | Method and apparatus for providing a shared nonvolatile memory system using a distributed FTL scheme |
CN107885456B (zh) * | 2016-09-29 | 2022-09-16 | 北京忆恒创源科技股份有限公司 | 减少io命令访问nvm的冲突 |
CN106933512B (zh) * | 2017-02-27 | 2020-03-27 | 深圳怡化电脑股份有限公司 | 一种数据读写的方法及其设备 |
CN109032522B (zh) * | 2018-07-25 | 2021-06-29 | 浪潮电子信息产业股份有限公司 | 固态硬盘的数据读取方法以及固态硬盘 |
-
2020
- 2020-01-17 CN CN202010052597.XA patent/CN111261206B/zh active Active
- 2020-06-24 WO PCT/CN2020/098034 patent/WO2021143049A1/zh active Application Filing
- 2020-06-24 US US17/793,454 patent/US11868620B2/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2006244191A (ja) * | 2005-03-04 | 2006-09-14 | Fujitsu Ltd | 計算機管理プログラム、管理対象計算機制御プログラム、計算機管理装置、管理対象計算機、計算機管理システム、計算機管理方法、管理対象計算機制御方法 |
US20120151110A1 (en) * | 2010-12-14 | 2012-06-14 | Richard Pointon | Process-safe read/write locks |
CN105550567A (zh) * | 2015-12-09 | 2016-05-04 | 国云科技股份有限公司 | 一种Windows虚拟机USB设备读写权限管控方法 |
CN109388645A (zh) * | 2017-08-11 | 2019-02-26 | 腾讯科技(深圳)有限公司 | 指令执行方法、指令执行装置及存储介质 |
CN111261206A (zh) * | 2020-01-17 | 2020-06-09 | 苏州浪潮智能科技有限公司 | 一种读写方法、装置和电子设备及可读存储介质 |
Also Published As
Publication number | Publication date |
---|---|
US20230117060A1 (en) | 2023-04-20 |
CN111261206B (zh) | 2022-03-08 |
CN111261206A (zh) | 2020-06-09 |
US11868620B2 (en) | 2024-01-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9128615B2 (en) | Storage systems that create snapshot queues | |
US7234004B2 (en) | Method, apparatus and program product for low latency I/O adapter queuing in a computer system | |
JP2008507201A5 (zh) | ||
WO2021093365A1 (zh) | 一种gpu显存管理控制方法及相关装置 | |
WO2021169496A1 (zh) | 数据读取方法、装置、设备及存储介质 | |
WO2022048358A1 (zh) | 数据处理方法、装置及存储介质 | |
US20100262810A1 (en) | Concurrent instruction operation method and device | |
WO2021143049A1 (zh) | 一种读写方法、装置和电子设备及可读存储介质 | |
WO2023124422A1 (zh) | 一种数据读写的控制方法及电子设备 | |
WO2021174698A1 (zh) | 虚拟机快照创建方法、装置、存储介质及计算机设备 | |
WO2024188050A1 (zh) | 分布式文件系统的文件锁管理方法、设备及介质 | |
WO2023155591A1 (zh) | 进度信息管控方法、微服务装置、电子设备及存储介质 | |
WO2024113838A1 (zh) | 处理器设置方法、装置、电子设备及存储介质 | |
WO2021139113A1 (zh) | 交易信息的加签方法、装置、计算机设备和存储介质 | |
CN115794446B (zh) | 一种消息处理方法、装置、电子设备和存储介质 | |
WO2020224218A1 (zh) | 基于hbase的数据写入方法、系统、装置及可读存储介质 | |
CN108062224B (zh) | 基于文件句柄的数据读写方法、装置及计算设备 | |
CN109426563B (zh) | 一种进程管理方法及装置 | |
JP5884566B2 (ja) | バッチ処理システム、進捗状況確認装置、進捗状況確認方法、及びプログラム | |
US20130198138A1 (en) | Model for capturing audit trail data with reduced probability of loss of critical data | |
WO2021159608A1 (zh) | 一种基于Protocol Buffer的镜像缓存方法 | |
US9703497B2 (en) | Storage system and storage control method | |
US6816954B2 (en) | System and method for tuning retry performance | |
CN111143418A (zh) | 一种数据库读取数据方法、装置、设备及存储介质 | |
WO2022126534A1 (zh) | 数据处理方法及相关设备 |
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: 20914009 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 20914009 Country of ref document: EP Kind code of ref document: A1 |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 20914009 Country of ref document: EP Kind code of ref document: A1 |