CN117991982A - Hard disk read-write method, device and apparatus - Google Patents

Hard disk read-write method, device and apparatus Download PDF

Info

Publication number
CN117991982A
CN117991982A CN202410005489.5A CN202410005489A CN117991982A CN 117991982 A CN117991982 A CN 117991982A CN 202410005489 A CN202410005489 A CN 202410005489A CN 117991982 A CN117991982 A CN 117991982A
Authority
CN
China
Prior art keywords
scheduling queue
data stream
request
hard disk
queue
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410005489.5A
Other languages
Chinese (zh)
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.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua 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 Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202410005489.5A priority Critical patent/CN117991982A/en
Publication of CN117991982A publication Critical patent/CN117991982A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • G06F3/0611Improving I/O performance in relation to response time
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0659Command handling arrangements, e.g. command buffers, queues, command scheduling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0676Magnetic disk device

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)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to the technical field of storage, in particular to a method, equipment and a device for reading and writing a hard disk, which are used for reducing seek time when the hard disk executes corresponding operation based on an operation request in a scheduling queue, so as to improve the reading and writing performance of the hard disk. The embodiment of the application determines a scheduling queue corresponding to any one data stream aiming at any one data stream; adding an operation request in any one data stream into a determined scheduling queue, wherein the operation request comprises a read request or a write request; and if the operation request in the scheduling queue meets the request issuing condition, issuing the operation request in the scheduling queue to the hard disk so as to enable the hard disk to execute corresponding operation.

Description

