CN110007869B - Memory data copying method, device, equipment and computer storage medium - Google Patents
Memory data copying method, device, equipment and computer storage medium Download PDFInfo
- Publication number
 - CN110007869B CN110007869B CN201910294464.0A CN201910294464A CN110007869B CN 110007869 B CN110007869 B CN 110007869B CN 201910294464 A CN201910294464 A CN 201910294464A CN 110007869 B CN110007869 B CN 110007869B
 - Authority
 - CN
 - China
 - Prior art keywords
 - iob
 - physical page
 - source
 - copying
 - copied
 - Prior art date
 - Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
 - Active
 
Links
Images
Classifications
- 
        
- G—PHYSICS
 - G06—COMPUTING OR CALCULATING; COUNTING
 - G06F—ELECTRIC DIGITAL DATA PROCESSING
 - G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
 - G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
 - G06F3/0601—Interfaces specially adapted for storage systems
 - G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
 - G06F3/061—Improving I/O performance
 
 - 
        
- G—PHYSICS
 - G06—COMPUTING OR CALCULATING; COUNTING
 - G06F—ELECTRIC DIGITAL DATA PROCESSING
 - G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
 - G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
 - G06F3/0601—Interfaces specially adapted for storage systems
 - G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
 - G06F3/0638—Organizing or formatting or addressing of data
 
 - 
        
- G—PHYSICS
 - G06—COMPUTING OR CALCULATING; COUNTING
 - G06F—ELECTRIC DIGITAL DATA PROCESSING
 - G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
 - G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
 - G06F3/0601—Interfaces specially adapted for storage systems
 - G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
 - G06F3/0646—Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
 - G06F3/065—Replication mechanisms
 
 
Landscapes
- Engineering & Computer Science (AREA)
 - Theoretical Computer Science (AREA)
 - Human Computer Interaction (AREA)
 - Physics & Mathematics (AREA)
 - General Engineering & Computer Science (AREA)
 - General Physics & Mathematics (AREA)
 - Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
 - Memory System Of A Hierarchy Structure (AREA)
 
Abstract
本发明公开了一种内存数据拷贝方法,包括:接收将源IOB的数据拷贝至目的IOB的内存数据拷贝指令;根据内存数据拷贝指令,将源IOB中待拷贝的物理页的逻辑页号拷贝至目的IOB,并将源IOB中待拷贝的物理页的引用计数加一。可见,将源IOB对应的物理页的数据拷贝至目的IOB时,不需要将源IOB对应的真实数据拷贝至目的IOB,只需要将源IOB对应的物理页的逻辑编号拷贝至目的IOB即可,通过这种方式,便可建立源IOB与目的IOB之间的引用关系,从而减少了内存数据的拷贝次数,提高IO处理效率;本发明还公开了一种内存数据拷贝装置、设备及计算机存储介质,同样能实现上述技术效果。
The invention discloses a method for copying memory data, comprising: receiving a memory data copy instruction for copying data of a source IOB to a destination IOB; and copying the logical page number of a physical page to be copied in the source IOB to The destination IOB, and the reference count of the physical page to be copied in the source IOB is incremented by one. It can be seen that when copying the data of the physical page corresponding to the source IOB to the destination IOB, it is not necessary to copy the real data corresponding to the source IOB to the destination IOB, but only need to copy the logical number of the physical page corresponding to the source IOB to the destination IOB. In this way, the reference relationship between the source IOB and the destination IOB can be established, thereby reducing the number of copies of memory data and improving the IO processing efficiency; the invention also discloses a memory data copying device, equipment and a computer storage medium , the above-mentioned technical effects can also be achieved.
Description
技术领域technical field
本发明涉及内存拷贝技术领域,更具体地说,涉及一种内存数据拷贝方法、装置、设备及计算机存储介质。The present invention relates to the technical field of memory copying, and more particularly, to a method, apparatus, device and computer storage medium for copying memory data.
背景技术Background technique
在存储系统中,通常内存管理是一个通用的模块,内存管理会影响整个存储系统IO(Input Output,输入输出)处理流程,如果内存管理效率不够高,则整个系统的性能将会受到影响。目前在内存拷贝时,需要对真实数据进行拷贝,这种内存拷贝方式拷贝次数较多,对于IOPS(IO per second,每秒输入输出)几十万、几百万的系统来说,每个IO处理过程中内存拷贝的次数直接影响到IO处理效率。In a storage system, memory management is usually a general module. Memory management affects the IO (Input Output, input and output) processing flow of the entire storage system. If the memory management efficiency is not high enough, the performance of the entire system will be affected. At present, when copying memory, it is necessary to copy real data. This memory copy method is copied many times. For systems with hundreds of thousands or millions of IOPS (IO per second, input and output per second), each IO The number of memory copies during processing directly affects the IO processing efficiency.
因此,如何减少内存数据的拷贝次数,提高IO处理效率,是本领域技术人员需要解决的问题。Therefore, how to reduce the number of copies of memory data and improve the IO processing efficiency is a problem that needs to be solved by those skilled in the art.
发明内容SUMMARY OF THE INVENTION
本发明的目的在于提供一种内存数据拷贝方法、装置、设备及计算机存储介质,以实现减少内存数据的拷贝次数,提高IO处理效率。The purpose of the present invention is to provide a method, device, equipment and computer storage medium for copying memory data, so as to reduce the number of times of copying memory data and improve IO processing efficiency.
为实现上述目的,本发明实施例提供了如下技术方案:To achieve the above purpose, the embodiments of the present invention provide the following technical solutions:
一种内存数据拷贝方法,包括:A method for copying memory data, including:
接收将源IOB的数据拷贝至目的IOB的内存数据拷贝指令;Receive the memory data copy instruction for copying the data of the source IOB to the destination IOB;
根据所述内存数据拷贝指令,将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB,并将所述源IOB中待拷贝的物理页的引用计数加一。According to the memory data copy instruction, the logical page number of the physical page to be copied in the source IOB is copied to the destination IOB, and the reference count of the physical page to be copied in the source IOB is incremented by one.
其中,根据所述内存数据拷贝指令,将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB,包括:Wherein, according to the memory data copy instruction, copying the logical page number of the physical page to be copied in the source IOB to the destination IOB, including:
判断所述目的IOB是否具有对应的物理页的逻辑页号;Determine whether the destination IOB has the logical page number of the corresponding physical page;
若没有对应的逻辑页号,则将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB;If there is no corresponding logical page number, copy the logical page number of the physical page to be copied in the source IOB to the destination IOB;
若有对应的逻辑页号,则判断所述源IOB中待拷贝的物理页是否为整个物理页;若是整个物理页,则将所述目的IOB对应的物理页的引用计数减一,并将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB。If there is a corresponding logical page number, then determine whether the physical page to be copied in the source IOB is the entire physical page; if it is the entire physical page, decrement the reference count of the physical page corresponding to the destination IOB by one, and add all The logical page number of the physical page to be copied in the source IOB is copied to the destination IOB.
其中,每个IOB包括:用来表示本IOB对应的各个物理页是否存储有数据的位图,用来表示本IOB的存储有数据的物理页的逻辑页号、用来指向下一个IOB的连接符。Wherein, each IOB includes: a bitmap used to indicate whether each physical page corresponding to this IOB stores data, a logical page number used to indicate the physical page of this IOB that stores data, and a connection used to point to the next IOB symbol.
其中,所述将所述源IOB中待拷贝的物理页的引用计数加一,包括:Wherein, adding one to the reference count of the physical page to be copied in the source IOB includes:
将页描述表中记录的与所述源IOB中待拷贝的物理页的引用计数加一;其中,所述页描述表中记录每个物理页的逻辑页号与页结构struct page之间的对应关系。Add one to the reference count recorded in the page description table and the physical page to be copied in the source IOB; wherein, the page description table records the correspondence between the logical page number of each physical page and the page structure struct page relation.
一种内存数据拷贝装置,包括:A memory data copy device, comprising:
指令接收模块,用于接收将源IOB的数据拷贝至目的IOB的内存数据拷贝指令;The instruction receiving module is used to receive the memory data copy instruction for copying the data of the source IOB to the destination IOB;
数据拷贝模块,用于根据所述内存数据拷贝指令,将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB;a data copy module, configured to copy the logical page number of the physical page to be copied in the source IOB to the destination IOB according to the memory data copy instruction;
引用计数更新模块,用于将所述源IOB中待拷贝的物理页的引用计数加一。A reference count update module, configured to increment the reference count of the physical page to be copied in the source IOB by one.
其中,所述数据拷贝模块包括:Wherein, the data copying module includes:
第一判断单元,用于判断所述目的IOB是否具有对应的物理页的逻辑页号;a first judging unit for judging whether the destination IOB has the logical page number of the corresponding physical page;
第一拷贝单元,用于在没有对应的逻辑页号时,将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB;a first copying unit, configured to copy the logical page number of the physical page to be copied in the source IOB to the destination IOB when there is no corresponding logical page number;
第二判断单元,用于在有对应的逻辑页号时,判断所述源IOB中待拷贝的物理页是否为整个物理页;a second judging unit, configured to judge whether the physical page to be copied in the source IOB is the entire physical page when there is a corresponding logical page number;
第二拷贝单元,用于在所述源IOB中待拷贝的物理页为整个物理页时,将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB;a second copy unit, configured to copy the logical page number of the physical page to be copied in the source IOB to the destination IOB when the physical page to be copied in the source IOB is an entire physical page;
第一更新单元,用于在所述源IOB中待拷贝的物理页为整个物理页时,将所述目的IOB对应的物理页的引用计数减一。The first updating unit is configured to decrement the reference count of the physical page corresponding to the destination IOB by one when the physical page to be copied in the source IOB is the entire physical page.
其中,所述数据拷贝模块还包括:Wherein, the data copy module also includes:
第二更新单元,用于在所述源IOB中待拷贝的物理页不为整个物理页时,将所述目的IOB对应的物理页的引用计数减一;a second update unit, configured to decrement the reference count of the physical page corresponding to the destination IOB by one when the physical page to be copied in the source IOB is not the entire physical page;
物理页分配单元,用于向所述目的IOB分配新物理页;a physical page allocation unit for allocating a new physical page to the destination IOB;
第三拷贝单元,用于将所述目的IOB对应的物理页中的原始数据和所述源IOB中待拷贝的物理页的数据,均拷贝至所述新物理页。The third copy unit is configured to copy both the original data in the physical page corresponding to the destination IOB and the data of the physical page to be copied in the source IOB to the new physical page.
一种内存数据拷贝设备,包括:A memory data copy device, comprising:
存储器,用于存储计算机程序;memory for storing computer programs;
处理器,用于执行所述计算机程序时实现上述内存数据拷贝方法的步骤。The processor is configured to implement the steps of the above-mentioned method for copying memory data when executing the computer program.
一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现上述内存数据拷贝方法的步骤。A computer-readable storage medium stores a computer program on the computer-readable storage medium, and when the computer program is executed by a processor, implements the steps of the above-mentioned method for copying memory data.
通过以上方案可知,本发明实施例提供的一种内存数据拷贝方法,包括:接收将源IOB的数据拷贝至目的IOB的内存数据拷贝指令;根据所述内存数据拷贝指令,将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB,并将所述源IOB中待拷贝的物理页的引用计数加一。It can be seen from the above solutions that a method for copying memory data provided by an embodiment of the present invention includes: receiving a memory data copying instruction for copying data of a source IOB to a destination IOB; The logical page number of the physical page to be copied is copied to the destination IOB, and the reference count of the physical page to be copied in the source IOB is incremented by one.
可见,在本实施例中,将源IOB对应的物理页的数据拷贝至目的IOB时,不需要将源IOB对应的真实数据拷贝至目的IOB,只需要将源IOB对应的物理页的逻辑编号拷贝至目的IOB即可,并将源IOB中待拷贝的物理页的引用计数加一,通过这种方式,便可建立源IOB与目的IOB之间的引用关系,从而减少了内存数据的拷贝次数,提高IO处理效率;It can be seen that, in this embodiment, when copying the data of the physical page corresponding to the source IOB to the destination IOB, it is not necessary to copy the real data corresponding to the source IOB to the destination IOB, but only the logical number of the physical page corresponding to the source IOB needs to be copied It is enough to reach the destination IOB, and add one to the reference count of the physical page to be copied in the source IOB. In this way, the reference relationship between the source IOB and the destination IOB can be established, thereby reducing the number of copies of memory data. Improve IO processing efficiency;
本发明还公开了一种内存数据拷贝装置、设备及计算机存储介质,同样能实现上述技术效果。The invention also discloses a memory data copying device, equipment and computer storage medium, which can also achieve the above technical effects.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.
图1为本发明实施例公开的一种内存数据拷贝方法流程示意图;1 is a schematic flowchart of a method for copying memory data disclosed in an embodiment of the present invention;
图2为本发明实施例公开的另一种内存数据拷贝方法流程示意图;2 is a schematic flowchart of another method for copying memory data disclosed in an embodiment of the present invention;
图3为本发明实施例公开的一种内存数据拷贝装置结构示意图。FIG. 3 is a schematic structural diagram of a device for copying memory data disclosed in an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
本发明实施例公开了一种内存数据拷贝方法、装置、设备及计算机存储介质,以实现减少内存数据的拷贝次数,提高IO处理效率。Embodiments of the present invention disclose a method, apparatus, device and computer storage medium for copying memory data, so as to reduce the number of times of copying memory data and improve IO processing efficiency.
参见图1,本发明实施例提供的一种内存数据拷贝方法,包括:Referring to FIG. 1, a method for copying memory data provided by an embodiment of the present invention includes:
S101、接收将源IOB的数据拷贝至目的IOB的内存数据拷贝指令;S101, receiving a memory data copy instruction for copying the data of the source IOB to the destination IOB;
具体的,IOB(input Output Buffer)为输入输出缓冲器,每个IOB与预定数量的物理页相对应;在本实施例中,具体通过内核模块在Linux内存管理的基础上进行内存管理。该内核模块在设备启动的时候加载,在向IOB分配物理页时,通过调用Linux内核提供的物理页分配接口,来实现向IOB分配指定数目的物理页面,并使用从0开始的逻辑页号进行编码;每个物理页的逻辑页号跟Linux struct page结构的对应关系通过页描述表page_descriptor进行维护,通过pd[i]便可得到逻辑页号为i的struct page结构。Specifically, an IOB (input Output Buffer) is an input and output buffer, and each IOB corresponds to a predetermined number of physical pages; in this embodiment, memory management is specifically performed on the basis of Linux memory management through a kernel module. The kernel module is loaded when the device is started. When allocating physical pages to the IOB, it allocates a specified number of physical pages to the IOB by calling the physical page allocation interface provided by the Linux kernel, and uses the logical page number starting from 0. Coding; the correspondence between the logical page number of each physical page and the Linux struct page structure is maintained through the page description table page_descriptor, and the struct page structure with the logical page number i can be obtained through pd[i].
在本实施例中,该内存数据拷贝指令,为将源IOB(src_iob)所对应的物理页中存储的待拷贝的数据,拷贝至目的IOB(dst_iob)对应的物理页的指令;进而,在本方案中,每个IOB包括:用来表示本IOB对应的各个物理页是否存储有数据的位图,用来表示本IOB的存储有数据的物理页的逻辑页号、用来指向下一个IOB的连接符。具体来说该IOB结构如下所示:In this embodiment, the memory data copy instruction is an instruction to copy the data to be copied stored in the physical page corresponding to the source IOB (src_iob) to the physical page corresponding to the destination IOB (dst_iob); In the scheme, each IOB includes: a bitmap used to indicate whether each physical page corresponding to this IOB stores data, a logical page number used to indicate the physical page of this IOB that stores data, and a bitmap used to point to the next IOB. Joiner. Specifically, the IOB structure is as follows:
通过该IOB结构可以看出,结构中的bitmap为位图,用于维护该IOB结构对应的各个物理页是否有效,该bitmap是8个uint8_t,每个bit对应pages[8]中的一个扇区sector是否有数据,因此,通过bitmap能体现出IOB对应的物理页是否存储有数据;结构中pages[8]用来表示该IOB对应的最多8个页的逻辑页号,可以看出一个IOB最多拥有8个页,即32KB内存;next为连接符,用于指向下一个IOB,用于实现大于32KB内存的情况。It can be seen from the IOB structure that the bitmap in the structure is a bitmap, which is used to maintain whether each physical page corresponding to the IOB structure is valid. The bitmap is 8 uint8_t, and each bit corresponds to a sector in pages[8] Whether the sector has data, therefore, the bitmap can reflect whether the physical page corresponding to the IOB stores data; pages[8] in the structure is used to indicate the logical page number of up to 8 pages corresponding to the IOB. It can be seen that an IOB has the most It has 8 pages, that is, 32KB of memory; next is the connector, which is used to point to the next IOB, which is used to achieve more than 32KB of memory.
S102、根据所述内存数据拷贝指令,将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB,并将所述源IOB中待拷贝的物理页的引用计数加一。S102. According to the memory data copy instruction, copy the logical page number of the physical page to be copied in the source IOB to the destination IOB, and increment the reference count of the physical page to be copied in the source IOB by one.
在本实施例中,接收到该内存数据拷贝指令copy(dst_iob,src_iob)时,便已经确定了源IOB和目的IOB,因此将源IOB中的数据拷贝至目的IOB时,为了减少拷贝真实数据的次数,在本实施例中仅将待拷贝的数据对应的逻辑页号拷贝至目的IOB,通过这种方式建立源IOB和目的IOB之间的引用关系,这样在访问目的IOB对应的数据时,可直接根据目的IOB的逻辑页号去访问源IOB中的数据;为了记录源IOB中的数据已经被其他IOB引用,所以将源IOB中待拷贝的物理页的逻辑页号拷贝至目的IOB后,需要将源IOB中待拷贝的物理页的引用计数加一,代表该物理页被其他IOB引用。In this embodiment, when the memory data copy instruction copy(dst_iob, src_iob) is received, the source IOB and the destination IOB have been determined. Therefore, when copying the data in the source IOB to the destination IOB, in order to reduce the time of copying the real data In this embodiment, only the logical page number corresponding to the data to be copied is copied to the destination IOB, and the reference relationship between the source IOB and the destination IOB is established in this way, so that when accessing the data corresponding to the destination IOB, the Access the data in the source IOB directly according to the logical page number of the destination IOB; in order to record that the data in the source IOB has been referenced by other IOBs, after copying the logical page number of the physical page to be copied in the source IOB to the destination IOB, it is necessary to The reference count of the physical page to be copied in the source IOB is incremented by one, indicating that the physical page is referenced by other IOBs.
需要说明的是,在本实施例中,物理页的引用计数维护在page descriptor表中,就是pd[i]的几个bits,因此,将所述源IOB中待拷贝的物理页的引用计数加一,可以包括:将页描述表中记录的与所述源IOB中待拷贝的物理页的引用计数加一;其中,页描述表中记录每个物理页的逻辑页号与页结构struct page之间的对应关系。It should be noted that, in this embodiment, the reference count of the physical page is maintained in the page descriptor table, which is several bits of pd[i]. Therefore, the reference count of the physical page to be copied in the source IOB is added First, it may include: adding one to the reference count of the physical page to be copied in the source IOB recorded in the page description table; wherein the logical page number of each physical page and the page structure struct page are recorded in the page description table. Correspondence between.
可以看出,页描述表中不仅仅记载了每个物理页的逻辑页号与页结构structpage之间的对应关系,还记载了每个物理页的引用计数,这样在物理页被引用或者被释放后,便可直接通过改变引用计数来实现。It can be seen that the page description table not only records the correspondence between the logical page number of each physical page and the page structure structpage, but also records the reference count of each physical page, so that the physical page is referenced or released. After that, it can be achieved directly by changing the reference count.
综上可见,在本实施例中,可通过内核模块调用Linux内核提供的物理页分配函数,向IOB分配物理页,通过page_descriptor表维护每个逻辑页号的物理页与linuxstruct page的对应关系。并且,该IOB的结构可以表示为一块内存,该结构使用bitmap,pages,next等实现页的分配和管理,在进行内存拷贝时,通过逻辑页号拷贝代替真实数据的拷贝,实现了内存数据的零拷贝,可以有效减少内存拷贝的次数,提高系统的性能,提升系统IOPS。To sum up, in this embodiment, the physical page allocation function provided by the Linux kernel can be called through the kernel module to allocate physical pages to the IOB, and the corresponding relationship between the physical page of each logical page number and the linuxstruct page can be maintained through the page_descriptor table. In addition, the structure of the IOB can be represented as a piece of memory. The structure uses bitmap, pages, next, etc. to realize page allocation and management. When copying memory, the copy of the real data is replaced by the copy of the logical page number, which realizes the copying of the memory data. Zero copy can effectively reduce the number of memory copies, improve system performance, and improve system IOPS.
参见图2,本发明实施例提供的一种内存数据拷贝方法,包括:Referring to FIG. 2, a method for copying memory data provided by an embodiment of the present invention includes:
S201、接收将源IOB的数据拷贝至目的IOB的内存数据拷贝指令;S201, receiving a memory data copy instruction for copying the data of the source IOB to the destination IOB;
S202、判断所述目的IOB是否具有对应的物理页的逻辑页号;若否,则执行S203,若是,则执行S204;S202, determine whether the destination IOB has the logical page number of the corresponding physical page; if not, execute S203, and if so, execute S204;
S203、将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB;S203, copying the logical page number of the physical page to be copied in the source IOB to the destination IOB;
S204、判断所述源IOB中待拷贝的物理页是否为整个物理页;若是,则执行S205;若否,则执行S206;S204, determine whether the physical page to be copied in the source IOB is the entire physical page; if so, execute S205; if not, execute S206;
S205、将所述目的IOB对应的物理页的引用计数减一,并将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB。S205. Decrease the reference count of the physical page corresponding to the destination IOB by one, and copy the logical page number of the physical page to be copied in the source IOB to the destination IOB.
S206、将所述目的IOB对应的物理页的引用计数减一,并向所述目的IOB分配新物理页,将目的IOB对应的物理页中的原始数据和源IOB中待拷贝的物理页的数据,均拷贝至所述新物理页。S206: Decrease the reference count of the physical page corresponding to the destination IOB by one, allocate a new physical page to the destination IOB, and combine the original data in the physical page corresponding to the destination IOB and the data of the physical page to be copied in the source IOB , are copied to the new physical page.
在本实施例中,针对内存数据拷贝,提供具体的拷贝策略,例如:In this embodiment, for memory data copy, a specific copy strategy is provided, for example:
1、如果源IOB(src_iob)有页,目的IOB(dst_iob)没有页,这时直接执行S203;该src_iob有页代表src_iob对应的pages[8]有页号,即物理页中有待拷贝的数据,由于是执行内存数据拷贝指令,因此src_iob一般为有页状态;dst_iob没有页,代表dst_iob没有分配过物理页页,就是dst_iob的pages[8]中还没有有效页号;在这种情况下,可直接将src_iob.pages中的逻辑页号拷贝到dst_iob.pages中,并且将src_iob中对应的物理页的引用计数加1。这种情况下只拷贝了物理页号,没有真实做内存的拷贝,实现了零拷贝。1. If the source IOB (src_iob) has a page, and the destination IOB (dst_iob) has no page, then execute S203 directly; the src_iob has a page representing that the pages[8] corresponding to src_iob has a page number, that is, the data to be copied in the physical page, Because the memory data copy instruction is executed, src_iob is generally in a paged state; dst_iob has no pages, which means that dst_iob has not allocated a physical page, that is, there is no valid page number in pages[8] of dst_iob; in this case, you can Directly copy the logical page number in src_iob.pages to dst_iob.pages, and increment the reference count of the corresponding physical page in src_iob by 1. In this case, only the physical page number is copied, and there is no real memory copy, which achieves zero copy.
2、如果src_iob有页,dst_iob有页,且整个页都会被覆盖,则执行S205;该dst_iob有页,代表dst_iob原来有一些数据,且这些数据可能引用的别的iob的页号,在这种情况下,如果src_iob中待拷贝的物理页是整个物理页,则需要释放dst_iob所引用的对应的页,即将dst_iob对应的物理页的引用计数减1,然后将src_iob中的逻辑页号拷贝到dst_iob中,并将src_iob的引用计数加1,这种情况,也是只做了物理页的拷贝,没有做真实的内存数据拷贝,实现了零拷贝。2. If src_iob has pages, dst_iob has pages, and the entire page will be covered, execute S205; the dst_iob has pages, which means that dst_iob originally has some data, and these data may refer to the page numbers of other iobs. In this case, if the physical page to be copied in src_iob is the entire physical page, the corresponding page referenced by dst_iob needs to be released, that is, the reference count of the physical page corresponding to dst_iob is decremented by 1, and then the logical page number in src_iob is copied to dst_iob , and add 1 to the reference count of src_iob. In this case, only physical page copies are made, and no real memory data copies are made, and zero copy is achieved.
3、如果src_iob有页,dst_iob有页,但只拷贝该页中部分内容(存储系统中IO过程中,内存拷贝以扇区(512字节)为单位,可能存在只拷贝几个扇区,但不拷贝整个页的操作),这时执行S206;3. If src_iob has a page, dst_iob has a page, but only part of the content of the page is copied (in the IO process in the storage system, the memory copy is in units of sectors (512 bytes), there may be only a few sectors copied, but operation without copying the entire page), then execute S206;
也就是说,如果dst_iob的pages[8]有页号,即这个iob原来有一些数据,且这些数据可能引用的别的iob的页号,例如:That is to say, if pages[8] of dst_iob has a page number, that is, this iob originally has some data, and the data may refer to the page number of other iob, for example:
dst_iob.pages[0]----iobx.pages[3]dst_iob.pages[0]----iobx.pages[3]
dst_iob引用了iobx的某个页,现在要给dst_iob拷贝数据,且拷贝的数据不是一个完整的页,是一个页的几个扇区,这时不能直接往dst_iob的pages里拷贝数据,因为这个页是共享的别人的页,一旦直接拷贝数据会导致另一个iob的页被修改;所以,需要先取消dst_iob对这个页的引用,然后给dst_iob分配一个新页,这个新页先拷贝旧页的内容,然后将src_iob的数据拷贝进这个新页。可以看出,这种方式下,零拷贝失效,需要做真实的页拷贝。dst_iob references a page of iobx, and now it is necessary to copy data to dst_iob, and the copied data is not a complete page, but several sectors of a page. At this time, data cannot be copied directly to the pages of dst_iob, because this page It is a shared page of others. Once the data is copied directly, the page of another iob will be modified; therefore, it is necessary to first cancel the reference of dst_iob to this page, and then allocate a new page to dst_iob, which copies the contents of the old page first. , and then copy the data of src_iob into this new page. It can be seen that in this way, the zero copy is invalid, and a real page copy needs to be done.
综上可以看出,在本方案中,针对目的IOB是否有逻辑页号,以及源IOB中待拷贝的物理页是否为整个物理页这两个条件,提出了多种拷贝策略,只要满足源IOB中待拷贝的物理页为整个物理页这个条件,在发生内存拷贝时,只需要拷贝物理页号,而不做真实的内存拷贝,提高内存拷贝的效率。From the above, it can be seen that in this scheme, according to the two conditions of whether the destination IOB has a logical page number, and whether the physical page to be copied in the source IOB is the entire physical page, a variety of copy strategies are proposed, as long as the source IOB is satisfied. In the condition that the physical page to be copied is the entire physical page, when a memory copy occurs, only the physical page number needs to be copied, and no real memory copy is performed, which improves the efficiency of memory copy.
下面对本发明实施例提供的内存数据拷贝装置进行介绍,下文描述的内存数据拷贝装置与上文描述的内存数据拷贝方法可以相互参照。The following describes the device for copying memory data provided by the embodiments of the present invention. The device for copying memory data described below and the method for copying memory data described above may refer to each other.
参见图3,本发明实施例提供的一种内存数据拷贝装置,包括:Referring to FIG. 3, an apparatus for copying memory data provided by an embodiment of the present invention includes:
       指令接收模块100,用于接收将源IOB的数据拷贝至目的IOB的内存数据拷贝指令;The 
       数据拷贝模块200,用于根据所述内存数据拷贝指令,将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB;A 
       引用计数更新模块300,用于将所述源IOB中待拷贝的物理页的引用计数加一。The reference 
其中,所述数据拷贝模块包括:Wherein, the data copying module includes:
第一判断单元,用于判断所述目的IOB是否具有对应的物理页的逻辑页号;a first judging unit for judging whether the destination IOB has the logical page number of the corresponding physical page;
第一拷贝单元,用于在没有对应的逻辑页号时,将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB;a first copying unit, configured to copy the logical page number of the physical page to be copied in the source IOB to the destination IOB when there is no corresponding logical page number;
第二判断单元,用于在有对应的逻辑页号时,判断所述源IOB中待拷贝的物理页是否为整个物理页;a second judging unit, configured to judge whether the physical page to be copied in the source IOB is the entire physical page when there is a corresponding logical page number;
第二拷贝单元,用于在所述源IOB中待拷贝的物理页为整个物理页时,将所述源IOB中待拷贝的物理页的逻辑页号拷贝至所述目的IOB;a second copy unit, configured to copy the logical page number of the physical page to be copied in the source IOB to the destination IOB when the physical page to be copied in the source IOB is an entire physical page;
第一更新单元,用于在所述源IOB中待拷贝的物理页为整个物理页时,将所述目的IOB对应的物理页的引用计数减一。The first updating unit is configured to decrement the reference count of the physical page corresponding to the destination IOB by one when the physical page to be copied in the source IOB is the entire physical page.
其中,所述数据拷贝模块还包括:Wherein, the data copy module also includes:
第二更新单元,用于在所述源IOB中待拷贝的物理页不为整个物理页时,将所述目的IOB对应的物理页的引用计数减一;a second update unit, configured to decrement the reference count of the physical page corresponding to the destination IOB by one when the physical page to be copied in the source IOB is not the entire physical page;
物理页分配单元,用于向所述目的IOB分配新物理页;a physical page allocation unit for allocating a new physical page to the destination IOB;
第三拷贝单元,用于将所述目的IOB对应的物理页中的原始数据和所述源IOB中待拷贝的物理页的数据,均拷贝至所述新物理页。The third copy unit is configured to copy both the original data in the physical page corresponding to the destination IOB and the data of the physical page to be copied in the source IOB to the new physical page.
其中,每个IOB包括:用来表示本IOB对应的各个物理页是否存储有数据的位图,用来表示本IOB的存储有数据的物理页的逻辑页号、用来指向下一个IOB的连接符。Wherein, each IOB includes: a bitmap used to indicate whether each physical page corresponding to this IOB stores data, a logical page number used to indicate the physical page of this IOB that stores data, and a connection used to point to the next IOB symbol.
其中,所述引用计数更新模块,具体用于将页描述表中记录的与所述源IOB中待拷贝的物理页的引用计数加一;其中,所述页描述表中记录每个物理页的逻辑页号与页结构struct page之间的对应关系。Wherein, the reference count update module is specifically configured to add one to the reference count recorded in the page description table and the physical page to be copied in the source IOB; wherein, the page description table records the reference count of each physical page The correspondence between the logical page number and the page structure struct page.
本发明实施例还公开了一种内存数据拷贝设备,包括:The embodiment of the present invention also discloses a memory data copy device, comprising:
存储器,用于存储计算机程序;memory for storing computer programs;
处理器,用于执行所述计算机程序时实现如上述实施例中所述的内存数据拷贝方法的步骤。The processor is configured to implement the steps of the method for copying memory data as described in the foregoing embodiments when executing the computer program.
本发明实施例还公开了一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上述实施例中所述的内存数据拷贝方法的步骤。An embodiment of the present invention further discloses a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the method for copying memory data described in the foregoing embodiment is implemented A step of.
其中,该存储介质可以包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。Wherein, the storage medium may include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other various storage media that can store program codes medium.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments can be referred to each other.
对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本发明。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above description of the disclosed embodiments enables any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (8)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title | 
|---|---|---|---|
| CN201910294464.0A CN110007869B (en) | 2019-04-12 | 2019-04-12 | Memory data copying method, device, equipment and computer storage medium | 
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title | 
|---|---|---|---|
| CN201910294464.0A CN110007869B (en) | 2019-04-12 | 2019-04-12 | Memory data copying method, device, equipment and computer storage medium | 
Publications (2)
| Publication Number | Publication Date | 
|---|---|
| CN110007869A CN110007869A (en) | 2019-07-12 | 
| CN110007869B true CN110007869B (en) | 2020-06-30 | 
Family
ID=67171418
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date | 
|---|---|---|---|
| CN201910294464.0A Active CN110007869B (en) | 2019-04-12 | 2019-04-12 | Memory data copying method, device, equipment and computer storage medium | 
Country Status (1)
| Country | Link | 
|---|---|
| CN (1) | CN110007869B (en) | 
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title | 
|---|---|---|---|---|
| WO2021231234A1 (en) * | 2020-05-12 | 2021-11-18 | Google Llc | Zero copy optimization for select * queries | 
| CN115576865A (en) * | 2022-10-10 | 2023-01-06 | 苏州浪潮智能科技有限公司 | Method and device for realizing data zero copy, computer equipment and storage medium | 
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title | 
|---|---|---|---|---|
| CN101278269A (en) * | 2005-10-07 | 2008-10-01 | 国际商业机器公司 | System and method for improved dmac translation mechanism | 
| US7480298B2 (en) * | 2004-08-30 | 2009-01-20 | International Business Machines Corporation | Lazy deregistration of user virtual machine to adapter protocol virtual offsets | 
| CN103257936A (en) * | 2012-02-17 | 2013-08-21 | 联想(北京)有限公司 | Memory mapping method and memory mapping module | 
| WO2016082191A1 (en) * | 2014-11-28 | 2016-06-02 | 华为技术有限公司 | File access method and apparatus | 
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title | 
|---|---|---|---|---|
| US20060075067A1 (en) * | 2004-08-30 | 2006-04-06 | International Business Machines Corporation | Remote direct memory access with striping over an unreliable datagram transport | 
- 
        2019
        
- 2019-04-12 CN CN201910294464.0A patent/CN110007869B/en active Active
 
 
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title | 
|---|---|---|---|---|
| US7480298B2 (en) * | 2004-08-30 | 2009-01-20 | International Business Machines Corporation | Lazy deregistration of user virtual machine to adapter protocol virtual offsets | 
| CN101278269A (en) * | 2005-10-07 | 2008-10-01 | 国际商业机器公司 | System and method for improved dmac translation mechanism | 
| CN103257936A (en) * | 2012-02-17 | 2013-08-21 | 联想(北京)有限公司 | Memory mapping method and memory mapping module | 
| WO2016082191A1 (en) * | 2014-11-28 | 2016-06-02 | 华为技术有限公司 | File access method and apparatus | 
Also Published As
| Publication number | Publication date | 
|---|---|
| CN110007869A (en) | 2019-07-12 | 
Similar Documents
| Publication | Publication Date | Title | 
|---|---|---|
| US7246195B2 (en) | Data storage management for flash memory devices | |
| US7805584B2 (en) | Method and system for restoring data | |
| US10331584B2 (en) | Internal system namespace exposed through use of two local processors and controller memory buffer with two reserved areas | |
| US11397668B2 (en) | Data read/write method and apparatus, and storage server | |
| CN111857592B (en) | Data storage method and device based on object storage system and electronic equipment | |
| US20080195833A1 (en) | Systems, methods and computer program products for operating a data processing system in which a file system's unit of memory allocation is coordinated with a storage system's read/write operation unit | |
| US8073673B2 (en) | Emulated memory management | |
| US7472252B2 (en) | Merging identical memory pages | |
| US8751547B2 (en) | Multiple file system and/or multi-host single instance store techniques | |
| US10635356B2 (en) | Data management method and storage controller using the same | |
| US10203899B2 (en) | Method for writing data into flash memory apparatus, flash memory apparatus, and storage system | |
| US8572338B1 (en) | Systems and methods for creating space-saving snapshots | |
| CN103412822A (en) | Operation method of non-volatile RAM, data operation method and relevant device | |
| CN113835616A (en) | Applied data management method, system and computer device | |
| CN110007869B (en) | Memory data copying method, device, equipment and computer storage medium | |
| CN107391050A (en) | A kind of data migration method, system, device and computer-readable recording medium | |
| US8549223B1 (en) | Systems and methods for reclaiming storage space on striped volumes | |
| US8954702B2 (en) | Extended address volume (EAV) allocation verification | |
| JP2021135538A (en) | Storage controller and storage control program | |
| WO2014153931A1 (en) | File storage method and device, access client and metadata server system | |
| CN111221468B (en) | Storage block data deletion method, device, electronic equipment and cloud storage system | |
| CN108984117B (en) | Data reading and writing method, medium and equipment | |
| CN110658999A (en) | An information update method, apparatus, device and computer-readable storage medium | |
| CN105718207A (en) | Data processing method, data read-write device and storage system | |
| CN115309668A (en) | SDD writing performance optimization method and device, computer equipment and storage medium | 
Legal Events
| Date | Code | Title | Description | 
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CP03 | Change of name, title or address | 
             Address after: Building 9, No.1, guanpu Road, Guoxiang street, Wuzhong Economic Development Zone, Wuzhong District, Suzhou City, Jiangsu Province Patentee after: Suzhou Yuannao Intelligent Technology Co.,Ltd. Country or region after: China Address before: Building 9, No.1, guanpu Road, Guoxiang street, Wuzhong Economic Development Zone, Wuzhong District, Suzhou City, Jiangsu Province Patentee before: SUZHOU LANGCHAO INTELLIGENT TECHNOLOGY Co.,Ltd. Country or region before: China  |