CN105302501B - A kind of control method and device of disk sector - Google Patents

A kind of control method and device of disk sector Download PDF

Info

Publication number
CN105302501B
CN105302501B CN201510893255.XA CN201510893255A CN105302501B CN 105302501 B CN105302501 B CN 105302501B CN 201510893255 A CN201510893255 A CN 201510893255A CN 105302501 B CN105302501 B CN 105302501B
Authority
CN
China
Prior art keywords
sector
read
chained list
write
write order
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510893255.XA
Other languages
Chinese (zh)
Other versions
CN105302501A (en
Inventor
李华英
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Uniview Technologies Co Ltd
Original Assignee
Zhejiang Uniview Technologies 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 Uniview Technologies Co Ltd filed Critical Zhejiang Uniview Technologies Co Ltd
Priority to CN201510893255.XA priority Critical patent/CN105302501B/en
Publication of CN105302501A publication Critical patent/CN105302501A/en
Application granted granted Critical
Publication of CN105302501B publication Critical patent/CN105302501B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

The present invention provides a kind of control method and device of disk sector, and this method includes:The write order less than sector-size is received, determines the corresponding sector command structure in the corresponding sector of write order and sector;If sectors status is to pre-read the state of issuing, write order is added to and issues chained list;If sectors status is to merge to write hair-like state, write order is added to waiting chained list;When pre- read command returns, the write order issued in chained list is merged in the pre-reads data that pre- read buffer includes, the data after merging are written to sector;When merging write order return, if waited in chained list, there are write orders, issue chained list by waiting for the write order in chained list to be added to, the write order issued in chained list is merged in the pre-reads data that pre- read buffer includes, the data after merging are written to sector.Technical solution through the invention so that sector can support the write order less than sector-size, save sector space, improve the process performance of write order, save memory source.

Description

A kind of control method and device of disk sector
Technical field
The present invention relates to technical field of memory more particularly to the control methods and device of a kind of disk sector.
Background technology
Currently, disk can be write data into, and data are read from disk.Each magnetic track on disk is divided into Several segmental arcs, these segmental arcs are exactly the sector of disk, and the read-write of disk is using sector as base unit, therefore, by data It is written to the sector of disk, and data are read from the sector of disk.
When writing data into sector or reading data from sector, sector only supports data volume to be more than sector-size The write order write order that either read command file system issues or read command be all sector-size integral multiple.For example, fan Area's size can be 512K, and write order is used to the data of 1M (512K*2) or 2M being written to sector, and read command is used for from fan The data of 1M or 2M are read in area.
But with the fast development of memory technology, under application scenes, it is frequently encountered write order or reads life The case where being less than sector-size is enabled, and the write order less than sector-size or read command are not supported in current sector.For example, In the disk array management of block virtualization, each disk is divided into virtual block up to ten thousand, in order to manage these virtual blocks, needs The management data of virtual block are written to sector, and each virtual block occupies a sector, the management data of each virtual block May there was only several bytes, far smaller than sector-size 512K, thus sector do not support the management data of virtual block write life It enables.
Invention content
The present invention provides a kind of control method of disk sector, the described method comprises the following steps:
The write order less than sector-size is received, determines the corresponding sector in the corresponding sector of the write order and the sector Imperative structures, the sector command structure includes sectors status, pre- read buffer, issue chained list and waits for chained list, it is described pre-read it is slow Pre-reads data of the bag deposit containing the sector-size being had been written into the sector;If the sectors status is to pre-read lower hair-like The write order is then added to and issues chained list by state;If the sectors status is to merge to write hair-like state, life is write by described Order is added to waiting chained list;
When pre- read command returns, writing in chained list is issued described in merging in the pre-reads data that the pre- read buffer includes Order, and the data after merging are written to the sector;
It, will be in the waiting chained list if there are write orders in the waiting chained list when merging write order return Write order, which is added to, issues chained list, and is issued in chained list described in merging in the pre-reads data that the pre- read buffer includes and write life It enables, and the data after merging is written to the sector.
The sector command structure is managed by Hash table, the Hash table is using the corresponding LBA value in sector as key assignments;Institute The process for determining the corresponding sector of write order and the corresponding sector command structure in the sector is stated, is specifically included:From described The address information of sector to be written is obtained in write order, and determines the corresponding fan of the write order using described address information Area;And the key assignments of the Hash table is inquired by the LBA value of the determining sector, the LBA value for obtaining the sector corresponds to Sector command structure;
The method further includes:It is corresponding if there is no the sector after determining the corresponding sector of the write order Sector command structure, creates the corresponding sector command structure in the sector, and the sectors status for recording the sector command structure is The state of issuing is pre-read, and reads the pre-reads data for the sector-size having been written into from the sector, is ordered in the sector It enables in the pre- read buffer of structure and stores the pre-reads data;
When the sectors status is to pre-read to issue state, in the pre-reads data that the pre- read buffer includes described in merging The write order in chained list is issued, and after the data after merging are written to the sector, by the fan of the sector command structure Zone state by pre-read issue status modifier be merge write hair-like state;
When the merging write order returns, the method further includes:If there is no write in the waiting chained list Order, then after the preset lime, delete the corresponding sector command structure in the sector.
It is described in the pre-reads data that the pre- read buffer includes merge described in issue chained list in write order, including:When It is described to issue in chained list when including multiple write orders, it is added to the time order and function for issuing chained list according to the multiple write order Sequentially, the multiple write order is merged into the pre-reads data successively.
It is described in the pre-reads data that the pre- read buffer includes merge described in issue chained list in write order, including:Root According to the write order issued in chained list the first offset within the sector and the first size, using memory copying mode, from First offset starts, and copies the write order to pre-reads data that the pre- read buffer includes, and the write order exists Size in the pre-reads data is first size.
The method further includes:
The read command less than sector-size is received, determines the corresponding sector in the corresponding sector of the read command and the sector Imperative structures, the sector command structure includes sectors status, pre- read buffer, issue chained list and waits for chained list, it is described pre-read it is slow Pre-reads data of the bag deposit containing the sector-size being had been written into the sector;If the sectors status is to pre-read lower hair-like The read command is then added to and issues chained list by state;If the sectors status is to read to return to processing state, the reading is ordered Order is added to waiting chained list;Wherein, after determining the corresponding sector of the read command, if there is no the corresponding fan in the sector Area's imperative structures, then create the corresponding sector command structure in the sector, and the sectors status for recording the sector command structure is The state of issuing is pre-read, and reads the pre-reads data for the sector-size having been written into from the sector, and in the sector The pre-reads data is stored in the pre- read buffer of imperative structures;
When pre- read command returns, sectors status is issued into status modifier to read to return to processing state, under by pre-reading Corresponding data are read in read command in hair chained list from the pre-reads data that the pre- read buffer includes, and the data of reading are returned Back to upper layer application;In the case where reading to return to processing state, if waited in chained list, there are read commands, will be in the waiting chained list Read command, which is added to, issues chained list, is read from the pre-reads data that the pre- read buffer includes according to the read command issued in chained list Corresponding data, and the data of reading are returned into upper layer application.
The present invention provides a kind of control device of disk sector, and described device specifically includes:
Determining module for receiving the write order less than sector-size, and determines the corresponding sector of the write order and institute State the corresponding sector command structure in sector, wherein the sector command structure specifically includes sectors status, pre- read buffer, issues Chained list and waiting chained list, and the pre- read buffer includes the pre-reads data for the sector-size being had been written into the sector; If the sectors status is to pre-read the state of issuing, the write order is added to and described issues chained list;If the sector State is to merge to write hair-like state, then the write order is added to the waiting chained list;
Writing module, described in when pre- read command returns, merging in the pre-reads data that the pre- read buffer includes The write order in chained list is issued, and the data after merging are written to the sector;
It, will be in the waiting chained list if there are write orders in the waiting chained list when merging write order return Write order, which is added to, issues chained list, and is issued in chained list described in merging in the pre-reads data that the pre- read buffer includes and write life It enables, and the data after merging is written to the sector.
The sector command structure is managed by Hash table, and the Hash table is using the corresponding LBA value in sector as key assignments; The determining module, specifically for determining the corresponding sector command structure in the corresponding sector of the write order and the sector In the process, the address information of sector to be written is obtained from write order, and determines the write order using described address information Corresponding sector;The key assignments that the Hash table is inquired by the LBA value of the sector, the LBA value for obtaining the sector are corresponding Sector command structure;
The determining module is additionally operable to after determining the corresponding sector of write order, corresponding if there is no the sector Sector command structure, creates the corresponding sector command structure in the sector, and the sectors status for recording the sector command structure is The state of issuing is pre-read, and reads the pre-reads data for the sector-size having been written into from the sector, is ordered in the sector It enables in the pre- read buffer of structure and stores the pre-reads data;
Said write module, is additionally operable to when the sectors status is to pre-read to issue state, includes in the pre- read buffer Pre-reads data in merge described in issue write order in chained list, and after the data after merging are written to the sector, then By the sectors status of the sector command structure by pre-read issue status modifier be merge write hair-like state;When life is write in the merging When enabling return, if there is no write orders to delete the corresponding fan in the sector after the preset lime in the waiting chained list Area's imperative structures.
Said write module, specifically for being issued in chained list described in the merging in the pre-reads data that the pre- read buffer includes Write order during, when it is described issue in chained list include multiple write orders when, be added to institute according to the multiple write order The chronological order for issuing chained list is stated, the multiple write order is merged into the pre-reads data successively.Said write mould Block, during specifically for issuing the write order in chained list described in the merging in the pre-reads data that the pre- read buffer includes, According to the write order issued in chained list the first offset within the sector and the first size, using memory copying mode, Since first offset, the write order is copied to the pre-reads data that the pre- read buffer includes, and the write order Size in the pre-reads data is first size.
The determining module is additionally operable to receive the read command less than sector-size, determines the corresponding sector of the read command Sector command structure corresponding with the sector, the sector command structure includes sectors status, pre- read buffer, issue chained list and It includes the pre-reads data for the sector-size being had been written into the sector to wait for chained list, the pre- read buffer;If described Sectors status is to pre-read the state of issuing, then is added to the read command and issues chained list;If the sectors status is to read to return The read command is then added to waiting chained list by processing state;After determining the corresponding sector of the read command, if there is no The corresponding sector command structure in the sector, then create the corresponding sector command structure in the sector, record the sector command The sectors status of structure is to pre-read the state of issuing, and the pre- reading for the sector-size having been written into is read from the sector According to, and store the pre-reads data in the pre- read buffer of the sector command structure;
Described device further includes:Read module is used for when pre- read command returns, by sectors status by pre-reading the state of issuing It is revised as reading to return to processing state, be read from the pre-reads data that the pre- read buffer includes according to the read command issued in chained list Corresponding data, and the data of reading are returned into upper layer application;In the case where reading to return to processing state, exist if waited in chained list Read command in the waiting chained list is then added to and issues chained list by read command, according to the read command issued in chained list from described Corresponding data are read in the pre-reads data that pre- read buffer includes, and the data of reading are returned into upper layer application.
Based on the above-mentioned technical proposal, in the embodiment of the present invention so that sector can support the write order less than sector-size, Multiple write orders less than sector-size can be written to a sector, without writing life to be each less than sector-size Individually one sector of application is enabled, so as to save sector space.Furthermore, it is possible to handle multiple writing less than sector-size simultaneously Order does not have to the write order that individually processing is each less than sector-size, so as to improve the process performance of write order.Moreover, Can be that all write orders less than sector-size only safeguard a pre- read buffer, and it is each small not have to for a sector A pre- read buffer is separately maintained in the write order of sector-size, and each pre- read buffer is required for applying for memory source again, It therefore can be to avoid more memory source be occupied, so as to save memory source.
Description of the drawings
Fig. 1 is the flow chart of the control method of the disk sector in one embodiment of the present invention;
Fig. 2 is the processing schematic diagram of the write order in one embodiment of the present invention;
Fig. 3 A and Fig. 3 B are the schematic diagrames of the test data in one embodiment of the present invention;
Fig. 4 is the flow chart of the writing method of the disk sector in one embodiment of the present invention;
Fig. 5 is the flow chart of the control method of the disk sector in one embodiment of the present invention;
Fig. 6 is the processing schematic diagram of the read command in one embodiment of the present invention;
Fig. 7 is the flow chart of the reading control method of the disk sector in one embodiment of the present invention;
Fig. 8 is the hardware structure diagram of the storage device in one embodiment of the present invention;
Fig. 9 is the structure chart of the control device of the disk sector in one embodiment of the present invention.
Specific implementation mode
For problems of the prior art, the embodiment of the present invention proposes a kind of control method of disk sector, can be with Using on a storage device, and to disk sector write process or read procedure controls.Wherein, each magnetic track on disk Several segmental arcs are divided into, these segmental arcs are exactly the sector of disk, and the read-write of disk is using sector as base unit.When connecing When receiving the write order or read command (integral multiple of such as sector-size) more than or equal to sector-size, at existing way It manages, this process is repeated no more in the present embodiment.It is such as virtual when receiving write order or the read command less than sector-size The technical solution of proposition of the embodiment of the present invention then may be used in the write order of the management data of block or read command, subsequent to write Either read command each means write order or read command less than sector-size for order.Under above application scene, such as Fig. 1 institutes Show, the control method of the disk sector can specifically include following steps:
Step 101, the write order less than sector-size is received, determines that the corresponding sector of the write order and the sector correspond to Sector command structure, which includes sectors status, pre- read buffer, issue chained list and waits for chained list, and this is pre- Read buffer includes the pre-reads data for the sector-size being had been written into the sector.If the sectors status is to pre-read lower hair-like The write order is then added to and issues chained list by state;If the sectors status is to merge to write hair-like state, which is added To waiting chained list.
In the embodiment of the present invention, after determining the corresponding sector of the write order, if there is currently no sector correspondences Sector command structure, then create the corresponding sector command structure in the sector, and record the sectors status of the sector command structure To pre-read the state of issuing, and the pre-reads data for the sector-size having been written into is read from the sector, and in the sector command knot The pre-reads data is stored in the pre- read buffer of structure.
, can be by Hash table come management sector imperative structures in the embodiment of the present invention, and the Hash table is with sector pair LBA (Logical Block Address, the logical block addresses) value answered is key assignments.On this basis, the write order pair is determined The process of the corresponding sector command structure in the sector answered and the sector, can specifically include but be not limited to such as under type:From this The address information of sector to be written is obtained in write order, and determines the corresponding sector of the write order using the address information;With And the key assignments of Hash table is inquired by the LBA value of determining sector, obtain the corresponding sector command structure of LBA value of sector.
As shown in Fig. 2, after receiving the write order less than sector-size, write order is stored to order receiving queue, And determine the corresponding sector of each write order in order receiving queue, as using the sector to be written carried in write order Location information determines corresponding sector.A, B, C represent different sectors, can be true based on the address information of the sector in write order Determine write order 1,2,3,5,13 and correspond to sector A, write order 4,6,7,12 corresponds to sector B, and write order 8,9,10,11 corresponds to sector C.
Wherein it is possible to by Hash table come management sector imperative structures, a Hash table, Hash table are constructed to each disk The corresponding sector command structure in each sector of disk is preserved, the sector is corresponding all to be write the sector command structure for recording The information of order, and the sector command structure may include the corresponding LBA value in the sector, sectors status, pre- read buffer, issue chain Table and waiting chained list, which writes hair-like state including pre-reading the state of issuing, merging, and Hash table is corresponding with sector LBA value is key assignments.
After determining the corresponding sector of write order, the key assignments of the LBA value inquiry Hash table of the sector can be directly utilized, Obtain the corresponding sector command structure of LBA value of sector.Carry out management sector imperative structures due to the use of Hash table, and by sector pair The LBA value answered is as key assignments, and Hash table is a data structure that can be directly accessed according to key assignments, by by key assignments A position of Hash table is mapped to access record, therefore Hash table quick search can be passed through with the speed for accelerating to search To sector command structure.
Wherein, after determining the corresponding sector of write order, if there is no the corresponding sector lives in the sector in Hash table Structure is enabled, then creates the corresponding sector command structure in the sector in Hash table, and the fan is recorded in the sector command structure The corresponding LBA value in area, the sectors status for recording the sector command structure be pre-read the state of issuing, and create a pre- read buffer, One issues chained list and a waiting chained list.
Wherein, if the corresponding sector command structure in the sector is not present in Hash table, then it represents that the sector is corresponding It is not created before sector command structure, or is deleted after creation.
Wherein, when sectors status is to pre-read to issue state, pre- read command will be executed, the pre- read command is entire for pre-reading The data of sector read the pre-reads data for the sector-size equal to the sector having been written into that is, from sector, and are ordered in sector It enables in the pre- read buffer of structure and stores the pre-reads data so that the pre- read buffer is big comprising the sector being had been written into the sector Small pre-reads data.For example, when the sector-size of sector A is 512K, then the data of 512K can be stored in the A of sector, in order to It is convenient to distinguish, the data of this 512K can be known as to pre-reads data, and pre- read command is used for what the reading from the A of sector had been written into The pre-reads data of the 512K, and will be in the storage to pre- read buffer of the pre-reads data of this 512K.
In embodiments of the present invention, can be that the corresponding all write orders in the sector only safeguard one for a sector Pre- read buffer, and without separately maintaining a pre- read buffer for each write order.Since each pre- read buffer is required for Shen again Please memory source, therefore, by only safeguarding a pre- read buffer for the corresponding all write orders in the sector, can to avoid occupy compared with More memory source, to save memory source.
It wherein, can be based on the sectors status of sector command structure, certainly when receiving the write order less than sector-size It is fixed that write order storage is still waited for into chained list to issuing chained list.If sectors status is to pre-read the state of issuing, then it represents that currently just The pre-reads data of entire sector is being pre-read, and the storage of pre-reads data has not been completed, write order is being added to issues at this time Chained list waits for pre- read command to return.And when pre- read command returns, indicate the storage for having completed pre-reads data, it will be pre- It reads in data storage to the pre- read buffer of sector command structure, executes step 102.If sectors status is to merge to write hair-like State, then it represents that the data after currently write-in merges into sector, and the write-in of the data after merging has not been completed Write order is added to waiting chained list by journey at this time, and write order to be combined is waited to return.And when merging write order return, it indicates The ablation process of data after completing to merge executes step 103.
Step 102, when pre- read command returns, merge in the pre-reads data that pre- read buffer includes and issue writing in chained list Order, and the data after merging are written to sector.Wherein, it can be that this is issued in chained list to issue the write order merged in chained list All write orders or part write order.
Wherein, when sectors status is to pre-read to issue state, then merge in the pre-reads data that pre- read buffer includes and issue Write order in chained list, and after the data after merging are written to sector, it can also be by the sector-like of sector command structure State by pre-read issue status modifier be merge write hair-like state.
Wherein, by configuring pre- read command, the pre-reads data of entire sector can be pre-read, and when pre- read command returns, Then indicate to have completed the storage of pre-reads data, it will be in pre-reads data storage to the pre- read buffer of sector command structure.It Afterwards, by configuring merging write order, the write order issued in chained list can be merged in the pre-reads data that pre- read buffer includes, and Data after merging are written to sector.
Step 103, when merging write order return, if waited in chained list, there are write orders, will wait in chained list Write order, which is added to, issues chained list, and merges the write order issued in chained list in the pre-reads data that pre- read buffer includes, and will Data after merging are written to sector.Write order is not present in chained list if waited for, after the preset lime, deletes sector pair The sector command structure answered.
Wherein, it is added to the write order issued in chained list for waiting in chained list, can is such institute waited in chained list There are write order or part write order.The write order merged in chained list is issued for this, can be that this issues owning in chained list Write order or part write order.
Wherein, when sectors status is to merge to write hair-like state, then under merging in the pre-reads data that pre- read buffer includes The write order in chained list is sent out, and after the data after merging are written to sector, the fan of sector command structure can also be kept Zone state is constant, that is, remains as merging and write hair-like state.
Wherein, by configuring merging write order, it can merge in the pre-reads data that pre- read buffer includes and issue in chained list Write order, the data after merging are written to sector.When merging write order return, life is write if wait for and existing in chained list It enables, then merges write order yet by configuration, the write order issued in chained list is merged in the pre-reads data that pre- read buffer includes, it will Data after merging are written to sector.Write order is not present in chained list if waited for, after the preset lime, deletes sector pair The sector command structure answered.
It is just to delete sector command knot after the preset lime when wherein, since write order is not present in waiting chained list Structure, rather than sector command structure is deleted at once, in this way, if receiving the corresponding write order in the sector again in preset time, Sector command structure is then no longer deleted, after avoiding sector command structure from being deleted, has the sector is corresponding to write life again at once Order needs to handle, and to create the corresponding sector command structure in the sector again, avoids the deletion repeatedly of sector command structure With establishment, process resource is saved.
Wherein, when write order is not present in waiting chained list, by deleting sector command structure from Hash table, to release The occupied storage resource of sector command structure is put, and the resource of Hash table can be saved.
Based on the above-mentioned technical proposal, in the embodiment of the present invention so that sector can support the write order less than sector-size, Multiple write orders less than sector-size can be written to a sector, without writing life to be each less than sector-size Individually one sector of application is enabled, so as to save sector space.Furthermore, it is possible to handle multiple writing less than sector-size simultaneously Order does not have to the write order that individually processing is each less than sector-size, so as to improve the process performance of write order.Moreover, Can be that all write orders less than sector-size only safeguard a pre- read buffer, and it is each small not have to for a sector A pre- read buffer is separately maintained in the write order of sector-size, and each pre- read buffer is required for applying for memory source again, It therefore can be to avoid more memory source be occupied, so as to save memory source.
For example, according to above-mentioned technical proposal, writing for write order (such as 32 bytes and 8 bytes) less than sector-size is realized Fashionable, then test data can be as shown in Figure 3A and Figure 3B.Wherein, write order that 4096 sizes are 32 bytes is being write to disk The same sector when, then it is 39 milliseconds to take, and is writing write order that 4096 sizes are 8 bytes to the same sector of disk When, then it takes as 38ms.Obviously, above-mentioned technical proposal can save processing time, and improve the process performance of write order.
In the embodiment of the present invention, for step 102 and step 103, under merging in the pre-reads data that pre- read buffer includes The process for sending out the write order in chained list, can specifically include but be not limited to such as under type:Existed according to the write order issued in chained list Write order is copied to and is pre-read since deviating first using memory copying mode by the first offset in sector and the first size The pre-reads data that caching includes, and size of the write order in pre-reads data is the first size.Wherein, include in pre- read buffer During merging the write order issued in chained list in pre-reads data, the write order issued in chained list can also be merged into and be pre-read In caching, to replace pre-reads data stored in pre- read buffer, i.e., in a sector according to the write order issued in chained list First offset and the first size copy write order to pre- read buffer using memory copying mode since deviating first, and Size of the write order in pre- read buffer is the first size.On this basis, the data in pre- read buffer are exactly to merge to issue chain The pre-reads data after write order in table, at this point it is possible to directly write the data (data after merging) in pre- read buffer Enter to corresponding sector.
For example, by the pre-reads data storage to pre- read buffer of the 512K in the A of sector, it is assumed that write order 1 is in the A of sector First offset is offset 1, and the first size is size 1, and first offset of the write order 2 in the A of sector is offset 2, and the first size is Size 2, first offset of the write order 3 in the A of sector are offset 3, and the first size is size 4, write order 5 in the A of sector the One offset is offset 4, and the first size is size 4, and first offset of the write order 13 in the A of sector is offset 5, and the first size is big It is small by 5.Then use memory copying mode, since offset 1, copy write order 1 to pre- read buffer, and write order 1 pre-read it is slow Size in depositing is size 1, replaces the pre-reads data of the position in pre- read buffer;Using memory copying mode, opened from offset 2 Begin, copies write order 2 to pre- read buffer, and size of the write order 2 in pre- read buffer is size 2, is replaced in pre- read buffer The pre-reads data of the position;Using memory copying mode write order 3 is copied to pre- read buffer since offset 3, and write life It is size 3 to enable 3 size in pre- read buffer, replaces the pre-reads data of the position in pre- read buffer;Using memory copying mode, Since offset 4, write order 5 is copied to pre- read buffer, and size of the write order 5 in pre- read buffer is size 4, is replaced pre- The pre-reads data of the position in read buffer;Using memory copying mode, since offset 5, write order 13 is copied to pre-read it is slow It deposits, and size of the write order 13 in pre- read buffer is size 5, replaces the pre-reads data of the position in pre- read buffer.Later, will The data (data after merging) of 512K in pre- read buffer are written to corresponding sector A.
Based on the above-mentioned technical proposal, it since the write order issued in chained list to be merged into pre- read buffer, is pre-read with replacing Stored pre-reads data in caching, and the data (data after merging) in pre- read buffer are written to sector.Therefore, Data in pre- read buffer are identical as the data being written in sector, in subsequent processes, it is no longer necessary to being read in sector Pre-reads data, the data in pre- read buffer are exactly the pre-reads data in sector, to avoid the process for repeating to read sector, are saved Overhead.
In the embodiment of the present invention, for step 102 and step 103, under merging in the pre-reads data that pre- read buffer includes The process for sending out the write order in chained list, can specifically include but be not limited to such as under type:When issuing in chained list life is write comprising multiple When enabling, then it is added to the chronological order for issuing chained list according to multiple write orders, multiple write orders is merged into pre-reads successively In the pre-reads data that caching includes.
For example, issuing the chronological order of chained list when multiple write orders are added to and being followed successively by write order 1, write order 2, write When order 3, write order 5, write order 13, first write order 1 is merged into pre-reads data, write order 2 is merged into pre-reads later In data, write order 3 is merged into pre-reads data later, write order 5 is merged into pre-reads data later, life will be write later 13 are enabled to be merged into pre-reads data.
Based on the above-mentioned technical proposal, when multiple write orders are the write orders for the same position of sector, it is ensured that The write order of subsequent write order covering front, and the write order of front is avoided to cover subsequent write order.For example, it is assumed that writing life Enable 1 and write order 2 in the A of sector first offset be offset 1, the first size is size 1, then user is sending out write order After 1, need to cover write order 1 by write order 2, in this way, write order 1 and write order 2 are added to the time order and function for issuing chained list Sequence is write order 1, write order 2, and therefore, aforesaid way can ensure that write order 2 covers write order 1.
The control process of writing of disk sector is described in detail below in conjunction with specific application scenarios, as shown in figure 4, should The writing method of disk sector can specifically include but be not limited to following steps:
Step 1 receives the write order for being less than sector-size.
Step 2 stores write order to order receiving queue.
Step 3 determines corresponding sector using the address information of the sector to be written carried in write order.
Step 4 judges to whether there is the corresponding sector command structure in the sector in Hash table.
If so, 5 are thened follow the steps, if not, thening follow the steps 8.
Step 5 judges whether the sectors status of sector command structure is to pre-read the state of issuing.If so, thening follow the steps 6, if not (i.e. sectors status is to merge to write hair-like state), then follow the steps 7.
Write order is added to and issues chained list by step 6.
Write order is added to waiting chained list by step 7.
Step 8 creates sector command structure in Hash table, and record sectors status is to pre-read the state of issuing.
Step 9, by pre- read command, pre-read the pre-reads data (sector-size being had been written into sector of entire sector Pre-reads data), by pre-reads data storage in the pre- read buffer of sector command structure.
Step 10, pre- read command return.
Step 11, by sectors status by pre-read issue status modifier be merge write hair-like state.
Step 12 merges all write orders issued in chained list in the pre-reads data that pre- read buffer includes.
Step 13 will merge the data after all write orders and be written to sector.
Step 14 merges write order return.
Merging is write result and returns to upper layer application by step 15, such as is written successfully or unsuccessfully.
Step 16 judges to wait in chained list with the presence or absence of write order.
If not, thening follow the steps 17;If so, thening follow the steps 18.
Step 17 deletes sector command structure from Hash table.
Step 18 will wait for all write orders in chained list to be added to and issue chained list.
Step 19 merges all write orders issued in chained list in the pre-reads data that pre- read buffer includes.
Step 20 will merge the data after all write orders and be written to sector, return to step 14.
The above process is to write control process for disk sector, and control process for the reading of disk sector, such as Fig. 5 institutes Show, the control method of the disk sector can specifically include following steps:
Step 501, the read command less than sector-size is received, determines that the corresponding sector of the read command and the sector correspond to Sector command structure, which includes sectors status, pre- read buffer, issue chained list and waits for chained list, and this is pre- Read buffer includes the pre-reads data for the sector-size being had been written into the sector.If the sectors status is to pre-read lower hair-like The read command is then added to and issues chained list by state;If the sectors status is to read to return to processing state, which is added To waiting chained list.
In the embodiment of the present invention, after determining the corresponding sector of the read command, if there is currently no sector correspondences Sector command structure, then create the corresponding sector command structure in the sector, and record the sectors status of the sector command structure To pre-read the state of issuing, and the pre-reads data for the sector-size having been written into is read from the sector, and in the sector command knot The pre-reads data is stored in the pre- read buffer of structure.
, can be by Hash table come management sector imperative structures in the embodiment of the present invention, Hash table is corresponding with sector LBA value is key assignments.On this basis, the mistake of the corresponding sector command structure in the corresponding sector of read command and the sector is determined Journey can specifically include but be not limited to such as under type:The address information of sector to be read is obtained from read command, and utilizing should Address information determines the corresponding sector of read command;The key assignments that Hash table is inquired by the LBA value of the sector, obtains the LBA value pair The sector command structure answered.
As shown in fig. 6, after receiving the read command less than sector-size, read command is stored to order receiving queue, And determine the corresponding sector of each read command in order receiving queue, as using the sector to be read carried in read command Location information determines corresponding sector.A, B, C represent different sectors, can be true based on the address information of the sector in read command Determine read command 1,2,3,5,13 and correspond to sector A, read command 4,6,7,12 corresponds to sector B, and read command 8,9,10,11 corresponds to sector C.
Wherein it is possible to by Hash table come management sector imperative structures, a Hash table, Hash table are constructed to each disk The corresponding sector command structure in each sector of disk is preserved, the sector command structure is for recording the corresponding all readings in the sector The information of order, and the sector command structure may include the corresponding LBA value in the sector, sectors status, pre- read buffer, issue chain Table and waiting chained list, the sectors status include pre-reading the state of issuing, reading to return to processing state, and Hash table is corresponding with sector LBA value is key assignments.
After determining the corresponding sector of read command, the key assignments of the LBA value inquiry Hash table of the sector can be directly utilized, Obtain the corresponding sector command structure of LBA value of sector.Carry out management sector imperative structures due to the use of Hash table, and by sector pair The LBA value answered is as key assignments, and Hash table is a data structure that can be directly accessed according to key assignments, by by key assignments A position of Hash table is mapped to access record, therefore Hash table quick search can be passed through with the speed for accelerating to search To sector command structure.
Wherein, after determining the corresponding sector of read command, if there is no the corresponding sector lives in the sector in Hash table Structure is enabled, then creates the corresponding sector command structure in the sector in Hash table, and the fan is recorded in the sector command structure The corresponding LBA value in area, the sectors status for recording the sector command structure be pre-read the state of issuing, and create a pre- read buffer, One issues chained list and a waiting chained list.
Wherein, if the corresponding sector command structure in the sector is not present in Hash table, then it represents that the sector is corresponding It is not created before sector command structure, or is deleted after creation.
Wherein, when sectors status is to pre-read to issue state, pre- read command will be executed, the pre- read command is entire for pre-reading The data of sector read the pre-reads data for the sector-size equal to the sector having been written into that is, from sector, and are ordered in sector It enables in the pre- read buffer of structure and stores the pre-reads data so that the pre- read buffer is big comprising the sector being had been written into the sector Small pre-reads data.For example, when the sector-size of sector A is 512K, then the data of 512K can be stored in the A of sector, in order to It is convenient to distinguish, the data of this 512K can be known as to pre-reads data, and pre- read command is used for what the reading from the A of sector had been written into The pre-reads data of the 512K, and will be in the storage to pre- read buffer of the pre-reads data of this 512K.
In embodiments of the present invention, can be that the corresponding all read commands in the sector only safeguard one for a sector Pre- read buffer, and without separately maintaining a pre- read buffer for each read command.Since each pre- read buffer is required for Shen again Please memory source, therefore, by only safeguarding a pre- read buffer for the corresponding all read commands in the sector, can to avoid occupy compared with More memory source, to save memory source.
It wherein, can be based on the sectors status of sector command structure, certainly when receiving the read command less than sector-size It is fixed that read command storage is still waited for into chained list to issuing chained list.If sectors status is to pre-read the state of issuing, then it represents that currently just In the pre-reads data for pre-reading entire sector, read command is added to issues chained list at this time, pre- read command is waited for return.And works as and pre-read When order returns, indicates the storage for having completed pre-reads data, pre-reads data is stored into pre-reading to sector command structure In caching, step 502 is executed.If sectors status is to read to return to processing state, then it represents that completed pre-reads data before Storage stores pre-reads data into the pre- read buffer of sector command structure, directly executes step 503.
Step 502, when pre- read command returns, sectors status is issued into status modifier as reading return processing shape by pre-reading State, and corresponding data are read from the pre-reads data that pre- read buffer includes according to the read command issued in chained list, and will read Data return to upper layer application.Wherein, the read command in chained list is issued, is specifically as follows all readings issued in chained list and orders Order or part read command.
Wherein, by configuring pre- read command, the pre-reads data of entire sector can be pre-read, and when pre- read command returns, Then indicate that the storage for having completed pre-reads data is incited somebody to action by pre-reads data storage to the pre- read buffer of sector command structure Sectors status issues status modifier as reading return processing state by pre-reading.
Step 503, in the case where reading to return to processing state, if waited in chained list, there are read commands, will wait in chained list Read command, which is added to, issues chained list, reads correspondence from the pre-reads data that pre- read buffer includes according to the read command issued in chained list Data, and the data of reading are returned into upper layer application.If wait for chained list in be not present read command, preset time it Afterwards, the corresponding sector command structure in sector is deleted.
Wherein, it is added to the read command issued in chained list for waiting in chained list, can is such institute waited in chained list There are read command or part read command.The read command in chained list is issued for this, can be that this issues the life of all readings in chained list Order or part read command.
Wherein, in the case where reading to return to processing state, it can be read from the pre-reads data that pre- read buffer includes and issue chained list In read command corresponding to data, and the data read are returned into upper layer application.Life is read if wait for and existing in chained list It enables, reads to return to processing state due to currently remaining as, it can read and issue from the pre-reads data that pre- read buffer includes The data corresponding to read command in chained list, and the data read are returned into upper layer application.Until waiting in chained list not There are read commands, then after the preset lime, delete the corresponding sector command structure in sector.
It is just to delete sector command knot after the preset lime when wherein, since read command is not present in waiting chained list Structure, rather than sector command structure is deleted at once, in this way, if receiving the corresponding read command in the sector again in preset time, Sector command structure is then no longer deleted, after avoiding sector command structure from being deleted, there is the corresponding reading life in the sector again at once Order needs to handle, and to create the corresponding sector command structure in the sector again, avoids the deletion repeatedly of sector command structure With establishment, process resource is saved.
Wherein, when read command is not present in waiting chained list, by deleting sector command structure from Hash table, to release The occupied storage resource of sector command structure is put, and the resource of Hash table can be saved.
Based on the above-mentioned technical proposal, in the embodiment of the present invention so that sector can support the read command less than sector-size, Multiple read commands less than sector-size can be written to a sector, without for each less than the reading of sector-size life Individually one sector of application is enabled, so as to save sector space.Furthermore, it is possible to handle multiple readings less than sector-size simultaneously Order does not have to the read command that individually processing is each less than sector-size, so as to improve the process performance of read command.Moreover, Can be that a pre- read buffer is only safeguarded in all read commands less than sector-size, and it is each small not have to for a sector A pre- read buffer is separately maintained in the read command of sector-size, and each pre- read buffer is required for applying for memory source again, It therefore can be to avoid more memory source be occupied, so as to save memory source.
In the embodiment of the present invention, for step 502 and step 503, according to the read command issued in chained list from pre- read buffer Including pre-reads data in read the processes of corresponding data, can specifically include but be not limited to such as under type:According to issuing chain Read command in table the second offset in a sector and the second size are pre-read since deviating second from what pre- read buffer included Corresponding data are read in data, and the size of the data read is the second size, is by the data for returning to upper layer application The read command corresponds to the data of size.
For example, by the pre-reads data storage to pre- read buffer of the 512K in the A of sector, it is assumed that read command 1 is in the A of sector Second offset is offset 1, and the second size is size 1, and second offset of the read command 2 in the A of sector is offset 2, and the second size is Size 2, second offset of the read command 3 in the A of sector are offset 3, and the second size is size 4, read command 5 in the A of sector the Two offsets are offset 4, and the second size is size 4, and second offset of the read command 13 in the A of sector is offset 5, and the second size is big It is small by 5.Pre-reads data then is read out from pre- read buffer, since offset 1, the data of size 1, the number are read from pre-reads data According to corresponding read command 1;Pre-reads data is read out from pre- read buffer, since offset 2, size 2 is read from pre-reads data Data, the data correspond to read command 2;Pre-reads data is read out from pre- read buffer, since offset 3, is read from pre-reads data The data of size 3 are taken, which corresponds to read command 3;Pre-reads data is read out from pre- read buffer, since offset 4, from pre-reading The data of size 4 are read in data, which corresponds to read command 5;Pre-reads data is read out from pre- read buffer, is opened from offset 5 Begin, the data of size 5 are read from pre-reads data, which corresponds to read command 13.Later, read five parts of data are returned To upper layer application.
Based on the above-mentioned technical proposal, need not be to pre-reads data be read in sector, the data in pre- read buffer are exactly sector In pre-reads data, to avoid repeat read sector process, save overhead.
In the embodiment of the present invention, for step 502 and step 503, according to the read command issued in chained list from pre- read buffer Including pre-reads data in read the processes of corresponding data, can specifically include but be not limited to such as under type:When issuing chained list In include multiple read commands when, then the chronological order for issuing chained list is added to according to multiple read commands, it is slow from pre-reading successively Corresponding data are read in the pre-reads data that bag deposit contains.
For example, when multiple read commands be added to issue chained list chronological order be followed successively by read command 1, read command 2, read When order 3, read command 5, read command 13,1 corresponding data of read command are first read from pre-reads data, later from pre-reads data 2 corresponding data of read command are read, 3 corresponding data of read command are read from pre-reads data later, later from pre-reads data 5 corresponding data of read command are read, read 13 corresponding data of read command from pre-reads data later.
The reading control process of disk sector is described in detail below in conjunction with specific application scenarios, as shown in fig. 7, should The reading control method of disk sector can specifically include but be not limited to following steps:
Step 1 receives the read command for being less than sector-size.
Step 2 stores read command to order receiving queue.
Step 3 determines corresponding sector using the address information of the sector to be read carried in read command.
Step 4 judges to whether there is the corresponding sector command structure in the sector in Hash table.
If so, 5 are thened follow the steps, if not, thening follow the steps 8.
Step 5 judges whether the sectors status of sector command structure is to pre-read the state of issuing.If so, thening follow the steps 6, if not (i.e. sectors status is to read to return to processing state), then follow the steps 7.
Read command is added to and issues chained list by step 6.
Read command is added to waiting chained list by step 7.
Step 8 creates sector command structure in Hash table, and record sectors status is to pre-read the state of issuing.
Step 9, by pre- read command, pre-read the pre-reads data (sector-size being had been written into sector of entire sector Pre-reads data), by pre-reads data storage in the pre- read buffer of sector command structure.
Step 10, pre- read command return.
Sectors status is issued status modifier as reading return processing state by step 11 by pre-reading.
Step 12 reads corresponding number according to the read command issued in chained list from the pre-reads data that pre- read buffer includes According to, and the data of reading are returned into upper layer application.
Step 13 judges to wait in chained list with the presence or absence of read command.
If not, thening follow the steps 14;If so, thening follow the steps 15.
Step 14 deletes sector command structure from Hash table.
Step 15 will wait for all read commands in chained list to be added to and issue chained list, return to step 12.
Based on inventive concept same as the above method, a kind of control of disk sector is additionally provided in the embodiment of the present invention The control device of device, the disk sector can be applied in storage device, and the control device of the disk sector can be by soft Part is realized, can also be realized by way of hardware or software and hardware combining.For implemented in software, as a logical meaning On device, be to be referred to corresponding computer program in nonvolatile memory by the processor of the storage device where it It enables and reads what operation in memory was formed.For hardware view, as shown in figure 8, for the control of disk sector proposed by the present invention A kind of hardware structure diagram of storage device where device processed, in addition to processor shown in Fig. 8, network interface, memory and non- Outside volatile memory, storage device can also include other hardware, such as be responsible for the forwarding chip of processing message;From hardware knot From structure, which is also possible to be distributed apparatus, may include multiple interface cards, to be reported in hardware view The extension of text processing.
As shown in figure 9, the structure chart of the control device for disk sector proposed by the present invention, the control dress of the disk sector Setting can apply in storage device, and the control device of the disk sector specifically includes:
Determining module 11, for receiving the write order less than sector-size, and determine the corresponding sector of the write order with The corresponding sector command structure in the sector, wherein the sector command structure specifically include sectors status, pre- read buffer, under It sends out chained list and waits for chained list, and the pre- read buffer includes the pre- reading for the sector-size being had been written into the sector According to;If the sectors status is to pre-read the state of issuing, the write order is added to and described issues chained list;If the fan Zone state is to merge to write hair-like state, then the write order is added to the waiting chained list;
Writing module 12, for when pre- read command returns, merging institute in the pre-reads data that the pre- read buffer includes The write order issued in chained list is stated, and the data after merging are written to the sector;
It, will be in the waiting chained list if there are write orders in the waiting chained list when merging write order return Write order, which is added to, issues chained list, and is issued in chained list described in merging in the pre-reads data that the pre- read buffer includes and write life It enables, and the data after merging is written to the sector.
The sector command structure is managed by Hash table, and the Hash table is with the corresponding logical block addresses in sector LBA value is key assignments;
The determining module 11, specifically for determining the corresponding sector in the corresponding sector of the write order and the sector During imperative structures, the address information of sector to be written is obtained from write order, and determine using described address information The corresponding sector of the write order;The key assignments that the Hash table is inquired by the LBA value of the determining sector, obtains the fan The corresponding sector command structure of LBA value in area;The determining module 11 is additionally operable to after determining the corresponding sector of write order, such as The corresponding sector command structure in the sector is not present in fruit, creates the corresponding sector command structure in the sector, records the fan The sectors status of area's imperative structures is to pre-read the state of issuing, and the sector-size having been written into is read from the sector Pre-reads data stores the pre-reads data in the pre- read buffer of the sector command structure;
Said write module 12 is additionally operable to when the sectors status is to pre-read to issue state, in the pre- read buffer packet Write order in chained list is issued described in merging in the pre-reads data contained, and after the data after merging are written to the sector, Then by the sectors status of the sector command structure by pre-read issue status modifier be merge write hair-like state;When the merging is write When order returns, if there is no write orders, and it is corresponding to delete the sector after the preset lime in the waiting chained list Sector command structure.
In the embodiment of the present invention, said write module 12, specifically in the pre-reads data that the pre- read buffer includes During issuing the write order in chained list described in merging, when described issue in chained list comprising multiple write orders, according to described Multiple write orders are added to the chronological order for issuing chained list, and the multiple write order is merged into described pre-read successively In data.Said write module 12, specifically for issuing chained list described in the merging in the pre-reads data that the pre- read buffer includes In write order during, it is big according to the write order issued in chained list the first offset within the sector and first It is small, using memory copying mode, since first offset, by the write order copy that the pre- read buffer includes to it is pre- Data are read, and size of the write order in the pre-reads data is first size.
The determining module 11 is additionally operable to receive the read command less than sector-size, determines the corresponding fan of the read command The corresponding sector command structure in area and the sector, the sector command structure include sectors status, pre- read buffer, issue chained list Include the pre-reads data for the sector-size being had been written into the sector with chained list, pre- read buffer is waited for;If the fan Zone state is to pre-read the state of issuing, then is added to the read command and issues chained list;If the sectors status is read at return The read command is then added to waiting chained list by reason state;After determining the corresponding sector of the read command, if there is no institute The corresponding sector command structure in sector is stated, then creates the corresponding sector command structure in the sector, records the sector command knot The sectors status of structure is to pre-read the state of issuing, and the pre-reads data for the sector-size having been written into is read from the sector, And store the pre-reads data in the pre- read buffer of the sector command structure;
Described device further includes:Read module 13 is used for when pre- read command returns, by sectors status by pre-reading lower hair-like State is revised as reading to return to processing state, is read from the pre-reads data that the pre- read buffer includes according to the read command issued in chained list Corresponding data are taken, and the data of reading are returned into upper layer application;In the case where reading to return to processing state, if waiting for chained list memory In read command, then the read command in the waiting chained list is added to and issues chained list, according to the read command issued in chained list from institute It states and reads corresponding data in the pre-reads data that pre- read buffer includes, and the data of reading are returned into upper layer application.
Wherein, the modules of apparatus of the present invention can be integrated in one, and can also be deployed separately.Above-mentioned module can close And be a module, multiple submodule can also be further split into.
Through the above description of the embodiments, those skilled in the art can be understood that the present invention can be by Software adds the mode of required general hardware platform to realize, naturally it is also possible to which by hardware, but the former is more in many cases Good embodiment.Based on this understanding, technical scheme of the present invention substantially in other words contributes to the prior art Part can be expressed in the form of software products, which is stored in a storage medium, if including Dry instruction is used so that a computer equipment (can be personal computer, server or the network equipment etc.) executes this hair Method described in bright each embodiment.It will be appreciated by those skilled in the art that attached drawing is the schematic diagram of a preferred embodiment, Module or flow in attached drawing are not necessarily implemented necessary to the present invention.
It will be appreciated by those skilled in the art that the module in device in embodiment can describe be divided according to embodiment It is distributed in the device of embodiment, respective change can also be carried out and be located in one or more devices different from the present embodiment.On The module for stating embodiment can be merged into a module, can also be further split into multiple submodule.The embodiments of the present invention Serial number is for illustration only, can not represent the quality of embodiment.
Disclosed above is only several specific embodiments of the present invention, and still, the present invention is not limited to this, any ability What the technical staff in domain can think variation should all fall into protection scope of the present invention.

Claims (8)

1. a kind of control method of disk sector, which is characterized in that the described method comprises the following steps:
The write order less than sector-size is received, determines the corresponding sector command in the corresponding sector of the write order and the sector Structure, the sector command structure include sectors status, pre- read buffer, issue chained list and wait for chained list, the pre- read buffer packet Pre-reads data containing the sector-size being had been written into the sector;If the sectors status is to pre-read the state of issuing, Then the write order is added to and issues chained list;If the sectors status is to merge to write hair-like state, by the write order It is added to waiting chained list;
When pre- read command returns, is issued in chained list described in merging in the pre-reads data that the pre- read buffer includes and write life It enables, and the data after merging is written to the sector;
When merging write order return, if there are write orders in the waiting chained list, it described will wait in chained list and write life Order, which is added to, issues chained list, and in the pre-reads data that the pre- read buffer includes merge described in issue chained list in write order, And the data after merging are written to the sector;
The sector command structure is managed by Hash table, and the Hash table is with the corresponding logical block addresses LBA in sector Value is key assignments;
The process of the corresponding sector command structure in the corresponding sector of the determination write order and the sector, specifically includes: The address information of sector to be written is obtained from the write order, and determines that the write order corresponds to using described address information Sector;And the key assignments of the Hash table is inquired by the LBA value of the determining sector, obtain the LBA value of the sector Corresponding sector command structure;
The method further includes:After determining the corresponding sector of the write order, if there is no the corresponding sector in the sector Imperative structures create the corresponding sector command structure in the sector, and the sectors status for recording the sector command structure is to pre-read State is issued, and reads the pre-reads data for the sector-size having been written into from the sector, in the sector command knot The pre-reads data is stored in the pre- read buffer of structure;
When the sectors status is to pre-read to issue state, issued described in merging in the pre-reads data that the pre- read buffer includes Write order in chained list, and after the data after merging are written to the sector, by the sector-like of the sector command structure State by pre-read issue status modifier be merge write hair-like state;
When the merging write order returns, the method further includes:If write order is not present in the waiting chained list, Then after the preset lime, the corresponding sector command structure in the sector is deleted.
2. according to the method described in claim 1, it is characterized in that, described close in the pre-reads data that the pre- read buffer includes And the process for issuing the write order in chained list, it specifically includes:
When it is described issue in chained list include multiple write orders when, according to the multiple write order be added to it is described issue chained list when Between sequencing, the multiple write order is merged into the pre-reads data successively.
3. method according to claim 1 or 2, which is characterized in that the pre-reads data for including in the pre- read buffer The process that the write order in chained list is issued described in middle merging, specifically includes:
According to the write order issued in chained list within the sector first offset and the first size, use memory copying side Formula copies the write order to pre-reads data that the pre- read buffer includes, and described write life since first offset It is first size to enable the size in the pre-reads data.
4. according to the method described in claim 1, it is characterized in that, the method further includes:
The read command less than sector-size is received, determines the corresponding sector command in the corresponding sector of the read command and the sector Structure;If the sectors status is to pre-read the state of issuing, the read command is added to and issues chained list;If the sector State is to read to return to processing state, then the read command is added to waiting chained list;Wherein, determining that the read command is corresponding Behind sector, if there is no the corresponding sector command structure in the sector, then the corresponding sector command structure in the sector is created, The sectors status for recording the sector command structure is to pre-read the state of issuing, and described in reading from the sector and having been written into The pre-reads data of sector-size, and store the pre-reads data in the pre- read buffer of the sector command structure;
When pre- read command returns, by sectors status, to issue status modifier be to read to return to processing state by pre-reading, according to issuing chain Corresponding data are read in read command in table from the pre-reads data that the pre- read buffer includes, and the data of reading are returned to Upper layer application;In the case where reading to return to processing state, if waited in chained list, there are read commands, and the reading in the waiting chained list is ordered Order, which is added to, issues chained list, reads correspondence from the pre-reads data that the pre- read buffer includes according to the read command issued in chained list Data, and the data of reading are returned into upper layer application.
5. a kind of control device of disk sector, which is characterized in that described device specifically includes:
Determining module for receiving the write order less than sector-size, and determines the corresponding sector of write order and the fan The corresponding sector command structure in area, wherein the sector command structure specifically includes sectors status, pre- read buffer, issues chained list With wait for chained list, and the pre- read buffer includes the pre-reads data of the sector-size being had been written into the sector;If The sectors status is to pre-read the state of issuing, then is added to the write order and described issues chained list;If the sectors status It is to merge to write hair-like state, then the write order is added to the waiting chained list;
Writing module, for when pre- read command returns, being issued described in merging in the pre-reads data that the pre- read buffer includes Write order in chained list, and the data after merging are written to the sector;
When merging write order return, if there are write orders in the waiting chained list, it described will wait in chained list and write life Order, which is added to, issues chained list, and in the pre-reads data that the pre- read buffer includes merge described in issue chained list in write order, And the data after merging are written to the sector;
The sector command structure is managed by Hash table, and the Hash table is with the corresponding logical block addresses LBA in sector Value is key assignments;
The determining module, specifically for determining the corresponding sector command knot in the corresponding sector of the write order and the sector During structure, the address information of sector to be written is obtained from write order, and write using described in the determination of described address information Order corresponding sector;The key assignments that the Hash table is inquired by the LBA value of the determining sector, obtains the sector The corresponding sector command structure of LBA value;
The determining module is additionally operable to after determining the corresponding sector of write order, if there is no the corresponding sector in the sector Imperative structures create the corresponding sector command structure in the sector, and the sectors status for recording the sector command structure is to pre-read State is issued, and reads the pre-reads data for the sector-size having been written into from the sector, in the sector command knot The pre-reads data is stored in the pre- read buffer of structure;
Said write module is additionally operable to when the sectors status is to pre-read to issue state, the pre- read buffer include it is pre- Write order in chained list is issued described in reading to merge in data, and after the data after merging are written to the sector, then by institute Stating the sectors status of sector command structure, to issue status modifier be to merge to write hair-like state by pre-reading;When the merging write order returns Hui Shi after the preset lime, deletes the corresponding sector life in the sector if write order is not present in the waiting chained list Enable structure.
6. device according to claim 5, which is characterized in that said write module is specifically used in the pre- read buffer Including pre-reads data in merge described in issue write order in chained list during, when described issue in chained list is write comprising multiple When order, it is added to the chronological order for issuing chained list according to the multiple write order, writes life by the multiple successively Order is merged into the pre-reads data.
7. device according to claim 5 or 6, which is characterized in that said write module, specifically for it is described pre-read it is slow During issuing the write order in chained list described in merging in the pre-reads data that bag deposit contains, life is write according to described issue in chained list The first offset and the first size within the sector is enabled, it will be described since first offset using memory copying mode Write order copies the pre-reads data that the pre- read buffer includes to, and size of the write order in the pre-reads data is institute State the first size.
8. device according to claim 5, which is characterized in that
The determining module is additionally operable to receive the read command less than sector-size, determines the corresponding sector of the read command and institute State the corresponding sector command structure in sector;If the sectors status is to pre-read the state of issuing, the read command is added to Issue chained list;If the sectors status is to read to return to processing state, the read command is added to waiting chained list;In determination Behind the corresponding sector of the read command, if there is no the corresponding sector command structure in the sector, then the sector pair is created The sector command structure answered, the sectors status for recording the sector command structure are to pre-read the state of issuing, and are read from the sector The pre-reads data for the sector-size having been written into is taken, and is stored in the pre- read buffer of the sector command structure described pre- Read data;
Described device further includes:Read module, for when pre- read command returns, sectors status to be issued status modifier by pre-reading To read to return to processing state, correspondence is read from the pre-reads data that the pre- read buffer includes according to the read command issued in chained list Data, and the data of reading are returned into upper layer application;In the case where reading to return to processing state, life is read if wait for and existing in chained list It enables, then the read command in the waiting chained list is added to and issues chained list, pre-read from described according to the read command issued in chained list Corresponding data are read in the pre-reads data that caching includes, and the data of reading are returned into upper layer application.
CN201510893255.XA 2015-11-27 2015-11-27 A kind of control method and device of disk sector Active CN105302501B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510893255.XA CN105302501B (en) 2015-11-27 2015-11-27 A kind of control method and device of disk sector

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510893255.XA CN105302501B (en) 2015-11-27 2015-11-27 A kind of control method and device of disk sector

Publications (2)

Publication Number Publication Date
CN105302501A CN105302501A (en) 2016-02-03
CN105302501B true CN105302501B (en) 2018-09-14

Family

ID=55199814

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510893255.XA Active CN105302501B (en) 2015-11-27 2015-11-27 A kind of control method and device of disk sector

Country Status (1)

Country Link
CN (1) CN105302501B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105912267B (en) * 2016-04-05 2019-01-18 深圳市四季宏胜科技有限公司 A kind of file allocation table treating method and apparatus
CN107797760B (en) * 2016-09-05 2021-06-11 北京忆恒创源科技有限公司 Method and device for accessing cache information and solid-state drive
CN106980469A (en) * 2017-03-07 2017-07-25 记忆科技(深圳)有限公司 A kind of method for improving solid state hard disc sequential write buffer efficiency
CN114253483B (en) * 2021-12-24 2023-07-04 深圳忆联信息系统有限公司 Command-based write cache management method and device, computer equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102087586A (en) * 2009-12-02 2011-06-08 成都市华为赛门铁克科技有限公司 Data processing method and device
CN104503710A (en) * 2015-01-23 2015-04-08 福州瑞芯微电子有限公司 Method and device for increasing writing speed of nand flash

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7139864B2 (en) * 2003-12-30 2006-11-21 Sandisk Corporation Non-volatile memory and method with block management system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102087586A (en) * 2009-12-02 2011-06-08 成都市华为赛门铁克科技有限公司 Data processing method and device
CN104503710A (en) * 2015-01-23 2015-04-08 福州瑞芯微电子有限公司 Method and device for increasing writing speed of nand flash

Also Published As

Publication number Publication date
CN105302501A (en) 2016-02-03

Similar Documents

Publication Publication Date Title
US7401174B2 (en) File system defragmentation and data processing method and apparatus for an information recording medium
CN105302501B (en) A kind of control method and device of disk sector
US10120795B2 (en) Wear-leveling nandflash memory reading/writing method
US20090157756A1 (en) File System For Storing Files In Multiple Different Data Storage Media
US7330947B2 (en) Method and apparatus for backing up data in virtual storage medium
CN104636266B (en) Cover tile magnetic recording hard disk, cover tile magnetic recording hard disk write method and the device of data
US20180366158A1 (en) Method for accessing shingled magnetic recording smr disk, and server
CN103608866A (en) Data wiping method and device for flash memory
CN110018966A (en) A kind of memory, storage system, host and data manipulation, rubbish recovering method
CN107644056B (en) File storage method, device and system
CN107111531A (en) Use the data recovery of distribution diagram
CN113377579B (en) Solid state disk data recovery method and system based on mapping table
KR20110005817A (en) Memory drive that can be operated like optical disk drive and method for virtualizing memory drive as optical disk drive
CN105589733B (en) A kind of data processing method and device
GB2413196A (en) Data storage method in which the memory space is divided into high reliability and low reliability areas
JP3511053B2 (en) Optical storage medium recorded in incremental packet mode
KR101481898B1 (en) Apparatus and method for scheduling command queue of solid state drive
CN107341073A (en) A kind of method and device for realizing container compatible mainframe fictitious host computer image file
CN111399774B (en) Data processing method and device based on snapshot under distributed storage system
JP2000215644A (en) Video recording/reproducing apparatus
JP2006323462A (en) File-copying device and file-copying method
JP4211563B2 (en) Playback / recording device
KR101102754B1 (en) Nand flash memory file system and method for accessing file thereof
JP5491201B2 (en) Semiconductor recording apparatus and semiconductor recording system
JP7435470B2 (en) Information processing device, information processing method, and information processing program

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant