The content of the invention
Based on the problems referred to above, the invention provides a kind of I O scheduling method and device, reasonably, efficiently to set to block
Standby storage carries out I O scheduling, so as to improve the read or write speed of storage system.
A kind of I O scheduling method that the present invention is provided, the I O scheduling method specifically include following step:
Step S100, when storage system is initialized, be that each physical disk in storage system sets up one one by one
Corresponding fifo queue;
The I/O request that topmost paper system sends is received, according to the I/O request, the disk letter included in request is obtained
Breath, and I/O request is inserted in fifo queue corresponding with target physical disk according to the disc information, it is fifo queue
Each I/O request of middle insertion sets up the conflict chained list of an one-to-one I/O request, and the conflict chained list of the I/O request is used
It is all in the corresponding fifo queue of record physical disk to have the I/O request for conflicting with described each I/O request for having existed;
Step S200, perform insert each I/O request to fifo queue, from the beginning of the head I/O request of the queue
Scanning, judges that the already present I/O request in the queue whether there is with the I/O request being currently inserted into and conflicts, if judged result
It is yes, execution step S300;If judged result is no, execution step S400;
Step S300, at once stopping scanning, arrange the first call back function, the I/O request being currently inserted into are added in queue
Exist in the conflict chained list corresponding to the I/O request of conflict, and the I/O request that mark is currently inserted into, the IO for treating and being currently inserted into please
After the completion of asking the I/O request of conflict to process, start scanning from the head I/O request of queue again, judge depositing in the queue
I/O request and the I/O request being currently inserted into the presence or absence of conflict, sort in the I/O request being currently inserted into up in waiting list
It is before on position and be currently inserted into after I/O request has an I/O request that IO conflicts all process terminates with described, further according to described
The event that first call back function is arranged, performs the event of the I/O request of insertion;
Step S400, the asynchronous I/O operation for directly performing insertion I/O request, and using should at the block device of underlying services
Front I/O request, arranges the second call back function;After the completion of I/O request is processed by the block device of underlying services, the second readjustment letter is called
Number, the notice arranged further according to second call back function are scheduled process.
Further, it is as a kind of embodiment, in step S400, described according to second call back function
The notice of setting, is scheduled process, comprises the following steps:
Step S410, I/O request after process is removed from the queue;
In conflict chained list after step S420, the detection process corresponding to I/O request, if there is IO to be handled please
Ask and do not conflict with the I/O request before sorting in waiting list;
Step S430, if so, then wake up pending I/O request and can perform asynchronous I/O operation;
Step S440, if it is not, then by pending I/O request, performing and starting scanning from the head I/O request of queue again, sentence
Already present I/O request in disconnected current queue, is arranged up in waiting list with the presence or absence of conflicting with currently pending I/O request
Sequence before pending I/O request on position and there is the I/O request that IO conflicts with the pending I/O request and all locate
Reason terminates, and the pending I/O request in the conflict chained list after processing corresponding to I/O request please with the IO before sequence in waiting list
Ask after not conflicting, further according to the notice that second call back function is arranged, wake up pending I/O request and can perform asynchronous IO
Operation.
It is preferred that used as a kind of embodiment, the I/O request performs asynchronous I/O operation and comprises the following steps:
Execution underlying services write the operation of cache memory and index zooms to internal memory operation.
It is preferred that as a kind of embodiment, set up conflict chain when each I/O request is inserted in the fifo queue
The original state of table is sky.
It is preferred that as a kind of embodiment, first call back function point in including I/O request because IO conflicts and
The event action that cannot temporarily process;Second call back function points to the notice that I/O request has been completed in including I/O request.
It is preferred that used as a kind of embodiment, the block device of the underlying services includes internal memory, solid state hard disc, disk
And cache memory.
It is preferred that used as a kind of embodiment, the disc information includes the numbering of target physical disk, disk sector
Initial address and length.
Correspondingly, present invention also offers a kind of I O scheduling device, including initial module, judge module, first process mould
Block and Second processing module, wherein:
The initial module, for when storage system is initialized, being that each physical disk in storage system is set up
One one-to-one fifo queue;The I/O request that topmost paper system sends is received, according to the I/O request, is obtained in request
Comprising disc information, and I/O request is inserted into by fifo queue corresponding with target physical disk according to the disc information
In, it is conflict chained list that each I/O request inserted in fifo queue sets up an one-to-one I/O request, the IO please
The conflict chained list asked is used to recording all with described each I/O request for having existed in the corresponding fifo queue of physical disk
There is the I/O request of conflict;
The judge module, for inserting each I/O request to fifo queue, from the head IO of the queue in execution
Request starts scanning, judges that the already present I/O request in the queue whether there is with the I/O request being currently inserted into and conflicts, if
Judged result is yes, then redirect first processing module and perform corresponding operating;If judged result is no, Second processing module is redirected
Perform corresponding operating;
The first processing module, for stopping scanning at once, arranges the first call back function, by the I/O request being currently inserted into
Exist in being added to queue in the conflict chained list corresponding to the I/O request of conflict, and the I/O request that mark is currently inserted into, treat and work as
After the completion of the I/O request of the I/O request conflict of front insertion is processed, start scanning from the head I/O request of queue again, judge described
Already present I/O request in queue, is sorted current up in waiting list with the presence or absence of conflicting with the I/O request being currently inserted into
It is before the I/O request on position of insertion and with it is described be currently inserted into I/O request and there is I/O request all process that IO conflicts terminate
Afterwards, the event for arranging further according to first call back function, performs the event of the I/O request of insertion;
The Second processing module, for the asynchronous I/O operation for directly performing insertion I/O request, and using underlying services
The current I/O request of block device process, arranges the second call back function;After the completion of I/O request is processed by the block device of underlying services, adjust
The second call back function is used, the notice arranged further according to second call back function is scheduled process.
Further, as a kind of embodiment, the Second processing module includes removing submodule, chained list detection
Module, first wake up submodule and second and wake up submodule, wherein:
The removal submodule, for I/O request after process is removed from the queue;
The chained list detection sub-module, for detecting in the conflict chained list after the process corresponding to I/O request, if deposit
Do not conflict in I/O request to be handled and with the I/O request before sorting in waiting list;
Described first wakes up submodule, is yes for judged result, then wakes up pending I/O request and can perform asynchronous IO
Operation;
Described second wakes up submodule, is no for judged result, then by pending I/O request, perform again from queue
Head I/O request starts scanning, judges that the already present I/O request in current queue whether there is with currently pending I/O request
Conflict, until sorting before pending I/O request on position in waiting list and depositing with the pending I/O request
Terminate in I/O request all process of IO conflicts, and the pending I/O request in the conflict chained list after processing corresponding to I/O request with etc.
After the I/O request before sequence in queue does not conflict, further according to the notice that second call back function is arranged, wake up pending
I/O request can perform asynchronous I/O operation.
Beneficial effects of the present invention include:
A kind of I O scheduling method and device that the present invention is provided, wherein method comprise the steps:It is initial in storage system
During change, it is that each physical disk in storage system sets up an one-to-one fifo queue;To insert in fifo queue
Each I/O request set up the conflict chained list of an one-to-one I/O request;Each I/O request is inserted to FIFO teams performing
After row, start scanning from the head I/O request of the queue, judge queue conflict, and by recording the conflict chained list of I/O request,
Realize preparing to get up by pending event, other I/O request conflicts being sent to using conflict chained list in chained list are released
Notify, so as to avoid with solid state hard disc as a large amount of IO conflicts caused during caching process, will so effectively improve I/O
Read-write speed and transfer rate.The I O scheduling method and device that the present invention is provided is ensureing data consistency, the base of integrity
On plinth, with reference to the characteristic of SDD cachings, the optimum of I O process ability is reached, so as to improve the read or write speed of storage system.
Specific embodiment
With reference to Figure of description, the specific embodiment of present invention I O dispatching method and device is illustrated.
The embodiment of the present invention is for as a example by the I O scheduling method of solid state hard disc, the present invention will be described, but is not limited to
This.In whole storage system, the process of IO is stored by the process of stratification, normally referred to as stack, SSD caching process is used as stack
One layer of centre and exist, it can receive I/O request from upper strata, be serve upper layers, while also can be provided using lower floor
Service.
A kind of I O scheduling method provided in an embodiment of the present invention, as shown in figure 1, the I O scheduling method specifically include it is following
Step:
Step S100, when storage system is initialized, be that each physical disk in storage system sets up one one by one
Corresponding fifo queue;
The I/O request that topmost paper system sends is received, according to the I/O request, the disk letter included in request is obtained
Breath, and I/O request is inserted in fifo queue corresponding with target physical disk according to the disc information, it is fifo queue
Each I/O request of middle insertion sets up the conflict chained list of an one-to-one I/O request, and the conflict chained list of the I/O request is used
It is all in the corresponding fifo queue of record physical disk to have the I/O request for conflicting with described each I/O request for having existed;
Step S200, perform insert each I/O request to fifo queue, from the beginning of the head I/O request of the queue
Scanning, judges that the already present I/O request in the queue whether there is with the I/O request being currently inserted into and conflicts, if judged result
It is yes, execution step S300;If judged result is no, execution step S400;
Step S300, at once stopping scanning, arrange the first call back function, the I/O request being currently inserted into are added in queue
Exist in the conflict chained list corresponding to the I/O request of conflict, and the I/O request that mark is currently inserted into, the IO for treating and being currently inserted into please
After the completion of asking the I/O request of conflict to process, start scanning from the head I/O request of queue again, judge depositing in the queue
I/O request and the I/O request being currently inserted into the presence or absence of conflict, sort in the I/O request being currently inserted into up in waiting list
It is before on position and be currently inserted into after I/O request has an I/O request that IO conflicts all process terminates with described, further according to described
The event that first call back function is arranged, performs the event of the I/O request of insertion;
Step S400, the asynchronous I/O operation for directly performing insertion I/O request, and using should at the block device of underlying services
Front I/O request, arranges the second call back function;After the completion of I/O request is processed by the block device of underlying services, the second readjustment letter is called
Number, the notice arranged further according to second call back function are scheduled process.
Further, it is as a kind of embodiment, in step S400, described according to second call back function
The notice of setting, is scheduled process, comprises the following steps:
Step S410, I/O request after process is removed from the queue;
In conflict chained list after step S420, the detection process corresponding to I/O request, if there is IO to be handled please
Ask and do not conflict with the I/O request before sorting in waiting list;
Step S430, if so, then wake up pending I/O request and can perform asynchronous I/O operation;
Step S440, if it is not, then by pending I/O request, performing and starting scanning from the head I/O request of queue again, sentence
Already present I/O request in disconnected current queue, is arranged up in waiting list with the presence or absence of conflicting with currently pending I/O request
Sequence before pending I/O request on position and there is the I/O request that IO conflicts with the pending I/O request and all locate
Reason terminates, and the pending I/O request in the conflict chained list after processing corresponding to I/O request please with the IO before sequence in waiting list
Ask after not conflicting, further according to the notice that second call back function is arranged, wake up pending I/O request and can perform asynchronous IO
Operation.
It is preferred that used as a kind of embodiment, the I/O request performs asynchronous I/O operation and comprises the following steps:
Execution underlying services write the operation of cache memory and index zooms to internal memory operation.
It is preferred that as a kind of embodiment, set up conflict chain when each I/O request is inserted in the fifo queue
The original state of table is sky.
It is preferred that as a kind of embodiment, first call back function point in including I/O request because IO conflicts and
The event action that cannot temporarily process;Second call back function points to the notice that I/O request has been completed in including I/O request.
It is preferred that used as a kind of embodiment, the block device of the underlying services includes internal memory, solid state hard disc, disk
And cache memory.
It is preferred that used as a kind of embodiment, the disc information includes the numbering of target physical disk, disk sector
Initial address and length.
It will be understood by those skilled in the art that the method for I O scheduling provided by the embodiment of the present invention, its essence is
Pass through:I/O request establishes conflict chained list when inserting, due to being asynchronous I/O operation during scheduling, so processing each I/O request
Queue conflict should be detected, in the current I/O request of the post processing that do not conflict, after having processed current I/O request, is called out under suitable conditions
Other I/O requests in awake its conflict chained list;Wherein, suitable condition is that queue does not conflict.
During enforcement, said process is realized by two call back functions:First call back function is used for current IO
The event action that cannot temporarily process because IO conflicts is asked, and waits current I/O request above-mentioned event not to be processed in conflict.Second
The current I/O request of other I/O requests that call back function is used to notify current I/O request to conflict in chained list is over, and suitable
Under the conditions of its wake up conflict chained list in other I/O requests perform asynchronous I/O operations;Wherein, suitable condition is that queue does not conflict.Letter
Concentrate the talk of, the first call back function is the event to be done in order to prepare current I/O request.Second call back function is to wake up conflict chain
Other I/O requests (notifying to have relieved conflict) of table.
Method in order to I O scheduling provided in an embodiment of the present invention is better described, the example for a reality are illustrated
I O scheduling realizes process.
After certain hour after storage system initialization, physical disk (numbering is 2) the corresponding FIFO in storage system
Queue;There is the I/O request that numbering is 1,2,3,4,5,6,7 in former queue, as shown in Figure 2 a, the I/O request being currently inserted into is
Numbering is 7 I/O request;(it should be noted that after certain hour, wherein 1 and 2 process of numbering terminates and removes
Above-mentioned queue.) as shown in Figure 2 b, in figure, each circle represents the I/O request for having removed from the queue, single underscore is represented
The I/O request for processing, double underline represent the I/O request being inserted into.
Step 301, execution insert I/O request (numbering is 7 I/O request) to fifo queue, from the head of the queue
IO (numbering is 3 I/O request) requests start scanning, judge already present I/O request and the IO being currently inserted in the queue
Request is with the presence or absence of conflict (numbering is the I/O request of 3-6), if the determination result is YES, execution step S302;If judged result is
It is no, then execution step S303;
Step S302, at once stopping scanning, arrange the first call back function, and by the I/O request being currently inserted into, (numbering is 7 IO
Request) be added to queue in there is the I/O request (assuming with the I/O request that numbering is 7 with to number be that 3 I/O request conflicts) of conflict
In corresponding conflict chained list, and the I/O request that mark is currently inserted into, treat that the I/O request conflicted with the I/O request being currently inserted into (is compiled
Number for 3 I/O request) process after the completion of, as shown in Figure 2 c, again from the head I/O request of queue start scanning, judge the team
Already present I/O request in row with the presence or absence of conflicting, is sorted up in waiting list and is inserted currently with the I/O request being currently inserted into
It is before the I/O request on position for entering and be currently inserted into after I/O request has an I/O request that IO conflicts all process terminates with described,
Further according to the event that first call back function is arranged, the event of the I/O request of insertion is performed;
In above-mentioned steps S302, when No. 3 IO in queue are conflicted with No. 7 No. IO, No. 7 requests at this moment wouldn't be processed,
After waiting No. 3 process to terminate, start scanning from the head I/O request of queue again, judge that the already present IO in the queue please
Ask (numbering is the I/O request of 4-6, and as shown in Figure 2 c, Fig. 2 b illustrate that the queue after removing No. 3 I/O requests) and be currently inserted into
I/O request (numbering is 7 I/O request) with the presence or absence of conflict, as long as until waiting list in sort the IO being currently inserted into please
It is before seeking on position and with it is described be currently inserted into I/O request and exist after I/O request all process that IO conflicts terminate (assume current
Queue 4,5,6 does not all conflict with 7), the event of the I/O request (numbering is 7 I/O request) for performing insertion is at this moment directly processed,
Wherein, the event for being arranged according to first call back function, performs the operation of above-mentioned event;
Certainly, in former queue numbering be the I/O request of 3-6 may be that 7 I/O request not conflict with numbering, will so hold
Row step S400:
Step S400, the asynchronous I/O operation for directly performing insertion I/O request (numbering is 7 I/O request), and taken using lower floor
The block device of business processes current I/O request, arranges the second call back function;Processed by the block device of underlying services in I/O request and completed
Afterwards, the second call back function is called, the notice arranged further according to second call back function is scheduled process.
In above-mentioned steps S400, then the I/O request that numbering is 7 is first processed, during execution, needs setting to call the second readjustment letter
Number, wait number be 7 I/O request process terminate after, call the second call back function, process and remove from former queue (numbering is 3-7)
Numbering is 7 I/O request, new queue as shown in Figure 3 a, propulsion over time, as the foundation of this storage system is asynchronous
I/O operation, so the I/O request for processing can be multiple, at this moment queue there may be various situations, and situations below is only to crowd
Many situations carry out several being analyzed:
May insert new IO (such as 8,9,10) in situation one, at this moment queue, at this moment queue there will be (3,4,5,6,
8th, 9,10), as shown in Figure 3 b, due to the I/O request for processing can be it is multiple, at this moment can treatable numbering 3 I/O request
And the I/O request that numbering is 8,9, the conflict chained list after so detecting the process corresponding to I/O request (numbering is 7 I/O request)
(in the conflict chained list for assuming the request that numbering is 7, being identified with 8 and 9), if there is I/O request to be handled and and waiting list
I/O request before middle sequence does not conflict.
Obvious numbering is that 3 I/O request can not possibly be conflicted (it is determined that mistake) with 7 presence, and at this moment No. 3 requests can be with IO
Process;But the process of No. 8 I/O requests, while needing to detect that again queue IO conflicts, will also detect that the numbering of firm removal is 7
I/O request conflict chained list (form of the vertical lower section of No. 7 I/O requests illustrates the conflict chained list of No. 7 I/O requests in Fig. 3 b), it is false
If without the I/O request that No. 8 are constituted with conflict in queue, it is clear that in above-mentioned hypothesized model, having No. 8 in No. 7 I/O request correspondence chained lists
I/O request, then the second call back function of No. 7 I/O request settings will wake up No. 8 requests, and No. 7 have removed, and can perform 8
Number;
If assuming only No. 9 I/O requests in No. 7 I/O request correspondence chained lists, when performing No. 9, queue is equally detected again
While IO conflicts (including 3,4,5,6, No. 8 I/O requests of detection), to also detect that the numbering of firm removal is the conflict of 7 I/O request
Chained list, at this moment only has No. 9 I/O requests in obvious No. 7 I/O requests correspondence chained list, but No. 7 I/O requests has moved out, please in No. 8 IO
Ask in the case of not conflicting with No. 9 I/O requests, the second call back function of No. 7 I/O request settings will wake up No. 9 I/O requests and can hold
Line asynchronous I/O operation.Therefore above-mentioned condition meets:Until sorting before pending I/O request on position in waiting list
And there is I/O request all process that IO conflicts with the pending I/O request and terminate, and rushing corresponding to I/O request after processing
After pending I/O request in prominent chained list is not conflicted with the I/O request before sequence in waiting list, further according to the described second readjustment
The notice of function setup, wakes up pending I/O request and can perform asynchronous I/O operation.
It will be understood by those skilled in the art that in above-mentioned steps, by arranging call back function and reasonable profit twice
Processed with the characteristic of solid state hard disc, so prepare to get up by pending event, be sent in chained list using conflict chained list
Other I/O request conflicts release notices, it is a large amount of as what is caused during caching process with solid state hard disc so as to avoid
IO conflicts, and will so effectively improve I/O read-write speed and transfer rate.
Based on same inventive concept, the embodiment of the present invention additionally provides a kind of I O scheduling device, as this device solves to ask
The principle of topic is similar to a kind of aforementioned I O scheduling method, therefore the enforcement of the device may refer to the enforcement of preceding method, repeats
Part is repeated no more.
Correspondingly, the embodiment of the present invention additionally provides a kind of I O scheduling device, as shown in figure 4, the I O scheduling device 40,
Including initial module 401, judge module 402, first processing module 403 and Second processing module 404, Fig. 5 illustrates this enforcement
In the storage system that the I O scheduling device of example is located, topmost paper system 10, cache20, the block device 30, IO of underlying services are adjusted
The structural relation schematic diagram of degree device 40, wherein:
The initial module 401, for when storage system 1 is initialized, being each physical disk in storage system
Set up an one-to-one fifo queue;The I/O request that topmost paper system 10 sends is received, according to the I/O request, is obtained
Disc information included in request, and I/O request is inserted into according to the disc information corresponding with target physical disk
In fifo queue, it is conflict chained list that each I/O request inserted in fifo queue sets up an one-to-one I/O request,
The conflict chained list of the I/O request be used to recording in the corresponding fifo queue of physical disk it is all with it is described existed it is each
Individual I/O request has the I/O request of conflict;
The judge module 402, for inserting each I/O request to fifo queue, from the head of the queue in execution
I/O request starts scanning, judges that the already present I/O request in the queue whether there is with the I/O request being currently inserted into and conflicts,
If the determination result is YES, then redirect first processing module and perform corresponding operating;If judged result is no, second processing mould is redirected
Block performs corresponding operating;
The first processing module 403, for stopping scanning at once, arranges the first call back function, by the IO being currently inserted into
Request is present in being added to queue in the conflict chained list corresponding to the I/O request of conflict, and the I/O request that mark is currently inserted into, and treats
After the completion of the I/O request conflicted with the I/O request being currently inserted into is processed, start scanning from the head I/O request of queue again, judge
Already present I/O request in the queue, is sorted up in waiting list with the presence or absence of conflicting with the I/O request being currently inserted into
It is before the I/O request on position being currently inserted into and with it is described be currently inserted into I/O request and there is the I/O request that IO conflicts all process
After end, further according to the event that first call back function is arranged, the event of the I/O request of insertion is performed;
The Second processing module 404, for the asynchronous I/O operation for directly performing insertion I/O request, and uses underlying services
Block device 30 process current I/O request, the second call back function is set;Processed by the block device of underlying services in I/O request and completed
Afterwards, the second call back function is called, the notice arranged further according to second call back function is scheduled process.
Further, as a kind of embodiment, the Second processing module includes removing submodule, chained list detection
Module, first wake up submodule and second and wake up submodule, wherein:
The removal submodule, for I/O request after process is removed from the queue;
The chained list detection sub-module, for detecting in the conflict chained list after the process corresponding to I/O request, if deposit
Do not conflict in I/O request to be handled and with the I/O request before sorting in waiting list;
Described first wakes up submodule, is yes for judged result, then wakes up pending I/O request and can perform asynchronous IO
Operation;
Described second wakes up submodule, is no for judged result, then by pending I/O request, perform again from queue
Head I/O request starts scanning, judges that the already present I/O request in current queue whether there is with currently pending I/O request
Conflict, until sorting before pending I/O request on position in waiting list and depositing with the pending I/O request
Terminate in I/O request all process of IO conflicts, and the pending I/O request in the conflict chained list after processing corresponding to I/O request with etc.
After the I/O request before sequence in queue does not conflict, further according to the notice that second call back function is arranged, wake up pending
I/O request can perform asynchronous I/O operation.
A kind of I O scheduling method and device provided in an embodiment of the present invention, wherein method comprise the steps:In storage system
During system initialization, it is that each physical disk in storage system sets up an one-to-one fifo queue;For fifo queue
Each I/O request of middle insertion sets up the conflict chained list of an one-to-one I/O request;Each I/O request is inserted extremely performing
After fifo queue, start scanning from the head I/O request of the queue, judge queue conflict, and by recording the conflict of I/O request
Chained list, realizes preparing to get up by pending event, and other I/O request conflicts being sent to using conflict chained list in chained list are released
Notice, so as to avoid with solid state hard disc as a large amount of IO conflicts caused during caching process, so will effectively
Improve I/O read-write speed and transfer rate.I O scheduling method and device provided in an embodiment of the present invention is ensureing that data are consistent
Property, on the basis of integrity, with reference to the characteristic of SDD cachings, the optimum of I O process ability is reached, so as to improve the reading of storage system
Writing rate.
Embodiment described above only expresses the several embodiments of the present invention, and its description is more concrete and detailed, but and
Therefore the restriction to the scope of the claims of the present invention can not be interpreted as.It should be pointed out that for one of ordinary skill in the art
For, without departing from the inventive concept of the premise, some deformations and improvement can also be made, these belong to the guarantor of the present invention
Shield scope.Therefore, the protection domain of patent of the present invention should be defined by claims.