WO2020000735A1 - 写数据方法、装置、计算机装置及存储介质 - Google Patents
写数据方法、装置、计算机装置及存储介质 Download PDFInfo
- Publication number
- WO2020000735A1 WO2020000735A1 PCT/CN2018/108127 CN2018108127W WO2020000735A1 WO 2020000735 A1 WO2020000735 A1 WO 2020000735A1 CN 2018108127 W CN2018108127 W CN 2018108127W WO 2020000735 A1 WO2020000735 A1 WO 2020000735A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- write
- written
- start address
- stream
- continuous
- 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.)
- Ceased
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
- G06F3/0644—Management of space entities, e.g. partitions, extents, pools
-
- 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/0655—Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
- G06F3/0656—Data buffering arrangements
-
- 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/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0679—Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
Definitions
- the type of main memory to be written and the type of cache to be written are specifically related to the computer equipment that handles the write operation. Therefore, the above-mentioned judgment of the main memory to be written and the cache to be written specifically is to obtain and judge the physical attributes of the main memory to be written and the cache to be written.
- Solid State Drives Solid State Drives
- the solid state drive is a hard drive made of a solid state electronic memory chip array.
- a solid state hard disk uses a flash memory (flash chip) as a storage medium, or a DRAM as a storage medium.
- determining whether the IO stream to be written includes continuous write IO includes:
- the length of the write IO refers to the length of the data to be operated on by the write IO, for example, the length of one continuous data to be written.
- the actual start address of obtaining the second write IO is 10, and according to the obtained actual start address of the second write IO, whether it is the same as the expected start address of the saved second write IO.
- the expected starting address of the second write IO is 10
- the actual starting address of the second write IO is 10, indicating that the write addresses of the second write IO and the first write IO are continuously.
- the continuous length between the jth write IO and the initial write IO is 15 at this time. If the preset length is 20, it is determined that the continuous length between the j-th write IO and the initial write IO does not reach the preset length at this time.
- the number of consecutive write IOs between the j-th write IO and the initial write IO refers to how many write IO write addresses have been consecutive from the initial write IO to the j-th write IO.
- the above preset number can be set as needed.
- the expected starting address of the j-th write IO is always stored in the k-th variable.
- the third write IO when the actual start address of the third write IO is the expected start address, it is determined that the write addresses of the third write IO and the second write IO are also continuous, and the third write IO and Whether the continuous length between the initial write IO (the initial write IO is the first write IO at this time) reaches the preset length and / or whether the number of consecutive write IOs between the third write IO and the initial write IO reaches the preset number .
- the method further includes:
- the method further includes:
- the IO stream to be written includes continuous write IO, obtain the continuous write IO, and write the operation data of the continuous write IO to the main memory to be written.
- the IO stream to be written does not include continuous write IO, write operation data of the IO stream to be written to the write-to-write buffer;
- the processing capacity of the disk may be strong, but the track needs to be frequently changed during the data writing process, which takes more time. Therefore, at this time, the operation data to be written to the IO stream can be directly written to the write-to-write cache, and then obtained from the write-to-write cache and written to the write-to-write main memory, so that the data can be written quickly. Into the cache.
- the data writing method provided in this application receives the IO stream to be written; determines whether the main memory to be written to the IO stream to be written is a preset main memory, and whether the to-be-written cache of the IO stream to be written is A preset cache; if the main memory to be written is a preset main memory and the cache to be written is a preset cache, judging whether the IO stream to be written includes continuous write IO; The stream includes continuous write IO, acquires the continuous write IO, and writes the operation data of the continuous write IO to the main memory to be written.
- the receiving module 210 is configured to receive an IO stream to be written.
- the first determining module 220 is configured to determine whether the main memory to be written of the IO stream to be written is a preset main memory, and whether the buffer to be written to the IO stream to be written is a preset cache.
- the type of main memory to be written and the type of cache to be written are specifically related to the computer equipment that handles the write operation. Therefore, the above-mentioned judgment of the main memory to be written and the cache to be written specifically is to obtain and judge the physical attributes of the main memory to be written and the cache to be written.
- the preset main memory is a disk
- the preset cache is a solid state disk.
- the to-be-written main memory of the to-be-written IO stream is not a preset main memory and / or the to-be-written cache of the to-be-written IO stream is not a preset cache
- the to-be-written The operation data of the input IO stream is written to the to-be-written cache; the operation data of the IO stream to be written from the to-be-written cache is written to the main memory to be written.
- An obtaining unit configured to determine an i-th write IO in the IO stream to be written as an initial write IO, obtain an actual start address and length of the i-th write IO, and obtain an actual start address and Length, where i is a positive integer.
- the value of i at this time is 1. If it is determined that the second write IO is the initial write IO, the value of i is 2 at this time.
- each write IO request includes the start address and length to be processed. Therefore, after the initial write IO is obtained, the actual start address and length of the initial write IO can be obtained.
- the length of the write IO refers to the length of the data to be operated on by the write IO, for example, the length of one continuous data to be written.
- a calculation unit configured to calculate an expected start address of the j-th write IO according to the actual start address and length of the i-th write IO, and store the expected start address of the j-th write IO in a k-th variable
- j i + 1
- the initial value of k is 1, and k is a positive integer.
- a second judgment unit configured to determine the j-th write IO if the actual start-address of the j-th write IO is equal to the expected start address of the j-th write IO stored in the k-th variable Whether the continuous length with the initial write IO reaches a preset length and / or whether the number of consecutive write IOs between the j-th write IO and the initial write IO reaches a preset number.
- the continuous length between the jth write IO and the initial write IO is 15 at this time. If the preset length is 20, it is determined that the continuous length between the j-th write IO and the initial write IO does not reach the preset length at this time.
- the number of consecutive write IOs between the j-th write IO and the initial write IO refers to how many write IO write addresses have been consecutive from the initial write IO to the j-th write IO.
- the above preset number can be set as needed.
- a first determining unit configured to: if the continuous length between the j-th write IO and the initial write IO reaches a preset length and / or the continuous between the j-th write IO and the initial write IO The number of write IOs reaches a preset number, it is identified that the j-th write IO and the initial write IO are continuous IOs, and it is determined that the to-be-written IO stream includes continuous write IOs.
- the length of the jth write IO reaches the preset length and / or the number of consecutive write IOs between the jth write IO and the initial write IO reaches a preset number, it indicates that the jth write IO
- the initial write IOs are consecutive write addresses in order, and a long period of data has been written. At this time, it is determined that there is continuous IO between the j-th write IO and the initial write IO.
- the initial write IO is the first write IO
- the actual start address of the second write IO is the same as the calculated expected start address, but between the second write IO and the first write IO
- the consecutive length did not reach the preset length and the number of consecutive write IOs between the second write IO and the first write IO did not reach the preset number.
- the expected starting address of the j-th write IO is always stored in the k-th variable.
- the expectation of the next write IO (that is, the third write IO) is calculated based on the actual start address of the second write IO. Start address and save it in variable k.
- the write operation module 240 is configured to: if the IO stream to be written includes continuous write IO, acquire the continuous write IO, and write the operation data of the continuous write IO to the main memory to be written.
- the write operation module is specifically configured to:
- the write operation may have been performed synchronously. Therefore, subsequent write IOs that are consecutive to the previous consecutive write IO can be determined as the main memory IO to be written, and then the operation data to be written to the main memory IO is written to the main memory to be written.
- the write IOs in the IO stream to be written have not yet performed write IO operations are consecutive write IOs, it can be determined by judging whether the addresses of the write IOs are continuous with the previous consecutive write IOs.
- the first write IO to the fifth write IO are consecutive write IOs.
- the addresses of the sixth write IO and the fifth write IO are consecutive, directly determine that the sixth write IO is to be written.
- Main memory IO write the sixth write IO directly into main memory.
- the IO stream to be written does not include continuous write IO, write operation data of the IO stream to be written to the to-be-written cache; and obtain the IO-to-be-write stream from the to-be-written cache
- the operation data is written into the main memory to be written.
- the data writing device receives the IO stream to be written through the receiving module; the first judgment module determines whether the main memory to be written of the IO stream to be written is a preset main memory, and the IO stream to be written Whether the to-be-written cache is a preset cache; if the to-be-written main memory is a preset main memory and the to-be-written cache is a preset cache, a second judgment module determines whether the to-be-written IO stream contains Continuous write IO; if the IO stream to be written contains continuous write IO, the write operation module obtains the continuous write IO, and writes the operation data of the continuous write IO to the main memory to be written.
- the present application selects an appropriate method for performing a write operation by judging the main memory to be written, the cache to be written, and the IO stream to be written, which can improve the efficiency of the write operation.
- FIG. 3 is a schematic structural diagram of a computer device according to a preferred embodiment of a method for writing data in this application.
- the computer device includes at least one transmitting device 31, at least one memory 32, at least one processor 33, at least one receiving device 34, and at least one communication bus.
- the communication bus is used to implement connection and communication between these components.
- the computer device is a device capable of automatically performing numerical calculation and / or information processing in accordance with an instruction set or stored in advance.
- the hardware includes, but is not limited to, a microprocessor and an Application Specific Integrated Circuit (ASIC). , Programmable Gate Array (Field-Programmable Gate Array, FPGA), Digital Processor (Digital Signal Processor, DSP), Embedded Equipment, etc.
- the computer device may further include a network device and / or a user device.
- the network device includes, but is not limited to, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on Cloud Computing, where the cloud computing is distributed computing A super virtual computer consisting of a set of loosely coupled computers.
- the network where the computer device is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), and the like.
- VPN Virtual Private Network
- the receiving device 34 and the sending device 31 may be wired sending ports, or may be wireless devices, for example, including an antenna device, for performing data communication with other devices.
- the memory 32 is configured to store program code.
- the memory 32 may be a circuit having a storage function in an integrated circuit without a physical object, such as a RAM (Random-Access Memory, Random Access Memory), a FIFO (First In First Out, FIFO) and the like.
- the memory 32 may also be a physical memory, such as a memory stick, a TF card (Trans-flash Card), a smart media card, a secure digital card, and a flash memory card. (flash card) and other storage devices.
- the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the objective of the solution of this embodiment.
- each functional module in each embodiment of the present application may be integrated into one processing unit, or each unit may exist separately physically, or two or more units may be integrated into one unit.
- the integrated unit can be implemented in the form of hardware, or in the form of hardware plus software functional modules.
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)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
一种写数据方法、写数据装置、计算机装置和计算机可读存储介质。所述方法包括:接收待写入IO流(S11);判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存(S12);若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所述待写入IO流是否包含连续写IO(S13);若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存(S14)。上述方法可以提高写数据的速度。
Description
本申请要求于2018年06月28日提交中国专利局,申请号为201810691015.5发明名称为“写数据方法、装置、计算机装置及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及存储技术领域,尤其涉及一种写数据方法、装置、计算机装置及存储介质。
计算机的读写操作也称为IO操作,IO即input/output。具体的,一个IO操作可以是读IO操作(例如,将数据从磁盘读取到内存)也可以是写IO操作(例如,将数据写入磁盘中)。写IO操作是计算机中一种常见的操作。写操作效率的提高有利于缩短用户等待时间,提高用户体验。因此,如何能够快速的进行写数据具有一定的现实意义,写操作效率的提高有利于提高了计算机的处理效率。
发明内容
鉴于以上内容,有必要提供一种写数据方法、装置、计算机装置及存储介质,能够提高写数据的速度。
本申请提供一种写数据方法,所述方法包括:
接收待写入IO流;
判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存;
若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所述待写入IO流是否包含连续写IO;
若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。
本申请还提供一种写数据装置,所述装置包括:
接收模块,用于接收待写入IO流;
第一判断模块,用于判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存;
第二判断模块,用于若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所述待写入IO流是否包含连续写IO;
写操作模块,用于若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。
本申请还提供一种计算机装置,所述计算机装置包括存储器及处理器,所述存储器用于存储至少一个指令,所述处理器用于执行所述至少一个指令以实现任意实施例中所述的写数据方法。
本申请还提供一种非易失性可读存储介质,其特征在于,所述非易失性可读存储介质存储有至少一个指令,所述至少一个指令被处理器执行时实现任意实施例中所述的写数据方法。
由以上技术方案看出,本申请通过接收待写入IO流;判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存;若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所述待写入IO流是否包含连续写IO;若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。在写数据时,根据待写入主存和待写入缓存对连续写IO的操作数据进行写处理,而不是将待写入IO流的操作数据都直接先写入主存再写入缓存,由于不同的主存和缓存处理数据的能力不同,对于连续的写IO,有些主存的处理能力强于缓存。因此,本申请通过待写入主存、待写入缓存以及待写入IO流的判断选择合适的方式进行写操作,可以提高写操作的效率。
图1是本申请实施例提供的一种写数据方法的流程图;
图2是本申请实施例提供的写数据装置的功能模块图;
图3是本申请实现写数据方法的较佳实施例的计算机装置的结构示意图。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
为使本申请的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本申请作进一步详细的说明。
如图1所示,图1为本申请实施例提供的一种写数据方法的流程图。根 据不同的需求,该流程图中步骤的顺序可以改变,某些步骤可以省略。
S11,接收待写入IO流。
其中,待写入IO流是多个写IO,每个写IO用于进行写数据操作。
通常,一个写IO包含要写入的地址以及要写入的数据(即写IO的操作数据)。
S12,判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存。
在计算机中进行写数据时,通常通过缓存机制来对大量的数据进行存储,具体是,利用缓存可以在短时间内存储大量数据的特点,在数据先存储在缓存中,再将数据从缓存中存储到主存中。
上述待写入IO流的待写入主存是要进行将数据进行写入的主存。上述待写入IO流的待写入缓存是要将数据进行写入的缓存。
待写入主存与待写入缓存为哪种类型具体与处理写操作的计算机设备有关。因此,上述对待写入主存和待写入缓存的判断具体是获取待写入主存和待写入缓存的物理属性并进行判断。
同时,上述预设主存的数据处理能力在处理连续写IO时,其数据处理能力大于上述预设缓存。上述预设主存可以根据需要设定。
可选的,所述预设主存为磁盘,所述预设缓存为固态硬盘。
上述固态硬盘(Solid State Drives,SSD)简称为固盘,固态硬盘是用固态电子存储芯片阵列而制成的硬盘。通常,固态硬盘中采用闪存(flash芯片)作为存储介质,或者是采用DRAM作为存储介质。
处理连续写IO时,若磁盘作为主存,固态硬盘作为缓存,此时主存的处理能力优于缓存。
通过对待写入主存和待写入缓存的判断,有利于确定写数据的方式。
可选的,若所述待写入IO流的待写入主存不为预设主存和/或所述待写入IO流的待写入缓存不为预设缓存,将所述待写入IO流的操作数据写入到所述待写入缓存;从所述待写入缓存获取所述待写入IO流的操作数据写入所述待写入主存。
S13,若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所述待写入IO流是否包含连续写IO。
上述连续写IO是地址连续的多个写IO,具体的,可以通过待写入IO流中写IO的地址判断待写入IO流中是否包含连续写IO。
进一步的,所述判断所述待写入IO流是否包含连续写IO包括:
(1)确定所述待写入IO流中第i个写IO为初始写IO,获取所述第i个写IO的实际起始地址和长度,得到初始写IO的实际起始地址和长度,其 中,i为正整数。
在判断待写入IO流之中是否包含连续写IO时,确定判断的起点,即确定从哪个写IO开始之后的一段是否为连续写IO。
具体的,在进行判断时,可以选取待写入IO流之中排列顺序在前的任意写IO为初始写IO。
例如,确定第1个写IO为初始写IO,则此时i的值为1。若确定第2个写IO为初始写IO,则此时i的值为2。
通常,每个写IO请求都包含了要处理的起始地址和长度,因此,在获取到初始写IO之后,就可以获取到初始写IO的实际起始地址和长度。
其中,在本实施例中,写IO的长度指写IO要操作的数据的长度,例如要写入一个连续的数据的长度。
(2)根据所述第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将所述第j个写IO的期待起始地址保存在第k变量中,其中,j=i+1,k的初始值为1,k为正整数。
上述当j=i+1,且根据第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,是指:根据第i个写IO的实际起始地址计算第i个写IO的下一个写IO的起始地址,该计算得到的起始地址为期待起始地址,并将这个起始地址的值,保存在一个变量k中。
例如,当i=1时,若第i个写IO的实际起始地址为8,长度为2,则第2个写IO的期待起始地址的计算方式为8+2=10,即第2个写IO的期待起始地址为10。并将这一期待起始地址进行保存在第一个变量之中。
(3)获取所述第j个写IO的实际起始地址和长度,判断所述第j个写IO的实际起始地址是否等于所述第k变量中保存的所述第j个写IO的期待起始地址。
通常,每个写IO都包含了要处理的IO起始地址和长度,因此,在获取到第j个写IO之后,就可以获取到第j个写IO的实际起始地址和长度。
在计算了下一个写IO的期待起始地址之后,根据实际获取到的下一个写IO来判断,该写IO的实际起始地址是否为之前计算得到的期待起始地址。
例如,获取第2个写IO的实际起始地址为10,根据获取到的第2个写IO的实际起始地址,与保存的第2个写IO的期待起始地址对比是否为相同的。
(4)若所述第j个写IO的实际起始地址等于所述第k变量中保存的所述第j个写IO的期待起始地址,判断所述第j个写IO与所述初始写IO之间的连续长度是否达到预设长度和/或所述第j个写IO与所述初始写IO之间的连续写IO数量是否达到预设数量。
例如,第2个写IO的期待起始地址为10,并且,获取到第2个写IO的实际起始地址为10,则表明第2个写IO与第1个写IO的写入地址是连续的。
上述第j个写IO与初始写IO之间的连续长度是否达到预设长度是指:从初始写IO到第j个写IO总共写入的数据的长度值是否达到预设长度。上述预设长度可以根据需要进行设定。
例如,第2个写IO写入数据长度为8,第1个写IO写入数据长度为7,则此时第j个写IO与初始写IO之间的连续长度为15。若预设长度为20,则确定此时第j个写IO与初始写IO之间的连续长度没有达到预设长度。
上述第j个写IO与初始写IO之间的连续写IO数量是指,从初始写IO到第j个写IO已经有多少个写IO的写入地址为连续的了。上述预设数量可以根据需要进行设定。
例如,第j个写IO为第2个写IO,初始写IO为第1个写IO,则此时,第j个写IO与初始写IO之间连的连续写IO数量为2个。若预设数量为3,则确定此时第j个写IO与初始写IO之间的连续写IO数量没有达到预设数量。
(5)若所述第j个写IO与所述初始写IO之间的连续长度达到预设长度和/或所述第j个写IO与所述初始写IO之间的连续写IO数量达到预设数量,识别所述第j个写IO与所述初始写IO之间为连续IO,确定所述待写入IO流包含连续写IO。
当第j个写IO的长度与初始写IO的长度达到预设长度和/或第j个写IO与初始写IO相距的连续写IO数量达到预设数量时,表明第j个写IO的与初始写IO之间依次为连续的写入地址,并且已经写入了一段较长的数据。此时,确定第j个写IO与初始写IO之间为连续IO。
在本实施例中,不仅通过写IO的地址判断是否连续,还根据写IO之间连续的长度或写数据长度进行判断,并非两个写IO为地址连续的就判断为是存在连续写IO,能够更精确的识别是否是连续的写IO。
(6)若所述第j个写IO与所述初始写IO之间的连续长度没有达到预设长度并且所述第j个写IO与所述初始写IO之间的连续写IO数量没有达到预设数量,令i=i+1,执行所述根据所述第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将所述第j个写IO的期待起始地址保存在第k变量中的操作。
例如,若初始写IO为第1个写IO,通过前述步骤得到第2个写IO的实际起始地址与计算得到的期待起始地址一致,但第2个写IO的与第1个写IO之间的连续长度没有达到预设长度并且第2个写IO与第1个写IO之间的连续写IO数量没有达到预设数量。
则,令i=i+1,执行根据第i个写IO的实际起始地址和长度计算第j个 写IO的期待起始地址,将第j个写IO的期待起始地址保存在第k变量中的操作,其中j=i+1。
此时,i=1+1=2,j=i+1=3,根据第2个写IO的实际起始地址和长度,计算第3个写IO的期待起始地址,将第3个写IO的期待起始地址保存在第k变量中。
在本实施例中,第k变量中始终保存的为第j个写IO的期待起始地址。
由于第2个写IO的实际起始地址已经在之前的计算中得到了,因此,此时根据第2个写IO的实际起始地址计算下一个写IO(即第3个写IO)的期待起始地址,并保存在变量k中。
依次类推,当第3个写IO的实际起始地址为期待起始地址时,确定第3个写IO与第2个写IO的写入地址也是连续的,判断所述第3个写IO与初始写IO(此时初始写IO为第1个写IO)之间的连续长度是否达到预设长度和/或第3个写IO与初始写IO之间的连续写IO数量是否达到预设数量。当第3个写IO与第1个写IO之间的连续长度没有达到预设长度并且连续的写IO数量没有达到预设数量时,根据第3个写IO的实际起始地址和长度计算第4个写IO的期待起始地址,直到第j个写IO的写入地址与前一个写IO的写入地址不连续时跳出循环,或者是第j个写IO与初始写IO之间的连续长度达到预设长度和/或第j个写IO与初始写IO之间的连续IO数量达到预设数量,确定待写入IO流包含连续写IO。
进一步的,所述方法还包括:
若所述第j个写IO的实际起始地址不等于所述第k变量中保存的所述第j个写IO的期待起始地址,确定所述第j个写IO与所述初始写IO之间不为连续写IO。
当获取到的第j个写IO的实际起始地址与第k变量中保存的第j个写IO的期待起始地址不相同,则表明第i个写IO实际的写入地址与前一个写IO的写入地址不是连续的写入地址。
此时,确定第j个写IO与前一个写IO的写入地址不是连续的写入地址,也表明第j个写IO与初始的写IO不为连续IO。
进一步的,所述方法还包括:
若所述第j个写IO的实际起始地址不等于所述第k变量中保存的所述第j个写IO的期待起始地址,令i=j,k=k+1,执行所述确定所述待写入IO流中第i个写IO为初始写IO,获取所述第i个写IO的实际起始地址和长度,得到初始写IO的实际起始地址和长度的操作。
例如,若j=5,当第5个写IO的实际起始地址不等于第k变量中保存的第5个写IO的期待起始地址,表明第5个写IO与前面计算过的写IO(如第 4个写IO和第3个写IO)都不为连续的。
令第5个写IO为初始写IO,从第5个写IO开始,依照上述的方法重新对后续的IO进行判断,在比较写IO的写入地址是否连续时,仍然是由后一个写IO与前一个写IO进行对比。即当某一个写IO的实际起始地址与期待起始地址不一致时,确定该写IO为初始写IO,计算该写IO之后的IO与该写IO的地址是否为连续。
同时,在本操作中,计算的下一个写IO保存在另一个变量之中。
在具体实施时,可以通过数组保存多个k的值。当数组中的每个数都被赋值了之后,也可以重新对数组中的变量进行赋值。
例如,数组有n个值,当个第1变量至第10变量都被赋值了之后,若仍有要保存的k值,可以将新的值保存在第一变量之中,或者是其他变量之中。
S14,若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。
当待写入IO流包含连续写IO,可以将多个连续IO确定为待写入主存IO,然后将待写入主存IO的操作数据写入到主存中。
可选的,所述将所述连续写IO的操作数据写入到所述待写入主存包括:
将与所述连续写IO相连续的写IO确定为待写入主存IO;
将所述待写入主存IO的操作数据写入所述待写入主存。
在实际应用中,由于对待写入IO流进行判断的同时,可能已经同步进行了写的操作。因此,可以在对后续与前面连续写IO相连续的写IO确定为待写入主存IO,进而将待写入主存IO的操作数据写入待写入主存。
具体的,判断待写入IO流中还未进行写IO操作的写IO是否为相连续的写IO,可以通过判断写IO的地址是否与前面连续写IO相连续来进行判断。
例如,第1个写IO至第5个写IO都为连续写IO,此时若第6个写IO与第5个写IO的地址为连续的,直接确定第6个写IO为待写入主存IO,将第6个写IO直接写入到主存中。
当待写入主存为磁盘并且待写入缓存为固态硬盘时,由于磁盘与固态硬盘的物理特性决定了,磁盘的读写速度快于固态硬盘的读写速度。并且,由于连续写IO在磁盘中进行写数据时,写入扇区相隔较近,磁头几乎不用换道或者换道时间极短。因此,将连续写IO直接写入到磁盘时,能够快速的将数据写入。
可选的,所述方法还包括:
若所述待写入IO流不包含连续写IO,将所述待写入IO流的操作数据写入到所述待写入缓存;
从所述待写入缓存获取所述待写入IO流的操作数据写入所述待写入主 存。
当待写入IO流不包含连续写IO时,由于磁盘的处理能力可能很强,但是在写入数据过程中需要频繁转换磁道,需花费较多的时间。所以此时,可以将待写入IO流的操作数据直接写入到待写入缓存中,然后在从待写入缓存中获取进行写入到待写入主存中,以使数据能快速写入缓存。
本申请提供的写数据方法接收待写入IO流;判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存;若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所述待写入IO流是否包含连续写IO;若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。在写数据时,根据待写入主存和待写入缓存对连续写IO的操作数据进行写处理,而不是将待写入IO流的操作数据都直接先写入主存再写入缓存,由于不同的主存和缓存处理数据的能力不同,对于连续的写IO,有些主存的处理能力强于缓存。因此,本申请通过待写入主存、待写入缓存以及待写入IO流的判断选择合适的方式进行写操作,可以提高写操作的效率。
如图2所示,图2为本申请实施例提供的写数据装置的功能模块图。所述写数据装置包括接收模块210、第一判断模块220、第二判断模块230和写操作模块240。本申请所称的模块是指一种能够被计算机装置的处理器所执行并且能够完成固定功能的一系列计算机可读指令段,其存储在计算机装置的存储器中。在本实施例中,关于各模块的功能将在后续的实施例中详述。
接收模块210,用于接收待写入IO流。
其中,待写入IO流是多个写IO,每个写IO用于进行写数据操作。
通常,一个写IO包含要写入的地址以及要写入的数据(即写IO的操作数据)。
第一判断模块220,用于判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存。
在计算机中进行写数据时,通常通过缓存机制来对大量的数据进行存储,具体是,利用缓存可以在短时间内存储大量数据的特点,在数据先存储在缓存中,再将数据从缓存中存储到主存中。
上述待写入IO流的待写入主存是要进行将数据进行写入的主存。上述待写入IO流的待写入缓存是要将数据进行写入的缓存。
待写入主存与待写入缓存为哪种类型具体与处理写操作的计算机设备有关。因此,上述对待写入主存和待写入缓存的判断具体是获取待写入主存和待写入缓存的物理属性并进行判断。
同时,上述预设主存的数据处理能力在处理连续写IO时,其数据处理能力大于上述预设缓存。上述预设主存可以根据需要设定。
可选的,所述预设主存为磁盘,所述预设缓存为固态硬盘。
上述固态硬盘(Solid State Drives,SSD)简称为固盘,固态硬盘是用固态电子存储芯片阵列而制成的硬盘。通常,固态硬盘中采用闪存(flash芯片)作为存储介质,或者是采用DRAM作为存储介质。
处理连续写IO时,若磁盘作为主存,固态硬盘作为缓存,此时主存的处理能力优于缓存。
通过对待写入主存和待写入缓存的判断,有利于确定写数据的方式。
可选的,若所述待写入IO流的待写入主存不为预设主存和/或所述待写入IO流的待写入缓存不为预设缓存,将所述待写入IO流的操作数据写入到所述待写入缓存;从所述待写入缓存获取所述待写入IO流的操作数据写入所述待写入主存。
第二判断模块230,用于若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所述待写入IO流是否包含连续写IO。
上述连续写IO是地址连续的多个写IO,具体的,可以通过待写入IO流中写IO的地址判断待写入IO流中是否包含连续写IO。
进一步的,所述第二判断模块230包括确定单元、计算单元、第一判断单元、第二判断单元、第一确定单元和第一触发单元。
获取单元,用于确定所述待写入IO流中第i个写IO为初始写IO,获取所述第i个写IO的实际起始地址和长度,得到初始写IO的实际起始地址和长度,其中,i为正整数。
在判断待写入IO流之中是否包含连续写IO时,确定判断的起点,即确定从哪个写IO开始之后的一段是否为连续写IO。
具体的,在进行判断时,可以选取待写入IO流之中排列顺序在前的任意写IO为初始写IO。
例如,确定第1个写IO为初始写IO,则此时i的值为1。若确定第2个写IO为初始写IO,则此时i的值为2。
通常,每个写IO请求都包含了要处理的起始地址和长度,因此,在获取到初始写IO之后,就可以获取到初始写IO的实际起始地址和长度。
其中,在本实施例中,写IO的长度指写IO要操作的数据的长度,例如要写入一个连续的数据的长度。
计算单元,用于根据所述第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将所述第j个写IO的期待起始地址保存在第k变量中,其中,j=i+1,k的初始值为1,k为正整数。
上述当j=i+1,且根据第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,是指:根据第i个写IO的实际起始地址计算第i个写IO的下一个写IO的起始地址,该计算得到的起始地址为期待起始地址,并将这个起始地址的值,保存在一个变量k中。
例如,当i=1时,若第i个写IO的实际起始地址为8,长度为2,则第2个写IO的期待起始地址的计算方式为8+2=10,即第2个写IO的期待起始地址为10。并将这一期待起始地址进行保存在第一个变量之中。
第一判断单元,用于获取所述第j个写IO的实际起始地址和长度,判断所述第j个写IO的实际起始地址是否等于所述第k变量中保存的所述第j个写IO的期待起始地址。
通常,每个写IO都包含了要处理的IO起始地址和长度,因此,在获取到第j个写IO之后,就可以获取到第j个写IO的实际起始地址和长度。
在计算了下一个写IO的期待起始地址之后,根据实际获取到的下一个写IO来判断,该写IO的实际起始地址是否为之前计算得到的期待起始地址。
例如,获取第2个写IO的实际起始地址为10,根据获取到的第2个写IO的实际起始地址,与保存的第2个写IO的期待起始地址对比是否为相同的。
第二判断单元,用于若所述第j个写IO的实际起始地址等于所述第k变量中保存的所述第j个写IO的期待起始地址,判断所述第j个写IO与所述初始写IO之间的连续长度是否达到预设长度和/或所述第j个写IO与所述初始写IO之间的连续写IO数量是否达到预设数量。
例如,第2个写IO的期待起始地址为10,并且,获取到第2个写IO的实际起始地址为10,则表明第2个写IO与第1个写IO的写入地址是连续的。
上述第j个写IO与初始写IO之间的连续长度是否达到预设长度是指:从初始写IO到第j个写IO总共写入的数据的长度值是否达到预设长度。上述预设长度可以根据需要进行设定。
例如,第2个写IO写入数据长度为8,第1个写IO写入数据长度为7,则此时第j个写IO与初始写IO之间的连续长度为15。若预设长度为20,则确定此时第j个写IO与初始写IO之间的连续长度没有达到预设长度。
上述第j个写IO与初始写IO之间的连续写IO数量是指,从初始写IO到第j个写IO已经有多少个写IO的写入地址为连续的了。上述预设数量可以根据需要进行设定。
例如,第j个写IO为第2个写IO,初始写IO为第1个写IO,则此时,第j个写IO与初始写IO之间连的连续写IO数量为2个。若预设数量为3,则确定此时第j个写IO与初始写IO之间的连续写IO数量没有达到预设数量。
第一确定单元,用于若所述第j个写IO与所述初始写IO之间的连续长度达到预设长度和/或所述第j个写IO与所述初始写IO之间的连续写IO数量达到预设数量,识别所述第j个写IO与所述初始写IO之间为连续IO,确定所述待写入IO流包含连续写IO。
当第j个写IO的长度与初始写IO的长度达到预设长度和/或第j个写IO与初始写IO相距的连续写IO数量达到预设数量时,表明第j个写IO的与初始写IO之间依次为连续的写入地址,并且已经写入了一段较长的数据。此时,确定第j个写IO与初始写IO之间为连续IO。
在本实施例中,不仅通过写IO的地址判断是否连续,还根据写IO之间连续的长度或写数据长度进行判断,并非两个写IO为地址连续的就判断为是存在连续写IO,能够更精确的识别是否是连续的写IO。
第一触发单元,用于若所述第j个写IO与所述初始写IO之间的连续长度没有达到预设长度并且所述第j个写IO与所述初始写IO之间的连续写IO数量没有达到预设数量,令i=i+1,触发所述计算单元根据所述第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将所述第j个写IO的期待起始地址保存在第k变量中的操作。
例如,若初始写IO为第1个写IO,并且第2个写IO的实际起始地址与计算得到的期待起始地址一致,但第2个写IO的与第1个写IO之间的连续长度没有达到预设长度并且第2个写IO与第1个写IO之间的连续写IO数量没有达到预设数量。
则,令i=i+1,执行根据第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将第j个写IO的期待起始地址保存在第k变量中的操作,其中j=i+1。
此时,i=1+1=2,j=i+1=3,根据第2个写IO的实际起始地址和长度,计算第3个写IO的期待起始地址,将第3个写IO的期待起始地址保存在第k变量中。
在本实施例中,第k变量中始终保存的为第j个写IO的期待起始地址。
由于第2个写IO的实际起始地址已经在之前的计算中得到了,因此,此时根据第2个写IO的实际起始地址计算下一个写IO(即第3个写IO)的期待起始地址,并保存在变量k中。
依次类推,当第3个写IO的实际起始地址为期待起始地址时,确定第3个写IO与第2个写IO的写入地址也是连续的,判断所述第3个写IO与初始写IO(此时初始写IO为第1个写IO)之间的连续长度是否达到预设长度和/或第3个写IO与初始写IO之间的连续写IO数量是否达到预设数量。当第3个写IO与第1个写IO之间的连续长度没有达到预设长度并且连续的写 IO数量没有达到预设数量时,根据第3个写IO的实际起始地址和长度计算第4个写IO的期待起始地址,直到第j个写IO的写入地址与前一个写IO的写入地址不连续时跳出循环,或者是第j个写IO与初始写IO之间的连续长度达到预设长度和/或第j个写IO与初始写IO之间的连续IO数量达到预设数量,确定待写入IO流包含连续写IO。
进一步的,所述第二判断模块还包括第二确定单元。
第二确定单元,用于若所述第j个写IO的实际起始地址不等于所述第k变量中保存的所述第j个写IO的期待起始地址,确定所述第j个写IO与所述初始写IO之间不为连续写IO。
当获取到的第j个写IO的实际起始地址与第k变量中保存的第j个写IO的期待起始地址不相同,则表明第i个写IO实际的写入地址与前一个写IO的写入地址不是连续的写入地址。
此时,确定第j个写IO与前一个写IO的写入地址不是连续的写入地址,也表明第j个写IO与初始的写IO不为连续IO。
进一步的,所述第二判断模块还包括第二触发单元。
第二触发单元,用于若所述第j个写IO的实际起始地址不等于所述第k变量中保存的所述第j个写IO的期待起始地址,令i=j,k=k+1,触发所述获取单元确定所述待写入IO流中第i个写IO为初始写IO,获取所述第i个写IO的实际起始地址和长度,得到初始写IO的实际起始地址和长度的操作。
例如,若j=5,当第5个写IO的实际起始地址不等于第k变量中保存的第5个写IO的期待起始地址,表明第5个写IO与前面计算过的写IO(如第4个写IO和第3个写IO)都不为连续的。
令第5个写IO为初始写IO,从第5个写IO开始,依照上述的方法重新对后续的IO进行判断,在比较写IO的写入地址是否连续时,仍然是由后一个写IO与前一个写IO进行对比。即当某一个写IO的实际起始地址与期待起始地址不一致时,确定该写IO为初始写IO,计算该写IO之后的IO与该写IO的地址是否为连续。
同时,在本操作中,计算的下一个写IO保存在另一个变量之中。
在具体实施时,可以通过数组保存多个k的值。当数组中的每个数都被赋值了之后,也可以重新对数组中的变量进行赋值。
例如,数组有n个值,当个第1变量至第10变量都被赋值了之后,若仍有要保存的k值,可以将新的值保存在第一变量之中,或者是其他变量之中。
写操作模块240,用于若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。
当待写入IO流包含连续写IO,可以将多个连续IO确定为待写入主存IO, 然后将待写入主存IO的操作数据写入到主存中。
可选的,所述写操作模块具体用于:
将与所述连续写IO相连续的写IO确定为待写入主存IO;将所述待写入主存IO的操作数据写入所述待写入主存。
在实际应用中,由于对待写入IO流进行判断的同时,可能已经同步进行了写的操作。因此,可以在对后续与前面连续写IO相连续的写IO确定为待写入主存IO,进而将待写入主存IO的操作数据写入待写入主存。
具体的,判断待写入IO流中还未进行写IO操作的写IO是否为相连续的写IO,可以通过判断写IO的地址是否与前面连续写IO相连续来进行判断。
例如,第1个写IO至第5个写IO都为连续写IO,此时若第6个写IO与第5个写IO的地址为连续的,直接确定第6个写IO为待写入主存IO,将第6个写IO直接写入到主存中。
当待写入主存为磁盘并且待写入缓存为固态硬盘时,由于磁盘与固态硬盘的物理特性决定了,磁盘的读写速度快于固态硬盘的读写速度。并且,由于连续写IO在磁盘中进行写数据时,写入扇区相隔较近,磁头几乎不用换道或者换道时间极短。因此,将连续写IO直接写入到磁盘时,能够快速的将数据写入。
可选的,所述写操作模块还用于:
若所述待写入IO流不包含连续写IO,将所述待写入IO流的操作数据写入到所述待写入缓存;从所述待写入缓存获取所述待写入IO流的操作数据写入所述待写入主存。
当待写入IO流不包含连续写IO时,由于磁盘的处理能力可能很强,但是在写入数据过程中需要频繁转换磁道,需花费较多的时间。所以此时,可以将待写入IO流的操作数据直接写入到待写入缓存中,然后在从待写入缓存中获取进行写入到待写入主存中,以使数据能快速写入缓存。
本申请提供的写数据装置通过接收模块接收待写入IO流;第一判断模块判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存;若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,第二判断模块判断所述待写入IO流是否包含连续写IO;若所述待写入IO流包含连续写IO,写操作模块获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。在写数据时,根据待写入主存和待写入缓存对连续写IO的操作数据进行写处理,而不是将待写入IO流的操作数据都直接先写入主存再写入缓存,由于不同的主存和缓存处理数据的能力不同,对于连续的写IO,有些主存的处理能力强于缓存。因此,本申请通过待写入主存、待写入缓存以及待写入IO流的判断选择合适的方 式进行写操作,可以提高写操作的效率。
上述以软件功能模块的形式实现的集成的单元,可以存储在一个非易失性可读取存储介质中。上述软件功能模块存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本申请各个实施例所述方法的部分步骤。
如图3所示,图3是本申请实现写数据方法的较佳实施例的计算机装置的结构示意图。所述计算机装置包括至少一个发送装置31、至少一个存储器32、至少一个处理器33、至少一个接收装置34以及至少一个通信总线。其中,所述通信总线用于实现这些组件之间的连接通信。
所述计算机装置是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程门阵列(Field-Programmable Gate Array,FPGA)、数字处理器(Digital Signal Processor,DSP)、嵌入式设备等。所述计算机装置还可包括网络设备和/或用户设备。其中,所述网络设备包括但不限于单个网络服务器、多个网络服务器组成的服务器组或基于云计算(Cloud Computing)的由大量主机或网络服务器构成的云,其中,云计算是分布式计算的一种,由一群松散耦合的计算机集组成的一个超级虚拟计算机。
所述计算机装置可以是,但不限于任何一种可与用户通过键盘、触摸板或声控设备等方式进行人机交互的电子产品,例如,平板电脑、智能手机、监控设备等终端。
所述计算机装置所处的网络包括,但不限于互联网、广域网、城域网、局域网、虚拟专用网络(Virtual Private Network,VPN)等。
其中,所述接收装置34和所述发送装置31可以是有线发送端口,也可以为无线设备,例如包括天线装置,用于与其他设备进行数据通信。
所述存储器32用于存储程序代码。所述存储器32可以是集成电路中没有实物形式的具有存储功能的电路,如RAM(Random-Access Memory,随机存取存储器)、FIFO(First In First Out,先进先出存储器)等。或者,所述存储器32也可以是具有实物形式的存储器,如内存条、TF卡(Trans-flash Card)、智能媒体卡(smart media card)、安全数字卡(secure digital card)、快闪存储器卡(flash card)等储存设备等等。
所述处理器33可以包括一个或者多个微处理器、数字处理器。所述处理器33可调用存储器32中存储的程序代码以执行相关的功能。例如,图3中所述的各个单元是存储在所述存储器32中的程序代码,并由所述处理器33所执行,以实现一种写数据方法。所述处理器33又称中央处理器(CPU, Central Processing Unit),是一块超大规模的集成电路,是运算核心(Core)和控制核心(Control Unit)。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其他的具体形式实现本申请。因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本申请内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第二等词语用来表示名称,而并不表示任何特定的顺序。
最后应说明的是,以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。
Claims (20)
- 一种写数据方法,其特征在于,所述方法包括:接收待写入IO流;判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存;若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所述待写入IO流是否包含连续写IO;若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。
- 如权利要求1所述的方法,其特征在于,所述判断所述待写入IO流是否包含连续写IO包括:确定所述待写入IO流中第i个写IO为初始写IO,获取所述第i个写IO的实际起始地址和长度,得到初始写IO的实际起始地址和长度,其中,i为正整数;根据所述第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将所述第j个写IO的期待起始地址保存在第k变量中,其中,j=i+1,k的初始值为1,k为正整数;获取所述第j个写IO的实际起始地址和长度,判断所述第j个写IO的实际起始地址是否等于所述第k变量中保存的所述第j个写IO的期待起始地址;若所述第j个写IO的实际起始地址等于所述第k变量中保存的所述第j个写IO的期待起始地址,判断所述第j个写IO与所述初始写IO之间的连续长度是否达到预设长度和/或所述第j个写IO与所述初始写IO之间的连续写IO数量是否达到预设数量;若所述第j个写IO与所述初始写IO之间的连续长度达到预设长度和/或所述第j个写IO与所述初始写IO之间的连续写IO数量达到预设数量,识别所述第j个写IO与所述初始写IO之间为连续IO,确定所述待写入IO流包含连续写IO;若所述第j个写IO与所述初始写IO之间的连续长度没有达到预设长度并且所述第j个写IO与所述初始写IO之间的连续写IO数量没有达到预设数量,令i=i+1,执行所述根据所述第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将所述第j个写IO的期待起始地址保存在第k变量中的操作。
- 如权利要求2所述的方法,其特征在于,所述方法还包括:若所述第j个写IO的实际起始地址不等于所述第k变量中保存的所述第j个写IO的期待起始地址,确定所述第j个写IO与所述初始写IO之间不为连续写IO。
- 如权利要求2所述的方法,其特征在于,所述方法还包括:若所述第j个写IO的实际起始地址不等于所述第k变量中保存的所述第j个写IO的期待起始地址,令i=j,k=k+1,执行所述确定所述待写入IO流中第i个写IO为初始写IO,获取所述第i个写IO的实际起始地址和长度,得到初始写IO的实际起始地址和长度的操作。
- 如权利要求1所述的方法,其特征在于,所述预设主存为磁盘,所述预设缓存为固态硬盘。
- 如权利要求1所述的方法,其特征在于,所述将所述连续写IO的操作数据写入到所述待写入主存包括:将与所述连续写IO相连续的写IO确定为待写入主存IO;将所述待写入主存IO的操作数据写入所述待写入主存。
- 如权利要求1所述的方法,其特征在于,所述方法还包括:若所述待写入IO流不包含连续写IO,将所述待写入IO流的操作数据写入到所述待写入缓存;从所述待写入缓存获取所述待写入IO流的操作数据写入所述待写入主存。
- 一种写数据装置,其特征在于,所述装置包括:接收模块,用于接收待写入IO流;第一判断模块,用于判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存;第二判断模块,用于若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所述待写入IO流是否包含连续写IO;写操作模块,用于若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。
- 一种计算机装置,其特征在于,所述计算机装置包括存储器及处理器,所述存储器用于存储至少一个指令,所述处理器用于执行所述至少一个指令以实现以下步骤:接收待写入IO流;判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存;若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所 述待写入IO流是否包含连续写IO;若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。
- 如权利要求9所述的计算机装置,其特征在于,所述判断所述待写入IO流是否包含连续写IO包括:确定所述待写入IO流中第i个写IO为初始写IO,获取所述第i个写IO的实际起始地址和长度,得到初始写IO的实际起始地址和长度,其中,i为正整数;根据所述第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将所述第j个写IO的期待起始地址保存在第k变量中,其中,j=i+1,k的初始值为1,k为正整数;获取所述第j个写IO的实际起始地址和长度,判断所述第j个写IO的实际起始地址是否等于所述第k变量中保存的所述第j个写IO的期待起始地址;若所述第j个写IO的实际起始地址等于所述第k变量中保存的所述第j个写IO的期待起始地址,判断所述第j个写IO与所述初始写IO之间的连续长度是否达到预设长度和/或所述第j个写IO与所述初始写IO之间的连续写IO数量是否达到预设数量;若所述第j个写IO与所述初始写IO之间的连续长度达到预设长度和/或所述第j个写IO与所述初始写IO之间的连续写IO数量达到预设数量,识别所述第j个写IO与所述初始写IO之间为连续IO,确定所述待写入IO流包含连续写IO;若所述第j个写IO与所述初始写IO之间的连续长度没有达到预设长度并且所述第j个写IO与所述初始写IO之间的连续写IO数量没有达到预设数量,令i=i+1,执行所述根据所述第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将所述第j个写IO的期待起始地址保存在第k变量中的操作。
- 如权利要求10所述的计算机装置,其特征在于,所述处理器用于执行所述至少一个指令时还实现以下步骤:若所述第j个写IO的实际起始地址不等于所述第k变量中保存的所述第j个写IO的期待起始地址,确定所述第j个写IO与所述初始写IO之间不为连续写IO。
- 如权利要求10所述的计算机装置,其特征在于,所述处理器用于执行所述至少一个指令时还实现以下步骤:若所述第j个写IO的实际起始地址不等于所述第k变量中保存的所述第 j个写IO的期待起始地址,令i=j,k=k+1,执行所述确定所述待写入IO流中第i个写IO为初始写IO,获取所述第i个写IO的实际起始地址和长度,得到初始写IO的实际起始地址和长度的操作。
- 如权利要求9所述的计算机装置,其特征在于,所述将所述连续写IO的操作数据写入到所述待写入主存包括:将与所述连续写IO相连续的写IO确定为待写入主存IO;将所述待写入主存IO的操作数据写入所述待写入主存。
- 如权利要求9所述的计算机装置,其特征在于,所述处理器用于执行所述至少一个指令时还实现以下步骤:若所述待写入IO流不包含连续写IO,将所述待写入IO流的操作数据写入到所述待写入缓存;从所述待写入缓存获取所述待写入IO流的操作数据写入所述待写入主存。
- 一种非易失性可读存储介质,其上存储有计算机指令,其特征在于,所述计算机指令被处理器执行时实现以下步骤:接收待写入IO流;判断所述待写入IO流的待写入主存是否为预设主存,以及所述待写入IO流的待写入缓存是否为预设缓存;若所述待写入主存为预设主存并且所述待写入缓存为预设缓存,判断所述待写入IO流是否包含连续写IO;若所述待写入IO流包含连续写IO,获取所述连续写IO,将所述连续写IO的操作数据写入到所述待写入主存。
- 如权利要求15所述的存储介质,其特征在于,所述判断所述待写入IO流是否包含连续写IO包括:确定所述待写入IO流中第i个写IO为初始写IO,获取所述第i个写IO的实际起始地址和长度,得到初始写IO的实际起始地址和长度,其中,i为正整数;根据所述第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将所述第j个写IO的期待起始地址保存在第k变量中,其中,j=i+1,k的初始值为1,k为正整数;获取所述第j个写IO的实际起始地址和长度,判断所述第j个写IO的实际起始地址是否等于所述第k变量中保存的所述第j个写IO的期待起始地址;若所述第j个写IO的实际起始地址等于所述第k变量中保存的所述第j个写IO的期待起始地址,判断所述第j个写IO与所述初始写IO之间的连续 长度是否达到预设长度和/或所述第j个写IO与所述初始写IO之间的连续写IO数量是否达到预设数量;若所述第j个写IO与所述初始写IO之间的连续长度达到预设长度和/或所述第j个写IO与所述初始写IO之间的连续写IO数量达到预设数量,识别所述第j个写IO与所述初始写IO之间为连续IO,确定所述待写入IO流包含连续写IO;若所述第j个写IO与所述初始写IO之间的连续长度没有达到预设长度并且所述第j个写IO与所述初始写IO之间的连续写IO数量没有达到预设数量,令i=i+1,执行所述根据所述第i个写IO的实际起始地址和长度计算第j个写IO的期待起始地址,将所述第j个写IO的期待起始地址保存在第k变量中的操作。
- 如权利要求16所述的存储介质,其特征在于,所述至少一个指令被所述处理器执行时还实现以下步骤:若所述第j个写IO的实际起始地址不等于所述第k变量中保存的所述第j个写IO的期待起始地址,确定所述第j个写IO与所述初始写IO之间不为连续写IO。
- 如权利要求16所述的存储介质,其特征在于,所述至少一个指令被所述处理器执行时还实现以下步骤:若所述第j个写IO的实际起始地址不等于所述第k变量中保存的所述第j个写IO的期待起始地址,令i=j,k=k+1,执行所述确定所述待写入IO流中第i个写IO为初始写IO,获取所述第i个写IO的实际起始地址和长度,得到初始写IO的实际起始地址和长度的操作。
- 如权利要求15所述的存储介质,其特征在于,所述将所述连续写IO的操作数据写入到所述待写入主存包括:将与所述连续写IO相连续的写IO确定为待写入主存IO;将所述待写入主存IO的操作数据写入所述待写入主存。
- 如权利要求15所述的存储介质,其特征在于,所述至少一个指令被所述处理器执行时还实现以下步骤:若所述待写入IO流不包含连续写IO,将所述待写入IO流的操作数据写入到所述待写入缓存;从所述待写入缓存获取所述待写入IO流的操作数据写入所述待写入主存。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810691015.5A CN109062499A (zh) | 2018-06-28 | 2018-06-28 | 写数据方法、装置、计算机装置及存储介质 |
| CN201810691015.5 | 2018-06-28 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020000735A1 true WO2020000735A1 (zh) | 2020-01-02 |
Family
ID=64817904
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2018/108127 Ceased WO2020000735A1 (zh) | 2018-06-28 | 2018-09-27 | 写数据方法、装置、计算机装置及存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109062499A (zh) |
| WO (1) | WO2020000735A1 (zh) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102591593A (zh) * | 2011-12-28 | 2012-07-18 | 华为技术有限公司 | 一种混合存储模式的切换方法、装置及系统 |
| CN106919342A (zh) * | 2015-12-28 | 2017-07-04 | 成都华为技术有限公司 | 基于自动精简配置的存储资源分配方法和装置 |
| US20170192702A1 (en) * | 2015-12-31 | 2017-07-06 | EMC IP Holding Company LLC | Method and apparatus for operating hybrid storage devices |
| CN107015763A (zh) * | 2017-03-03 | 2017-08-04 | 北京中存超为科技有限公司 | 混合存储系统中ssd管理方法及装置 |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101241420A (zh) * | 2008-03-20 | 2008-08-13 | 杭州华三通信技术有限公司 | 用于提高写地址非连续的数据存储效率的方法和存储设备 |
| CN101354636A (zh) * | 2008-09-08 | 2009-01-28 | 创新科存储技术(深圳)有限公司 | 一种向磁盘阵列中写入数据的方法及系统 |
| TWI588824B (zh) * | 2015-12-11 | 2017-06-21 | 捷鼎國際股份有限公司 | 加快在不連續頁面寫入資料之電腦系統及其方法 |
| CN107145301B (zh) * | 2016-03-01 | 2020-09-01 | 深信服科技股份有限公司 | 基于混合磁盘的数据存取方法及装置 |
-
2018
- 2018-06-28 CN CN201810691015.5A patent/CN109062499A/zh active Pending
- 2018-09-27 WO PCT/CN2018/108127 patent/WO2020000735A1/zh not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102591593A (zh) * | 2011-12-28 | 2012-07-18 | 华为技术有限公司 | 一种混合存储模式的切换方法、装置及系统 |
| CN106919342A (zh) * | 2015-12-28 | 2017-07-04 | 成都华为技术有限公司 | 基于自动精简配置的存储资源分配方法和装置 |
| US20170192702A1 (en) * | 2015-12-31 | 2017-07-06 | EMC IP Holding Company LLC | Method and apparatus for operating hybrid storage devices |
| CN107015763A (zh) * | 2017-03-03 | 2017-08-04 | 北京中存超为科技有限公司 | 混合存储系统中ssd管理方法及装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109062499A (zh) | 2018-12-21 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US10417137B2 (en) | Flushing pages from solid-state storage device | |
| CN113419824A (zh) | 数据处理方法、装置、系统及计算机存储介质 | |
| US9916104B2 (en) | Techniques for entry to a lower power state for a memory device | |
| WO2017041570A1 (zh) | 向缓存写入数据的方法及装置 | |
| CN106371764A (zh) | 一种虚拟块设备数据处理的方法及装置 | |
| US20190102301A1 (en) | Technologies for enforcing coherence ordering in consumer polling interactions | |
| CN113918527B (zh) | 一种基于文件缓存的调度方法、装置与计算设备 | |
| CN113986134B (zh) | 存储数据的方法、读取数据的方法和装置 | |
| CN104781794A (zh) | 用于非易失性存储器中的数据结构的暂时和持久状态之间的原地改变 | |
| US20150301917A1 (en) | Memory Monitoring Method and Related Apparatus | |
| US12430080B2 (en) | Method for dynamic management of command queues in synchronous write operations | |
| TWI871157B (zh) | 用於記憶體管理機會與記憶體交換任務之運算系統及管理其之方法 | |
| CN113127382A (zh) | 用于追加写的数据读取方法、装置、设备和介质 | |
| CN117687850A (zh) | 硬盘性能测试方法、装置、电子设备和存储介质 | |
| CN114730249A (zh) | 不同类型的存储器之间的页迁移的减少 | |
| EP3585017A2 (en) | Technologies for providing adaptive polling of packet queues | |
| CN104281545B (zh) | 一种数据读取方法及设备 | |
| CN110515861B (zh) | 处理刷写命令的存储设备及其方法 | |
| CN112825024A (zh) | 命令融合、拆分方法与NVMe控制器 | |
| CN112463037B (zh) | 一种元数据保存方法、装置、设备、产品 | |
| CN104899158A (zh) | 访存优化方法和装置 | |
| US11055218B2 (en) | Apparatus and methods for accelerating tasks during storage caching/tiering in a computing environment | |
| WO2017054714A1 (zh) | 磁盘阵列的读方法及装置 | |
| WO2020000735A1 (zh) | 写数据方法、装置、计算机装置及存储介质 | |
| CN117539407A (zh) | 数据存储方法、电子设备及计算机可读存储介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18924313 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 18924313 Country of ref document: EP Kind code of ref document: A1 |