Hard disk read-write method, device and apparatus
Technical Field
The present application relates to the field of storage technologies, and in particular, to a method, an apparatus, and a device for reading and writing a hard disk.
Background
The hard disk is generally used as a storage device, and is usually accessed to a computer, a server or an embedded device for use. The devices can be collectively called a host using a hard disk, and in the use process, the host side issues an operation request to the hard disk, the hard disk executes corresponding operation after receiving the operation request, and then the execution result and data are returned to the host side.
A mechanical Hard Disk (HDD) is one of the Hard disks as a common storage medium. The mechanical hard disk consists of magnetic head, motor and several disks. The working principle is that when the host computer is to read or write a section of data in a certain area of the hard disk, the hard disk needs to move the motor and the disk to corresponding positions to start to execute the read operation or the write operation. Among them, the process of the motor and the disk movement is called a seek process.
Typically, a mechanical hard disk includes multiple partitions, and operations need to be performed on the locations of the multiple partitions at the same time, so that the above process accesses the hard disk for multiple data streams.
For the case of accessing a hard disk by multiple data streams, in the related art, a queue is generally created for one process, and operation requests in all data streams to be processed by one process are added to the queue, and since there may be a large difference between access addresses of operation requests in different data streams, after the hard disk performs an operation request of one data stream, it takes a long seek time to move a magnetic head and a disk to an address to be accessed by the next data stream, so that when the hard disk performs a corresponding operation based on the operation request in the queue, it takes a long seek time to reduce performance.
Disclosure of Invention
The application aims to provide a method, equipment and a device for reading and writing a hard disk, which are used for reducing seek time when the hard disk executes corresponding operation based on an operation request in a scheduling queue, so as to improve the reading and writing performance of the hard disk.
In a first aspect, the present application provides a hard disk read-write method, the method including:
determining a scheduling queue corresponding to any one data stream according to the any one data stream; wherein one of the data streams corresponds to one of the scheduling queues;
Adding an operation request in any one data stream to the determined scheduling queue, wherein the operation request comprises at least one of a read request and a write request;
and if the number of the operation requests in the scheduling queue meets the request issuing condition, issuing the operation requests in the scheduling queue to a hard disk so as to enable the hard disk to execute corresponding operations.
In a second aspect, the present application provides a hard disk read-write apparatus, the apparatus comprising:
the determining module is used for determining a scheduling queue corresponding to any one data stream according to the any one data stream; wherein one of the data streams corresponds to one of the scheduling queues;
A joining module, configured to join an operation request in the arbitrary data stream to the determined scheduling queue, where the operation request includes at least one of a read request and a write request;
and the issuing module is used for issuing the operation requests in the dispatching queue to a hard disk if the number of the operation requests in the dispatching queue meets the issuing request condition so as to enable the hard disk to execute corresponding operations.
In an alternative embodiment, the determining module is specifically configured to:
For any one data stream, determining a scheduling queue corresponding to the any one data stream by inquiring a mapping relation between a preset sequence number and the scheduling queue based on the sequence number of the any one data stream.
An alternative embodiment is also for:
If the sequence number of any one data stream is not queried in the mapping relation, creating a corresponding new scheduling queue for the any one data stream;
And updating the mapping relation based on the sequence number of any one data stream and the new scheduling queue.
In an alternative embodiment, the request-issuing condition includes some or all of the following:
condition 1, the number of operation requests in the dispatch queue is not less than a number threshold;
The waiting time of the scheduling queue is not smaller than a time threshold value; the starting time of the waiting time is determined based on part or all of the scheduling queue creation time, the time of the operation request in the air conditioner queue and the time of the operation request added to the scheduling queue for the first time;
the data flow corresponding to the scheduling queue is in an end state, wherein the end state is that no newly generated data exists in the data flow;
And 4, the scheduling queue does not join the operation request within a preset time length.
In an alternative embodiment, the issuing module is further configured to:
and if at least one of the condition 1 and the condition 2 in the condition content of the issuing request is met, the operation request in the scheduling queue is emptied, and the step of adding the operation request in any one data stream into the determined scheduling queue is executed.
In an alternative embodiment, the issuing module is further configured to:
and if at least one of the condition 3 and the condition 4 in the condition content of the issuing request is met, releasing the scheduling queue.
In an alternative embodiment, the issuing module is further configured to:
Based on the addresses corresponding to the operation requests in the scheduling queue, adjusting the arrangement sequence of the operation requests in the scheduling queue;
The issuing module is specifically configured to:
And issuing the operation requests in the scheduling queue to the hard disk according to the arrangement sequence of the operation requests in the scheduling queue after adjustment.
In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, where the memory stores program code that, when executed by the processor, causes the processor to perform the steps of any of the methods of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer storage medium storing computer instructions that, when run on a computer, cause the computer to perform the steps of any of the methods of the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program product comprising a computer program stored in a computer readable storage medium; when the computer program is read from the computer readable storage medium by a processor of an electronic device, the processor executes the computer program, causing the electronic device to perform the steps of any of the methods of the first aspect.
The technical scheme provided by the embodiment of the application at least has the following beneficial effects:
The embodiment of the application aims at any data flow, and adds the operation request in the data flow into the determined scheduling queue by determining the scheduling queue corresponding to the data flow. The application adds the operation requests in different data streams into the corresponding scheduling queues by setting the binding relation between the scheduling queues and the data streams, and improves the continuity of addresses of the operation requests in the scheduling queues, thereby reducing the seek time of the hard disk and improving the read-write performance of the hard disk when the hard disk executes corresponding operations based on the operation requests in the scheduling queues.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this specification, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute a limitation on the application. In the drawings:
FIG. 1 is an application scenario of an alternative hard disk read-write method according to an embodiment of the present application;
FIG. 2 is a flow chart of a method for reading and writing a hard disk according to an embodiment of the application;
FIG. 3 is a flowchart of an embodiment of the present application for issuing an operation request in a dispatch queue to a hard disk;
FIG. 4 is an overall flow chart of an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a hard disk read-write device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Wherein the described embodiments are some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Also, in the description of the embodiments of the present application, unless otherwise indicated, "and, means or, for example, a/B may represent a or B; the text "and/or" is merely an association relation describing the associated object, and indicates that three relations may exist, for example, a and/or B may indicate: the three cases where a exists alone, a and B exist together, and B exists alone, and furthermore, in the description of the embodiments of the present application, "plural" means two or more than two.
The terms "first," "second," and the like, are used below for descriptive purposes only and are not to be construed as implying or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first", "a second", or the like may explicitly or implicitly include one or more such feature, and in the description of embodiments of the application, unless otherwise indicated, the meaning of "a plurality" is two or more.
In order to facilitate understanding of the method, the device and the apparatus for reading and writing a hard disk provided by the embodiments of the present application, part of terms in the embodiments of the present application are explained below to facilitate understanding by those skilled in the art.
1. A Process (Process) is a basic unit of resource allocation by a system, and is a basis of an operating system structure.
2. The data stream (DATA STREAM) is a set of ordered, byte data sequences having a start and an end, typically contiguous in the corresponding address space on the hard disk.
An application scenario of an optional hard disk read-write method provided by the embodiment of the application is described below with reference to the accompanying drawings.
As shown in fig. 1, an application scenario of an alternative hard disk read-write method according to an embodiment of the present application includes a hard disk management device 10 and a hard disk 11.
The hard disk management device 10 determines a scheduling queue corresponding to any one data stream for any one data stream; wherein one data stream corresponds to one scheduling queue; adding an operation request in any one data stream to a determined scheduling queue, wherein the operation request comprises at least one of a read request and a write request;
if the number of operation requests in the dispatch queue meets the request issuing condition, the operation requests in the dispatch queue are issued to the hard disk 11, so that the hard disk 11 executes the corresponding operation.
Alternatively, the hard disk management device 10 in the present application may be connected to the hard disk 11 by wired connection. The application is not limited in this regard.
It should be noted that, the hard disk management device 10 in the embodiment of the present application may be an electronic device, a server, an embedded device, or the like, which is not limited in this aspect of the present application.
The electronic equipment can be a mobile phone, a computer, an intelligent home, a vehicle-mounted terminal and the like; the server may be a physical server.
As shown in fig. 2, the method for reading and writing a hard disk provided by the application comprises the following specific steps:
step S201, determining a scheduling queue corresponding to any one data stream according to any one data stream;
wherein one data stream corresponds to one scheduling queue;
It should be noted that, a scheduling queue may correspond to at least one data stream, and a scheduling queue may include a portion of a data stream processed by one process, or may include a data stream processed by a different process, which is not limited in this aspect of the present application.
In implementation, when any newly generated data stream is received, the embodiment of the application allocates a corresponding sequence number to the data stream.
It should be noted that, at the same time, the serial numbers corresponding to different data streams are different.
Optionally, the embodiment of the present application provides that a corresponding sequence number is allocated to the newly generated data stream in the following manner:
mode 1, a hard disk drive program in a hard disk management device allocates a corresponding serial number for a newly generated data stream;
in implementation, for a newly generated data stream, the data stream management unit applies a corresponding sequence number to the scheduling module of the hard disk drive program, and the scheduling module allocates a corresponding sequence number.
Optionally, in the embodiment of the present application, after the scheduling module allocates a corresponding sequence number, a corresponding scheduling queue may be created for the sequence number, and a mapping relationship between the sequence number and the scheduling queue may be determined.
The scheduling module of the hard disk drive in the embodiment of the application can be an I/O scheduling module.
It should be noted that, the hard disk driver is used for controlling and managing the hard disk, and is responsible for communication and data exchange with the hard disk. The main function of the hard disk drive program is to realize the control and access to the bottom layer of the hard disk.
Mode 2, a data stream management unit in the hard disk management device allocates a corresponding serial number for the newly generated data stream;
in practice, for a newly generated data stream, the data stream management unit assigns a corresponding sequence number to the data stream.
It should be noted that, the data flow management unit is used for controlling and managing data flow, and is responsible for coordinating transmission and processing of data between various components inside the system. The main function of the data stream management unit is to optimize data access and transmission, providing an efficient data stream management and scheduling strategy.
In an exemplary embodiment, in a video surveillance video scene, if a plurality of cameras are in an on state, a data stream is corresponding to video data collected by any one of the cameras.
The video data collected by different cameras corresponds to different data streams.
It should be noted that, addresses corresponding to operation requests in a data stream generated by video data are consecutive, where the addresses corresponding to the operation requests are locations where corresponding operations are performed in the hard disk based on the operation requests.
Wherein each operation request corresponds to an address.
Optionally, in the embodiment of the present application, based on the sequence number corresponding to the data stream, a field may be added to each operation request in the data stream, so that the operation request carries the sequence number of the data stream, and when the hard disk driver receives the operation request, the hard disk driver checks the sequence number corresponding to the operation request, and determines the corresponding scheduling queue.
It should be noted that, in the embodiment of the present application, when the data stream management unit in the hard disk management device sends an operation request to the hard disk driver, the data stream management unit adds a field to the operation request to be sent, and carries a sequence number corresponding to the data stream to which the operation request belongs.
In an optional implementation manner, for any one data stream, a scheduling queue corresponding to the data stream is determined by querying a mapping relationship between a preset sequence number and the scheduling queue based on the sequence number of the data stream.
In implementation, after the hard disk drive program receives the operation request, the scheduling queue corresponding to the data stream is determined by querying a mapping relation between a preset sequence number and the scheduling queue based on the sequence number corresponding to the data stream to which the operation request belongs carried by the operation request.
It should be noted that, in the mapping relationship between the preset sequence number and the scheduling queue in the embodiment of the present application, the corresponding scheduling queue may be represented by using the identification information corresponding to the scheduling queue, and the mapping relationship may be the mapping relationship between the sequence number and the identification information corresponding to the scheduling queue.
For example, based on the operation request in the scheduling queue, if the sequence number of the data stream is 2 and a mapping relationship between the sequence number 2 and the scheduling queue 2 is found in the mapping relationship between the preset sequence number and the scheduling queue, it is determined that the scheduling queue corresponding to the data stream is the scheduling queue 2.
Optionally, for any scheduling queue, a mapping relationship between a sequence number and a scheduling queue preset in the embodiment of the present application may include a mapping relationship between the scheduling queue and one data stream, or a mapping relationship between the scheduling queue and multiple data streams.
The multiple data streams included in the mapping relationship between the scheduling queue and the multiple data streams are partial data streams needing to be processed in one process and/or data streams needing to be processed in different processes.
It should be noted that, the present application is not limited to how to determine the partial data stream, and may be determined according to a preset rule or may be determined randomly.
In another alternative embodiment, for any one data stream, if the sequence number of the data stream is not queried in the mapping relationship, a corresponding new scheduling queue is created for the data stream.
In implementation, after the hard disk drive program receives the operation request, based on the sequence number corresponding to the data stream to which the operation request belongs carried by the operation request, if the sequence number of the data stream is not queried in the mapping relation, a corresponding new scheduling queue is created for the data stream.
If the sequence number of the data stream is not queried in the mapping relationship between the preset sequence number and the scheduling queue, determining that the data stream is a newly generated data stream, and creating a corresponding new scheduling queue for the data stream is required.
In the embodiment of the present application, in the case that in mode 2, a data stream management unit in a hard disk management device allocates a corresponding sequence number for a newly generated data stream, after receiving an operation request, a hard disk driver determines that a scheduling queue corresponding to the sequence number does not exist according to the sequence number of the data stream carried in the operation request, and then the hard disk management device creates the corresponding scheduling queue according to the sequence number.
In implementation, the scheduling module in the hard disk management device can create a corresponding new scheduling queue according to the sequence number.
For example, if a camera is newly added, the data stream corresponding to the video data collected by the newly added camera is a newly generated data stream.
Optionally, after the new scheduling queue is created, the embodiment of the present application may update the mapping relationship based on the sequence number of the data stream and the new scheduling queue.
Exemplary, the embodiment of the application determines the mapping relation between the serial number of the data stream and the identification information corresponding to the new scheduling queue based on the serial number of the data stream and the identification information corresponding to the new scheduling queue, and updates the preset mapping relation between the serial number and the new scheduling queue.
Step S202, adding an operation request in any one data stream into a determined scheduling queue;
wherein the operation request includes a read request or a write request;
In implementation, the embodiment of the application aims at the operation request of any data stream, and the hard disk driver adds the operation request into the determined scheduling queue according to the sequence number corresponding to the data stream.
For example, if the sequence number corresponding to the data flow to which the operation request belongs is 2 and the sequence number 2 corresponds to the scheduling queue 2, the operation request is added to the scheduling queue 2.
It should be noted that, in the embodiment of the present application, for a plurality of data streams, if a scheduling queue corresponds to one data stream, an operation request in the data stream is added to the scheduling queue; if one scheduling queue corresponds to a plurality of data streams, the operation requests in the corresponding plurality of data streams are added to the scheduling queue.
Step 203, if the number of operation requests in the dispatch queue meets the request issuing condition, issuing the operation requests in the dispatch queue to the hard disk, so that the hard disk executes the corresponding operation.
Optionally, for step S203, an embodiment of the present application provides a flowchart for issuing an operation request in a dispatch queue to a hard disk as shown in fig. 3, where the specific steps are as follows:
Step S301, if the number of operation requests in the scheduling queue meets the request issuing condition, adjusting the arrangement sequence of each operation request in the scheduling queue based on the address corresponding to each operation request in the scheduling queue;
optionally, the conditions for issuing the request in the embodiment of the present application include some or all of the following:
the number of operation requests in the scheduling queue is not less than a number threshold value under the condition 1;
In implementation, whether the number of operation requests in the scheduling queue is not smaller than the number threshold is judged according to the set number threshold.
The waiting time of the scheduling queue is not smaller than a time threshold value;
In implementation, whether the waiting time of the scheduling queue is not smaller than the time threshold is judged according to the set time threshold.
The starting time of the waiting time is determined based on a part or all of the scheduling queue creating time, the time of the operation request in the air conditioner queue and the time of the operation request added into the scheduling queue for the first time;
In implementation, after the scheduling queue is created, the operation request is added to the scheduling queue based on the data flow, the operation request is issued after the scheduling queue meets the issuing request condition, the operation request in the scheduling queue is cleared, and if the scheduling queue still exists, the operation request is added to the scheduling queue based on the data flow continuously. The time of the operation request in the air conditioner queue is the time of the operation request in the air conditioner queue last time of the scheduling queue.
The time of the operation request first added to the scheduling queue may be the time of the operation request first added to the scheduling queue after the scheduling queue is created, or the time of the operation request first added to the scheduling queue after the operation request in the scheduling queue is cleared.
For a newly created scheduling queue, the creation time of the scheduling queue may be taken as the starting time of the waiting time, or the time of the operation request of first joining the scheduling queue after the scheduling queue is created may be taken as the starting time of the waiting time; if the operation request is not a newly created scheduling queue, the time of the operation request in the air conditioner queue can be used as the starting time of the waiting time, or the time of the operation request which is added into the scheduling queue first after the operation request in the air conditioner queue is cleared can be used as the starting time of the waiting time. The application is not limited in this regard.
In an alternative embodiment, based on the above-mentioned request-issuing condition, if at least one of condition 1 and condition 2 in the request-issuing condition content is satisfied, the operation request in the air conditioner queue is cleared, and step S202 is performed.
In implementation, after the operation request in the dispatch queue is cleared, the operation request in the data stream is continuously added into the determined dispatch queue for the data stream, whether the number of the operation requests in the dispatch queue meets the issue request condition is judged, after the issue request condition is confirmed to be met, the operation request in the dispatch queue is issued to the hard disk, and the hard disk executes corresponding operation based on the operation request. The specific process principle is consistent with the above process, and the present application is not repeated here.
The data flow corresponding to the scheduling queue is in an end state;
Wherein the end state is that no newly generated data exists in the data stream;
For example, if the scheduling queue corresponds to one data stream, it needs to be determined that the data stream is in an end state, and if the scheduling queue corresponds to multiple data streams, it needs to be determined that the multiple data streams are all in an end state.
In implementation, the hard disk management device further includes a service module, after the service module determines that the data stream is in an end state, the service module notifies a hard disk driver in the hard disk management device, and after the hard disk driver receives the notification, the hard disk driver determines whether other data streams corresponding to the scheduling queue are in an end state, and if so, determines that the data stream corresponding to the scheduling queue is in an end state.
And 4, the scheduling queue does not join the operation request within a preset time length.
Optionally, the embodiment of the application determines whether the scheduling queue does not join the operation request within a preset duration by periodically checking the scheduling queue.
In another alternative embodiment, based on the request-issuing condition, if at least one of the condition 3 and the condition 4 in the request-issuing condition content is satisfied, the scheduling queue is released after issuing the operation request in the scheduling queue.
In implementation, after the above request issuing condition is satisfied, the embodiment of the present application adjusts the arrangement order of the operation requests in the scheduling queue according to the addresses corresponding to the operation requests in the scheduling queue.
In an optional implementation manner, according to the address corresponding to each operation request, the embodiment of the application adjusts the arrangement order of each operation request in the scheduling queue according to the order of the addresses, so as to obtain the scheduling queue containing the operation requests arranged based on the order of the addresses.
In another alternative embodiment, after the addresses of the operation requests in the scheduling queue are arranged, the operation requests in the scheduling queue may be further combined.
After the addresses of the operation requests in the scheduling queue are arranged, if the access addresses of the operation requests in the scheduling queue are consecutive, the operation requests corresponding to the consecutive addresses are combined to obtain corresponding operation requests.
The application can improve the read-write performance of the hard disk by combining the operation requests corresponding to the continuous addresses.
Step S302, according to the arrangement sequence of the operation requests adjusted in the scheduling queue, the operation requests in the scheduling queue are issued to the hard disk.
In implementation, based on the arrangement sequence of each operation request after adjustment in the scheduling queue, after the operation request in the scheduling queue is issued to the hard disk, the hard disk executes corresponding operation according to the arrangement sequence after adjustment of each operation request, that is, executes corresponding operation according to the address of the operation request after adjustment, so that the address position of the hard disk, which needs to be moved, is continuous as much as possible, the seek time of the hard disk is reduced, and the performance is improved.
As shown in fig. 4, an overall flowchart of an embodiment of the present application includes the following specific steps:
Step S401, a data stream management unit allocates a sequence number for each data stream;
step S402, the data stream management unit sends an operation request in the data stream to the hard disk drive program;
In implementation, a field is added for an operation request to be sent, and the field carries a sequence number corresponding to a data stream to which the operation request belongs.
Step S403, the hard disk drive program determines the serial number corresponding to the data stream to which the operation request belongs based on the received operation request;
in implementation, the hard disk drive program determines the sequence number corresponding to the data stream to which the operation request belongs based on the sequence number carried by the received operation request.
Step S404, judging whether a scheduling queue corresponding to the sequence number exists; if yes, go to step S405; if not, executing step S409;
if the scheduling queue corresponding to the sequence number does not exist, the newly generated data stream is indicated.
Step S405, adding the operation request into a corresponding scheduling queue;
Step S406, judging whether the scheduling queue meets the requirement of winding a piece; if yes, go to step S407; if not, executing step S405;
It should be noted that the embodiment of the present application further includes periodically detecting whether the dispatch queue needs to be released.
Wherein whether a release of the dispatch queue is required may be determined by at least one of: if the data flow corresponding to the scheduling queue is determined to be ended, releasing the scheduling queue; and if the operation request of the corresponding sequence number is detected to be not added into the scheduling queue for a long time, releasing the scheduling queue.
Step S407, issuing an operation request in a scheduling queue to the hard disk;
in implementation, before issuing the operation request in the scheduling queue, the operation request in the scheduling queue is ordered and combined according to the corresponding address.
Step S408, the hard disk executes corresponding operation based on the operation request;
step S409, a new scheduling queue is created, and the operation request is added into the new scheduling queue.
The following describes a device or apparatus provided by an embodiment of the present application, where explanation or illustration of the same or corresponding technical features as those described in the above method is omitted.
As shown in fig. 5, an electronic device 500 provided in an embodiment of the present application includes a processor 501 and a memory 502; a memory 502 for storing a computer program; a processor 501 for reading the computer program in the memory 502 and performing the following operations:
determining a scheduling queue corresponding to any one data stream according to the any one data stream; wherein one of the data streams corresponds to one of the scheduling queues;
Adding an operation request in any one data stream into the determined scheduling queue, wherein the operation request comprises a read request or a write request;
And if the operation request in the scheduling queue meets the request issuing condition, issuing the operation request in the scheduling queue to a hard disk so as to enable the hard disk to execute corresponding operation.
In some embodiments, the processor 501 is specifically configured to:
For any one data stream, determining a scheduling queue corresponding to the any one data stream by inquiring a mapping relation between a preset sequence number and the scheduling queue based on the sequence number of the any one data stream.
In some embodiments, it is further configured to:
If the sequence number of any one data stream is not queried in the mapping relation, creating a corresponding new scheduling queue for the any one data stream;
And updating the mapping relation based on the sequence number of any one data stream and the new scheduling queue.
In some implementations, the issue request condition includes some or all of the following:
condition 1, the number of operation requests in the dispatch queue is not less than a number threshold;
The waiting time of the scheduling queue is not smaller than a time threshold value; the starting time of the waiting time is determined based on part or all of the scheduling queue creation time, the time of the operation request in the air conditioner queue and the time of the operation request added to the scheduling queue for the first time;
the data flow corresponding to the scheduling queue is in an end state, wherein the end state is that no newly generated data exists in the data flow;
And 4, the scheduling queue does not join the operation request within a preset time length.
In some implementations, the processor 501 is further configured to:
and if at least one of the condition 1 and the condition 2 in the condition content of the issuing request is met, the operation request in the scheduling queue is emptied, and the step of adding the operation request in any one data stream into the determined scheduling queue is executed.
In some implementations, the processor 501 is further configured to:
and if at least one of the condition 3 and the condition 4 in the condition content of the issuing request is met, releasing the scheduling queue.
In some implementations, the processor 501 is further configured to:
Based on the addresses corresponding to the operation requests in the scheduling queue, adjusting the arrangement sequence of the operation requests in the scheduling queue;
In some embodiments, the processor 501 is specifically configured to:
And issuing the operation requests in the scheduling queue to the hard disk according to the arrangement sequence of the operation requests in the scheduling queue after adjustment.
In some embodiments, the processor 501 may be a CPU (central processing unit), an ASIC (Application SPECIFIC INTEGRATED Circuit), an FPGA (Field-Programmable gate array) or a CPLD (Complex Programmable Logic Device ), and the processor may also employ a multi-core architecture.
The processor is operable to perform any of the methods provided by embodiments of the present application in accordance with the obtained executable instructions by invoking a computer program stored in a memory. The processor and the memory may also be physically separate.
It should be noted that, the above device provided in the embodiment of the present invention can implement all the method steps implemented in the method embodiment and achieve the same technical effects, and detailed descriptions of the same parts and beneficial effects as those in the method embodiment in this embodiment are omitted.
Referring to fig. 6, a hard disk read-write device provided by an embodiment of the present application includes: a determining module 601, a joining module 602 and a issuing module 603;
a determining module 601, configured to determine, for any one data flow, a scheduling queue corresponding to the any one data flow; wherein one of the data streams corresponds to one of the scheduling queues;
A joining module 602, configured to join an operation request in the arbitrary data stream to the determined scheduling queue, where the operation request includes at least one of a read request and a write request;
And the issuing module 603 is configured to issue the operation requests in the scheduling queue to a hard disk if the number of operation requests in the scheduling queue meets an issue request condition, so that the hard disk executes a corresponding operation.
In an alternative embodiment, the determining module 601 is specifically configured to:
For any one data stream, determining a scheduling queue corresponding to the any one data stream by inquiring a mapping relation between a preset sequence number and the scheduling queue based on the sequence number of the any one data stream.
An alternative embodiment is also for:
If the sequence number of any one data stream is not queried in the mapping relation, creating a corresponding new scheduling queue for the any one data stream;
And updating the mapping relation based on the sequence number of any one data stream and the new scheduling queue.
In an alternative embodiment, the request-issuing condition includes some or all of the following:
condition 1, the number of operation requests in the dispatch queue is not less than a number threshold;
The waiting time of the scheduling queue is not smaller than a time threshold value; the starting time of the waiting time is determined based on part or all of the scheduling queue creation time, the time of the operation request in the air conditioner queue and the time of the operation request added to the scheduling queue for the first time;
the data flow corresponding to the scheduling queue is in an end state, wherein the end state is that no newly generated data exists in the data flow;
And 4, the scheduling queue does not join the operation request within a preset time length.
In an alternative embodiment, the issuing module 603 is further configured to:
and if at least one of the condition 1 and the condition 2 in the condition content of the issuing request is met, the operation request in the scheduling queue is emptied, and the step of adding the operation request in any one data stream into the determined scheduling queue is executed.
In an alternative embodiment, the issuing module 603 is further configured to:
and if at least one of the condition 3 and the condition 4 in the condition content of the issuing request is met, releasing the scheduling queue.
In an alternative embodiment, the issuing module 603 is further configured to:
Based on the addresses corresponding to the operation requests in the scheduling queue, adjusting the arrangement sequence of the operation requests in the scheduling queue;
in an alternative embodiment, the issuing module 603 is specifically configured to:
And issuing the operation requests in the scheduling queue to the hard disk according to the arrangement sequence of the operation requests in the scheduling queue after adjustment.
Embodiments of the present application also provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the method of any of the above embodiments. The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
An embodiment of the present application provides a computer readable storage medium storing computer program instructions for use in an apparatus provided in the embodiment of the present application, where the computer program instructions include a program for executing any one of the methods provided in the embodiment of the present application. The computer readable storage medium may be a non-transitory computer readable medium.
The computer-readable storage medium can be any available medium or data storage device that can be accessed by a computer, including, but not limited to, magnetic storage (e.g., floppy disks, hard disks, magnetic tape, magneto-optical disks (MOs), etc.), optical storage (e.g., CD, DVD, BD, HVD, etc.), and semiconductor storage (e.g., ROM, EPROM, EEPROM, nonvolatile storage (NAND FLASH), solid State Disk (SSD)), etc.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

