CN108021513A - A kind of date storage method and device - Google Patents

A kind of date storage method and device Download PDF

Info

Publication number
CN108021513A
CN108021513A CN201610946331.3A CN201610946331A CN108021513A CN 108021513 A CN108021513 A CN 108021513A CN 201610946331 A CN201610946331 A CN 201610946331A CN 108021513 A CN108021513 A CN 108021513A
Authority
CN
China
Prior art keywords
data
stored
correspondence
virtual memory
section
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.)
Granted
Application number
CN201610946331.3A
Other languages
Chinese (zh)
Other versions
CN108021513B (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.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN201610946331.3A priority Critical patent/CN108021513B/en
Publication of CN108021513A publication Critical patent/CN108021513A/en
Application granted granted Critical
Publication of CN108021513B publication Critical patent/CN108021513B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache

Abstract

The embodiment of the present application provides a kind of date storage method and device, applied to terminal, the terminal includes at least one disk, disk is divided at least two virtual memory sections according to the order of physical address, and metadata memory paragraph is used to store the first kind correspondence storehouse of correspondence between the mark of storage file and each virtual memory section.The date storage method includes:Receive the data to be stored of file destination;According to the mark of file destination and first kind correspondence storehouse, the destination virtual memory paragraph for storing data to be stored is determined;According to the end storage location that data are stored in destination virtual memory paragraph, the capacity of free memory in destination virtual memory paragraph is obtained;Judge whether the capacity is more than or equal to the data volume of the data to be stored;If it is, using the end storage location as the start memory location of data to be stored, data to be stored is stored to destination virtual memory paragraph.The present embodiment can reduce the time for reading file data.

Description

A kind of date storage method and device
Technical field
This application involves field of computer technology, more particularly to a kind of date storage method and device.
Background technology
Computer is when storing data, generally can be according to disk physics if current file to be stored only has one The data of sequential storage this document of address.With increasing for file to be stored, disk generally requires to store multiple files at the same time Data., can be according to the order-assigned physical address of data arrival when disk stores the data of multiple files at the same time.And at the same time What the data of multiple files of storage often alternately reached, in this way, the data of a file may be stored in multistage In scattered physical address.
When reading the file stored in the manner described above, since the data of this document are dispersed in different physical address In, these physical address may correspond to different disk sector and magnetic track, and therefore, the mechanical arm of disk needs continually to switch Sector and magnetic track, certainly will so extend the time for reading file data.
The content of the invention
The purpose of the embodiment of the present application is the provision of a kind of date storage method and device, to reduce reading file data Time.Specific technical solution is as follows.
In order to achieve the above object, this application discloses a kind of date storage method, applied to terminal, the terminal includes At least one disk, the disk are divided at least two virtual memory sections, each virtual memory according to the order of physical address The corresponding range of physical addresses of section is misaligned, and the virtual memory section for being identified as preset value is metadata memory paragraph;Wherein, the member Data storing section, the mark pass corresponding with the first kind of correspondence between each virtual memory section for storing storage file It is storehouse, the mark of Duan Yuyi file of a virtual memory corresponds to;The described method includes:
Receive the data to be stored of file destination;
According to the mark of the file destination and the first kind correspondence storehouse, determine to be used to store the number to be stored According to destination virtual memory paragraph;
According to the end storage location that data are stored in the destination virtual memory paragraph, the destination virtual storage is obtained The capacity of free memory in section;
Judge whether the capacity is more than or equal to the data volume of the data to be stored;
If it is, using the end storage location as the start memory location of the data to be stored, wait to deposit by described Storage data are stored to the destination virtual memory paragraph.
Optionally, the metadata memory paragraph, is additionally operable to storage and represents whether each virtual memory section has stored data Storage mark;The method further includes:
When the capacity is less than the data volume of the data to be stored, the data to be stored is divided into the first data With the second data, wherein, the data volume of first data is equal to the capacity;
Identified according to the storage, never store and determined in the virtual memory section of data for storing second data First virtual memory section;
Start memory location using the end storage location as first data, first data are stored to institute Destination virtual memory paragraph is stated, second data are stored to the first virtual memory section.
Optionally, the mark according to the file destination and the first kind correspondence storehouse, determine to be used to store The step of destination virtual memory paragraph of the data to be stored, including:
Judge in the first kind correspondence storehouse with the presence or absence of the correspondence of the mark for the file destination;
If it is, determine that the file destination is in storage state, and from the first kind correspondence storehouse with In the corresponding virtual memory section of mark of the file destination, determine that the destination virtual for storing the data to be stored stores Section;
If it is not, then determining that the file destination is in non-storage state, and identified according to the storage, never store number According to virtual memory section in determine destination virtual memory paragraph for storing the data to be stored.
Optionally, in the mark according to the file destination and the first kind correspondence storehouse, determine to be used to deposit Before the step of storing up the destination virtual memory paragraph of the data to be stored, further include:
Determine first logical address section of the data to be stored in the file destination;
The metadata memory paragraph, be additionally operable to storage data logical address section hereof with disk physically Second class correspondence storehouse of correspondence between the section of location;
The data to be stored was stored the step of destination virtual memory paragraph described, is further included:
Determine the target physical address section of the storage data to be stored, wherein, the starting of the target physical address section Physical address is the end storage location, terminates number of the physical address for the end storage location and the data to be stored According to the sum of amount;
First correspondence of the first logical address section and target physical address section is stored to second class pair It should be related to storehouse.
Optionally, described the step of determining the first logical address section of the data to be stored in the file destination, Including:
According to the order for receiving the data to be stored, first of the data to be stored in the file destination is determined Logical address section.
Optionally, first correspondence by the first logical address section and target physical address section is stored to institute The step of stating the second class correspondence storehouse, including:
Obtain the target correspondence for the file destination stored in the second class correspondence storehouse;
Judge in the target correspondence with the presence or absence of logical address section it is adjacent with the first logical address section, and Physical address section second correspondence adjacent with the target physical address section;
If it is present merge first correspondence and the second correspondence, and by second correspondence more The new correspondence for after merging.
Optionally, the metadata memory paragraph, is additionally operable to store the mark of storage file and writes behaviour for carrying out covering The three classes correspondence storehouse of correspondence between the virtual memory section of work;
The mark according to the file destination and the first kind correspondence storehouse, determine to be used for store and described wait to deposit The step of storing up the destination virtual memory paragraph of data, including:
Judge to whether there is the correspondence for the first logical address section in the second class correspondence storehouse;
If it is present determine the data to be stored to cover overwriting data, will in the three classes correspondence storehouse and The corresponding virtual memory section of mark of the file destination is determined as the second virtual memory section, from the second virtual memory section Determine the destination virtual memory paragraph for storing the data to be stored.
Optionally, the metadata memory paragraph, being additionally operable to storage, the mark of storage file writes behaviour with being used to add 4th class correspondence storehouse of correspondence between the virtual memory section of work;The method further includes:
When the correspondence for the first logical address section is not present in the second class correspondence storehouse, determine The data to be stored writes data for addition, will be corresponding with the mark of the file destination in the 4th class correspondence storehouse Virtual memory section is determined as the 3rd virtual memory section, determines to be used to store the number to be stored from the 3rd virtual memory section According to destination virtual memory paragraph.
Optionally, first correspondence by the first logical address section and target physical address section is stored to institute The step of stating the second class correspondence storehouse, including:
The original correspondence for the first logical address section is searched from the second class correspondence storehouse;
The original correspondence is updated to the first corresponding of the first logical address section and target physical address section Relation.
In order to achieve the above object, this application discloses a kind of data storage device, applied to terminal, the terminal includes At least one disk, the disk are divided at least two virtual memory sections, each virtual memory according to the order of physical address The corresponding range of physical addresses of section is misaligned, and the virtual memory section for being identified as preset value is metadata memory paragraph;Wherein, the member Data storing section, the mark pass corresponding with the first kind of correspondence between each virtual memory section for storing storage file It is storehouse, the mark of Duan Yuyi file of a virtual memory corresponds to;Described device includes:
Data reception module, for receiving the data to be stored of file destination;
Memory paragraph determining module, for the mark according to the file destination and the first kind correspondence storehouse, determines For storing the destination virtual memory paragraph of the data to be stored;
Procurement of reserve capacity module, for according to the end storage location that data are stored in the destination virtual memory paragraph, obtaining Take the capacity of free memory in the destination virtual memory paragraph;
Capacity determination module, for judging whether the capacity is more than or equal to the data volume of the data to be stored;
Data memory module, for when the capacity be more than or equal to the data to be stored data volume when, with the end Tail storage location is the start memory location of the data to be stored, and the data to be stored is stored to the destination virtual and is deposited Store up section.
Optionally, the metadata memory paragraph, is additionally operable to storage and represents whether each virtual memory section has stored data Storage mark;Described device further includes:
Data segmentation module, for when the capacity be less than the data to be stored data volume when, will be described to be stored Data are divided into the first data and the second data, wherein, the data volume of first data is equal to the capacity;
The memory paragraph determining module, is additionally operable to be identified according to the storage, in the virtual memory section for never storing data Determine the first virtual memory section for storing second data;
The data memory module, is additionally operable to the starting using the end storage location as first data and stores position Put, first data are stored to the destination virtual memory paragraph, second data are stored to described first and are virtually deposited Store up section.
Optionally, the memory paragraph determining module, including:
First judging submodule, the file destination is directed to for judging to whether there is in the first kind correspondence storehouse Mark correspondence;
First determination sub-module, for when the judging result of first judging submodule is is, determining the target File is in storage state, and corresponding with the mark of the file destination from the first kind correspondence storehouse virtually deposits Store up in section, determine the destination virtual memory paragraph for storing the data to be stored;
Second determination sub-module, for when the judging result of first judging submodule is no, determining the target File is in non-storage state, and is identified according to the storage, never stores and determines to be used to store in the virtual memory section of data The destination virtual memory paragraph of the data to be stored.
Optionally, before the memory paragraph determining module, further include:
Logical address section determining module, for determine the data to be stored in the file destination first logically Location section;
The metadata memory paragraph, be additionally operable to storage data logical address section hereof with disk physically Second class correspondence storehouse of correspondence between the section of location;
After the data memory module, further include:
Physical address section determining module, for determining the target physical address section of the storage data to be stored, wherein, institute The start physical address for stating target physical address section is the end storage location, terminates physical address and stores position for the end Put with the data volume of the data to be stored and;
First correspondence memory module, for by the first couple of the first logical address section and target physical address section It should be related to and store to the second class correspondence storehouse.
Optionally, the logical address section determining module, is specifically used for:
According to the order for receiving the data to be stored, first of the data to be stored in the file destination is determined Logical address section.
Optionally, the first correspondence memory module, including:
Submodule is obtained, for obtaining the target for the file destination stored in the second class correspondence storehouse Correspondence;
Second judgment submodule, for judging to whether there is logical address section and described first in the target correspondence Logical address section is adjacent, and the second correspondence that physical address section is adjacent with the target physical address section;
First renewal submodule, for when the judging result of the second judgment submodule is is, merging described first Correspondence and the second correspondence, and second correspondence is updated to the correspondence after merging.
Optionally, the metadata memory paragraph, is additionally operable to store the mark of storage file and writes behaviour for carrying out covering The three classes correspondence storehouse of correspondence between the virtual memory section of work;
The memory paragraph determining module, including:
3rd judging submodule, first logic is directed to for judging to whether there is in the second class correspondence storehouse The correspondence of address field;
3rd determination sub-module, for when the judging result of the 3rd judging submodule is is, determining described to wait to deposit Storage data is cover overwriting data, by virtual memory corresponding with the mark of the file destination in the three classes correspondence storehouse Section is determined as the second virtual memory section, and the target for storing the data to be stored is determined from the second virtual memory section Virtual memory section.
Optionally, the metadata memory paragraph, being additionally operable to storage, the mark of storage file writes behaviour with being used to add 4th class correspondence storehouse of correspondence between the virtual memory section of work;The memory paragraph determining module further includes:
4th determination sub-module, for when the 3rd judging submodule judging result for it is no when, determine described to wait to deposit Storage data write data for addition, by virtual memory corresponding with the mark of the file destination in the 4th class correspondence storehouse Section is determined as the 3rd virtual memory section, and the target for storing the data to be stored is determined from the 3rd virtual memory section Virtual memory section.
Optionally, the first correspondence memory module, including:
Submodule is searched, for searching the original for the first logical address section from the second class correspondence storehouse Beginning correspondence;
Second renewal submodule, for the original correspondence to be updated to the first logical address section and object Manage the first correspondence of address field.
As seen from the above technical solution, in the embodiment of the present application, the terminal as executive agent is receiving file destination Data to be stored when, according to the first kind correspondence storehouse stored in the mark of file destination and metadata memory paragraph, determine Stored for storing the destination virtual memory paragraph of data to be stored, and according to the end that data are stored in destination virtual memory paragraph Position, obtains the capacity of free memory in destination virtual memory paragraph, when the capacity is more than or equal to the data of data to be stored During amount, the start memory location using the end storage location as data to be stored, is stored to destination virtual memory paragraph.
During using above-mentioned data storage method, the data in virtual memory section are sequential storages.And due to virtual memory Section in division is divided according to the order of physical address, and the corresponding physical address of each virtual memory section is suitable from small to large Sequence is increased, therefore the data in virtual memory section are the sequential storages according to physical address.Using the embodiment of the present application Technical solution, reduces the degree of scatter for the physical address section that file data is stored, therefore when reading file data, can Reduce the time for reading file data.
Brief description of the drawings
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, below will be to embodiment or existing There is attached drawing needed in technology description to be briefly described.It should be evident that drawings in the following description are only this Some embodiments of application, for those of ordinary skill in the art, without creative efforts, can be with Other attached drawings are obtained according to these attached drawings.
Fig. 1 is a kind of flow diagram of date storage method provided by the embodiments of the present application;
Fig. 2 is a kind of structure diagram after division virtual memory section inside disk;
Fig. 3 is a kind of flow diagram when the judging result of step S104 in Fig. 1 is no;
Fig. 4 is another flow diagram of date storage method provided by the embodiments of the present application;
Fig. 5 is a kind of flow diagram of step S102 in Fig. 4;
Fig. 6 is a kind of structure diagram of data storage device provided by the embodiments of the present application;
Fig. 7 is another structure diagram of data storage device provided by the embodiments of the present application.
Embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, the technical solution in the embodiment of the present application is carried out clear, complete Whole description.Obviously, described embodiment is only the part of the embodiment of the application, instead of all the embodiments.Base Embodiment in the application, those of ordinary skill in the art are obtained all on the premise of creative work is not made Other embodiment, shall fall in the protection scope of this application.
The embodiment of the present application provides a kind of date storage method and device, can reduce the time for reading file data.
In order to make the statement of the application clearer, be listed below this application involves technical term.
File system:It is present in host side, the software with storage file information is responsible in operating system, is to file The space of storage device carries out tissue and distribution, is responsible for the system that file stores and the file of deposit is protected and retrieved.
SSD:The manufactured hard disk with solid-state electronic storage chip array, by control unit and storage unit (FLASH cores Piece, dram chip) composition.
SMR(Shingled Magnetic Recording):Full name is stacked tile type Magnetographic Technology, is storage of new generation Technology, the technology make the structure of medium pass through overlapping magnetic track there occurs the change of matter --- similar to the stacking tile on roof, weight It is new to have adjusted the mode of data storage, and then track density is improved, add the capacity of single dish.SMR disks are divided into three species Type:Host Administration Host Manage, host perceive Host Aware and driven management Drive Manage.
zone:Memory space on disk is cut into multiple continuous spaces, is referred to as zone, i.e., the storage on disk Unit or memory paragraph.On the memory paragraph, there is certain characteristic --- when data make write operation, sequential write can only be carried out.This Zone in application has two layers of definition, one layer be disk define in itself be known as Pzone;One layer is that file system defines, and is claimed For Vzone.
CMR:ColossalMR, especially big magneto-resistor in rare earth doped oxide.A kind of medium in mechanical disk, it is allowed to It is machine-readable to write.
Logical address:A kind of address that file system abstracts, is to fictionalize a kind of address come, you can to describe number According to the address of offset hereof, its object is file.
Physical address:The LBA addresses of the visible LBA of host side (Logic Block Address) address, i.e. disk, often A LBA corresponds to the physical address of physical presence on physical disk, for file system or operating system (host side), disk The LBA addresses at (disk end) are changeless.
Host Manage:A kind of disk by host side control read-write, it is actual physically that its read-write object refers to disk Location.I.e. the LBA addresses of host side are linear and one-to-one with disk physical address.Thus, host side stores Pzone The write operation of section must assure that it is order write operation, and otherwise disk can report an error.In the structure of disk, there are CMR and SMR areas, CMR areas allow random read-write.
Host Aware:A kind of disk by host side control read-write, its read-write object refer to the physical address of disk reality. I.e. the LBA addresses of host side are linear and one-to-one with disk physical address.It is different from Host Manage, in Pzone In memory paragraph, host side can carry out random writing operations, but its write performance can decline very much.
Drive Manage:A kind of disk by disk control read-write, its read-write object refer to the physical address of disk reality. I.e. the LBA addresses of host side are nonlinear with disk physical address, i.e., its Pzone and LBA has carried out non-linear on algorithm Mapping, this part is realized by disk firmware.Different from Host Manage and Host Aware, Drive manage can be carried out Random write, its performance depend on the firmware algorithm of hard disk itself.In addition, it also supports erasing trim instructions.
Random write:The physical address section of write-in exists compared with large span, or the end of the physical address section more than last time write-in Tail address, or the end address of the physical address section less than last time write-in.
Sequential write:The physical address section of write-in accepts the end address of the physical address section of last write-in every time, is referred to as For sequential write.
Trim:Storage device is told to wipe the interface instruction of which data.
Random write:The physical address section of write-in exists compared with large span, or the end of the physical address section more than last time write-in Tail address, or the end address of the physical address section less than last time write-in.
Below by specific embodiment, the application is described in detail.
Fig. 1 is a kind of flow diagram of date storage method provided by the embodiments of the present application, applied to terminal.The end End can include the equipment such as computer, laptop, tablet computer, smart mobile phone.The terminal includes at least one disk, The disk is divided at least two virtual memory sections according to the order of physical address, and each virtual memory section is corresponding physically Location scope is misaligned.In division, the corresponding physical address section of each virtual memory section can be usually divided into the same size , i.e., the capacity of the free memory of each virtual memory section can be identical.It is identified as the virtual memory section of preset value For metadata memory paragraph.
Wherein, the metadata memory paragraph, can be used for storage the mark of storage file and each virtual memory section it Between correspondence first kind correspondence storehouse, the mark of Duan Yuyi file of a virtual memory corresponds to.One file corresponds to Only one identifies.
As a kind of embodiment, the physical address section of metadata memory paragraph can be than the thing of other virtual memory sections The size of reason address field is some larger, and the size of the physical address section of other virtual memory sections can be the same.
It is pointed out that terminal includes at least two parts, a part is software section, i.e. operating system part, another Part is hardware components, i.e. disk segment.The present embodiment is specifically to be performed by the file system in terminal operating system.Should File system be responsible for storage file information, tissue and distribution are carried out to the space of file-storage device (i.e. disk), also It is responsible for storing file to disk and the file of deposit being protected and retrieved.
Fig. 2 is that disk is divided into a kind of structure diagram after virtual memory section.The mark of virtual memory section in figure Respectively Vzone0, Vzone1, Vzone2 ..., VzoneX etc., it is virtual below each virtual memory section to have indicated this in figure The start physical address num (x) and end physical address num (x+1) of the physical address section of memory paragraph, such as the physics of Vzone0 Address field is [num0, num1].The virtual memory section for being identified as Vzone0 is arranged to metadata memory paragraph.
When dividing virtual memory section, if there is actual memory paragraph Pzone in itself in disk, such as in SMR disks Type is the disk of Host manage and the disk of Host Aware, then when dividing Vzone, virtual memory section Vzone can be with Corresponded with Pzone.If disk there is no actual memory paragraph Pzone, can be stored according to actual data in itself Demand determines the size of the corresponding physical address sections of virtual memory section Vzone.For example, when disk is frequently necessary to storage big data text During part, can the corresponding physical address sections of Vzone be set larger;, can be with when disk often stores small data file The corresponding physical address sections of Vzone are set smaller.
Specifically, the date storage method of the present embodiment includes the following steps:
Step S101:Receive the data to be stored of file destination.
Specifically, terminal receive client transmission data to be stored when, if the data to be stored belongs to one New file, then terminal can create the file destination for data to be stored, and determine to deposit for storing the virtual of this document Store up section.If the data to be stored belongs to stored file, terminal can determine which the data to be stored belongs to A file.
Step S102:According to the mark of file destination and first kind correspondence storehouse, determine to be used to store data to be stored Destination virtual memory paragraph.
It is pointed out that first kind correspondence storehouse, for storing the mark of storage file and each virtual memory Correspondence between section.Virtual memory section corresponding with the mark of storage file, for storing the data of this document.
In the present embodiment, a virtual memory section only stores the data from a file, and the data of a file can To be stored in multiple virtual memory sections.When the data volume of this document is smaller, when not being filled with a virtual memory section, also no longer The data of alternative document are stored thereto.
In a kind of embodiment of the application, in the case of the data of stored mark file of looking over so as to check, first corresponds to The correspondence being stored with relation storehouse between the mark of file destination and each virtual memory section, so, according to file destination Mark and first kind correspondence storehouse, can be from first when determining the destination virtual memory paragraph for storing data to be stored The correspondence of the mark for the file destination is searched in class correspondence storehouse, according to the virtual memory in the correspondence Section, determines the destination virtual memory paragraph for storing data to be stored.
Virtual memory section in the correspondence can be one, or two and two or more.In definite target During virtual memory section, virtually depositing for data can not be filled with according to definite in virtual memory section corresponding with the mark of file destination Section is stored up, the virtual memory section of data is not filled with according to this, determines the destination virtual memory paragraph for storing data to be stored.
Step S103:According to the end storage location that data are stored in destination virtual memory paragraph, obtain destination virtual and deposit Store up the capacity of free memory in section.
Specifically, metadata memory paragraph, can be also used for storing the write pointer position in each virtual memory section, this writes finger Pin position is directed toward the physical address in virtual memory section, for representing that the end that data are stored in the virtual memory section stores position Put.When virtual memory Duan Zhongwei stores data, the value of its write pointer position is the start physical address of the virtual memory section, when When being filled with data in the virtual memory section, the value of its write pointer position is the end physical address of the virtual memory section.
According to the end storage location that data are stored in destination virtual memory paragraph, obtaining can use in destination virtual memory paragraph The capacity of memory space, can include:
The corresponding write pointer position of destination virtual memory paragraph in metadata memory paragraph is obtained, is by the write pointer location determination The end storage location of data is stored in destination virtual memory paragraph, by the end storage location and the end of destination virtual memory paragraph Physical address between tail physical address is sized to the capacity of free memory.
Step S104:Judge whether the capacity is more than or equal to the data volume of data to be stored, if it is, explanation target Virtual memory section can store data to be stored, perform step S105.
If it is not, then illustrate that the capacity can not leave data to be stored.Number to be stored how is stored in this case According to can be realized by numerous embodiments, it may be determined that the virtual memory sections of data is not stored to store data to be stored, A part of data of data to be stored can be stored in destination virtual memory paragraph, another part data, which are stored in, does not store data Virtual memory section in.The present embodiment is not specifically limited to how to store data in this case.
For example, capacity when each virtual memory section of disk does not store data is 256MB.Current goal virtual memory section The capacity of free memory be 54MB, the data volume of data to be stored is 10MB, due to 54MB>10MB, it is thus identified that mesh Mark virtual memory section can store data to be stored.When the data volume of data to be stored is 60MB, it is seen that 54MB<60MB, this In the case of kind, it may be determined that virtual memory section for not storing data stores the data to be stored.
Step S105:Start memory location using end storage location as data to be stored, by data to be stored store to Destination virtual memory paragraph.
When judging that the capacity is more than or equal to the data volume of data to be stored, data to be stored can be stored to mesh Mark virtual memory section.
It should be noted that using end storage location as the start memory location of data to be stored, data to be stored is deposited Storage illustrates in virtual memory section, data to be stored is the physical address according to virtual memory section to destination virtual memory paragraph Sequential storage from small to large, and in virtual memory intersegmental part be Coutinuous store.
As shown in the above, in the present embodiment, the terminal as executive agent is waited to deposit receiving file destination When storing up data, according to the first kind correspondence storehouse stored in the mark of file destination and metadata memory paragraph, determine to be used to deposit The destination virtual memory paragraph of data to be stored is stored up, and according to the end storage location that data are stored in destination virtual memory paragraph, The capacity of free memory in destination virtual memory paragraph is obtained, when the capacity is more than or equal to the data volume of data to be stored, Start memory location using the end storage location as data to be stored, is stored to destination virtual memory paragraph.
During using above-mentioned data storage method, the data in virtual memory section are sequential storages.And due to virtual memory Section in division is divided according to the order of physical address, and the corresponding physical address of each virtual memory section is suitable from small to large Sequence is increased, therefore the data in virtual memory section are the sequential storages according to physical address.Using the embodiment of the present application Technical solution, reduces the degree of scatter for the physical address section that file data is stored, therefore when reading file data, can Reduce the time for reading file data.
In a kind of embodiment of embodiment illustrated in fig. 1, when step S104 judging result for it is no when, can be by Data to be stored is stored according to the mode of flow diagram as shown in Figure 3.Wherein, the metadata memory paragraph, can be also used for depositing Storage represents whether each virtual memory section has stored the storage mark of data.For example, using 1 as the storage mark for having stored data Know, identified 0 as the storage for not storing data.Flow diagram includes shown in Fig. 3:
Step S106:When the capacity is less than the data volume of data to be stored, data to be stored is divided into the first number According to the second data, wherein, the data volume of first data is equal to the capacity.
Step S107:Identified according to the storage, never store and determine to be used to store second in the virtual memory section of data First virtual memory section of data.
Specifically, in order to reduce the degree of scatter of the data of file destination institute storage location, identified according to the storage, from Do not store determined in the virtual memory section of data for store the second data the first virtual memory section when, can be deposited according to described Storage mark, does not store recently and in the virtual memory sections of data from the physical address section with destination virtual memory paragraph, determines to use In the first virtual memory section for storing the second data.
Since terminal is when storing data, the data of multiple files are probably alternately to store, therefore are determining first During virtual memory section, the address of the first virtual memory section may be continuous with the address of destination virtual memory paragraph, it is also possible to discontinuous. , can be by the thing with destination virtual memory paragraph in order to reduce the degree of scatter for the physical address section that the data of file destination are stored Reason address field is immediate and does not store virtual memory section selected as the first virtual memory section of data.
As a kind of embodiment, due to when dividing each virtual memory section, according to the suitable of disk physical address Sequence is divided, and the numbering of virtual memory section is also to arrange from small to large according to the order of physical address, therefore, from target The physical address section of virtual memory section is nearest and does not store in the virtual memory section of data, determines for storing the second data First virtual memory section, can include:The virtual memory of data is not stored recently and from the numbering with destination virtual memory paragraph Duan Zhong, determines the first virtual memory section for storing the second data.
For example, in fig. 2, file A is stored in Vzone1, Vzone2 and Vzone4, file B is stored in Vzone3, Other Vzone do not store data.When file destination is file B, in the data to be stored of storage file B, if The residual capacity of Vzone3 is less than the data volume of data to be stored, then can select immediate not with the physical address of Vzone3 The Vzone5 of data is stored as the first virtual memory section.Since Vzone4 has stored the data of file A, it is It is not the virtual memory section for not storing data.
Step S108:Start memory location using the end storage location as first data, the first data are deposited Storage stores the second data to the first virtual memory section to destination virtual memory paragraph.
Due to not storing any data also in the first virtual memory section, its write pointer position is start physical address. When storing the second data to the first virtual memory section, the second data are stored since its start physical address.
In this embodiment, when the capacity of the free memory of destination virtual memory paragraph is less than data to be stored During data volume, when storing data to be stored, data to be stored is divided into two parts data, a part of data are used for destination virtual The free space of memory paragraph is filled with, and another part data are stored in the virtual memory section for not storing data.Therefore, it is literary with target If there is the virtual memory section for not being filled with data in the corresponding virtual memory section of mark of part, then the number of the virtual memory section Amount there is usually one.
As it can be seen that in this embodiment, when the capacity is less than the data volume of data to be stored, by data to be stored Two parts data are divided into, a part of data store to destination virtual memory paragraph, another part data and store to first and virtually deposit Store up section.That is, the data of file destination are stored at least in destination virtual memory paragraph and the first virtual memory section.Due to One virtual memory section be with the physical address of destination virtual memory paragraph recently and do not store the virtual memory section of data, therefore, In present embodiment, when the capacity is less than the data volume of data to be stored, the thing that file data is stored can be also reduced The degree of scatter of address field is managed, reduces the time for reading file data.
In a kind of embodiment of embodiment illustrated in fig. 1, file destination can be storage file or Non- storage file.Therefore, step S102, according to the mark of file destination and first kind correspondence storehouse, determines to treat for storage The destination virtual memory paragraph of data is stored, implementation below can be included:
Step 1:Judge with the presence or absence of the correspondence of the mark for file destination in first kind correspondence storehouse, if It is then to perform step 2;If it is not, then perform step 3.
When there is the correspondence for the mark of file destination in first kind correspondence storehouse, illustrate that file destination is Storage file.When the correspondence for the mark of file destination is not present in first kind correspondence storehouse, illustrate target File is non-storage file.
Step 2:Determine that file destination is in storage state, and the mark from first kind correspondence storehouse with file destination Know in corresponding virtual memory section, determine the destination virtual memory paragraph for storing data to be stored.
When file destination is in storage state, there is existing and file destination mark in metadata memory paragraph Corresponding virtual memory section.When in the virtual memory section include be not filled with data virtual memory section when, can according to target The corresponding virtual memory section for not being filled with data of mark of file, determines destination virtual memory paragraph.When in the virtual memory section not During comprising the virtual memory section for not being filled with data, i.e., with the mark of file destination, corresponding virtual memory section is filled with data just When, in the virtual memory section that can never store data, determine destination virtual memory paragraph.That is, one is distributed newly for file destination It is hollow intend memory paragraph, which is determined as destination virtual memory paragraph.
In a kind of embodiment of the application, when destination virtual memory paragraph is not store the virtual memory sections of data When, the correspondence that the mark of file destination is not stored to also the virtual memory section of data with this stores pass corresponding to the first kind It is storehouse.
Step 3:Determine that file destination is in non-storage state, and identified according to the storage, never store the void of data Intend determining the destination virtual memory paragraph for storing data to be stored in memory paragraph.
It is not corresponding with the mark of file destination in metadata memory paragraph when definite file destination is in non-storage state Virtual memory section, i.e. the data of file destination did not store also.At this time, in the virtual memory section for never storing data, really The virtual memory that sets the goal section.
Likewise, in a kind of embodiment of the application, can also include after step 3:By file destination The correspondence of mark and destination virtual memory paragraph store to first kind correspondence storehouse.
Specifically, never determine that the destination virtual for storing data to be stored stores in the virtual memory section of storage data Section, can include:Never store and select start physical address minimum or termination physical address minimum in the virtual memory section of data Virtual memory section, be determined as the destination virtual memory paragraph for storing data to be stored.
That is, not storing the virtual memory section of data according to the sequential selection of physical address, it is determined as being used to store The destination virtual memory paragraph of data to be stored.
As it can be seen that in the present embodiment, in definite destination virtual memory paragraph, according to the mark and the first kind of file destination Correspondence storehouse, judges that whether in storage state, target is determined according to judging result in different ways for file destination Virtual memory section.
In another embodiment of the application, it can be improved on the basis of embodiment illustrated in fig. 1.The implementation The detailed process of example may refer to flow diagram shown in Fig. 4.Unlike embodiment illustrated in fig. 1, before step S102, I.e. in the mark according to file destination and first kind correspondence storehouse, determine that the destination virtual for storing data to be stored stores Before section, it can also include the following steps:
Step S101 ':Determine first logical address section of the data to be stored in file destination.
It should be noted that logical address is the address of data hereof, for showing data hereof opposite Position (i.e. offset).
Specifically, determining first logical address section of the data to be stored in file destination, can include:Treated according to reception The order of data is stored, determines first logical address section of the data to be stored in file destination.That is, in file destination, number According to logical address be that order is gradually increased, and logical address is continuous.
For example, when file destination is larger, such as file destination is video stream file, can be according to reception video stream data Order, determine the video stream data corresponding logical address section in video stream file.
It is understood that since the data of file are probably to be received in batches by terminal, terminal is managed for convenience The data that include of reason this document, can be that the data received every time distribute a logical address section, which can be with For representing the offset (i.e. relative position) of the data in this document.Meanwhile also to generate logical address section with physically The correspondence of location section, in this way, terminal could read the data according to logical address and the correspondence from disk.
Metadata memory paragraph, can be used for storing the second class correspondence storehouse, the second class correspondence storehouse is used to store number According to the correspondence between physical address section of the logical address section and data hereof in disk.
It is corresponding, in the embodiment shown in fig. 1, after step S105, i.e., stored by data to be stored to target void After intending memory paragraph, it can also include the following steps:
Step S105 ':Determine the target physical address section of the storage data to be stored.
Wherein, the start physical address of target physical address section is the end storage location, terminates physical address as end Tail storage location and data to be stored data volume and.
Step S105 〞:First correspondence of the first logical address section and target physical address section is stored to the second class Correspondence storehouse.
For example, the logical address section of data to be stored is 0x0-0x100, corresponding physical address section is 0x1000- 0x1100, [0x0-0x100,0x1000-0x1100] are the first correspondence.
As a kind of specific embodiment, the first correspondence can use initial logical address, start physical address Represented with the mode of data volume length.Table 1 show the correspondence of a kind of logical address section and physical address section.Wherein, compile Number represent logical address section [L0, L0+LEN0] and the correspondence of physical address section [P0, P0+LEN0] for 1 correspondence, Other correspondences are similar, are not described further in detail.
Table 1
Numbering Initial logical address Start physical address Data volume length
0 L0 P0 LEN0
1 L1 P1 LEN1
2 L2 P2 LEN2
As it can be seen that in the present embodiment, for the data to be stored of reception, terminal determines first logically for data to be stored Location section, which is a kind of virtual address, can describe offset address of the data to be stored in file destination, can Enough determine relative position of the data to be stored in file destination.Data to be stored is stored to destination virtual memory paragraph, Also the first correspondence between the first logical address section and target physical address section is stored to the second class correspondence storehouse. In this way, it can more accurately determine its physical location (i.e. physical location) when being read out to data to be stored when operation.
In a kind of embodiment of embodiment illustrated in fig. 4, step S105 〞, by the first logical address section and target First correspondence of physical address section is stored to the second class correspondence storehouse, can be included:
Step 1:Obtain the target correspondence for file destination stored in the second class correspondence storehouse.
Specifically, step 1 can include:According to the mark of file destination, search and be somebody's turn to do in the second class correspondence storehouse The corresponding target correspondence of mark of file destination.
It is understood that in the second class correspondence storehouse, it is corresponding with physical address section in storage logical address section During relation, it can be stored in units of file.For example, a file is correspondingly arranged a mapping table, deposited in the mapping table Storage and the corresponding logical address of mark of this document and the correspondence list item of physical address.The mapping table of each file stores In the second class correspondence storehouse.
Step 2:Judge adjacent with the first logical address section with the presence or absence of logical address section in target correspondence, and thing Address field second correspondence adjacent with target physical address section is managed, if it is present thinking in the second class correspondence storehouse In the presence of the correspondence adjacent with the first correspondence, step 3 is performed;Closed if it does not exist, then thinking that the second class corresponds to It is that the correspondence adjacent with the first correspondence is not present in storehouse, disregards.
Step 3:Merge the first correspondence and the second correspondence, and the second correspondence is updated to pair after merging It should be related to.
For example, as it is known that [0x100-0x200,0x1000-0x1100] is the first correspondence, [0x0-0x100,0xf00- 0x1000] it is target correspondence.Wherein, comma, " left side be logical address, right side is physical address.It may determine that, on It is adjacent to state logical address and physical address in two correspondences.Above-mentioned two correspondence can be merged into [0x00- 0x200,0xf00-0x1100], and target correspondence is updated to correspondence [0x00-0x200,0xf00- after merging 0x1100]。
And for example, it is known that table 1 is the corresponding mapping tables of file destination A, wherein the list item that numbering is 0 and 1, which is target, corresponds to pass System, the list item that numbering is 2 is the first correspondence.If pair that correspondence [L0, P0, LEN0] and numbering that numbering is 0 are 2 It should be related between [L2, P2, LEN2] and meet L0+LEN0=L2, P0+LEN0=P2, then it is assumed that numbering is 0 and 2 correspondence It can merge.Wherein, three amounts in symbol [] are followed successively by initial logical address, start physical address and data volume length.Close After and, the correspondence that numbering is 0 is changed into [L0, P0, LEN0 '].Table 2 is the corresponding mapping tables of file destination A after merging.
Table 2
Numbering Initial logical address Start physical address Data volume length
0 L0 P0 LEN0′
1 L1 P1 LEN1
As can be seen that the correspondence after merging includes the physical address and logical address of stored data to be stored Correspondence.
As it can be seen that in the present embodiment, when storing the first correspondence, using correspondence folding, first Correspondence implements union operation when can merge with other correspondences, so as to simplify the second class correspondence storehouse, saves member The memory space of data storing section.
In a kind of embodiment of embodiment illustrated in fig. 4, the metadata memory paragraph, is additionally operable to store The three classes correspondence storehouse of correspondence between the mark of file and the virtual memory section for carrying out covering write operation, and The mark for storing storage file is corresponding with the 4th class of correspondence between the virtual memory section for add write operation Relation storehouse.
It is corresponding, the step S102 in embodiment illustrated in fig. 4, according to the mark of file destination and first kind correspondence Storehouse, determines the destination virtual memory paragraph for storing the data to be stored, can be carried out according to flow diagram shown in Fig. 5, Specifically include:
Step S102A:Judge to whether there is the correspondence for the first logical address section in the second class correspondence storehouse, If it is present the operation for thinking this time write-in data to be stored is covering write operation, step S105 〞 B are performed at this time;If no In the presence of, then it is assumed that this time the operation of write-in data to be stored is additional write operation, performs step S105 〞 C at this time.
It is pointed out that as executive agent terminal determine data to be stored the first logical address section when, can Existing logical address section to be determined as to the first logical address section of data to be stored as needed, will can also not divide It is determined as the first logical address section of data to be stored with the logical address section crossed.
For example, as it is known that terminal distribution is 3 to the virtual memory section that customer end A is used to store monitor video data, it is corresponding Physical address section be 0x0-0x1100.When the free memory of this 3 virtual memory sections is not filled with, terminal can be according to Order distributes logical address for data to be stored.When the free memory of this 3 virtual memory sections is filled with, terminal can be with Again since 0x0 logical address is distributed for data to be stored.
Step S102B:Data to be stored is determined to cover overwriting data, by three classes correspondence storehouse with file destination Identify corresponding virtual memory section and be determined as the second virtual memory section, determine to be used to store described treat from the second virtual memory section Store the destination virtual memory paragraph of data.
Specifically, the second definite virtual memory section may more than one.When the quantity of the second virtual memory section is two And during the above, the virtual memory section that the second virtual memory Duan Zhongwei is filled with to data is determined as destination virtual memory paragraph.
Step S102C:Determine data to be stored for addition write data, by the 4th class correspondence storehouse with file destination Identify corresponding virtual memory section and be determined as the 3rd virtual memory section, determine to be used to store described treat from the 3rd virtual memory section Store the destination virtual memory paragraph of data.
Specifically, the 3rd definite virtual memory section may more than one.When the quantity of the 3rd virtual memory section is two And during the above, the virtual memory section that the 3rd virtual memory Duan Zhongwei is filled with to data is determined as destination virtual memory paragraph.
As it can be seen that in the present embodiment, data to be stored can cover overwriting data or add to write data, have Body, can be according to the judgement knot that whether there is the correspondence for the first logical address section in the second class correspondence storehouse Fruit, to determine which kind of operation is data to be stored belong to.
In the present embodiment, when data to be stored is to cover overwriting data, step S105 〞, by described first logically Location section and the first correspondence of target physical address section are stored to the second class correspondence storehouse, can specifically be included:
Step 1:The original correspondence for the first logical address section is searched from the second class correspondence storehouse.
Step 2:The original correspondence is updated to the first couple of the first logical address section and target physical address section It should be related to.
It should be noted that the physical address section in original correspondence is different from target physical address section, when treating After storing data storage, the physical address section in original correspondence should be updated to target physical address section.
For example, the correspondence [L0, P0, LEN0] that numbering is 0 in table 1 corresponds to pass to perform before covering write operation System, after execution covering is write, above-mentioned correspondence should be updated to [L0, P20, LEN0].Wherein, three amounts in symbol [] It is followed successively by initial logical address, start physical address and data volume length.
In view of the content involved in above example, it is seen that first kind correspondence can be stored in metadata memory paragraph The information such as storehouse, the second class correspondence storehouse, three classes correspondence storehouse and the 4th class correspondence storehouse.With reference to instantiation Elaborate again to the metadata memory paragraph in the embodiment of the present application.
Metadata memory paragraph can preserve herein below:
Headspace Superblock Vzone bitmaps Vzone descriptors File index bitmap File index Mapping table
Superblock backs up Vzone bitmaps back up Vzone descriptors back up File index backs up
Headspace (Boot block):For storing disk partition information etc..
Superblock (Super block):Save file system related information, contains what current file system was assigned to Vzone is numbered, the total number of Vzone, the total number of idle Vzone, maximum file number (the i.e. file rope of file system permission Draw the number of inode), current file system be assigned to Vzone numberings, disk type etc..Wherein, a file index corresponds to One file.Superblock backup (Super block back) is the backup in the region.
Vzone bitmaps (Vzone bitmap):Each represents a Vzone, and 1 representative has used, and 0 representative is not used. Vzone bitmaps backup (Vzone bitmap back) is the backup in the region.
Vzone descriptors (Vzone description):Describe current Vzone write pointers (write pointer) Position, the position of the write pointer are the end storage location referred in the above.Vzone descriptors back up (Vzone Description back) be the region backup.
File index bitmap (inode bitmap):Each represents a file, and 1 representative has used, and 0 representative does not make With.During document creation, the bitmap can be searched, according to bitmap, ascending distribution index number.
File index (Inode):Describe the information of file, including have recorded the start physical address (LBA of mapping table Location), an index is a file.In addition, index also have recorded file and the corresponded manner of Vzone, i.e. a Vzone is corresponded to Multiple files (multi) or a Vzone can only be possessed (only) by this document.It is right that the region further includes file data institute The Vzone numberings that should be stored, i.e. first kind correspondence storehouse.More specifically, current file can also be included in the region to correspond to Execution covering write operation Vzone numberings and perform the Vzone numberings of additional write operation, i.e., comprising three classes correspondence storehouse With the 4th class correspondence storehouse.File index backup (Inode back) is the backup in the region.
Mapping table (hik map):The relation of each Documents Logical address field and disk physical address section is recorded, that is, records Two class correspondence storehouses.
The order and structure size of above regional are not fixed, and only show that there are these data in metadata memory paragraph.
Fig. 6 is a kind of structure diagram of data storage device provided by the embodiments of the present application, applied to terminal, with Fig. 1 Shown embodiment of the method is corresponding.The terminal includes at least one disk, and the disk is divided according to the order of physical address For at least two virtual memory sections, the corresponding range of physical addresses of each virtual memory section is misaligned, is identified as the void of preset value Plan memory paragraph is metadata memory paragraph;Wherein, the metadata memory paragraph, for storing the mark of storage file and each void The first kind correspondence storehouse of correspondence between plan memory paragraph, the mark of Duan Yuyi file of a virtual memory correspond to;Institute Stating device includes:
Data reception module 601, for receiving the data to be stored of file destination;
Memory paragraph determining module 602, for the mark according to the file destination and the first kind correspondence storehouse, really The fixed destination virtual memory paragraph for being used to store the data to be stored;
Procurement of reserve capacity module 603, for according to the end storage location that data are stored in the destination virtual memory paragraph, Obtain the capacity of free memory in the destination virtual memory paragraph;
Capacity determination module 604, for judging whether the capacity is more than or equal to the data volume of the data to be stored;
Data memory module 605, for when the capacity be more than or equal to the data to be stored data volume when, with described End storage location is the start memory location of the data to be stored, and the data to be stored is stored to the destination virtual Memory paragraph.
In a kind of embodiment of embodiment illustrated in fig. 6, the metadata memory paragraph, is additionally operable to storage and represents each Whether a virtual memory section has stored the storage mark of data;Described device can also include:
Data segmentation module (not shown), for when the capacity be less than the data to be stored data volume when, The data to be stored is divided into the first data and the second data, wherein, the data volume of first data is equal to the appearance Amount;
The memory paragraph determining module 602, is additionally operable to be identified according to the storage, never stores the virtual memory section of data In determine the first virtual memory section for storing second data;
The data memory module 605, is additionally operable to the starting using the end storage location as first data and stores Position, first data are stored to the destination virtual memory paragraph, and second data are stored to described first virtual Memory paragraph.
In a kind of embodiment of embodiment illustrated in fig. 6, the memory paragraph determining module 602, can include:
First judging submodule (not shown), is directed to for judging to whether there is in the first kind correspondence storehouse The correspondence of the mark of the file destination;
First determination sub-module (not shown), for when first judging submodule judging result for be when, Determine that the file destination is in storage state, and the mark from the first kind correspondence storehouse with the file destination In corresponding virtual memory section, the destination virtual memory paragraph for storing the data to be stored is determined;
Second determination sub-module (not shown), for when first judging submodule judging result for it is no when, Determine that the file destination is in non-storage state, and identified according to the storage, in the virtual memory section for never storing data Determine the destination virtual memory paragraph for storing the data to be stored.
In another embodiment of the application, embodiment illustrated in fig. 6 can be improved.Mould is determined in the memory paragraph Before block 602, logical address section determining module 601 ' can also be included, shown in structure diagram as shown in Figure 7.The embodiment with Embodiment of the method is corresponding shown in Fig. 4.
The logical address section determining module 601 ', for determining the data to be stored in the file destination One logical address section;
The metadata memory paragraph, be additionally operable to storage data logical address section hereof with disk physically Second class correspondence storehouse of correspondence between the section of location;
After the data memory module 605, it can also include:
Physical address section determining module 605 ', for determining the target physical address section of the storage data to be stored, its In, the start physical address of the target physical address section is the end storage location, and termination physical address is the end Storage location and the data to be stored data volume and;
First correspondence memory module, 605 〞, for by the of the first logical address section and target physical address section One correspondence is stored to the second class correspondence storehouse.
In a kind of embodiment of embodiment illustrated in fig. 7, the logical address section determining module 601 ', Ke Yiyong In:
According to the order for receiving the data to be stored, first of the data to be stored in the file destination is determined Logical address section.
In a kind of embodiment of embodiment illustrated in fig. 7,605 〞 of the first correspondence memory module can be with Including:
Obtain submodule (not shown), for obtain stored in the second class correspondence storehouse be directed to the mesh Mark the target correspondence of file;
Second judgment submodule (not shown), for judging to whether there is logical address in the target correspondence Section is adjacent with the first logical address section, and the second corresponding pass that physical address section is adjacent with the target physical address section System;
First renewal submodule (not shown), for when the second judgment submodule judging result for be when, Merge first correspondence and the second correspondence, and second correspondence is updated to the corresponding pass after merging System.
In a kind of embodiment of embodiment illustrated in fig. 7, the metadata memory paragraph, is additionally operable to store The three classes correspondence storehouse of correspondence between the mark of file and the virtual memory section for carrying out covering write operation;
The memory paragraph determining module 602, can include:
3rd judging submodule (not shown), is directed to for judging to whether there is in the second class correspondence storehouse The correspondence of the first logical address section;
3rd determination sub-module (not shown), for when the 3rd judging submodule judging result for be when, The data to be stored is determined to cover overwriting data, by the mark pair in the three classes correspondence storehouse with the file destination The virtual memory section answered is determined as the second virtual memory section, determines to be used for from the second virtual memory section to store and described waits to deposit Store up the destination virtual memory paragraph of data.
In a kind of embodiment of embodiment illustrated in fig. 7, the metadata memory paragraph, is additionally operable to store 4th class correspondence storehouse of correspondence between the mark of file and the virtual memory section for add write operation;It is described Memory paragraph determining module can also include:
4th determination sub-module (not shown), for when the 3rd judging submodule judging result for it is no when, Determine that the data to be stored writes data for addition, by the mark pair in the 4th class correspondence storehouse with the file destination The virtual memory section answered is determined as the 3rd virtual memory section, determines to be used for from the 3rd virtual memory section to store and described waits to deposit Store up the destination virtual memory paragraph of data.
In a kind of embodiment of embodiment illustrated in fig. 7,605 〞 of the first correspondence memory module can be with Including:
Submodule (not shown) is searched, is patrolled for being searched from the second class correspondence storehouse for described first Collect the original correspondence of address field;
Second renewal submodule (not shown), for the original correspondence to be updated to described first logically First correspondence of location section and target physical address section.
Since above device embodiment is obtained based on embodiment of the method, there is identical technique effect with this method, Therefore details are not described herein for the technique effect of device embodiment.
For device embodiment, since it is substantially similar to embodiment of the method, so describe fairly simple, it is related Part illustrates referring to the part of embodiment of the method.
It should be noted that herein, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any this actual relation or order.Moreover, term " comprising ", "comprising" or any other variant be intended to it is non- It is exclusive to include, so that process, method, article or equipment including a series of elements not only include those key elements, But also including other elements that are not explicitly listed, or further include solid by this process, method, article or equipment Some key elements.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that including Also there are other identical element in the process of the key element, method, article or equipment.
It will appreciated by the skilled person that all or part of step in the above embodiment is can to pass through journey Sequence instructs relevant hardware, and come what is completed, the program can be stored in computer read/write memory medium.It is designated herein Storage medium, refers to ROM/RAM, magnetic disc, CD etc..
The foregoing is merely the preferred embodiment of the application, the protection domain of the application is not intended to limit.It is all Any modification, equivalent substitution, improvement and etc. done within spirit herein and principle, are all contained in the protection domain of the application It is interior.

Claims (18)

1. a kind of date storage method, applied to terminal, it is characterised in that the terminal includes at least one disk, the magnetic Disk is divided at least two virtual memory sections according to the order of physical address, the corresponding range of physical addresses of each virtual memory section Misaligned, the virtual memory section for being identified as preset value is metadata memory paragraph;Wherein, the metadata memory paragraph, for storing The first kind correspondence storehouse for identifying the correspondence between each virtual memory section of storage file, a virtual memory section It is corresponding with the mark of a file;The described method includes:
Receive the data to be stored of file destination;
According to the mark of the file destination and the first kind correspondence storehouse, determine for storing the data to be stored Destination virtual memory paragraph;
According to the end storage location that data are stored in the destination virtual memory paragraph, obtain in the destination virtual memory paragraph The capacity of free memory;
Judge whether the capacity is more than or equal to the data volume of the data to be stored;
If it is, using the end storage location as the start memory location of the data to be stored, by the number to be stored According to storing to the destination virtual memory paragraph.
2. according to the method described in claim 1, it is characterized in that, the metadata memory paragraph, is additionally operable to storage and represents each Whether virtual memory section has stored the storage mark of data;The method further includes:
When the capacity is less than the data volume of the data to be stored, the data to be stored is divided into the first data and the Two data, wherein, the data volume of first data is equal to the capacity;
According to it is described storage identify, never store data virtual memory section in determine for store second data first Virtual memory section;
Start memory location using the end storage location as first data, first data are stored to the mesh Virtual memory section is marked, second data are stored to the first virtual memory section.
It is 3. according to the method described in claim 2, it is characterized in that, described according to the mark of the file destination and described first Class correspondence storehouse, the step of determining the destination virtual memory paragraph for storing the data to be stored, including:
Judge in the first kind correspondence storehouse with the presence or absence of the correspondence of the mark for the file destination;
If it is, determine that the file destination is in storage state, and from the first kind correspondence storehouse with it is described In the corresponding virtual memory section of mark of file destination, the destination virtual memory paragraph for storing the data to be stored is determined;
If it is not, then determining that the file destination is in non-storage state, and identified according to the storage, never store data The destination virtual memory paragraph for storing the data to be stored is determined in virtual memory section.
4. according to the method described in claim 2, it is characterized in that, in the mark according to the file destination and described A kind of correspondence storehouse, before the step of determining the destination virtual memory paragraph for storing the data to be stored, further includes:
Determine first logical address section of the data to be stored in the file destination;
The metadata memory paragraph, is additionally operable to the storage logical address section of data hereof and the physical address section in disk Between correspondence the second class correspondence storehouse;
The data to be stored was stored the step of destination virtual memory paragraph described, is further included:
Determine the target physical address section of the storage data to be stored, wherein, the starting physics of the target physical address section Address is the end storage location, terminates data volume of the physical address for the end storage location and the data to be stored Sum;
The first logical address section is stored to second class is corresponding with the first correspondence of target physical address section and is closed It is storehouse.
5. according to the method described in claim 4, it is characterized in that, described determine the data to be stored in the file destination In the first logical address section the step of, including:
According to the order for receiving the data to be stored, first logic of the data to be stored in the file destination is determined Address field.
6. according to the method described in claim 4, it is characterized in that, it is described by the first logical address section and target physical The step of first correspondence of location section is stored to the second class correspondence storehouse, including:
Obtain the target correspondence for the file destination stored in the second class correspondence storehouse;
Judge adjacent with the first logical address section with the presence or absence of logical address section in the target correspondence, and physics Address field second correspondence adjacent with the target physical address section;
If it is present merging first correspondence and the second correspondence, and second correspondence is updated to Correspondence after merging.
7. according to the method described in claim 4, it is characterized in that, the metadata memory paragraph, is additionally operable to store text The three classes correspondence storehouse of correspondence between the mark of part and the virtual memory section for carrying out covering write operation;
The mark according to the file destination and the first kind correspondence storehouse, determine to be used to store the number to be stored According to destination virtual memory paragraph the step of, including:
Judge to whether there is the correspondence for the first logical address section in the second class correspondence storehouse;
If it is present determine the data to be stored to cover overwriting data, by the three classes correspondence storehouse with it is described The corresponding virtual memory section of mark of file destination is determined as the second virtual memory section, is determined from the second virtual memory section For storing the destination virtual memory paragraph of the data to be stored.
8. the method according to the description of claim 7 is characterized in that the metadata memory paragraph, is additionally operable to store text 4th class correspondence storehouse of correspondence between the mark of part and the virtual memory section for add write operation;The side Method further includes:
When the correspondence for the first logical address section is not present in the second class correspondence storehouse, determine described Data to be stored writes data for addition, will be corresponding with the mark of the file destination virtual in the 4th class correspondence storehouse Memory paragraph is determined as the 3rd virtual memory section, is determined from the 3rd virtual memory section for storing the data to be stored Destination virtual memory paragraph.
9. the method according to the description of claim 7 is characterized in that it is described by the first logical address section and target physical The step of first correspondence of location section is stored to the second class correspondence storehouse, including:
The original correspondence for the first logical address section is searched from the second class correspondence storehouse;
The original correspondence is updated to the first correspondence of the first logical address section and target physical address section.
10. a kind of data storage device, applied to terminal, it is characterised in that the terminal includes at least one disk, the magnetic Disk is divided at least two virtual memory sections according to the order of physical address, the corresponding range of physical addresses of each virtual memory section Misaligned, the virtual memory section for being identified as preset value is metadata memory paragraph;Wherein, the metadata memory paragraph, for storing The first kind correspondence storehouse for identifying the correspondence between each virtual memory section of storage file, a virtual memory section It is corresponding with the mark of a file;Described device includes:
Data reception module, for receiving the data to be stored of file destination;
Memory paragraph determining module, for the mark according to the file destination and the first kind correspondence storehouse, determines to be used for Store the destination virtual memory paragraph of the data to be stored;
Procurement of reserve capacity module, for according to the end storage location that data are stored in the destination virtual memory paragraph, obtaining institute State the capacity of free memory in destination virtual memory paragraph;
Capacity determination module, for judging whether the capacity is more than or equal to the data volume of the data to be stored;
Data memory module, for when data volume of the capacity more than or equal to the data to be stored, being deposited with the end Storage space is set to the start memory location of the data to be stored, and the data to be stored is stored to the destination virtual and is stored Section.
11. device according to claim 10, it is characterised in that the metadata memory paragraph, is additionally operable to storage and represents each Whether a virtual memory section has stored the storage mark of data;Described device further includes:
Data segmentation module, for when the capacity be less than the data to be stored data volume when, by the data to be stored The first data and the second data are divided into, wherein, the data volume of first data is equal to the capacity;
The memory paragraph determining module, is additionally operable to be identified according to the storage, never stores in the virtual memory section of data and determine For storing the first virtual memory section of second data;
The data memory module, is additionally operable to the start memory location using the end storage location as first data, will First data are stored to the destination virtual memory paragraph, and second data are stored to the first virtual memory section.
12. according to the devices described in claim 11, it is characterised in that the memory paragraph determining module, including:
First judging submodule, for judging to whether there is the mark for the file destination in the first kind correspondence storehouse The correspondence of knowledge;
First determination sub-module, for when the judging result of first judging submodule is is, determining the file destination In storage state, and the virtual memory section corresponding with the mark of the file destination from the first kind correspondence storehouse In, determine the destination virtual memory paragraph for storing the data to be stored;
Second determination sub-module, for when the judging result of first judging submodule is no, determining the file destination Identified in non-storage state, and according to the storage, never determine to be used to store in the virtual memory section of storage data described The destination virtual memory paragraph of data to be stored.
13. according to the devices described in claim 11, it is characterised in that before the memory paragraph determining module, further include:
Logical address section determining module, for determining first logical address of the data to be stored in the file destination Section;
The metadata memory paragraph, is additionally operable to the storage logical address section of data hereof and the physical address section in disk Between correspondence the second class correspondence storehouse;
After the data memory module, further include:
Physical address section determining module, for determining the target physical address section of the storage data to be stored, wherein, the mesh The start physical address for marking physical address section be the end storage location, terminate physical address for the end storage location and The sum of the data volume of the data to be stored;
First correspondence memory module, for the first corresponding pass by the first logical address section with target physical address section System is stored to the second class correspondence storehouse.
14. device according to claim 13, it is characterised in that the logical address section determining module, is specifically used for:
According to the order for receiving the data to be stored, first logic of the data to be stored in the file destination is determined Address field.
15. device according to claim 13, it is characterised in that the first correspondence memory module, including:
Submodule is obtained, is corresponded to for obtaining the target for the file destination stored in the second class correspondence storehouse Relation;
Second judgment submodule, for judging in the target correspondence with the presence or absence of logical address section and first logic Address field is adjacent, and the second correspondence that physical address section is adjacent with the target physical address section;
First renewal submodule, for when the judging result of the second judgment submodule is is, merging described first and corresponding to Relation and the second correspondence, and second correspondence is updated to the correspondence after merging.
16. device according to claim 13, it is characterised in that the metadata memory paragraph, is additionally operable to store The three classes correspondence storehouse of correspondence between the mark of file and the virtual memory section for carrying out covering write operation;
The memory paragraph determining module, including:
3rd judging submodule, first logical address is directed to for judging to whether there is in the second class correspondence storehouse The correspondence of section;
3rd determination sub-module, for when the judging result of the 3rd judging submodule is is, determining the number to be stored It is according to cover overwriting data, virtual memory section corresponding with the mark of the file destination in the three classes correspondence storehouse is true It is set to the second virtual memory section, the destination virtual for storing the data to be stored is determined from the second virtual memory section Memory paragraph.
17. device according to claim 16, it is characterised in that the metadata memory paragraph, is additionally operable to store 4th class correspondence storehouse of correspondence between the mark of file and the virtual memory section for add write operation;It is described Memory paragraph determining module further includes:
4th determination sub-module, for when the judging result of the 3rd judging submodule is no, determining the number to be stored Data are write according to for addition, virtual memory section corresponding with the mark of the file destination in the 4th class correspondence storehouse is true It is set to the 3rd virtual memory section, the destination virtual for storing the data to be stored is determined from the 3rd virtual memory section Memory paragraph.
18. device according to claim 16, it is characterised in that the first correspondence memory module, including:
Submodule is searched, for being searched from the second class correspondence storehouse for the original right of the first logical address section It should be related to;
Second renewal submodule, for the original correspondence to be updated to the first logical address section with target physical First correspondence of location section.
CN201610946331.3A 2016-11-02 2016-11-02 Data storage method and device Active CN108021513B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610946331.3A CN108021513B (en) 2016-11-02 2016-11-02 Data storage method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610946331.3A CN108021513B (en) 2016-11-02 2016-11-02 Data storage method and device

Publications (2)

Publication Number Publication Date
CN108021513A true CN108021513A (en) 2018-05-11
CN108021513B CN108021513B (en) 2021-09-10

Family

ID=62069958

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610946331.3A Active CN108021513B (en) 2016-11-02 2016-11-02 Data storage method and device

Country Status (1)

Country Link
CN (1) CN108021513B (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109683825A (en) * 2018-12-24 2019-04-26 广东浪潮大数据研究有限公司 A kind of storage system online data compression method, device and equipment
CN110502184A (en) * 2018-05-17 2019-11-26 杭州海康威视系统技术有限公司 A kind of method of storing data, the method, apparatus and system for reading data
CN110633052A (en) * 2019-09-05 2019-12-31 北京达佳互联信息技术有限公司 Method and device for storing embedded parameters
WO2020024933A1 (en) * 2018-07-31 2020-02-06 杭州海康威视系统技术有限公司 Data writing method and server
CN111399762A (en) * 2019-11-27 2020-07-10 杭州海康威视系统技术有限公司 Data storage method, device and storage system
CN111803917A (en) * 2020-06-30 2020-10-23 北京金山云网络技术有限公司 Resource processing method and device
CN111913657A (en) * 2020-07-10 2020-11-10 长沙景嘉微电子股份有限公司 Block data read-write method, device, system and storage medium
CN112286948A (en) * 2020-11-18 2021-01-29 成都佳华物链云科技有限公司 Data storage method, reading method and device of time sequence database
WO2021208089A1 (en) * 2020-04-17 2021-10-21 华为技术有限公司 Memory management method and control device
CN113783800A (en) * 2021-11-10 2021-12-10 恒生电子股份有限公司 Data packet processing method and device, computer equipment and readable storage medium
CN114124883A (en) * 2021-10-12 2022-03-01 鸬鹚科技(深圳)有限公司 Data access method and device based on cloud storage address, computer equipment and medium
CN115292266A (en) * 2022-05-30 2022-11-04 中国电子科技集团公司第五十二研究所 High-reliability log storage method based on memory

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622350A (en) * 2011-01-26 2012-08-01 腾讯科技(深圳)有限公司 Method, device and system for writing data
CN103345925A (en) * 2012-03-02 2013-10-09 Hgst荷兰公司 Shingle-written magnetic recording device with hybrid E-regions
CN103810114A (en) * 2014-03-07 2014-05-21 华为技术有限公司 Method and device for distributing storage space
CN104461390A (en) * 2014-12-05 2015-03-25 华为技术有限公司 Method and device for writing data into imbricate magnetic recording SMR hard disk
CN104636266A (en) * 2014-05-09 2015-05-20 华为技术有限公司 SMR hard disk and data writing method and device for SMR hard disk
US20150347022A1 (en) * 2014-05-28 2015-12-03 International Business Machines Corporation Reading and writing via file system for tape recording system
CN105183399A (en) * 2015-09-30 2015-12-23 北京奇艺世纪科技有限公司 Data writing and reading method and device based on elastic block storage
WO2016101828A1 (en) * 2014-12-24 2016-06-30 华为技术有限公司 Data reading method and device
US20160196215A1 (en) * 2015-01-07 2016-07-07 Fujitsu Limited Storage apparatus, storage system, and data read method
CN107315533A (en) * 2016-04-26 2017-11-03 杭州海康威视数字技术股份有限公司 A kind of date storage method and device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622350A (en) * 2011-01-26 2012-08-01 腾讯科技(深圳)有限公司 Method, device and system for writing data
CN103345925A (en) * 2012-03-02 2013-10-09 Hgst荷兰公司 Shingle-written magnetic recording device with hybrid E-regions
CN103810114A (en) * 2014-03-07 2014-05-21 华为技术有限公司 Method and device for distributing storage space
CN104636266A (en) * 2014-05-09 2015-05-20 华为技术有限公司 SMR hard disk and data writing method and device for SMR hard disk
US20150347022A1 (en) * 2014-05-28 2015-12-03 International Business Machines Corporation Reading and writing via file system for tape recording system
CN104461390A (en) * 2014-12-05 2015-03-25 华为技术有限公司 Method and device for writing data into imbricate magnetic recording SMR hard disk
WO2016101828A1 (en) * 2014-12-24 2016-06-30 华为技术有限公司 Data reading method and device
US20160196215A1 (en) * 2015-01-07 2016-07-07 Fujitsu Limited Storage apparatus, storage system, and data read method
CN105183399A (en) * 2015-09-30 2015-12-23 北京奇艺世纪科技有限公司 Data writing and reading method and device based on elastic block storage
CN107315533A (en) * 2016-04-26 2017-11-03 杭州海康威视数字技术股份有限公司 A kind of date storage method and device

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110502184A (en) * 2018-05-17 2019-11-26 杭州海康威视系统技术有限公司 A kind of method of storing data, the method, apparatus and system for reading data
CN110502184B (en) * 2018-05-17 2021-01-05 杭州海康威视系统技术有限公司 Data storage method, data reading method, device and system
WO2020024933A1 (en) * 2018-07-31 2020-02-06 杭州海康威视系统技术有限公司 Data writing method and server
CN109683825B (en) * 2018-12-24 2022-05-24 广东浪潮大数据研究有限公司 Storage system online data compression method, device and equipment
CN109683825A (en) * 2018-12-24 2019-04-26 广东浪潮大数据研究有限公司 A kind of storage system online data compression method, device and equipment
CN110633052A (en) * 2019-09-05 2019-12-31 北京达佳互联信息技术有限公司 Method and device for storing embedded parameters
CN110633052B (en) * 2019-09-05 2023-09-19 北京达佳互联信息技术有限公司 Method and device for storing embedded parameters
CN111399762A (en) * 2019-11-27 2020-07-10 杭州海康威视系统技术有限公司 Data storage method, device and storage system
US11853549B2 (en) 2019-11-27 2023-12-26 Hangzhou Hikvision System Technology Co., Ltd. Index storage in shingled magnetic recording (SMR) storage system with non-shingled region
CN111399762B (en) * 2019-11-27 2021-06-18 杭州海康威视系统技术有限公司 Data storage method, device and storage system
WO2021208089A1 (en) * 2020-04-17 2021-10-21 华为技术有限公司 Memory management method and control device
CN111803917A (en) * 2020-06-30 2020-10-23 北京金山云网络技术有限公司 Resource processing method and device
CN111913657B (en) * 2020-07-10 2023-06-09 长沙景嘉微电子股份有限公司 Block data read-write method, device, system and storage medium
CN111913657A (en) * 2020-07-10 2020-11-10 长沙景嘉微电子股份有限公司 Block data read-write method, device, system and storage medium
CN112286948B (en) * 2020-11-18 2023-05-23 成都佳华物链云科技有限公司 Data storage method, data reading method and data storage device of time sequence database
CN112286948A (en) * 2020-11-18 2021-01-29 成都佳华物链云科技有限公司 Data storage method, reading method and device of time sequence database
CN114124883A (en) * 2021-10-12 2022-03-01 鸬鹚科技(深圳)有限公司 Data access method and device based on cloud storage address, computer equipment and medium
CN114124883B (en) * 2021-10-12 2023-09-12 鸬鹚科技(深圳)有限公司 Data access method and device based on cloud storage address, computer equipment and medium
CN113783800A (en) * 2021-11-10 2021-12-10 恒生电子股份有限公司 Data packet processing method and device, computer equipment and readable storage medium
CN115292266A (en) * 2022-05-30 2022-11-04 中国电子科技集团公司第五十二研究所 High-reliability log storage method based on memory

Also Published As

Publication number Publication date
CN108021513B (en) 2021-09-10

Similar Documents

Publication Publication Date Title
CN108021513A (en) A kind of date storage method and device
US10649910B2 (en) Persistent memory for key-value storage
CN106548789B (en) Method and apparatus for operating stacked tile type magnetic recording equipment
CN105589812B (en) Disk fragments method for sorting, device and host
CN104461390B (en) Write data into the method and device of imbricate magnetic recording SMR hard disks
US9841906B2 (en) Zone forward drive management
US6636879B1 (en) Space allocation in a write anywhere file system
US8438195B2 (en) File system operating method and devices using the same
US11803517B2 (en) File system for anonymous write
CN103019887B (en) Data back up method and device
CN103064639A (en) Method and device for storing data
US20160041778A1 (en) Managing data within a storage device based on file system metadata
US20110153972A1 (en) Free space defragmention in extent based file system
US20150052292A1 (en) Method for erasing data entity in memory module
CN107729558A (en) Method, system, device and the computer-readable storage medium that file system fragmentation arranges
CN101763317A (en) Data eliminating method of magnetic medium
US10838624B2 (en) Extent pool allocations based on file system instance identifiers
CN102253985B (en) File system data management method and system
CN106406759A (en) Data storage method and device
CN107203341A (en) Date storage method, device and flash chip based on flash memory
TW201021027A (en) Disk layout method for object-based storage device
CN103257928B (en) Flash memory device data managing method and system
CN100447758C (en) Snapshot management method for logic disk
CN106919342A (en) Storage resource distribution method and device based on automatic simplify configuration
CN106775450B (en) A kind of data distribution method in mixing storage system

Legal Events

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