Claims (10)

1. A method for reading from and writing to a hard disk, the method comprising:
determining a scheduling queue corresponding to any one data stream according to the any one data stream; wherein one of the data streams corresponds to one of the scheduling queues;
Adding an operation request in any one data stream into the determined scheduling queue, wherein the operation request comprises a read request or a write request;
And if the operation request in the scheduling queue meets the request issuing condition, issuing the operation request in the scheduling queue to a hard disk so as to enable the hard disk to execute corresponding operation.
2. The method of claim 1, wherein the determining, for any one data flow, a scheduling queue corresponding to the any one data flow comprises:
For any one data stream, determining a scheduling queue corresponding to the any one data stream by inquiring a mapping relation between a preset sequence number and the scheduling queue based on the sequence number of the any one data stream.
3. The method of claim 2, wherein the method further comprises:
If the sequence number of any one data stream is not queried in the mapping relation, creating a corresponding new scheduling queue for the any one data stream;
And updating the mapping relation based on the sequence number of any one data stream and the new scheduling queue.
4. The method of claim 1, wherein the request-for-delivery condition includes some or all of:
condition 1, the number of operation requests in the dispatch queue is not less than a number threshold;
The waiting time of the scheduling queue is not smaller than a time threshold value; the starting time of the waiting time is determined based on part or all of the scheduling queue creation time, the time of the operation request in the air conditioner queue and the time of the operation request added to the scheduling queue for the first time;
the data flow corresponding to the scheduling queue is in an end state, wherein the end state is that no newly generated data exists in the data flow;
And 4, the scheduling queue does not join the operation request within a preset time length.
5. The method of claim 4, further comprising, after said issuing said operation request within said dispatch queue to a hard disk:
and if at least one of the condition 1 and the condition 2 in the condition content of the issuing request is met, the operation request in the queue is emptied, and the step of adding the operation request in any one data stream into the determined scheduling queue is executed.
6. The method of claim 4, further comprising, after said issuing said operation request within said dispatch queue to a hard disk:
and if at least one of the condition 3 and the condition 4 in the condition content of the issuing request is met, releasing the scheduling queue.
7. The method of any of claims 1-6, further comprising, after the number of operation requests in the dispatch queue satisfies a request-down condition, before the issuing of the operation requests in the dispatch queue to a hard disk:
Based on the addresses corresponding to the operation requests in the scheduling queue, adjusting the arrangement sequence of the operation requests in the scheduling queue;
the issuing the operation request in the scheduling queue to the hard disk comprises the following steps:
And issuing the operation requests in the scheduling queue to the hard disk according to the arrangement sequence of the operation requests in the scheduling queue after adjustment.
8. A hard disk read-write apparatus, comprising:
the determining module is used for determining a scheduling queue corresponding to any one data stream according to the any one data stream; wherein one of the data streams corresponds to one of the scheduling queues;
A joining module, configured to join an operation request in the arbitrary data stream to the determined scheduling queue, where the operation request includes at least one of a read request and a write request;
and the issuing module is used for issuing the operation requests in the dispatching queue to a hard disk if the number of the operation requests in the dispatching queue meets the issuing request condition so as to enable the hard disk to execute corresponding operations.
9. An electronic device comprising a processor and a memory, wherein the memory stores program code that, when executed by the processor, causes the processor to perform the steps of the method of any of claims 1 to 7.
10. A computer readable storage medium, characterized in that it comprises a computer program for causing an electronic device to perform the steps of the method according to any one of claims 1-7 when said computer program is run on the electronic device.
CN202410005489.5A 2024-01-02 2024-01-02 Hard disk read-write method, device and apparatus Pending CN117991982A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410005489.5A CN117991982A (en) 2024-01-02 2024-01-02 Hard disk read-write method, device and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410005489.5A CN117991982A (en) 2024-01-02 2024-01-02 Hard disk read-write method, device and apparatus

Publications (1)

Publication Number Publication Date
CN117991982A true CN117991982A (en) 2024-05-07

Family

ID=90886316

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410005489.5A Pending CN117991982A (en) 2024-01-02 2024-01-02 Hard disk read-write method, device and apparatus

Country Status (1)

Country Link
CN (1) CN117991982A (en)

Similar Documents

Publication Publication Date Title
US9003135B2 (en) Efficient allocation and reclamation of thin-provisioned storage
JP5029513B2 (en) Information processing apparatus, information processing apparatus control method, and program
US20170075614A1 (en) Memory system and host apparatus
CN104461735B (en) A kind of method and apparatus that cpu resource is distributed under virtualization scene
US20100037231A1 (en) Method for reading/writing data in a multithread system
KR101544309B1 (en) Method and apparatus for controlling non-volatile memory based on stream
WO2017050064A1 (en) Memory management method and device for shared memory database
CN109240607B (en) File reading method and device
CN111522659B (en) Space use method and device
US9612746B1 (en) Allocation method for meeting system performance and application service level objective (SLO)
US9164885B2 (en) Storage control device, storage control method, and recording medium
US20160011792A1 (en) Media control device and control method
JP5414943B2 (en) System and method for managing a virtual tape library domain
CN110413217B (en) Method, apparatus and computer program product for managing a storage system
US20080320212A1 (en) Control device and control method of nonvolatile memory and storage device
CN111562883B (en) Cache management system, method and device for solid state disk
CN117991982A (en) Hard disk read-write method, device and apparatus
CN112445412B (en) Data storage method and device
EP2109315B1 (en) Video server and file management method
US11698735B2 (en) Common storage management device and common storage management method
US9058113B2 (en) Storage region providing device, storage region providing method, and recording medium
US9170929B2 (en) Memory controller
CN113467724B (en) CRC (cyclic redundancy check) code storage method, device, equipment and medium
CN108431789B (en) Memory control apparatus and operating method thereof
WO2021088587A1 (en) Data access method and apparatus, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination