WO2017107015A1 - Storage space allocation method, and storage device - Google Patents

Storage space allocation method, and storage device Download PDF

Info

Publication number
WO2017107015A1
WO2017107015A1 PCT/CN2015/098108 CN2015098108W WO2017107015A1 WO 2017107015 A1 WO2017107015 A1 WO 2017107015A1 CN 2015098108 W CN2015098108 W CN 2015098108W WO 2017107015 A1 WO2017107015 A1 WO 2017107015A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage space
granularity
allocation granularity
space
size
Prior art date
Application number
PCT/CN2015/098108
Other languages
French (fr)
Chinese (zh)
Inventor
张鹏
叶茂
张国彬
程卓
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201580056639.4A priority Critical patent/CN107533435B/en
Priority to PCT/CN2015/098108 priority patent/WO2017107015A1/en
Publication of WO2017107015A1 publication Critical patent/WO2017107015A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers

Definitions

  • the present invention relates to the field of storage, and in particular, to a storage space allocation method and a storage device.
  • the granularity at which the storage device allocates storage space for data write requests is fixed. That is, for different data sizes of data to be written carried in the data write request, the storage device allocates a storage space of size kQ to the data write request in units of a fixed storage space size Q, where k is a positive integer. Because, in the same storage architecture, the amount of data per write varies little, so the allocation granularity is much larger than the data size of a certain write, resulting in wasted storage space, or much smaller than a certain write.
  • the data size causes a problem of excessive amount of metadata for describing the storage attributes of the data.
  • SAN Storage Area Network
  • NAS Network Attached Storage
  • SANs are mostly “overwrite writes”, and the amount of data written per write is usually large, which is suitable for large-granular space allocation; NAS is mostly “new write”, and the amount of data written per write is usually small. Suitable for small-grained space allocation.
  • the first aspect provides a storage space allocation method, which is applied to a storage device, and includes: preset N different allocation granularities for a storage space of the storage device, where the allocation granularity is used as a unit for allocating the storage space. And each allocation granularity has an allocatable storage space, wherein N is a positive integer greater than 1; the method comprises: the storage device receiving a data write request, the data write request including data to be written; a size of the write data and the predetermined allocation granularity, selecting an allocation granularity of the allocated storage space for the data write request from the N different allocation granularities; and using the selected allocation granularity as The data write request allocates storage space.
  • the storage device can select a different data size for the data write request of different data sizes, and allocate a storage space to the data write request, so that the amount of data written by the storage device varies greatly each time.
  • the storage device can allocate storage space with the allocation granularity closest to the size of each data write, thereby avoiding the problem of waste of storage space or excessive amount of metadata caused by a single allocation granularity.
  • the allocating a storage space for the data write request by using the selected allocation granularity comprises: comparing a size of the data to be written M a size L 1 of the unallocated storage space in the allocatable storage space of the selected allocation granularity; determining that L 1 is not less than M, and allocating a size of kQ n to the data write request from the unallocated storage space a storage space, where k is a positive integer not less than 1, and Q n is the selected distribution granularity, M ⁇ kQ n ⁇ min ⁇ L 1 , M+Q n ⁇ .
  • the above implementation is an example in which the storage device allocates a storage space for the data write request with the selected allocation granularity.
  • the allocating a storage space for the data write request by using the selected allocation granularity comprises: comparing a size of the data to be written a size L 1 of unallocated storage space in the allocatable storage space with the selected allocation granularity; determining that L 1 is less than M, determining the unallocated storage space size L 1 and the allocatable storage of the selected allocation granularity
  • the sum of the reclaimed storage space sizes L 2 in the space is not less than M
  • the reclaimed storage space refers to the storage space that has been allocated in the allocatable space of the selected allocation granularity, and the data written therein has been wiped a storage space after the partition
  • a storage space of size kQ n is allocated for the data write request from the unallocated storage space and the recovered storage space, where M ⁇ kQ n ⁇ min ⁇ L 1 +L 2 , M+Q n ⁇ .
  • the foregoing implementation manner is another example in which the storage device allocates a storage space for the data write request by using the selected allocation granularity.
  • the storage device may allocate the unallocated storage space of the selected allocated granularity to the data.
  • the write request increases the utilization of the allocatable storage space of the selected allocation granularity.
  • the third possible implementation manner of the first aspect further comprising: comparing a size M of the data to be written and the selecting The size L 1 of the unallocated storage space in the allotable storage space of the allocation granularity; when L 1 is less than M, the allocation granularity adjacent to the selected allocation granularity is identified, and the allocatable storage from the adjacent allocated granularity is identified unallocated storage space can be increased allocates storage for the selected particle size distribution, wherein the particle size distribution of the adjacent Q n-1 is greater than the selected particle size distribution Q n. In this way, the storage device can be allocated with different allocation granularities for the same storage space, which increases the flexibility of storage space utilization.
  • the storage device consolidates the small
  • the method further includes: determining that there is no consecutive address of size Q n-1 in the recovered storage space When the space is determined, the sum of the unallocated storage space size L 1 and the reclaimed storage space size L 2 in the allotable storage space of the selected allocation granularity is not less than the M; the reclaimed storage space refers to a storage space in which the data written in the allocated storage space of the selected allocation granularity has been erased; the data write request is from the unallocated storage space and the recycled storage space A storage space of size kQ n is allocated, where M ⁇ kQ n ⁇ min ⁇ L 1 + L 2 , M+Q n ⁇ .
  • the unallocated storage in the allocable storage space from the adjacent allocation granularity Adding an allocatable storage space for the selected allocation granularity in the space, comprising: comparing a sum of the assignable storage space of the selected allocation granularity with the adjacent allocated granularity and a preset for the selected allocated granularity Allocating a storage space quota; determining that the sum of the allotable storage space of the selected allocation granularity and the adjacent allocation granularity is not greater than a preset allocation of storage space quota for the selected allocation granularity, from the adjacent allocation An allocatable storage space is allocated for the selected allocation granularity in the unallocated storage space of the granular allocatable storage space.
  • a second aspect provides a storage device, where a storage space of the storage device is pre-configured with N different allocation granularities, where the allocation granularity is used as a unit for allocating the storage space, and each allocated granularity has an allotable storage space.
  • N is a positive integer greater than 1;
  • the storage device includes: a receiving unit, configured to receive a data write request, the data write request includes data to be written, and a determining unit configured to use the data to be written And a predetermined allocation granularity, selecting an allocation granularity of the allocated storage space for the data write request from the N different allocation granularities; and an allocating unit, configured to use the selected allocation granularity
  • the data write request allocates storage space.
  • the allocating unit is configured to: compare a size M of the data to be written with an allocatable storage space of the selected allocation granularity The size L 1 of the unallocated storage space; when it is determined that L 1 is not less than M, a storage space of size kQ n is allocated for the data write request from the unallocated storage space, where k is a positive integer not less than 1.
  • Q n is the assigned granularity of the selection, M ⁇ kQ n ⁇ min ⁇ L 1 , M+Q n ⁇ .
  • the allocating unit is configured to: compare a size M of the data to be written with an allocatable storage space of the selected allocation granularity The size L 1 of the unallocated storage space; when it is determined that L 1 is less than M, the sum of the unallocated storage space size L 1 and the reclaimed storage space size L 2 in the allotable storage space of the selected allocation granularity is not less than M; the reclaimed storage space refers to a storage space that has been allocated in the allocatable space of the selected allocation granularity, and a storage space in which data written therein has been erased; from the unallocated storage space And storing, in the recovered storage space, a storage space of size kQ n for the data write request, where M ⁇ kQ n ⁇ min ⁇ L 1 +L 2 , M+Q n ⁇ .
  • the allocating unit is configured to: compare a size M of the data to be written with an allocatable storage space of the selected allocation granularity The size L 1 of the unallocated storage space; when it is determined that L 1 is smaller than M, the allocation granularity adjacent to the selected allocation granularity is identified, and the unallocated storage space of the distributable storage space of the adjacent allocated granularity is said selected particle size distribution may be allocated to allocate storage space, wherein the particle size distribution of the adjacent Q n-1 is greater than the selected particle size distribution Q n.
  • the fourth possible implementation manner of the second aspect further comprising: a releasing unit, configured to: compare the adjacent allocation granularity Allocating a storage space size with a first threshold; determining whether the size of the unallocated storage space of the adjacent allocation granularity is smaller than the first threshold, and detecting whether the selected storage space of the allocated storage space of the allocated storage space is There is at least one contiguous address space of size Q n-1 ; determining that at least one contiguous address space of size Q n-1 exists in the recovered storage space, releasing the at least one contiguous address space to the neighbor Allocating storage space of the granularity; the allocation unit is specifically configured to: select from the unallocated storage space of the adjacent allocation granularity including the at least one consecutive address space of size Qn -1 The allocation granularity allocation allocates storage space.
  • the allocating unit is further configured to compare a sum of the allotable storage space of the selected allocation granularity with the adjacent allocation granularity and a preset granularity for the selected allocation granularity The allocatable storage space quota; determining that the sum of the allocable storage space of the selected allocation granularity and the adjacent allocation granularity is not greater than the preset allocatable storage space quota for the selected allocation granularity, from the neighboring The unallocated storage space of the allocatable storage space of the allocated granularity allocates an allocatable storage space for the selected allocation granularity.
  • a storage device including: a processor, a memory, a memory, a communication interface, and a communication bus, wherein the processor, the memory, the memory, and the communication interface are completed by the communication bus Communication with each other;
  • the memory includes a storage space for storing data;
  • the memory is for storing program code, the program code is N different distribution granularities pre-set by the storage space in the memory, An allocation granularity as a unit for allocating the storage space, and each allocation granularity has an allocatable storage space, wherein N is a positive integer greater than 1;
  • the processor executes the program code in the memory to cause the The processor performs the method of the first aspect, or any of the possible implementations of the first aspect above.
  • the method further includes: comparing a size of the unallocated storage space in the allotable storage space of the selected allocation granularity with a second threshold; when the selected allocated granularity is not allocated in the storage space When the size of the allocated storage space is smaller than the second threshold, the unallocated storage space in the allotable storage space of the allocation granularity adjacent to the selected allocation granularity increases the allocateable storage space for the selected allocated granularity, The adjacent distribution granularity Q n-1 is greater than the selected distribution granularity Q n .
  • the allocable storage space may be increased for the allocated granularity from the unallocated storage space larger than the allocation granularity adjacent to the allocated granularity. , to ensure that each allocation granularity has enough allocateable storage space.
  • the method further includes: detecting, at a preset time, the reclaimed storage space of the allocated storage space of the selected allocation granularity, whether there is at least one consecutive address of size Q n-1 Space; determining that at least one contiguous address space of size Q n-1 is released to the selected allocation granularity when there is at least one contiguous address space of size Q n-1 in the recovered storage space particle size distribution may be adjacent to allocate storage space adjacent to the particle size distribution Q n-1 is greater than the selected particle size distribution Q n.
  • the storage device can sequentially release the reclaimed storage space of each allocated granularity, thereby sequentially integrating the small-sized storage space into a larger granular storage space with consecutive addresses, thereby reducing storage fragmentation.
  • FIG. 1 is a schematic flowchart of a method for allocating a storage space according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of an allocatable storage space with different allocation granularities in a storage space according to an embodiment of the present invention
  • FIG. 3 is a schematic flowchart of a method for allocating storage space by using a selected allocation granularity as a data write request according to an embodiment of the present disclosure
  • FIG. 4 is a schematic flowchart of a method for increasing an allocatable storage space for an allocation granularity Q n from an allocatable storage space of an allocation granularity Q n-1 according to an embodiment of the present disclosure
  • FIG. 5 is a schematic diagram of another allocatable storage space with different allocation granularities in a storage space according to an embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of a storage device according to an embodiment of the present disclosure.
  • FIG. 7 is a schematic structural diagram of another storage device according to an embodiment of the present invention.
  • the following embodiments are applied to a storage device, which may be a storage array, a solid state hard disk, a tiled magnetic recording hard disk, or the like.
  • a storage device receives a data write request sent by another device, it is The data write request allocates a storage space to store data to be written in the data write request.
  • An embodiment of the present invention provides a method for allocating a storage space, where the method is applied to a storage device, where a storage space of the storage device is pre-configured with N different allocation granularities, and the allocation granularity is used as a unit for allocating the storage space. And each allocation granularity has an allocatable storage space, and the allotable storage space of each allocation granularity may be preset, or may be set when the data write request allocated by the allocation granularity is received for the first time. . Where N is a positive integer greater than one. As shown in Figure 1, the method includes:
  • the storage device receives a data write request, where the data write request includes data to be written.
  • the storage device may be an external storage device connected to the server, or may be a storage server connected to the client.
  • the data write request may be that the storage device receives from a server or client connected thereto.
  • the storage device selects an allocation granularity of the allocated storage space for the data write request from the N different allocation granularities according to the size of the to-be-written data and the preset allocation granularity.
  • the value indicates that the N different allocation granularities of the storage space may be preset by the user according to the actual amount of data written to the storage device each time. For example, if the storage device combines both SAN and NAS storage architectures, if the SAN storage architecture writes data in the range of 60M (megabytes) to 64M, the SAN storage architecture writes data each time. The amount is in the range of 10KB (kilobytes) to 64KB, and the two allocation granularities of 64M and 64KB can be preset for the storage space.
  • the storage device can calculate a difference between the size of the data to be written and each of the allocated granularities, and select an allocation granularity with a minimum absolute value of the difference from the data size. For example, if two allocation granularities of 64M (megabytes) and 64 kilobytes (kilobytes) are preset for the storage space, in this case, the storage device receives a data write request with a size of 10 KB to be carried with the data to be written.
  • the storage device may select an allocation granularity of 64 KB as an allocation granularity for allocating storage space to the data write request; the storage device is received and carried
  • the size of the data to be written is 60M
  • the data write request is due to The 64M allocation granularity is closest to the size of the data to be written. Therefore, the storage device can select a 64M allocation granularity as the allocation granularity of allocating storage space to the data write request.
  • the policy of the storage device selecting the allocation granularity of the storage space for the data write request may be set according to actual requirements. For example, if the two allocation granularities of the storage space are 50M and 30M, at this time, for the data to be written with a data size of 60M, according to the implementation described above, the distribution granularity closest to the data size is 50M, but If the storage device selects a 50M allocation granularity to allocate storage space for the data to be written, it needs to allocate two 50M storage spaces to store 60M of data, which will result in wasted 40M storage space.
  • the storage device can select a distribution granularity of 30M to allocate storage space for the data to be written, and two storage spaces of 30M size store 60M of data, thereby avoiding waste of storage space. That is, for the distribution granularity Q n and Q n-1 , if the absolute value of the difference between k n Q n and the size M of the data to be written is greater than k n-1 Q n-1 and to be written The absolute value of the difference between the sizes M of the data, then the selection granularity Q n is the allocation granularity of allocating the storage space to the data write request, and vice versa, selecting Q n-1 to allocate the storage space to the data write request.
  • the allocation granularity where k n is the number of storage spaces of size Q n allocated by the storage device for the data to be written, and k n-1 is the size allocated by the storage device for the data to be written is Q n-1
  • the preset allocation granularity is 64M and 64KB, and the size of the data to be written is 32M
  • the storage device selects 64 KB of the allocation granularity of 32M to be written to the data allocation storage space, it needs to be allocated. 500 64KB of storage space, resulting in fragmentation of storage and excessive metadata. If the storage device selects a 64M allocation granularity of 32M to be written to the data allocation storage space, 32M storage space is wasted.
  • the preset condition may be that the difference between the size of the storage space allocated for the data write request and the size of the data to be written cannot exceed 1M.
  • the storage device can select a 64 KB allocation granularity of 32 M to be written according to the preset condition; if the storage fragmentation degree is required to be the lowest in the specific implementation process, the preset condition is: for the same For the data write request, the storage space allocated by the storage device of the same granularity cannot exceed two. Therefore, the storage device can select a 64M allocation storage space to be written with a storage granularity of 32M according to the preset condition.
  • the value indicates that, in order to avoid the case where the size of the data to be written is different from the preset granularity of each of the foregoing, the N allocation granularities in the preset storage space in the embodiment of the present invention. At the same time, the difference between the adjacent two distribution granularities can be reduced.
  • the storage device allocates a storage space for the data write request by using the selected allocation granularity.
  • the selected allocation granularity corresponds to an allocation queue
  • the storage device may divide the unallocated storage space of the selected allocated granularity into a plurality of storage subspaces, wherein the size of each storage subspace is equal to the selected one.
  • the size of the granularity Q n is allocated and the address of the storage subspace is added to the allocation queue. In this way, when the storage device allocates storage space to the data write request, the storage device can directly allocate from the allocation queue, and does not need to temporarily divide the unallocated storage space of the selected allocation granularity, thereby improving the allocation efficiency.
  • the storage space described in this document may be a logical unit number (LUN).
  • LUN logical unit number
  • a LUN can usually be accessed by only one host.
  • the embodiment of the present invention may preset N allocation granularities for each LUN.
  • the method for the storage device to allocate the storage space to the data write request may refer to the foregoing steps S101 to S103, and details are not described herein again.
  • the storage device can select a different data size for the data write request of different data sizes, and allocate storage space to the data write request, thereby avoiding waste of storage space or excessive amount of metadata caused by a single allocation granularity. problem.
  • the allocateable storage space of each allocation granularity is from the unallocated storage space of the allotable storage space of the allocated granularity adjacent to the allocated granularity.
  • Allocating, and the adjacent allocation granularity is greater than the allocation granularity, and when the allocatable storage space of the allocated granularity is allocated, the distributable storage space adjacent to the allocation granularity and larger than the allocated granularity of the allocated granularity may be allocated.
  • the storage space is allocated for the allocation granularity in the unallocated storage space. As shown in FIG.
  • Q n may then allocate the memory space allocated from unallocated storage space of the Q n-1, said Q n-1 may allocate memory from the unallocated space in Q n-2 storage space allocation, when the n-Q may be allocated after the allocation of storage space, storage space can be allocated can be allocated from the n-Q Q unallocated storage space of n-1.
  • the allocatable storage space of the Q n-2 may be a storage space corresponding to one LUN, or may be a partial storage space in a LUN, if Q n
  • the allocatable storage space of the -2 is a part of the storage space of the LUN
  • the allocatable storage space of the Q n-2 is allocated, the storage may be allocated for the Q n-2 from the storage space corresponding to the LUN. space.
  • the storage device allocates the storage space for the data write request by using the selected allocation granularity to specifically include:
  • Storage space can be allocated S1031, the device compares the memory size of the data to be written with a particle size distribution of the M selected unallocated storage space size of L 1.
  • S1032 The storage device allocates a storage space of size kQ n for the data write request from the unallocated storage space when determining that L 1 is not less than M.
  • the storage space may be allocated for the data to be written in two manners.
  • the method is to allocate a storage space for the data to be written from the collected storage space of the selected allocation granularity, as shown in steps S1033' and S1034', and the second manner is to allocate a granularity from the selection.
  • a storage space is allocated for the allocated granularity in the unallocated storage space of the allocatable storage space that is adjacent to the allocated granularity of the selected allocation granularity, as shown in step S1033 and step S1034.
  • the first method specifically includes the following steps:
  • the reclaimed storage space refers to a storage space in the allocatable space of the selected allocation granularity that has been allocated and the data written therein has been erased.
  • the memory device determines the size of the unallocated storage space 1 and a particle size distribution of the selected storage space can be allocated in the L-recovered storage space is not less than 2 L and M, which is not from the memory device Allocating a storage space and storing a size of kQ n for the data write request in the recycled storage space, where M ⁇ kQ n ⁇ min ⁇ L 1 +L 2 , M+Q n ⁇ .
  • the storage device may perform the steps shown in step S1033 and step S1034 when it is determined that the sum of the unallocated storage space size L 1 and the allocated storage granularity of the allocated storage granularity L 2 is less than M
  • the second way is to allocate storage space for the data to be written.
  • the second method specifically includes the following steps:
  • the storage device is less than M L is determined identifying the selected allocation granularity adjacent allocation granularity 1, a particle size distribution from the adjacent storage space can be allocated unallocated storage space allocated to said selected Granular allocation allocates storage space.
  • the adjacent distribution granularity Q n-1 is greater than the selected distribution granularity Q n .
  • the storage device may allocate an allocatable storage space of size kQ n-1 for the selected allocation granularity from the unallocated storage space of the adjacent allocated granularity according to the size M of the data to be written.
  • kQ n-1 is greater than M and less than Q n-1 +M.
  • the size of the data to be written is 10M
  • the adjacent allocation granularity Q n-1 is 100M.
  • the storage device may be from the unallocated storage space of the adjacent allocated granularity.
  • the selected allocation granularity is allocated to a storage space of 100M in size.
  • the storage device may allocate an allocatable storage of size kQ n-1 for the selected allocation granularity from the unallocated storage space of the adjacent allocated granularity according to the difference between L 1 and M. Space, where kQ n-1 is greater than ML 1 and less than Q n-1 + ML 1 .
  • the size of data to be written to 120M, the particle size distribution adjacent to Q n-1 50M, the selected particle size distribution Q n is 40M, the selected unallocated memory space allocation granularity is 80M, the In this case, the storage device may allocate a storage space of a size of 50M for the selected allocation granularity from the unallocated storage space of the adjacent allocation granularity.
  • the storage device allocates a storage space of size kQ n for the data write request from the unallocated storage space of the selected allocation granularity.
  • step S1033 The method for allocating the allocatable storage space for the allocation granularity Q n from the allocatable storage space of the allocation granularity Q n-1 in the storage device in step S1033 is specifically described below with reference to FIG. 4, including:
  • the storage device compares a sum of the allotable storage space of the selected allocation granularity with the adjacent allocated granularity and an allocatable storage space quota preset for the selected allocated granularity.
  • the storage device determines that the sum of the allotable storage space of the selected allocation granularity and the adjacent allocation granularity is greater than a preset allocateable storage space quota for the selected allocated granularity, and is no longer the selection.
  • the allocation granularity allocates storage space, that is, returns write failure information.
  • the storage device cannot continue to allocate the granularity for 10M from the 40M allocated granularity of the allocatable storage space.
  • the storage space can be allocated, and the storage space allocation due to a certain allocation granularity is avoided, so that no storage space is available for other allocation granularities.
  • the storage device may Allocating storage space of the allocated granularity and the allocated storage space for the data to be written, when the sum of the unallocated storage space and the reclaimed storage space is insufficient to be the to-be-written When the data allocates space, the storage device returns write failure information.
  • the storage device determines that the sum of the allotable storage space of the selected allocation granularity and the adjacent allocation granularity is not greater than a preset allocateable storage space quota for the selected allocation granularity, and compares the adjacent allocation.
  • the first threshold may be equal to the size of the adjacent allocation granularity Q n-1 , in which case, when the unallocated storage space of the adjacent allocation granularity is less than one allocation granularity,
  • the selected allocation granularity allocation may allocate storage space.
  • the threshold value may be greater than the first adjacent particle size distribution Q n-1, to avoid the allocation granularity adjacent unallocated memory space is allocated to all of the selected allocation granularity.
  • the storage device determines that at least one contiguous address space of size Q n-1 is released to the adjacent allocation when there is at least one contiguous address space of size Q n-1 in the reclaimed storage space. Granular, allocatable storage space.
  • step S10336 after the at least one contiguous address space of size Q n-1 is released to the contiguous storage granularity of the allocatable storage space, the storage device may release the released storage space and the adjacent storage space.
  • the unallocated storage space of the allocated granularity is integrated and re-allocated according to the adjacent allocation granularity, which reduces storage fragmentation.
  • the selected allocation granularity corresponds to a reclaiming queue
  • the storage device may At least one address of the Q n-1 contiguous address space is added to the reclaim queue, so that the storage device can directly release the storage space from the reclaim queue according to the release granularity of size Q n-1 to the adjacent allocation. Granular in the allocatable storage space.
  • the storage device may further detect, in the reclaimed storage space of the allocated storage space of the selected allocation granularity, at least one consecutive address space of size Q n-1 , and upon determining that the storage space has been recovered at least a contiguous address space of size n-1, Q, the release of at least the size of a contiguous address space Q n-1 is adjacent to the particle size distribution can be assigned storage.
  • the storage device sequentially releases the reclaimed storage space of each allocated granularity, thereby sequentially integrating the small-sized storage space into a larger granular storage space with consecutive addresses, thereby reducing storage fragmentation.
  • the storage device determines that there is no at least one contiguous address space of size Qn -1 in the reclaimed storage space
  • the unallocated storage space may be further removed from the selected allocation granularity. And allocating storage space for the to-be-written data in the reclaimed storage space, where the sum of the unallocated storage space and the reclaimed storage space is insufficient to allocate space for the data to be written
  • the device returns a write failure message.
  • the storage device allocates an allocatable storage space for the selected allocation granularity from the unallocated storage space of the adjacent allocation granularity including the at least one consecutive address space of size Qn -1 .
  • the storage device can directly integrate the released storage space with the unallocated storage space of the adjacent allocated granularity, and After repartitioning, an allocatable storage space for allocation to the selected allocation granularity.
  • the storage device may also release the reclaimed storage space of each allocated granularity, thereby sequentially integrating the small-sized storage space into a larger granular storage space with consecutive addresses, and assigning each of the granularities to the granularity. After the reclaimed storage space is released in turn, allocate storage space for each allocation granularity to minimize storage fragmentation.
  • the storage device may trigger the allocation granularity adjacent to the selected allocation granularity. Allocating storage space for the selected allocation granularity in the allocated storage space.
  • the storage device may also be pre-set allocation granularity respective second threshold value, so that the storage space and a second threshold value R n of the storage device may be selected by comparing the particle size distribution can be allocated unallocated storage space, when When the unallocated storage space size R n in the allotable storage space of the selected allocation granularity is smaller than the second threshold, the selection is from the allotable storage space of the allocation granularity adjacent to the selected allocation granularity The allocation granularity allocation allocates storage space, thus ensuring that each allocation granularity has sufficient allocable storage space.
  • the storage spaces of the N allocation granularities are independent, and the relationship in the foregoing implementation manner does not exist.
  • the storage space of the storage device includes an allocatable storage space of the allocation granularity Q n , an allocatable storage space of the allocation granularity Q n-1 , and an allocatable storage space of the allocation granularity Q n-2 , wherein the allocation The allocatable storage space of the granularity Q n , the allocation granularity Q n-1 and the allocation granularity Q n-2 are all allocated from the total storage space of the storage device.
  • step S103 specifically includes step S1031, step S1032 and step S1033' and step S1034' shown in FIG. 3, and details are not described herein again.
  • the granularity Q n is allocated and the granularity Q n-1 is allocated.
  • the sum of the allocable storage space of the allocation granularity Q n-2 may be a storage space corresponding to one LUN, or may be a partial storage space in one LUN.
  • the storage device may reallocate the allocable storage space to the selected allocation granularity in the storage space corresponding to the LUN.
  • the embodiment of the present invention further provides a storage device 60, which is configured to perform a storage space allocation method provided by the foregoing method embodiment, where the storage space of the storage device 60 is pre-set with N different allocation granularities.
  • the allocation granularity is a unit for allocating the storage space, and each allocation granularity has an allocatable storage space, where N is a positive integer greater than one.
  • the storage Device 60 includes:
  • the receiving unit 61 is configured to receive a data write request, where the data write request includes data to be written;
  • a determining unit 62 configured to select, according to the size of the data to be written and the preset allocation granularity, an allocation granularity of the allocated storage space for the data write request from the N different allocation granularities;
  • the allocating unit 63 is configured to allocate a storage space for the data write request with the selected allocation granularity.
  • the allocating unit 63 is specifically configured to:
  • Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
  • a storage space of size kQ n is allocated for the data write request from the unallocated storage space, where k is a positive integer not less than 1, and Q n is the selected allocation Particle size, M ⁇ kQ n ⁇ min ⁇ L 1 , M+Q n ⁇ .
  • the allocating unit 63 is specifically configured to:
  • Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
  • the recycled storage space is Refers to the storage space that has been allocated in the allocatable space of the selected allocation granularity, and the storage space in which the data written therein has been erased;
  • the allocating unit 63 is specifically configured to:
  • Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
  • the particle size distribution is determined that the allocation is smaller than L 1 M, identifying the selected allocation granularity adjacent allocation granularity, the selection of the particle size from an adjacent dispensing allocated storage space unallocated storage space may be allocated for storage Space, wherein the adjacent distribution granularity Q n-1 is greater than the selected distribution granularity Q n .
  • the storage device 60 further includes a release unit 64, configured to compare the unallocated storage space size of the adjacent allocation granularity with a first threshold; determine unallocated storage of the adjacent allocated granularity When the size of the space is smaller than the first threshold, detecting whether there is at least one contiguous address space of size Q n-1 in the reclaimed storage space of the allocatable storage space of the selected allocation granularity; determining the reclaimed storage When there is at least one contiguous address space of size Q n-1 in the space, the at least one contiguous address space is released to the contiguous storage granularity of the allocatable storage space; the allocating unit 63 is specifically configured to include particle size distribution of said at least one unallocated storage space Q n-1 consecutive address space adjacent to the particle size distribution for dispensing the selected storage space can be allocated.
  • the allocating unit 63 is further configured to compare a sum of the allotable storage space of the selected allocation granularity with the adjacent allocated granularity and an allocatable storage space quota preset for the selected allocated granularity. And determining, when the sum of the allotable storage space of the selected allocation granularity and the adjacent allocation granularity is not greater than the preset allocatable storage space quota for the selected allocation granularity, the assignable from the adjacent allocation granularity The unallocated storage space of the storage space allocates an allocatable storage space for the selected allocation granularity.
  • the allocating unit 63 is further configured to compare a size of the unallocated storage space in the allotable storage space of the selected allocation granularity with a second threshold; when the selected allocated granularity is in the allotable storage space When the size of the unallocated storage space is less than the second threshold, the unallocated storage space in the allotable storage space of the allocation granularity adjacent to the selected allocation granularity increases the allocatable storage space for the selected allocation granularity wherein the particle size distribution of adjacent Q n-1 is greater than the selected particle size distribution Q n.
  • the releasing unit 64 is further configured to detect, in the reclaimed storage space of the selectable storage space of the selected allocation granularity, at least one consecutive size of Q n-1 An address space; when it is determined that there is at least one contiguous address space of size Q n-1 in the reclaimed storage space, releasing the at least one contiguous address space of size Q n-1 to the selected allocation granularity the particle size distribution may be adjacent to allocate storage space adjacent to the particle size distribution Q n-1 is greater than the selected particle size distribution Q n.
  • the above division of the storage device functional unit is only a logical function division, and the actual implementation may have another division manner.
  • the determination unit 62 and the allocation unit 63 may be divided into a processing unit.
  • the physical implementation of the above functional units may also be implemented in various manners.
  • the determining unit 62 may be a central processing unit or an application specific integrated circuit (ASIC).
  • ASIC application specific integrated circuit
  • the storage device is configured to allocate a storage space to the data write request by using a different allocation granularity for data write requests of different data sizes, so that the amount of data is different for each write to the storage device.
  • the storage device can allocate storage space with the allocation granularity closest to the size of each data write, thereby avoiding the problem of waste of storage space or excessive amount of metadata caused by a single allocation granularity.
  • the embodiment of the present invention further provides another storage device, as shown in FIG. 7, including: a processor 71, a communication interface 72, a memory 73, a memory 74, and a communication bus 75;
  • the processor 71, the communication interface 72, the memory 73, and the memory 74 complete communication with each other via the communication bus 75.
  • the communication interface 72 is configured to communicate with an external device.
  • the memory 73 includes a storage space for storing data.
  • the memory 74 is configured to store program code, where the program code is pre-set with N different allocation granularities for the storage space in the memory, where the allocation granularity is used as a unit for allocating the storage space, and each allocation The granularity has an allocatable storage space, where N is a positive integer greater than one.
  • the processor 71 is configured to execute the program code in the memory 74 to perform a method for allocating a storage space provided by the foregoing method embodiment. For details, refer to the method embodiment described above for FIG. 1 , FIG. 3 and FIG. Detailed description will not be repeated here.
  • the disclosed system, apparatus, and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
  • the above-described integrated unit implemented in the form of a software functional unit can be stored in a computer readable storage medium.
  • the software functional units described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform portions of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes. .

Abstract

A storage space allocation method and a storage device relating to the field of storage and used for allocating a storage space by means of different allocation granularities according to the size of data written into the storage device each time. The method comprises: a storage device receiving a data write request, wherein the data write request comprises data to be written (S101); according to the size of the data to be written and N allocation granularities pre-set for a storage space, selecting, from the N different allocation granularities, an allocation granularity for allocating the storage space for the data write request (S102); and allocating the storage space for the data write request by means of the selected allocation granularity (S103), wherein the allocation granularity serves as a unit for allocating the storage space, and each allocation granularity has a storage space capable of being allocated.

Description

存储空间的分配方法及存储设备Storage space allocation method and storage device 技术领域Technical field
本发明涉及存储领域,尤其涉及一种存储空间的分配方法及存储设备。The present invention relates to the field of storage, and in particular, to a storage space allocation method and a storage device.
背景技术Background technique
现有技术中,存储设备为数据写请求分配存储空间的粒度是固定的。也就是说,对于数据写请求中携带的待写入数据的不同数据大小,存储设备均以固定的存储空间大小Q为单位,向数据写请求分配大小为kQ的存储空间,k为正整数。由于,在同一存储架构下,每次写入的数据量的变化范围较小,因此,不会出现分配粒度远大于某次写入的数据大小导致存储空间浪费,或者远小于某次写入的数据大小导致用于描述该数据的存储属性的元数据量过多的问题。In the prior art, the granularity at which the storage device allocates storage space for data write requests is fixed. That is, for different data sizes of data to be written carried in the data write request, the storage device allocates a storage space of size kQ to the data write request in units of a fixed storage space size Q, where k is a positive integer. Because, in the same storage architecture, the amount of data per write varies little, so the allocation granularity is much larger than the data size of a certain write, resulting in wasted storage space, or much smaller than a certain write. The data size causes a problem of excessive amount of metadata for describing the storage attributes of the data.
但是,随着存储技术的发展,存储数据量不断增大,数据管理越来越复杂,现有技术中出现了统一存储的产品形态,即一个存储设备中融合了存储区域网络(英文全称:Storage Area Network,简称:SAN)和网络连接式存储(英文全称:Network Attached Storage,简称:NAS)两种存储架构。其中,SAN通常用于保存结构化数据,其主要应用在需要高速块级别访问的数据操作服务器,比如数据库、高利用率的文件服务器等;NAS一般用于保存非结构化数据,其主要应用在需要进行文件共享的服务器。并且,SAN以“覆盖写”居多,其每次写入的数据量通常较大,适合大粒度的空间分配;NAS以“新增写”居多,其每次写入的数据量通常较小,适合小粒度的空间分配。However, with the development of storage technology, the amount of stored data is increasing, and data management is becoming more and more complex. In the prior art, a unified storage product form appears, that is, a storage device is integrated with a storage area network (English full name: Storage Area Network (referred to as: SAN) and network-attached storage (English full name: Network Attached Storage, referred to as: NAS) two storage architecture. Among them, SAN is usually used to store structured data. It is mainly used in data operation servers that require high-speed block-level access, such as databases, high-utilization file servers, etc. NAS is generally used to store unstructured data. Its main application is in A server that needs to share files. Moreover, SANs are mostly "overwrite writes", and the amount of data written per write is usually large, which is suitable for large-granular space allocation; NAS is mostly "new write", and the amount of data written per write is usually small. Suitable for small-grained space allocation.
由上可知,针对每次写入存储设备的数据量差异较大的情况,若继续采用现有技术以固定粒度分配存储空间,将导致存储空间浪费或者元数据量过多,因此,目前急需一种更加优化的方案来针对每次写入存储设备的数据量差异较大的情况进行存储空间分配。 As can be seen from the above, in the case where the amount of data written to the storage device differs greatly, if the storage space is allocated at a fixed granularity by using the prior art, the storage space is wasted or the amount of metadata is excessive. Therefore, there is an urgent need for one. A more optimized solution to allocate storage space for a large difference in the amount of data written to the storage device each time.
发明内容Summary of the invention
本发明的目的是提供一种存储空间的分配方法及存储设备,用以根据每次写入存储设备的数据量的大小以不同的分配粒度进行存储空间分配。It is an object of the present invention to provide a storage space allocation method and a storage device for performing storage space allocation at different allocation granularities according to the size of the data amount written to the storage device each time.
上述目的将通过独立权利要求中的特征来达成。进一步的实现方式在从属权利要求、说明书和附图中体现。The above object is achieved by the features of the independent claims. Further implementations are embodied in the dependent claims, the description and the figures.
第一方面,提供一种存储空间的分配方法,应用于存储设备,包括:为所述存储设备的存储空间预设N个不同的分配粒度,所述分配粒度作为分配所述存储空间的单位,且每个分配粒度具有可分配存储空间,其中,N是大于1的正整数;所述方法包括:所述存储设备接收数据写请求,所述数据写请求包括待写入数据;根据所述待写入数据的大小以及所述预先设定的分配粒度,从所述N个不同分配粒度中为所述数据写请求选择一个分配存储空间的分配粒度;并以所述选择的分配粒度为所述数据写请求分配存储空间。The first aspect provides a storage space allocation method, which is applied to a storage device, and includes: preset N different allocation granularities for a storage space of the storage device, where the allocation granularity is used as a unit for allocating the storage space. And each allocation granularity has an allocatable storage space, wherein N is a positive integer greater than 1; the method comprises: the storage device receiving a data write request, the data write request including data to be written; a size of the write data and the predetermined allocation granularity, selecting an allocation granularity of the allocated storage space for the data write request from the N different allocation granularities; and using the selected allocation granularity as The data write request allocates storage space.
采用上述方法,该存储设备对于不同数据大小的数据写请求,可以选择不同的分配粒度向该数据写请求分配存储空间,这样,针对每次写入该存储设备的数据量差异较大的情况,该存储设备可以选择与每次数据写入大小最接近的分配粒度分配存储空间,避免了单一的分配粒度可能造成的存储空间浪费或者元数据量过多的问题。According to the above method, the storage device can select a different data size for the data write request of different data sizes, and allocate a storage space to the data write request, so that the amount of data written by the storage device varies greatly each time. The storage device can allocate storage space with the allocation granularity closest to the size of each data write, thereby avoiding the problem of waste of storage space or excessive amount of metadata caused by a single allocation granularity.
结合第一方面,在第一方面的第一种可能的实现方式中,所述以所述选择的分配粒度为所述数据写请求分配存储空间,包括:比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1;确定L1不小于M时,从所述未分配存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,k为不小于1的正整数,Qn是所述选择的分配粒度,M≤kQn<min{L1,M+Qn}。上述实现方式是存储设备以所述选择的分配粒度为所述数据写请求分配存储空间的一个示例。With reference to the first aspect, in a first possible implementation manner of the first aspect, the allocating a storage space for the data write request by using the selected allocation granularity comprises: comparing a size of the data to be written M a size L 1 of the unallocated storage space in the allocatable storage space of the selected allocation granularity; determining that L 1 is not less than M, and allocating a size of kQ n to the data write request from the unallocated storage space a storage space, where k is a positive integer not less than 1, and Q n is the selected distribution granularity, M ≤ kQ n <min{L 1 , M+Q n }. The above implementation is an example in which the storage device allocates a storage space for the data write request with the selected allocation granularity.
结合第一方面,在第一方面的第二种可能的实现方式中,所述以所述选择的分配粒度为所述数据写请求分配存储空间,包括:比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小 L1;确定L1小于M时,确定所述未分配存储空间大小L1以及所述选择的分配粒度的可分配存储空间中已回收存储空间大小L2之和不小于M;所述已回收存储空间是指所述选择的分配粒度的可分配空间中已被分配的存储空间,且写入其中的数据已被擦除后的存储空间;从所述未分配存储空间以及所述已回收存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,M≤kQn<min{L1+L2,M+Qn}。上述实现方式是存储设备以所述选择的分配粒度为所述数据写请求分配存储空间的另一个示例,采用上述实现方式,存储设备可以将所述选择的分配粒度的未分配存储空间分配给数据写请求,提高了所述选择的分配粒度的可分配存储空间的利用率。With reference to the first aspect, in a second possible implementation manner of the first aspect, the allocating a storage space for the data write request by using the selected allocation granularity comprises: comparing a size of the data to be written a size L 1 of unallocated storage space in the allocatable storage space with the selected allocation granularity; determining that L 1 is less than M, determining the unallocated storage space size L 1 and the allocatable storage of the selected allocation granularity The sum of the reclaimed storage space sizes L 2 in the space is not less than M; the reclaimed storage space refers to the storage space that has been allocated in the allocatable space of the selected allocation granularity, and the data written therein has been wiped a storage space after the partition; a storage space of size kQ n is allocated for the data write request from the unallocated storage space and the recovered storage space, where M≤kQ n <min{L 1 +L 2 , M+Q n }. The foregoing implementation manner is another example in which the storage device allocates a storage space for the data write request by using the selected allocation granularity. In the foregoing implementation manner, the storage device may allocate the unallocated storage space of the selected allocated granularity to the data. The write request increases the utilization of the allocatable storage space of the selected allocation granularity.
结合第一方面,或者以上第一方面的任一种可能的实现方式,在第一方面的第三种可能的实现方式中,还包括:比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1;确定L1小于M时,识别与所述选择的分配粒度相邻的分配粒度,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度增加可分配存储空间,其中,所述相邻的分配粒度Qn-1大于所述选择的分配粒度Qn。这样,存储设备对于同一存储空间可以采用不同的分配粒度进行分配,增加了存储空间利用的灵活性。In combination with the first aspect, or any one of the foregoing possible implementation manners of the first aspect, the third possible implementation manner of the first aspect, further comprising: comparing a size M of the data to be written and the selecting The size L 1 of the unallocated storage space in the allotable storage space of the allocation granularity; when L 1 is less than M, the allocation granularity adjacent to the selected allocation granularity is identified, and the allocatable storage from the adjacent allocated granularity is identified unallocated storage space can be increased allocates storage for the selected particle size distribution, wherein the particle size distribution of the adjacent Q n-1 is greater than the selected particle size distribution Q n. In this way, the storage device can be allocated with different allocation granularities for the same storage space, which increases the flexibility of storage space utilization.
结合第一方面,或者以上第一方面的任一种可能的实现方式,在第一方面的第四种可能的实现方式中,所述从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间包括:比较该相邻的分配粒度的未分配存储空间大小与第一阈值;确定该相邻的分配粒度的未分配存储空间大小小于所述第一阈值时,检测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间;确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,从包括所述至少一个大小为Qn-1的连续地址空间的该相邻的分配粒度的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。这样,存储设备将小粒度的存储空间整合为地址连续的更大粒度的存储空间进行释 放,减少了存储碎片。With reference to the first aspect, or any one of the foregoing possible implementation manners of the first aspect, in the fourth possible implementation manner of the first aspect, the unallocated storage space from the adjacent allocation granularity is not allocated Allocating the allocable storage space for the selected allocation granularity in the storage space comprises: comparing the unallocated storage space size of the adjacent allocation granularity with a first threshold; determining that the unallocated storage space size of the adjacent allocation granularity is smaller than When the first threshold is detected, detecting whether there is at least one contiguous address space of size Q n-1 in the reclaimed storage space of the allocatable storage space of the selected allocation granularity; determining that at least the reclaimed storage space exists when the particle size distribution of a contiguous address space Q n-1, which comprises at least one selected from a contiguous address space of size Q n-1 is adjacent to the particle size distribution of unallocated memory space for allocation Storage space can be allocated. In this way, the storage device consolidates the small-grained storage space into a more granular storage space with continuous addresses, reducing storage fragmentation.
结合第一方面的第四种可能的实现方式,在第一方面的第五种可能的实现方式中,还包括:在确定所述已回收存储空间中不存在大小为Qn-1的连续地址空间时,确定所述未分配存储空间大小L1以及所述选择的分配粒度的可分配存储空间中已回收存储空间大小L2之和不小于所述M;所述已回收存储空间是指所述选择的分配粒度的可分配空间中已被分配的存储空间中写入的数据已被擦除的存储空间;从所述未分配存储空间以及所述已回收存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,M≤kQn<min{L1+L2,M+Qn}。In conjunction with the fourth possible implementation of the first aspect, in a fifth possible implementation manner of the first aspect, the method further includes: determining that there is no consecutive address of size Q n-1 in the recovered storage space When the space is determined, the sum of the unallocated storage space size L 1 and the reclaimed storage space size L 2 in the allotable storage space of the selected allocation granularity is not less than the M; the reclaimed storage space refers to a storage space in which the data written in the allocated storage space of the selected allocation granularity has been erased; the data write request is from the unallocated storage space and the recycled storage space A storage space of size kQ n is allocated, where M ≤ kQ n <min{L 1 + L 2 , M+Q n }.
结合第一方面,或者以上第一方面的任一种可能的实现方式,在第一方面的第六种可能的实现方式中,在从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度增加可分配存储空间,包括:比较所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和与为所述选择的分配粒度预设的可分配存储空间配额;确定所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和不大于为所述选择的分配粒度预设可分配存储空间配额时,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。With reference to the first aspect, or any one of the foregoing possible implementation manners of the first aspect, in the sixth possible implementation manner of the first aspect, the unallocated storage in the allocable storage space from the adjacent allocation granularity Adding an allocatable storage space for the selected allocation granularity in the space, comprising: comparing a sum of the assignable storage space of the selected allocation granularity with the adjacent allocated granularity and a preset for the selected allocated granularity Allocating a storage space quota; determining that the sum of the allotable storage space of the selected allocation granularity and the adjacent allocation granularity is not greater than a preset allocation of storage space quota for the selected allocation granularity, from the adjacent allocation An allocatable storage space is allocated for the selected allocation granularity in the unallocated storage space of the granular allocatable storage space.
第二方面,提供一种存储设备,所述存储设备的存储空间预设有N个不同的分配粒度,所述分配粒度作为分配所述存储空间的单位,且每个分配粒度具有可分配存储空间,其中,N是大于1的正整数;所述存储设备包括:接收单元,用于接收数据写请求,所述数据写请求包括待写入数据;确定单元,用于根据所述待写入数据的大小以及所述预设的分配粒度,从所述N个不同的分配粒度中为所述数据写请求选择一个分配存储空间的分配粒度;分配单元,用于以所述选择的分配粒度为所述数据写请求分配存储空间。A second aspect provides a storage device, where a storage space of the storage device is pre-configured with N different allocation granularities, where the allocation granularity is used as a unit for allocating the storage space, and each allocated granularity has an allotable storage space. Wherein, N is a positive integer greater than 1; the storage device includes: a receiving unit, configured to receive a data write request, the data write request includes data to be written, and a determining unit configured to use the data to be written And a predetermined allocation granularity, selecting an allocation granularity of the allocated storage space for the data write request from the N different allocation granularities; and an allocating unit, configured to use the selected allocation granularity The data write request allocates storage space.
结合第二方面,在第二方面的第一种可能的实现方式中,所述分配单元具体用于:比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1;确定L1不小于M时,从所述未分配存 储空间中为所述数据写请求分配大小为kQn的存储空间,其中,k为不小于1的正整数,Qn是所述选择的分配粒度,M≤kQn<min{L1,M+Qn}。With reference to the second aspect, in a first possible implementation manner of the second aspect, the allocating unit is configured to: compare a size M of the data to be written with an allocatable storage space of the selected allocation granularity The size L 1 of the unallocated storage space; when it is determined that L 1 is not less than M, a storage space of size kQ n is allocated for the data write request from the unallocated storage space, where k is a positive integer not less than 1. Q n is the assigned granularity of the selection, M ≤ kQ n <min{L 1 , M+Q n }.
结合第二方面,在第二方面的第二种可能的实现方式中,所述分配单元具体用于:比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1;确定L1小于M时,确定所述未分配存储空间大小L1以及所述选择的分配粒度的可分配存储空间中已回收存储空间大小L2之和不小于M;所述已回收存储空间是指所述选择的分配粒度的可分配空间中已被分配的存储空间,且写入其中的数据已被擦除后的存储空间;从所述未分配存储空间以及所述已回收存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,M≤kQn<min{L1+L2,M+Qn}。With reference to the second aspect, in a second possible implementation manner of the second aspect, the allocating unit is configured to: compare a size M of the data to be written with an allocatable storage space of the selected allocation granularity The size L 1 of the unallocated storage space; when it is determined that L 1 is less than M, the sum of the unallocated storage space size L 1 and the reclaimed storage space size L 2 in the allotable storage space of the selected allocation granularity is not less than M; the reclaimed storage space refers to a storage space that has been allocated in the allocatable space of the selected allocation granularity, and a storage space in which data written therein has been erased; from the unallocated storage space And storing, in the recovered storage space, a storage space of size kQ n for the data write request, where M≤kQ n <min{L 1 +L 2 , M+Q n }.
结合第二方面,在第二方面的第三种可能的实现方式中,所述分配单元具体用于:比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1;确定L1小于M时,识别与所述选择的分配粒度相邻的分配粒度,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间,其中,所述相邻的分配粒度Qn-1大于所述选择的分配粒度QnWith reference to the second aspect, in a third possible implementation manner of the second aspect, the allocating unit is configured to: compare a size M of the data to be written with an allocatable storage space of the selected allocation granularity The size L 1 of the unallocated storage space; when it is determined that L 1 is smaller than M, the allocation granularity adjacent to the selected allocation granularity is identified, and the unallocated storage space of the distributable storage space of the adjacent allocated granularity is said selected particle size distribution may be allocated to allocate storage space, wherein the particle size distribution of the adjacent Q n-1 is greater than the selected particle size distribution Q n.
结合第二方面,或者以上第二方面的任一种可能的实现方式,在第二方面的第四种可能的实现方式中,还包括释放单元,用于:比较该相邻的分配粒度的未分配存储空间大小与第一阈值;确定该相邻的分配粒度的未分配存储空间大小小于所述第一阈值时,检测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间;确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,将所述至少一个连续地址空间释放至该相邻的分配粒度的可分配存储空间;所述分配单元具体用于,从包括所述至少一个大小为Qn-1的连续地址空间的该相邻的分配粒度的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。With reference to the second aspect, or any one of the foregoing possible implementation manners of the second aspect, the fourth possible implementation manner of the second aspect, further comprising: a releasing unit, configured to: compare the adjacent allocation granularity Allocating a storage space size with a first threshold; determining whether the size of the unallocated storage space of the adjacent allocation granularity is smaller than the first threshold, and detecting whether the selected storage space of the allocated storage space of the allocated storage space is There is at least one contiguous address space of size Q n-1 ; determining that at least one contiguous address space of size Q n-1 exists in the recovered storage space, releasing the at least one contiguous address space to the neighbor Allocating storage space of the granularity; the allocation unit is specifically configured to: select from the unallocated storage space of the adjacent allocation granularity including the at least one consecutive address space of size Qn -1 The allocation granularity allocation allocates storage space.
结合第二方面,或者以上第二方面的任一种可能的实现方式,在第二方 面的第五种可能的实现方式中,所述分配单元还用于,比较所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和与为所述选择的分配粒度预设的可分配存储空间配额;确定所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和不大于为所述选择的分配粒度预设可分配存储空间配额时,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。In combination with the second aspect, or any of the possible implementations of the second aspect above, in the second party In a fifth possible implementation manner, the allocating unit is further configured to compare a sum of the allotable storage space of the selected allocation granularity with the adjacent allocation granularity and a preset granularity for the selected allocation granularity The allocatable storage space quota; determining that the sum of the allocable storage space of the selected allocation granularity and the adjacent allocation granularity is not greater than the preset allocatable storage space quota for the selected allocation granularity, from the neighboring The unallocated storage space of the allocatable storage space of the allocated granularity allocates an allocatable storage space for the selected allocation granularity.
第三方面,提供一种存储设备,包括:处理器,存储器,内存,通信接口和通信总线,其中,所述处理器,所述存储器,所述内存和所述通信接口通过所述通信总线完成相互间的通信;所述存储器包括用于存储数据的存储空间;所述内存用于存放程序代码,所述程序代码为所述存储器中的存储空间预设有的N个不同的分配粒度,所述分配粒度作为分配所述存储空间的单位,且每个分配粒度具有可分配存储空间,其中,N是大于1的正整数;所述处理器执行所述内存中的程序代码,以使所述处理器执行执行第一方面,或以上第一方面的任一种可能的实现方式所述的方法。In a third aspect, a storage device is provided, including: a processor, a memory, a memory, a communication interface, and a communication bus, wherein the processor, the memory, the memory, and the communication interface are completed by the communication bus Communication with each other; the memory includes a storage space for storing data; the memory is for storing program code, the program code is N different distribution granularities pre-set by the storage space in the memory, An allocation granularity as a unit for allocating the storage space, and each allocation granularity has an allocatable storage space, wherein N is a positive integer greater than 1; the processor executes the program code in the memory to cause the The processor performs the method of the first aspect, or any of the possible implementations of the first aspect above.
在某些可能的实现方式中,还包括:比较所述选择的分配粒度的可分配存储空间中未分配存储空间的大小与第二阈值;当所述选择的分配粒度的可分配存储空间中未分配存储空间的大小小于所述第二阈值时,从与所述选择的分配粒度相邻的分配粒度的可分配存储空间中的未分配存储空间为所述选择的分配粒度增加可分配存储空间,其中,该相邻的分配粒度Qn-1大于所述选择的分配粒度Qn。这样,当某一分配粒度的未分配存储空间大小低于第二阈值时,均可从大于且与该分配粒度相邻的分配粒度的未分配存储空间中,为该分配粒度增加可分配存储空间,保证了每一个分配粒度拥有足够的可分配存储空间。In some possible implementations, the method further includes: comparing a size of the unallocated storage space in the allotable storage space of the selected allocation granularity with a second threshold; when the selected allocated granularity is not allocated in the storage space When the size of the allocated storage space is smaller than the second threshold, the unallocated storage space in the allotable storage space of the allocation granularity adjacent to the selected allocation granularity increases the allocateable storage space for the selected allocated granularity, The adjacent distribution granularity Q n-1 is greater than the selected distribution granularity Q n . In this way, when the size of the unallocated storage space of a certain allocation granularity is lower than the second threshold, the allocable storage space may be increased for the allocated granularity from the unallocated storage space larger than the allocation granularity adjacent to the allocated granularity. , to ensure that each allocation granularity has enough allocateable storage space.
在某些可能的实现方式中,还包括:每隔预设时间,检测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间;确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,将所述至少一个大小为Qn-1的连续地址空间释放至与所述选 择的分配粒度相邻的分配粒度的可分配存储空间,该相邻的分配粒度Qn-1大于所述选择的分配粒度Qn。这样,存储设备可以将每一个分配粒度的已回收存储空间依次释放,从而将小粒度的存储空间依次整合为地址连续的更大粒度的存储空间,减少了存储碎片。In some possible implementation manners, the method further includes: detecting, at a preset time, the reclaimed storage space of the allocated storage space of the selected allocation granularity, whether there is at least one consecutive address of size Q n-1 Space; determining that at least one contiguous address space of size Q n-1 is released to the selected allocation granularity when there is at least one contiguous address space of size Q n-1 in the recovered storage space particle size distribution may be adjacent to allocate storage space adjacent to the particle size distribution Q n-1 is greater than the selected particle size distribution Q n. In this way, the storage device can sequentially release the reclaimed storage space of each allocated granularity, thereby sequentially integrating the small-sized storage space into a larger granular storage space with consecutive addresses, thereby reducing storage fragmentation.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are the present invention. For some embodiments, other drawings may be obtained from those of ordinary skill in the art without departing from the drawings.
图1为本发明实施例提供的一种存储空间的分配方法的流程示意图;1 is a schematic flowchart of a method for allocating a storage space according to an embodiment of the present invention;
图2为本发明实施例提供的一种存储空间中不同分配粒度的可分配存储空间的示意图;2 is a schematic diagram of an allocatable storage space with different allocation granularities in a storage space according to an embodiment of the present invention;
图3为本发明实施例提供的一种以选择的分配粒度为数据写请求分配存储空间的方法的流程示意图;FIG. 3 is a schematic flowchart of a method for allocating storage space by using a selected allocation granularity as a data write request according to an embodiment of the present disclosure;
图4为本发明实施例提供的一种从分配粒度Qn-1的可分配存储空间中为分配粒度Qn增加可分配存储空间的方法的流程示意图;4 is a schematic flowchart of a method for increasing an allocatable storage space for an allocation granularity Q n from an allocatable storage space of an allocation granularity Q n-1 according to an embodiment of the present disclosure;
图5为本发明实施例提供的另一种存储空间中不同分配粒度的可分配存储空间的示意图;FIG. 5 is a schematic diagram of another allocatable storage space with different allocation granularities in a storage space according to an embodiment of the present invention; FIG.
图6为本发明实施例提供的一种存储设备的结构示意图;FIG. 6 is a schematic structural diagram of a storage device according to an embodiment of the present disclosure;
图7为本发明实施例提供的另一种存储设备的结构示意图。FIG. 7 is a schematic structural diagram of another storage device according to an embodiment of the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚地描述。The technical solutions in the embodiments of the present invention will be clearly described below in conjunction with the accompanying drawings in the embodiments of the present invention.
以下实施例应用于存储设备,该存储设备可以是存储阵列,固态硬盘,叠瓦式磁记录硬盘等。存储设备在接收到其他设备发送的数据写请求时,为 该数据写请求分配存储空间,以存储该数据写请求中的待写入数据。The following embodiments are applied to a storage device, which may be a storage array, a solid state hard disk, a tiled magnetic recording hard disk, or the like. When the storage device receives a data write request sent by another device, it is The data write request allocates a storage space to store data to be written in the data write request.
本发明实施例提供一种存储空间的分配方法,该方法应用于存储设备,其中,针对该存储设备的存储空间预设有N个不同的分配粒度,所述分配粒度作为分配该存储空间的单位,且每个分配粒度具有可分配存储空间,每个分配粒度的可分配存储空间可以是预设的,也可以是第一次接收到以该分配粒度进行分配的数据写请求时,才设置的。其中,N是大于1的正整数。如图1所示,该方法包括:An embodiment of the present invention provides a method for allocating a storage space, where the method is applied to a storage device, where a storage space of the storage device is pre-configured with N different allocation granularities, and the allocation granularity is used as a unit for allocating the storage space. And each allocation granularity has an allocatable storage space, and the allotable storage space of each allocation granularity may be preset, or may be set when the data write request allocated by the allocation granularity is received for the first time. . Where N is a positive integer greater than one. As shown in Figure 1, the method includes:
S101、该存储设备接收数据写请求,该数据写请求包括待写入数据。S101. The storage device receives a data write request, where the data write request includes data to be written.
其中,该存储设备可以是与服务器相连的外接存储设备,也可以是与客户端相连的存储服务器。该数据写请求可以是该存储设备从与之相连的服务器或者客户端接收到的。The storage device may be an external storage device connected to the server, or may be a storage server connected to the client. The data write request may be that the storage device receives from a server or client connected thereto.
S102、该存储设备根据该待写入数据的大小以及该预先设定的分配粒度,从该N个不同分配粒度中为该数据写请求选择一个分配存储空间的分配粒度。S102. The storage device selects an allocation granularity of the allocated storage space for the data write request from the N different allocation granularities according to the size of the to-be-written data and the preset allocation granularity.
值的说明的是,存储空间的N个不同的分配粒度可以是用户根据每次写入该存储设备的数据量的实际情况进行预设的。例如,在该存储设备融合了SAN和NAS两种存储架构的情况下,若SAN存储架构每次的数据写入量在60M(兆)至64M范围之内,SAN存储架构每次的数据写入量在10KB(千字节)至64KB范围之内,则可以为存储空间预设64M和64KB两个分配粒度。The value indicates that the N different allocation granularities of the storage space may be preset by the user according to the actual amount of data written to the storage device each time. For example, if the storage device combines both SAN and NAS storage architectures, if the SAN storage architecture writes data in the range of 60M (megabytes) to 64M, the SAN storage architecture writes data each time. The amount is in the range of 10KB (kilobytes) to 64KB, and the two allocation granularities of 64M and 64KB can be preset for the storage space.
这样,步骤S102中,该存储设备可以计算待写入数据的大小分别与每个分配粒度的差值,并选择与所述数据大小的差值的绝对值最小的分配粒度。例如,若针对存储空间预设64M(兆)和64KB(千字节)两个分配粒度,在此种情况下,该存储设备在接收到携带的待写入数据的大小为10KB的数据写请求时,由于64KB的分配粒度与该待写入数据的大小最接近,因此,该存储设备可选择64KB的分配粒度为向该数据写请求分配存储空间的分配粒度;该存储设备在接收到携带的待写入数据的大小为60M的数据写请求时,由于 64M的分配粒度与该待写入数据的大小最接近,因此,该存储设备可选择64M的分配粒度为向该数据写请求分配存储空间的分配粒度。Thus, in step S102, the storage device can calculate a difference between the size of the data to be written and each of the allocated granularities, and select an allocation granularity with a minimum absolute value of the difference from the data size. For example, if two allocation granularities of 64M (megabytes) and 64 kilobytes (kilobytes) are preset for the storage space, in this case, the storage device receives a data write request with a size of 10 KB to be carried with the data to be written. When the allocation granularity of 64 KB is closest to the size of the data to be written, the storage device may select an allocation granularity of 64 KB as an allocation granularity for allocating storage space to the data write request; the storage device is received and carried When the size of the data to be written is 60M, the data write request is due to The 64M allocation granularity is closest to the size of the data to be written. Therefore, the storage device can select a 64M allocation granularity as the allocation granularity of allocating storage space to the data write request.
上述只是举例说明,存储设备选择为数据写请求分配存储空间的分配粒度的策略可以根据实际需求进行设定。例如,若存储空间的两个分配粒度为50M和30M,此时,对于数据大小为60M的待写入数据,按照上述举例说明的实现方式,与该数据大小最接近的分配粒度为50M,但是,存储设备若选择50M的分配粒度为该待写入数据分配存储空间,其需要分配两个50M大小的存储空间存储60M的数据,将导致40M的存储空间浪费,因此,在此种情况下,该存储设备可以选择30M的分配粒度为该待写入数据分配存储空间,两个30M大小的存储空间存储60M的数据,避免了存储空间的浪费。也就是说,对于分配粒度Qn和Qn-1,若knQn与待写入数据的大小M之间的差值的绝对值,大于kn-1Qn-1与待写入数据的大小M之间的差值的绝对值,则选择分配粒度Qn为向该数据写请求分配存储空间的分配粒度,反之,则选择Qn-1为向该数据写请求分配存储空间的分配粒度,其中,kn是存储设备为该待写入数据分配的大小为Qn的存储空间的个数,kn-1是存储设备为该待写入数据分配的大小为Qn-1的存储空间的个数,M≤knQn<M+Qn,M≤kn-1Qn-1<M+Qn-1The foregoing is only an example. The policy of the storage device selecting the allocation granularity of the storage space for the data write request may be set according to actual requirements. For example, if the two allocation granularities of the storage space are 50M and 30M, at this time, for the data to be written with a data size of 60M, according to the implementation described above, the distribution granularity closest to the data size is 50M, but If the storage device selects a 50M allocation granularity to allocate storage space for the data to be written, it needs to allocate two 50M storage spaces to store 60M of data, which will result in wasted 40M storage space. Therefore, in this case, The storage device can select a distribution granularity of 30M to allocate storage space for the data to be written, and two storage spaces of 30M size store 60M of data, thereby avoiding waste of storage space. That is, for the distribution granularity Q n and Q n-1 , if the absolute value of the difference between k n Q n and the size M of the data to be written is greater than k n-1 Q n-1 and to be written The absolute value of the difference between the sizes M of the data, then the selection granularity Q n is the allocation granularity of allocating the storage space to the data write request, and vice versa, selecting Q n-1 to allocate the storage space to the data write request. The allocation granularity, where k n is the number of storage spaces of size Q n allocated by the storage device for the data to be written, and k n-1 is the size allocated by the storage device for the data to be written is Q n-1 The number of storage spaces, M ≤ k n Q n <M+Q n , M ≤ k n-1 Q n-1 <M+Q n-1 .
另一个例子,在预设的分配粒度为64M和64KB,而待写入数据的大小为32M的情况下,存储设备若选择64KB的分配粒度为32M的待写入数据分配存储空间,其需要分配500个64KB的存储空间,导致存储碎片化,元数据量过多。而存储设备若选择64M的分配粒度为32M的待写入数据分配存储空间,则会导致32M的存储空间浪费。在此种情况下,若具体实施过程中对存储利用率要求较高,则可预设条件:为数据写请求分配的存储空间的大小与待写入数据的大小之间的差值不能超过1M,这样,该存储设备根据该预设条件即可选择64KB的分配粒度为32M的待写入数据分配存储空间;若具体实施过程中要求存储碎片化程度最低,则可预设条件:针对同一个数据写请求,存储设备分配的相同粒度的存储空间不能超过两个,这样,该存储设备根据该预设条件即可选择64M的分配粒度为32M的待写入数据分配存储空间。另 外,值的说明的是,为了避免上述举例中,待写入数据的大小与预设的每个分配粒度均相差较大的情况出现,本发明实施例在预设存储空间的N个分配粒度时,可以减小相邻两个分配粒度之间的差值。As another example, in the case where the preset allocation granularity is 64M and 64KB, and the size of the data to be written is 32M, if the storage device selects 64 KB of the allocation granularity of 32M to be written to the data allocation storage space, it needs to be allocated. 500 64KB of storage space, resulting in fragmentation of storage and excessive metadata. If the storage device selects a 64M allocation granularity of 32M to be written to the data allocation storage space, 32M storage space is wasted. In this case, if the storage utilization requirement is high in the specific implementation process, the preset condition may be that the difference between the size of the storage space allocated for the data write request and the size of the data to be written cannot exceed 1M. In this way, the storage device can select a 64 KB allocation granularity of 32 M to be written according to the preset condition; if the storage fragmentation degree is required to be the lowest in the specific implementation process, the preset condition is: for the same For the data write request, the storage space allocated by the storage device of the same granularity cannot exceed two. Therefore, the storage device can select a 64M allocation storage space to be written with a storage granularity of 32M according to the preset condition. Another In addition, the value indicates that, in order to avoid the case where the size of the data to be written is different from the preset granularity of each of the foregoing, the N allocation granularities in the preset storage space in the embodiment of the present invention. At the same time, the difference between the adjacent two distribution granularities can be reduced.
S103、该存储设备以所述选择的分配粒度为该数据写请求分配存储空间。S103. The storage device allocates a storage space for the data write request by using the selected allocation granularity.
示例地,所述选择的分配粒度对应一分配队列,该存储设备可以将该选择的分配粒度的未分配存储空间划分为多个存储子空间,其中,每个存储子空间的大小等于该选择的分配粒度的大小Qn,并将该存储子空间的地址加入该分配队列。这样,该存储设备在向数据写请求分配存储空间时,可以直接从该分配队列中分配,无需临时对所述选择的分配粒度的未分配存储空间进行划分,提高了分配效率。For example, the selected allocation granularity corresponds to an allocation queue, and the storage device may divide the unallocated storage space of the selected allocated granularity into a plurality of storage subspaces, wherein the size of each storage subspace is equal to the selected one. The size of the granularity Q n is allocated and the address of the storage subspace is added to the allocation queue. In this way, when the storage device allocates storage space to the data write request, the storage device can directly allocate from the allocation queue, and does not need to temporarily divide the unallocated storage space of the selected allocation granularity, thereby improving the allocation efficiency.
例如,该数据写请求中待写入数据的大小为M,则该存储设备可以从该分配队列中向该数据写请求分配k个存储子空间,其中,k为不小于1的正整数,且M≤kQn<M+Qn。也就是说,若该选择的分配粒度为64KB,则对于大小为130KB的待写入数据,该存储设备为该待写入数据分配的存储空间大小为3*64KB=192KB。For example, if the size of the data to be written in the data write request is M, the storage device may allocate k storage subspaces from the allocation queue to the data write request, where k is a positive integer not less than 1, and M≤kQ n <M + Q n. That is, if the selected allocation granularity is 64 KB, the storage space allocated by the storage device for the data to be written is 3*64 KB=192 KB for the data to be written with a size of 130 KB.
另外,需要说明的是,本文所述的存储空间可以是一个逻辑存储单元(Logical Unit Number,LUN),通常情况下,一个LUN通常只能被一个主机访问。在此种情况下,若存储设备存在多个LUN用于被多个主机访问,本发明实施例可以为每个LUN预设N个分配粒度。这样,针对每一个LUN,存储设备向数据写请求分配存储空间的方法可以参照上述步骤S101至步骤S103,此处不再赘述。In addition, it should be noted that the storage space described in this document may be a logical unit number (LUN). Generally, a LUN can usually be accessed by only one host. In this case, if the storage device has multiple LUNs for being accessed by multiple hosts, the embodiment of the present invention may preset N allocation granularities for each LUN. In this way, for each LUN, the method for the storage device to allocate the storage space to the data write request may refer to the foregoing steps S101 to S103, and details are not described herein again.
采用上述方法,该存储设备对于不同数据大小的数据写请求,可以选择不同的分配粒度向该数据写请求分配存储空间,避免了单一的分配粒度可能造成的存储空间浪费或者元数据量过多的问题。With the above method, the storage device can select a different data size for the data write request of different data sizes, and allocate storage space to the data write request, thereby avoiding waste of storage space or excessive amount of metadata caused by a single allocation granularity. problem.
在本发明实施例的一种可能的实现方式中,除了最大的分配粒度,每个分配粒度的可分配存储空间从与该分配粒度相邻的分配粒度的可分配存储空间的未分配存储空间中分配,且所述相邻的分配粒度大于该分配粒度,当该 分配粒度的可分配存储空间分配完后,可从与该分配粒度相邻的且大于该分配粒度的分配粒度的可分配存储空间的未分配存储空间中为该分配粒度分配存储空间,如图2所示,相邻的分配粒度Qn、Qn-1、及Qn-2的大小关系为Qn<Qn-1<Qn-2,则所述Qn的可分配存储空间从所述Qn-1的未分配存储空间分配,所述Qn-1的可分配存储空间从所述Qn-2的未分配存储空间空间分配,当Qn的可分配存储空间分配完后,则可从Qn-1的未分配存储空间中为Qn分配可分配存储空间。所述Qn-2的可分配存储空间,即N个分配粒度中的最大分配粒度的可分配存储空间可以为一个LUN对应的存储空间,也可以为一个LUN中的部分存储空间,若Qn-2的可分配存储空间为一个LUN中的部分存储空间时,则当Qn-2的可分配存储空间分配完后,则可从所述LUN对应的存储空间中为Qn-2分配存储空间。In a possible implementation manner of the embodiment of the present invention, in addition to the maximum allocation granularity, the allocateable storage space of each allocation granularity is from the unallocated storage space of the allotable storage space of the allocated granularity adjacent to the allocated granularity. Allocating, and the adjacent allocation granularity is greater than the allocation granularity, and when the allocatable storage space of the allocated granularity is allocated, the distributable storage space adjacent to the allocation granularity and larger than the allocated granularity of the allocated granularity may be allocated. The storage space is allocated for the allocation granularity in the unallocated storage space. As shown in FIG. 2 , the size relationship between adjacent allocation granularities Q n , Q n-1 , and Q n-2 is Q n <Q n-1 < Q n-2, Q n may then allocate the memory space allocated from unallocated storage space of the Q n-1, said Q n-1 may allocate memory from the unallocated space in Q n-2 storage space allocation, when the n-Q may be allocated after the allocation of storage space, storage space can be allocated can be allocated from the n-Q Q unallocated storage space of n-1. The allocatable storage space of the Q n-2 , that is, the maximum allocated granularity of the N allocation granularities, may be a storage space corresponding to one LUN, or may be a partial storage space in a LUN, if Q n When the allocatable storage space of the -2 is a part of the storage space of the LUN, when the allocatable storage space of the Q n-2 is allocated, the storage may be allocated for the Q n-2 from the storage space corresponding to the LUN. space.
基于上述可能的实现方式,上述步骤S103中,存储设备以所述选择的分配粒度为该数据写请求分配存储空间具体包括:Based on the foregoing possible implementation manner, in the foregoing step S103, the storage device allocates the storage space for the data write request by using the selected allocation granularity to specifically include:
S1031、该存储设备比较该待写入数据的大小M与该选择的分配粒度的可分配存储空间中未分配存储空间的大小L1Storage space can be allocated S1031, the device compares the memory size of the data to be written with a particle size distribution of the M selected unallocated storage space size of L 1.
S1032、该存储设备在确定L1不小于M时,从所述未分配存储空间中为所述数据写请求分配大小为kQn的存储空间。S1032: The storage device allocates a storage space of size kQ n for the data write request from the unallocated storage space when determining that L 1 is not less than M.
若该存储设备确定L1小于M,即所选择的分配粒度的未分配存储空间小于待写入数据的大小时,则可通过两种方式获取为所述待写入数据分配存储空间,第一种方式为从所述选择的分配粒度的已回收存储空间为所述待写入数据分配存储空间,具体如步骤S1033’和S1034’所示,第二种方式为从与所述选择分配粒度相邻的且大于所述选择的分配粒度的分配粒度的可分配存储空间的未分配存储空间中为该分配粒度分配存储空间,具体如步骤S1033和步骤S1034所示。If the storage device determines that L 1 is smaller than M, that is, the unallocated storage space of the selected allocation granularity is smaller than the size of the data to be written, the storage space may be allocated for the data to be written in two manners. The method is to allocate a storage space for the data to be written from the collected storage space of the selected allocation granularity, as shown in steps S1033' and S1034', and the second manner is to allocate a granularity from the selection. A storage space is allocated for the allocated granularity in the unallocated storage space of the allocatable storage space that is adjacent to the allocated granularity of the selected allocation granularity, as shown in step S1033 and step S1034.
其中,第一种方式具体包括如下步骤:The first method specifically includes the following steps:
S1033’、该存储设备在确定L1小于M时,比较所述未分配存储空间大小L1与所述选择的分配粒度的可分配存储空间中已回收存储空间大小L2之和与 M。S1033 ', the memory device in determining L 1 is less than M, comparing the unallocated storage space L 1 and a particle size distribution of the selected storage space can be allocated memory space recovered sum and L 2 M.
其中,所述已回收存储空间是指所述选择的分配粒度的可分配空间中已被分配且写入其中的数据已被擦除后的存储空间。The reclaimed storage space refers to a storage space in the allocatable space of the selected allocation granularity that has been allocated and the data written therein has been erased.
S1034’、该存储设备确定所述未分配存储空间大小L1与所述选择的分配粒度的可分配存储空间中已回收存储空间大小L2之和不小于M时,该存储设备从所述未分配存储空间以及所述已回收存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,M≤kQn<min{L1+L2,M+Qn}。When S1034 ', the memory device determines the size of the unallocated storage space 1 and a particle size distribution of the selected storage space can be allocated in the L-recovered storage space is not less than 2 L and M, which is not from the memory device Allocating a storage space and storing a size of kQ n for the data write request in the recycled storage space, where M≤kQ n <min{L 1 +L 2 , M+Q n }.
在确定所述未分配存储空间大小L1以及所述选择的分配粒度的可分配存储空间中已回收存储空间大小L2之和小于M时,该存储设备可以执行步骤S1033和步骤S1034示出的第二种方式为所述待写入数据分配存储空间。The storage device may perform the steps shown in step S1033 and step S1034 when it is determined that the sum of the unallocated storage space size L 1 and the allocated storage granularity of the allocated storage granularity L 2 is less than M The second way is to allocate storage space for the data to be written.
第二种方式具体包括如下步骤:The second method specifically includes the following steps:
S1033、该存储设备确定L1小于M时,识别与所述选择的分配粒度相邻的分配粒度,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。S1033, the storage device is less than M L is determined identifying the selected allocation granularity adjacent allocation granularity 1, a particle size distribution from the adjacent storage space can be allocated unallocated storage space allocated to said selected Granular allocation allocates storage space.
其中,该相邻的分配粒度Qn-1大于所述选择的分配粒度QnThe adjacent distribution granularity Q n-1 is greater than the selected distribution granularity Q n .
示例地,该存储设备可以根据待写入数据的大小M,从该相邻的分配粒度的未分配存储空间中为所述选择的分配粒度分配大小为kQn-1的可分配存储空间,其中,kQn-1大于M且小于Qn-1+M。例如,该待写入数据的大小为10M,该相邻的分配粒度Qn-1为100M,在此种情况下,该存储设备可以从该相邻的分配粒度的未分配存储空间中为所述选择的分配粒度分配大小为100M的存储空间。For example, the storage device may allocate an allocatable storage space of size kQ n-1 for the selected allocation granularity from the unallocated storage space of the adjacent allocated granularity according to the size M of the data to be written. , kQ n-1 is greater than M and less than Q n-1 +M. For example, the size of the data to be written is 10M, and the adjacent allocation granularity Q n-1 is 100M. In this case, the storage device may be from the unallocated storage space of the adjacent allocated granularity. The selected allocation granularity is allocated to a storage space of 100M in size.
另一个例子,该存储设备可以根据L1与M之间的差值,从该相邻的分配粒度的未分配存储空间中为所述选择的分配粒度分配大小为kQn-1的可分配存储空间,其中,kQn-1大于M-L1且小于Qn-1+M-L1。例如,待写入数据大小为120M,该相邻的分配粒度Qn-1为50M,所述选择的分配粒度Qn为40M,所述选择的分配粒度的未分配存储空间大小为80M,在此种情况下,该存储设备可以从该相邻的分配粒度的未分配存储空间中为所述选择的分配粒度分配 大小为50M的存储空间。In another example, the storage device may allocate an allocatable storage of size kQ n-1 for the selected allocation granularity from the unallocated storage space of the adjacent allocated granularity according to the difference between L 1 and M. Space, where kQ n-1 is greater than ML 1 and less than Q n-1 + ML 1 . For example, the size of data to be written to 120M, the particle size distribution adjacent to Q n-1 50M, the selected particle size distribution Q n is 40M, the selected unallocated memory space allocation granularity is 80M, the In this case, the storage device may allocate a storage space of a size of 50M for the selected allocation granularity from the unallocated storage space of the adjacent allocation granularity.
S1034、该存储设备从所述选择的分配粒度的未分配存储空间中为所述数据写请求分配大小为kQn的存储空间。S1034. The storage device allocates a storage space of size kQ n for the data write request from the unallocated storage space of the selected allocation granularity.
下面将结合图4具体说明步骤S1033中存储设备从分配粒度Qn-1的可分配存储空间中为分配粒度Qn分配可分配存储空间的方法,包括:The method for allocating the allocatable storage space for the allocation granularity Q n from the allocatable storage space of the allocation granularity Q n-1 in the storage device in step S1033 is specifically described below with reference to FIG. 4, including:
S10331、该存储设备比较所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和与为所述选择的分配粒度预设的可分配存储空间配额。S10331. The storage device compares a sum of the allotable storage space of the selected allocation granularity with the adjacent allocated granularity and an allocatable storage space quota preset for the selected allocated granularity.
S10332、该存储设备确定所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和大于为所述选择的分配粒度预设可分配存储空间配额时,则不再为所述选择的分配粒度分配存储空间,即返回写入失败信息。S10332. The storage device determines that the sum of the allotable storage space of the selected allocation granularity and the adjacent allocation granularity is greater than a preset allocateable storage space quota for the selected allocated granularity, and is no longer the selection. The allocation granularity allocates storage space, that is, returns write failure information.
也就是说,该存储设备可以预先对各个分配粒度的可分配存储空间设置配额,例如,若存储空间总的大小为500M,该存储空间的两个分配粒度分别是40M和10M,40M分配粒度的可分配存储空间的配额为400M,10M分配粒度的可分配存储空间的配额是100M,在此种情况下,若存储设备已从40M分配粒度的可分配存储空间向10M分配粒度分配了80M可分配存储空间,由于80M+40M=120M,超过了为10M分配粒度的可分配存储空间预设的配额100M,因此,该存储设备不能继续从该40M分配粒度的可分配存储空间中为10M分配粒度分配可分配存储空间,避免了由于某一分配粒度的存储空间分配过多,导致其他分配粒度无存储空间可用。That is, the storage device may set a quota for the allocatable storage space of each allocation granularity in advance. For example, if the total storage space size is 500M, the two allocation granularities of the storage space are 40M and 10M, respectively, and 40M allocation granularity. The quota of the allocable storage space is 400M, and the quota of the 10M allocated granularity of the allocable storage space is 100M. In this case, if the storage device has allocated 80M distributable from the 40M allocation granularity of the allocatable storage space to the 10M allocation granularity. The storage space, because 80M+40M=120M, exceeds the quota of 100M for the 10M allocated storage space. Therefore, the storage device cannot continue to allocate the granularity for 10M from the 40M allocated granularity of the allocatable storage space. The storage space can be allocated, and the storage space allocation due to a certain allocation granularity is avoided, so that no storage space is available for other allocation granularities.
可选地,在确定所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和大于为所述选择的分配粒度预设可分配存储空间配额时,该存储设备可以从所述选择的分配粒度的未分配存储空间以及已回收存储空间中为所述待写入数据分配存储空间,当所述未分配存储空间以及所述已回收存储空间大小之和不足以为所述待写入数据分配空间时,则所述存储设备返回写入失败信息。Optionally, when the sum of the allocatable storage space of the selected allocation granularity and the adjacent allocation granularity is greater than the preset allocatable storage space quota for the selected allocation granularity, the storage device may Allocating storage space of the allocated granularity and the allocated storage space for the data to be written, when the sum of the unallocated storage space and the reclaimed storage space is insufficient to be the to-be-written When the data allocates space, the storage device returns write failure information.
S10333、该存储设备确定所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和不大于为所述选择的分配粒度预设可分配存储空间配额 时,比较该相邻的分配粒度的可分配存储空间中未分配存储空间大小Rn-1与第一阈值。S10333. The storage device determines that the sum of the allotable storage space of the selected allocation granularity and the adjacent allocation granularity is not greater than a preset allocateable storage space quota for the selected allocation granularity, and compares the adjacent allocation. The unallocated storage space size R n-1 and the first threshold in the granular allotable storage space.
其中,该第一阈值可以等于该相邻的分配粒度的大小Qn-1,在此种情况下,也就是说,该相邻的分配粒度的未分配存储空间不足一个分配粒度时,无法向所述选择的分配粒度分配可分配存储空间。The first threshold may be equal to the size of the adjacent allocation granularity Q n-1 , in which case, when the unallocated storage space of the adjacent allocation granularity is less than one allocation granularity, The selected allocation granularity allocation may allocate storage space.
另外,该第一阈值可以大于该相邻的分配粒度的大小Qn-1,以避免该相邻的分配粒度的未分配存储空间被全部分配给所述选择的分配粒度。Further, the threshold value may be greater than the first adjacent particle size distribution Q n-1, to avoid the allocation granularity adjacent unallocated memory space is allocated to all of the selected allocation granularity.
S10334、该存储设备确定该相邻分配粒度的未分配存储空间大小不小于该第一阈值时,从该相邻分配粒度的未分配存储空间中,为所述选择的分配粒度分配可分配存储空间。S10334, when the storage device determines that the unallocated storage space size of the adjacent allocation granularity is not less than the first threshold, allocates an allocateable storage space for the selected allocation granularity from the unallocated storage space of the adjacent allocated granularity. .
S10335、该存储设备确定该相邻的分配粒度的可分配存储空间大小Rn-1小于所述第一阈值时,检测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间。S10335. When the storage device determines that the allocateable storage space size R n-1 of the adjacent allocation granularity is smaller than the first threshold, whether the reclaimed storage space of the selectable storage granularity of the allocated storage space is detected is There is at least one contiguous address space of size Qn -1 .
S10336、该存储设备确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,将所述至少一个大小为Qn-1的连续地址空间释放至该相邻的分配粒度的可分配存储空间。S10336. The storage device determines that at least one contiguous address space of size Q n-1 is released to the adjacent allocation when there is at least one contiguous address space of size Q n-1 in the reclaimed storage space. Granular, allocatable storage space.
由于所述选择的分配粒度的可分配存储空间均来自于该相邻分配粒度的可分配存储空间,所述选择的分配粒度的已回收存储空间中的数据虽然已经被擦除,但是,所述已回收存储空间仍然需要按照所述选择的分配粒度进行分配。步骤S10336中,所述至少一个大小为Qn-1的连续地址空间被释放至该相邻的分配粒度的可分配存储空间后,该存储设备即可以将释放回的存储空间与该相邻的分配粒度的未分配存储空间进行整合,并重新按照该相邻的分配粒度进行分配,减少了存储碎片。Since the allocatable storage space of the selected allocation granularity is from the allocatable storage space of the adjacent allocation granularity, the data in the recovered storage space of the selected allocated granularity has been erased, but The reclaimed storage space still needs to be allocated according to the selected allocation granularity. In step S10336, after the at least one contiguous address space of size Q n-1 is released to the contiguous storage granularity of the allocatable storage space, the storage device may release the released storage space and the adjacent storage space. The unallocated storage space of the allocated granularity is integrated and re-allocated according to the adjacent allocation granularity, which reduces storage fragmentation.
示例地,所述选择的分配粒度对应一回收队列,在所述选择的分配粒度的已回收存储空间中,存在至少一个大小为Qn-1的连续地址空间时,该存储设备即可将该至少一个大小为Qn-1连续地址空间的地址加入到该回收队列中,这样,该存储设备可以直接从该回收队列中按照大小为Qn-1的释放粒度释放 存储空间至该相邻分配粒度的可分配存储空间中。For example, the selected allocation granularity corresponds to a reclaiming queue, and when there is at least one contiguous address space of size Q n-1 in the reclaimed storage space of the selected allocated granularity, the storage device may At least one address of the Q n-1 contiguous address space is added to the reclaim queue, so that the storage device can directly release the storage space from the reclaim queue according to the release granularity of size Q n-1 to the adjacent allocation. Granular in the allocatable storage space.
可选地,该存储设备还可以每隔预设时间,检测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间,并在确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,将所述至少一个大小为Qn-1的连续地址空间释放至该相邻的分配粒度的可分配存储空间。这样,存储设备将每一个分配粒度的已回收存储空间依次释放,从而将小粒度的存储空间依次整合为地址连续的更大粒度的存储空间,减少了存储碎片。Optionally, the storage device may further detect, in the reclaimed storage space of the allocated storage space of the selected allocation granularity, at least one consecutive address space of size Q n-1 , and upon determining that the storage space has been recovered at least a contiguous address space of size n-1, Q, the release of at least the size of a contiguous address space Q n-1 is adjacent to the particle size distribution can be assigned storage. In this way, the storage device sequentially releases the reclaimed storage space of each allocated granularity, thereby sequentially integrating the small-sized storage space into a larger granular storage space with consecutive addresses, thereby reducing storage fragmentation.
可选地,如果在步骤10335中,该存储设备确定所述已回收存储空间中不存在至少一个大小为Qn-1的连续地址空间,可以进一步从所述选择的分配粒度的未分配存储空间以及已回收存储空间中为所述待写入数据分配存储空间,当所述未分配存储空间以及所述已回收存储空间大小之和不足以为所述待写入数据分配空间时,则所述存储设备返回写入失败信息。Optionally, if, in step 10335, the storage device determines that there is no at least one contiguous address space of size Qn -1 in the reclaimed storage space, the unallocated storage space may be further removed from the selected allocation granularity. And allocating storage space for the to-be-written data in the reclaimed storage space, where the sum of the unallocated storage space and the reclaimed storage space is insufficient to allocate space for the data to be written The device returns a write failure message.
S10337、该存储设备从该相邻的分配粒度的包括该至少一个大小为Qn-1的连续地址空间的未分配存储空间中,为所述选择的分配粒度分配可分配存储空间。S10337. The storage device allocates an allocatable storage space for the selected allocation granularity from the unallocated storage space of the adjacent allocation granularity including the at least one consecutive address space of size Qn -1 .
也就是说,对于释放回该相邻的分配粒度的可分配存储空间的存储空间,该存储设备可以直接将释放回的存储空间跟该相邻的分配粒度的未分配的存储空间进行整合,并在重新划分后,用于分配给所述选择的分配粒度的可分配存储空间。That is, for the storage space of the allocatable storage space that is released back to the adjacent allocation granularity, the storage device can directly integrate the released storage space with the unallocated storage space of the adjacent allocated granularity, and After repartitioning, an allocatable storage space for allocation to the selected allocation granularity.
可选地,该存储设备还可以将每一个分配粒度的已回收存储空间依次释放,从而将小粒度的存储空间依次整合为地址连续的更大粒度的存储空间,并在将每一个分配粒度的已回收存储空间依次释放后,为每一个分配粒度分配可分配存储空间,以最大程度上避免存储碎片。Optionally, the storage device may also release the reclaimed storage space of each allocated granularity, thereby sequentially integrating the small-sized storage space into a larger granular storage space with consecutive addresses, and assigning each of the granularities to the granularity. After the reclaimed storage space is released in turn, allocate storage space for each allocation granularity to minimize storage fragmentation.
由上述步骤S1035以及步骤S1036可知,在所述选择的分配粒度的未分配存储空间大小小于待写入数据的大小时,可以触发存储设备从与所述选择的分配粒度相邻的分配粒度的可分配存储空间中为所述选择的分配粒度分配 可分配存储空间。可选地,存储设备还可以预先设置各个分配粒度的第二阈值,这样,该存储设备可以比较所述选择的分配粒度的可分配存储空间中未分配存储空间大小Rn与第二阈值,当所述选择的分配粒度的可分配存储空间中未分配存储空间大小Rn小于所述第二阈值时,从与所述选择的分配粒度相邻的分配粒度的可分配存储空间中为所述选择的分配粒度分配可分配存储空间,从而保证了每一个分配粒度拥有足够的可分配存储空间。According to the foregoing step S1035 and step S1036, when the size of the unallocated storage space of the selected allocation granularity is smaller than the size of the data to be written, the storage device may trigger the allocation granularity adjacent to the selected allocation granularity. Allocating storage space for the selected allocation granularity in the allocated storage space. Alternatively, the storage device may also be pre-set allocation granularity respective second threshold value, so that the storage space and a second threshold value R n of the storage device may be selected by comparing the particle size distribution can be allocated unallocated storage space, when When the unallocated storage space size R n in the allotable storage space of the selected allocation granularity is smaller than the second threshold, the selection is from the allotable storage space of the allocation granularity adjacent to the selected allocation granularity The allocation granularity allocation allocates storage space, thus ensuring that each allocation granularity has sufficient allocable storage space.
以上为从一个分配粒度的相邻分配粒度的可分配存储空间的未分配存储空间为该分配粒度分配可分配存储空间的场景下,为待写入数据分配存储空间的实现方式的说明。The above is an explanation of an implementation manner of allocating storage space for data to be written in a scenario in which an unallocated storage space of an allocatable storage space of a neighboring allocation granularity of an allocation granularity is allocated an allocatable storage space.
在本发明实施例的另一种可能的实现方式中,所述N个分配粒度的存储空间是独立的,并不存在上述实现方式中的关系。如图5所示,存储设备的存储空间中包括分配粒度Qn的可分配存储空间,分配粒度Qn-1的可分配存储空间以及分配粒度Qn-2的可分配存储空间,其中,分配粒度Qn,分配粒度Qn-1和分配粒度Qn-2的可分配存储空间均从存储设备总的存储空间中分配。在此种实现方式下,步骤S103具体包括图3中示出的步骤S1031,步骤S1032和步骤S1033’和步骤S1034’,此处不再赘述,另外,分配粒度Qn,分配粒度Qn-1和分配粒度Qn-2的可分配存储空间之和可以为一个LUN对应的存储空间,也可以为一个LUN中的部分存储空间,若分配粒度Qn,分配粒度Qn-1和分配粒度Qn-2的可分配存储空间之和为一个LUN对应的部分存储空间时,则在该存储设备在确定所述L1小于所述M时,确定所述未分配存储空间大小L1以及所述选择的分配粒度的可分配存储空间中已回收存储空间大小L2之和小于M时,该存储设备可在该LUN所对应的存储空间中给所述选择的分配粒度再分配可分配的存储空间。In another possible implementation manner of the embodiment of the present invention, the storage spaces of the N allocation granularities are independent, and the relationship in the foregoing implementation manner does not exist. As shown in FIG. 5, the storage space of the storage device includes an allocatable storage space of the allocation granularity Q n , an allocatable storage space of the allocation granularity Q n-1 , and an allocatable storage space of the allocation granularity Q n-2 , wherein the allocation The allocatable storage space of the granularity Q n , the allocation granularity Q n-1 and the allocation granularity Q n-2 are all allocated from the total storage space of the storage device. In this implementation, step S103 specifically includes step S1031, step S1032 and step S1033' and step S1034' shown in FIG. 3, and details are not described herein again. In addition, the granularity Q n is allocated and the granularity Q n-1 is allocated. The sum of the allocable storage space of the allocation granularity Q n-2 may be a storage space corresponding to one LUN, or may be a partial storage space in one LUN. If the granularity Q n is allocated, the allocation granularity Q n-1 and the allocation granularity Q When the sum of the assignable storage spaces of n-2 is a partial storage space corresponding to one LUN, when the storage device determines that the L1 is smaller than the M, determining the unallocated storage space size L1 and the selected When the sum of the reclaimed storage space sizes L2 in the allotable storage space of the allocation granularity is less than M, the storage device may reallocate the allocable storage space to the selected allocation granularity in the storage space corresponding to the LUN.
本发明实施例还提供一种存储设备60,用于执行上述方法实施例提供的一种存储空间的分配方法,其中,该存储设备60的存储空间预设有N个不同的分配粒度,所述分配粒度作为分配所述存储空间的单位,且每个分配粒度具有可分配存储空间,其中,N是大于1的正整数。如图6所示,所述存储 设备60包括:The embodiment of the present invention further provides a storage device 60, which is configured to perform a storage space allocation method provided by the foregoing method embodiment, where the storage space of the storage device 60 is pre-set with N different allocation granularities. The allocation granularity is a unit for allocating the storage space, and each allocation granularity has an allocatable storage space, where N is a positive integer greater than one. As shown in Figure 6, the storage Device 60 includes:
接收单元61,用于接收数据写请求,所述数据写请求包括待写入数据;The receiving unit 61 is configured to receive a data write request, where the data write request includes data to be written;
确定单元62,用于根据所述待写入数据的大小以及所述预设的分配粒度,从所述N个不同的分配粒度中为所述数据写请求选择一个分配存储空间的分配粒度;a determining unit 62, configured to select, according to the size of the data to be written and the preset allocation granularity, an allocation granularity of the allocated storage space for the data write request from the N different allocation granularities;
分配单元63,用于以所述选择的分配粒度为所述数据写请求分配存储空间。The allocating unit 63 is configured to allocate a storage space for the data write request with the selected allocation granularity.
可选地,所述分配单元63具体用于:Optionally, the allocating unit 63 is specifically configured to:
比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
确定L1不小于M时,从所述未分配存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,k为不小于1的正整数,Qn是所述选择的分配粒度,M≤kQn<min{L1,M+Qn}。When it is determined that L 1 is not less than M, a storage space of size kQ n is allocated for the data write request from the unallocated storage space, where k is a positive integer not less than 1, and Q n is the selected allocation Particle size, M ≤ kQ n <min{L 1 , M+Q n }.
可选地,所述分配单元63具体用于:Optionally, the allocating unit 63 is specifically configured to:
比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
确定L1小于M时,确定所述未分配存储空间大小L1以及所述选择的分配粒度的可分配存储空间中已回收存储空间大小L2之和不小于M;所述已回收存储空间是指所述选择的分配粒度的可分配空间中已被分配的存储空间,且写入其中的数据已被擦除后的存储空间;When it is determined that L 1 is less than M, the sum of the unallocated storage space size L 1 and the reclaimed storage space size L 2 in the allotable storage space of the selected allocation granularity is not less than M; the recycled storage space is Refers to the storage space that has been allocated in the allocatable space of the selected allocation granularity, and the storage space in which the data written therein has been erased;
从所述未分配存储空间以及所述已回收存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,M≤kQn<min{L1+L2,M+Qn}。Allocating a storage space of size kQ n for the data write request from the unallocated storage space and the recovered storage space, where M≤kQ n <min{L 1 +L 2 ,M+Q n } .
可选地,所述分配单元63具体用于:Optionally, the allocating unit 63 is specifically configured to:
比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
确定L1小于M时,识别与所述选择的分配粒度相邻的分配粒度,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度 分配可分配存储空间,其中,所述相邻的分配粒度Qn-1大于所述选择的分配粒度QnThe particle size distribution is determined that the allocation is smaller than L 1 M, identifying the selected allocation granularity adjacent allocation granularity, the selection of the particle size from an adjacent dispensing allocated storage space unallocated storage space may be allocated for storage Space, wherein the adjacent distribution granularity Q n-1 is greater than the selected distribution granularity Q n .
可选地,该存储设备60还包括释放单元64,该释放单元64用于,比较该相邻的分配粒度的未分配存储空间大小与第一阈值;确定该相邻的分配粒度的未分配存储空间大小小于所述第一阈值时,检测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间;确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,将所述至少一个连续地址空间释放至该相邻的分配粒度的可分配存储空间;所述分配单元63具体用于,从包括所述至少一个大小为Qn-1的连续地址空间的该相邻的分配粒度的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。Optionally, the storage device 60 further includes a release unit 64, configured to compare the unallocated storage space size of the adjacent allocation granularity with a first threshold; determine unallocated storage of the adjacent allocated granularity When the size of the space is smaller than the first threshold, detecting whether there is at least one contiguous address space of size Q n-1 in the reclaimed storage space of the allocatable storage space of the selected allocation granularity; determining the reclaimed storage When there is at least one contiguous address space of size Q n-1 in the space, the at least one contiguous address space is released to the contiguous storage granularity of the allocatable storage space; the allocating unit 63 is specifically configured to include particle size distribution of said at least one unallocated storage space Q n-1 consecutive address space adjacent to the particle size distribution for dispensing the selected storage space can be allocated.
可选地,所述分配单元63还用于,比较所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和与为所述选择的分配粒度预设的可分配存储空间配额;确定所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和不大于为所述选择的分配粒度预设可分配存储空间配额时,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。Optionally, the allocating unit 63 is further configured to compare a sum of the allotable storage space of the selected allocation granularity with the adjacent allocated granularity and an allocatable storage space quota preset for the selected allocated granularity. And determining, when the sum of the allotable storage space of the selected allocation granularity and the adjacent allocation granularity is not greater than the preset allocatable storage space quota for the selected allocation granularity, the assignable from the adjacent allocation granularity The unallocated storage space of the storage space allocates an allocatable storage space for the selected allocation granularity.
可选地,所述分配单元63还用于,比较所述选择的分配粒度的可分配存储空间中未分配存储空间的大小与第二阈值;当所述选择的分配粒度的可分配存储空间中未分配存储空间的大小小于所述第二阈值时,从与所述选择的分配粒度相邻的分配粒度的可分配存储空间中的未分配存储空间为所述选择的分配粒度增加可分配存储空间,其中,该相邻的分配粒度Qn-1大于所述选择的分配粒度QnOptionally, the allocating unit 63 is further configured to compare a size of the unallocated storage space in the allotable storage space of the selected allocation granularity with a second threshold; when the selected allocated granularity is in the allotable storage space When the size of the unallocated storage space is less than the second threshold, the unallocated storage space in the allotable storage space of the allocation granularity adjacent to the selected allocation granularity increases the allocatable storage space for the selected allocation granularity wherein the particle size distribution of adjacent Q n-1 is greater than the selected particle size distribution Q n.
可选地,所述释放单元64还用于,每隔预设时间,检测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间;确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,将所述至少一个大小为Qn-1的连续地址空间释放至与所述选 择的分配粒度相邻的分配粒度的可分配存储空间,该相邻的分配粒度Qn-1大于所述选择的分配粒度QnOptionally, the releasing unit 64 is further configured to detect, in the reclaimed storage space of the selectable storage space of the selected allocation granularity, at least one consecutive size of Q n-1 An address space; when it is determined that there is at least one contiguous address space of size Q n-1 in the reclaimed storage space, releasing the at least one contiguous address space of size Q n-1 to the selected allocation granularity the particle size distribution may be adjacent to allocate storage space adjacent to the particle size distribution Q n-1 is greater than the selected particle size distribution Q n.
值得说明的是,以上对存储设备功能单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如上述确定单元62和分配单元63可以划分为一处理单元。并且,上述各功能单元的物理实现也可以有多种实现方式,例如,上述确定单元62可以是一中央处理器,也可以是特定集成电路(Application Specific Integrated Circuit,ASIC)。It should be noted that the above division of the storage device functional unit is only a logical function division, and the actual implementation may have another division manner. For example, the determination unit 62 and the allocation unit 63 may be divided into a processing unit. The physical implementation of the above functional units may also be implemented in various manners. For example, the determining unit 62 may be a central processing unit or an application specific integrated circuit (ASIC).
另外,所属本领域的技术人员应该了解到,为描述的方便和简洁,上述描述的存储设备的各单元的具体工作过程,可以参照前述方法实施例中对应的过程,在此不再赘述。In addition, those skilled in the art should understand that, for the convenience and brevity of the description, the specific working process of each unit of the foregoing storage device may refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
采用上述存储设备,该存储设备对于不同数据大小的数据写请求,可以选择不同的分配粒度向该数据写请求分配存储空间,这样,针对每次写入该存储设备的数据量差异较大的情况,该存储设备可以选择与每次数据写入大小最接近的分配粒度分配存储空间,避免了单一的分配粒度可能造成的存储空间浪费或者元数据量过多的问题。The storage device is configured to allocate a storage space to the data write request by using a different allocation granularity for data write requests of different data sizes, so that the amount of data is different for each write to the storage device. The storage device can allocate storage space with the allocation granularity closest to the size of each data write, thereby avoiding the problem of waste of storage space or excessive amount of metadata caused by a single allocation granularity.
本发明实施例还提供另一种存储设备,如图7所示,包括:处理器(processor)71、通信接口(Communications Interface)72、存储器(memory)73、内存74和通信总线75;其中,所述处理器71、所述通信接口72、所述存储器73和所述内存74通过所述通信总线75完成相互间的通信。The embodiment of the present invention further provides another storage device, as shown in FIG. 7, including: a processor 71, a communication interface 72, a memory 73, a memory 74, and a communication bus 75; The processor 71, the communication interface 72, the memory 73, and the memory 74 complete communication with each other via the communication bus 75.
所述通信接口72,用于与外部设备进行通信。The communication interface 72 is configured to communicate with an external device.
所述存储器73,包括用于存储数据的存储空间。The memory 73 includes a storage space for storing data.
所述内存74,用于存放程序代码,所述程序代码为所述存储器中的存储空间预设有N个不同的分配粒度,所述分配粒度作为分配所述存储空间的单位,且每个分配粒度具有可分配存储空间,其中,N是大于1的正整数。The memory 74 is configured to store program code, where the program code is pre-set with N different allocation granularities for the storage space in the memory, where the allocation granularity is used as a unit for allocating the storage space, and each allocation The granularity has an allocatable storage space, where N is a positive integer greater than one.
所述处理器71用于执行所述内存74中的程序代码,以执行上述方法实施例提供的一种存储空间的分配方法,具体可参照上述方法实施例对图1,图3以及图4的详细描述,此处不再赘述。 The processor 71 is configured to execute the program code in the memory 74 to perform a method for allocating a storage space provided by the foregoing method embodiment. For details, refer to the method embodiment described above for FIG. 1 , FIG. 3 and FIG. Detailed description will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided by the present application, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
上述以软件功能单元的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The above-described integrated unit implemented in the form of a software functional unit can be stored in a computer readable storage medium. The software functional units described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform portions of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes. .
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。While the preferred embodiment of the invention has been described, it will be understood that Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and the modifications and
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。 It is apparent that those skilled in the art can make various modifications and variations to the invention without departing from the spirit and scope of the invention. Thus, it is intended that the present invention cover the modifications and modifications of the invention

Claims (17)

  1. 一种存储空间的分配方法,应用于存储设备,其特征在于,为所述存储设备的存储空间预设N个不同的分配粒度,所述分配粒度作为分配所述存储空间的单位,且每个分配粒度具有可分配存储空间,其中,N是大于1的正整数;所述方法包括:A storage space allocation method is applied to a storage device, wherein N different distribution granularities are preset for a storage space of the storage device, where the allocation granularity is used as a unit for allocating the storage space, and each The allocation granularity has an allocatable storage space, where N is a positive integer greater than one; the method includes:
    所述存储设备接收数据写请求,所述数据写请求包括待写入数据;The storage device receives a data write request, where the data write request includes data to be written;
    根据所述待写入数据的大小以及所述预设的分配粒度,从所述N个不同的分配粒度中为所述数据写请求选择一个分配存储空间的分配粒度;并And selecting, according to the size of the data to be written and the preset allocation granularity, an allocation granularity of the allocated storage space for the data write request from the N different allocation granularities;
    以所述选择的分配粒度为所述数据写请求分配存储空间。Allocating storage space for the data write request with the selected allocation granularity.
  2. 根据权利要求1所述的方法,其特征在于,所述以所述选择的分配粒度为所述数据写请求分配存储空间,包括:The method according to claim 1, wherein the allocating storage space for the data write request by the selected allocation granularity comprises:
    比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
    确定L1不小于M时,从所述未分配存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,k为不小于1的正整数,Qn是所述选择的分配粒度,M≤kQn<min{L1,M+Qn}。When it is determined that L 1 is not less than M, a storage space of size kQ n is allocated for the data write request from the unallocated storage space, where k is a positive integer not less than 1, and Q n is the selected allocation Particle size, M ≤ kQ n <min{L 1 , M+Q n }.
  3. 根据权利要求1所述的方法,其特征在于,所述以所述选择的分配粒度为所述数据写请求分配存储空间,包括:The method according to claim 1, wherein the allocating storage space for the data write request by the selected allocation granularity comprises:
    比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
    确定L1小于M时,确定所述未分配存储空间大小L1以及所述选择的分配粒度的可分配存储空间中已回收存储空间大小L2之和不小于所述M;所述已回收存储空间是指所述选择的分配粒度的可分配空间中已被分配的存储空间中写入的数据已被擦除的存储空间;When it is determined that L 1 is less than M, determining that the unallocated storage space size L 1 and the selected allocated storage granularity of the allocated storage space size L 2 are not smaller than the M; the recycled storage Space refers to a storage space in which data written in a storage space that has been allocated in the allocatable space of the selected allocation granularity has been erased;
    从所述未分配存储空间以及所述已回收存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,M≤kQn<min{L1+L2,M+Qn}。 Allocating a storage space of size kQ n for the data write request from the unallocated storage space and the recovered storage space, where M≤kQ n <min{L 1 +L 2 ,M+Q n } .
  4. 根据权利要求1所述的方法,其特征在于,还包括:The method of claim 1 further comprising:
    比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
    确定L1小于M时,识别与所述选择的分配粒度相邻的分配粒度,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间,其中,所述相邻的分配粒度Qn-1大于所述选择的分配粒度QnWhen it is determined that L 1 is less than M, identifying an allocation granularity adjacent to the selected allocation granularity, and allocating allocateable storage for the selected allocated granularity from the unallocated storage space of the adjacent allocated granularity of the allotable storage space Space, wherein the adjacent distribution granularity Q n-1 is greater than the selected distribution granularity Q n .
  5. 根据权利要求4所述的方法,其特征在于,所述从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间包括:The method according to claim 4, wherein the allocating the allocatable storage space for the selected allocation granularity from the unallocated storage space of the adjacent allocated granularity of the allocatable storage space comprises:
    比较该相邻的分配粒度的未分配存储空间大小与第一阈值;Comparing the size of the unallocated storage space of the adjacent allocation granularity with a first threshold;
    确定该相邻的分配粒度的未分配存储空间大小小于所述第一阈值时,检测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间,所述已回收存储空间是指所述选择的分配粒度的可分配空间中已被分配的存储空间中写入的数据已被擦除的存储空间;And determining, when the unallocated storage space size of the adjacent allocation granularity is smaller than the first threshold, detecting whether at least one size is Q n-1 in the recovered storage space of the allocatable storage space of the selected allocation granularity. a contiguous address space, where the reclaimed storage space refers to a storage space in which the data written in the allocated storage space in the allocatable space of the selected allocation granularity has been erased;
    确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,将所述至少一个大小为Qn-1的连续地址空间释放至该相邻的分配粒度的可分配存储空间;Determining, when the at least one contiguous address space of size Q n-1 exists in the recovered storage space, releasing the at least one contiguous address space of size Q n-1 to the contiguous storage granularity of the allocatable storage space;
    从包括所述至少一个大小为Qn-1的连续地址空间的该相邻的分配粒度的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。An allocatable storage space is allocated for the selected allocation granularity from the unallocated storage space of the adjacent allocation granularity including the at least one consecutive address space of size Qn -1 .
  6. 根据权利要求4所述的方法,其特征在于,所述从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间,包括:The method according to claim 4, wherein the allocating the allocatable storage space for the selected allocation granularity from the unallocated storage space of the contiguous allocated granularity of the allocatable storage space comprises:
    比较所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和与为所述选择的分配粒度预设的可分配存储空间配额;Comparing the sum of the assignable storage space of the selected allocation granularity with the adjacent allocation granularity and the allocatable storage space quota preset for the selected allocation granularity;
    确定所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和不 大于为所述选择的分配粒度预设可分配存储空间配额时,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。Determining the sum of the assignable storage space of the selected allocation granularity and the adjacent allocation granularity When the allocateable storage space quota is preset to be greater than the selected allocation granularity, the allocateable storage space is allocated for the selected allocation granularity from the unallocated storage space of the adjacent allocated granularity of the allotable storage space.
  7. 根据权利要求1至3任一项所述的方法,其特征在于,还包括:The method according to any one of claims 1 to 3, further comprising:
    比较所述选择的分配粒度的可分配存储空间中未分配存储空间的大小与第二阈值;Comparing a size of the unallocated storage space in the allotable storage space of the selected allocation granularity with a second threshold;
    当所述选择的分配粒度的可分配存储空间中未分配存储空间的大小小于所述第二阈值时,从与所述选择的分配粒度相邻的分配粒度的可分配存储空间中的未分配存储空间为所述选择的分配粒度分配可分配存储空间,其中,该相邻的分配粒度Qn-1大于所述选择的分配粒度QnUnallocated storage in an allocatable storage space of an allocation granularity adjacent to the selected allocation granularity when a size of unallocated storage space in the allocatable storage space of the selected allocation granularity is less than the second threshold the selection of the particle size distribution may be allocated to allocate storage space, wherein the particle size distribution of adjacent Q n-1 is greater than the selected particle size distribution Q n.
  8. 根据权利要求1至3任一项所述的方法,其特征在于,还包括:The method according to any one of claims 1 to 3, further comprising:
    每隔预设时间,检测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间;Having a minimum of at least one consecutive address space of size Q n-1 in the recovered storage space of the allocatable storage space of the selected allocation granularity is detected every preset time;
    确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,将所述至少一个大小为Qn-1的连续地址空间释放至与所述选择的分配粒度相邻的分配粒度的可分配存储空间,该相邻的分配粒度Qn-1大于所述选择的分配粒度QnDetermining the recovered storage space size is at least a contiguous address space Q n-1, the size of the release to at least one adjacent particle size distribution Q is selected contiguous address space of n-1 the particle size distribution may be allocated storage space, adjacent to the particle size distribution Q n-1 is greater than the selected particle size distribution Q n.
  9. 一种存储设备,其特征在于,所述存储设备的存储空间预设有N个不同的分配粒度,所述分配粒度作为分配所述存储空间的单位,且每个分配粒度具有可分配存储空间,其中,N是大于1的正整数;所述存储设备包括:A storage device, wherein a storage space of the storage device is pre-set with N different allocation granularities, where the allocation granularity is used as a unit for allocating the storage space, and each allocated granularity has an allocatable storage space. Where N is a positive integer greater than 1; the storage device includes:
    接收单元,用于接收数据写请求,所述数据写请求包括待写入数据;a receiving unit, configured to receive a data write request, where the data write request includes data to be written;
    确定单元,用于根据所述待写入数据的大小以及所述预设的分配粒度,从所述N个不同的分配粒度中为所述数据写请求选择一个分配存储空间的分配粒度;a determining unit, configured to select, according to the size of the data to be written and the preset allocation granularity, an allocation granularity of the allocated storage space for the data write request from the N different allocation granularities;
    分配单元,用于以所述选择的分配粒度为所述数据写请求分配存储空间。And an allocating unit, configured to allocate a storage space for the data write request by using the selected allocation granularity.
  10. 根据权利要求9所述的存储设备,其特征在于,所述分配单元具体用于: The storage device according to claim 9, wherein the allocating unit is specifically configured to:
    比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
    确定L1不小于M时,从所述未分配存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,k为不小于1的正整数,Qn是所述选择的分配粒度,M≤kQn<min{L1,M+Qn}。When it is determined that L 1 is not less than M, a storage space of size kQ n is allocated for the data write request from the unallocated storage space, where k is a positive integer not less than 1, and Q n is the selected allocation Particle size, M ≤ kQ n <min{L 1 , M+Q n }.
  11. 根据权利要求9所述的存储设备,其特征在于,所述分配单元具体用于:The storage device according to claim 9, wherein the allocating unit is specifically configured to:
    比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
    确定L1小于M时,确定所述未分配存储空间大小L1以及所述选择的分配粒度的可分配存储空间中已回收存储空间大小L2之和不小于M;所述已回收存储空间是指所述选择的分配粒度的可分配空间中已被分配的存储空间,且写入其中的数据已被擦除后的存储空间;When it is determined that L 1 is less than M, the sum of the unallocated storage space size L 1 and the reclaimed storage space size L 2 in the allotable storage space of the selected allocation granularity is not less than M; the recycled storage space is Refers to the storage space that has been allocated in the allocatable space of the selected allocation granularity, and the storage space in which the data written therein has been erased;
    从所述未分配存储空间以及所述已回收存储空间中为所述数据写请求分配大小为kQn的存储空间,其中,M≤kQn<{L1+L2,M+Qn}。Unallocated storage space and the storage space for the recovered data write request to the allocated size of the storage space from the kQ n, wherein, M≤kQ n <{L 1 + L 2, M + Q n}.
  12. 根据权利要求9所述的存储设备,其特征在于,所述分配单元具体用于:The storage device according to claim 9, wherein the allocating unit is specifically configured to:
    比较所述待写入数据的大小M与所述选择的分配粒度的可分配存储空间中未分配存储空间的大小L1Comparing the size of the data to be written to the selected M and particle size distribution may be allocated storage space size of the memory space unallocated L 1;
    确定L1小于M时,识别与所述选择的分配粒度相邻的分配粒度,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间,其中,所述相邻的分配粒度Qn-1大于所述选择的分配粒度QnWhen it is determined that L 1 is less than M, identifying an allocation granularity adjacent to the selected allocation granularity, and allocating allocateable storage for the selected allocated granularity from the unallocated storage space of the adjacent allocated granularity of the allotable storage space Space, wherein the adjacent distribution granularity Q n-1 is greater than the selected distribution granularity Q n .
  13. 根据权利要求12所述的存储设备,其特征在于,还包括释放单元,所述释放单元用于:The storage device according to claim 12, further comprising a release unit, wherein the release unit is configured to:
    比较该相邻的分配粒度的未分配存储空间大小与第一阈值;Comparing the size of the unallocated storage space of the adjacent allocation granularity with a first threshold;
    确定该相邻的分配粒度的未分配存储空间大小小于所述第一阈值时,检 测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间;And determining, when the unallocated storage space size of the adjacent allocation granularity is smaller than the first threshold, detecting whether at least one size of the reclaimed storage space of the allocated storage granularity of the selected allocation granularity is Q n-1 Continuous address space;
    确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,将所述至少一个连续地址空间释放至该相邻的分配粒度的可分配存储空间;Determining, when the at least one contiguous address space of size Q n-1 exists in the reclaimed storage space, releasing the at least one contiguous address space to the contiguous storage granularity of the contiguous storage space;
    所述分配单元具体用于,从包括所述至少一个大小为Qn-1的连续地址空间的该相邻的分配粒度的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。The allocating unit is configured to allocate an allocatable storage space for the selected allocation granularity from an unallocated storage space of the adjacent allocation granularity including the at least one consecutive address space of size Qn -1 .
  14. 根据权利要求12所述的存储设备,其特征在于,所述分配单元还用于,The storage device according to claim 12, wherein said allocating unit is further configured to:
    比较所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和与为所述选择的分配粒度预设的可分配存储空间配额;Comparing the sum of the assignable storage space of the selected allocation granularity with the adjacent allocation granularity and the allocatable storage space quota preset for the selected allocation granularity;
    确定所述选择的分配粒度的可分配存储空间与该相邻的分配粒度之和不大于为所述选择的分配粒度预设可分配存储空间配额时,从该相邻的分配粒度的可分配存储空间的未分配存储空间中为所述选择的分配粒度分配可分配存储空间。Determining the allocatable storage from the adjacent allocation granularity when the sum of the allotable storage space of the selected allocation granularity and the adjacent allocation granularity is not greater than the preset allocatable storage space quota for the selected allocation granularity The allocateable storage space is allocated for the selected allocation granularity in the unallocated storage space of the space.
  15. 根据权利要求9至11任一项所述的存储设备,其特征在于,所述分配单元还用于:The storage device according to any one of claims 9 to 11, wherein the allocating unit is further configured to:
    比较所述选择的分配粒度的可分配存储空间中未分配存储空间的大小与第二阈值;Comparing a size of the unallocated storage space in the allotable storage space of the selected allocation granularity with a second threshold;
    当所述选择的分配粒度的可分配存储空间中未分配存储空间的大小小于所述第二阈值时,从与所述选择的分配粒度相邻的分配粒度的可分配存储空间中的未分配存储空间为所述选择的分配粒度增加可分配存储空间,其中,该相邻的分配粒度Qn-1大于所述选择的分配粒度QnUnallocated storage in an allocatable storage space of an allocation granularity adjacent to the selected allocation granularity when a size of unallocated storage space in the allocatable storage space of the selected allocation granularity is less than the second threshold allocating space for the selected particle size increase the allocated storage space, wherein the particle size distribution of adjacent Q n-1 is greater than the selected particle size distribution Q n.
  16. 根据权利要求9至11任一项所述的存储设备,其特征在于,所述存储设备包括的释放单元,用于:The storage device according to any one of claims 9 to 11, wherein the storage device comprises a release unit, configured to:
    每隔预设时间,检测所述选择的分配粒度的可分配存储空间的已回收存储空间中,是否存在至少一个大小为Qn-1的连续地址空间; Having a minimum of at least one consecutive address space of size Q n-1 in the recovered storage space of the allocatable storage space of the selected allocation granularity is detected every preset time;
    确定所述已回收存储空间中存在至少一个大小为Qn-1的连续地址空间时,将所述至少一个大小为Qn-1的连续地址空间释放至与所述选择的分配粒度相邻的分配粒度的可分配存储空间,该相邻的分配粒度Qn-1大于所述选择的分配粒度QnDetermining, when the at least one consecutive address space of size Q n-1 exists in the recovered storage space, releasing the at least one consecutive address space of size Q n-1 to be adjacent to the selected allocation granularity the particle size distribution may be allocated storage space, adjacent to the particle size distribution Q n-1 is greater than the selected particle size distribution Q n.
  17. 一种存储设备,其特征在于,包括:处理器,存储器,内存,通信接口和通信总线,其中,所述处理器,所述存储器,所述内存和所述通信接口通过所述通信总线完成相互间的通信;A storage device, comprising: a processor, a memory, a memory, a communication interface, and a communication bus, wherein the processor, the memory, the memory, and the communication interface complete each other through the communication bus Communication between
    所述存储器包括用于存储数据的存储空间;The memory includes a storage space for storing data;
    所述内存用于存放程序代码,所述程序代码为所述存储器中的存储空间预设有N个不同的分配粒度,所述分配粒度作为分配所述存储空间的单位,且每个分配粒度具有可分配存储空间,其中,N是大于1的正整数;The memory is configured to store program code, where the program code is pre-set with N different allocation granularities for the storage space in the memory, where the allocation granularity is used as a unit for allocating the storage space, and each allocation granularity has Allocated storage space, where N is a positive integer greater than one;
    所述处理器执行所述内存中的程序代码,以使所述处理器执行权利要求1-9中任意一项所述的方法。 The processor executes the program code in the memory to cause the processor to perform the method of any of claims 1-9.
PCT/CN2015/098108 2015-12-21 2015-12-21 Storage space allocation method, and storage device WO2017107015A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201580056639.4A CN107533435B (en) 2015-12-21 2015-12-21 Storage space allocation method and storage equipment
PCT/CN2015/098108 WO2017107015A1 (en) 2015-12-21 2015-12-21 Storage space allocation method, and storage device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/098108 WO2017107015A1 (en) 2015-12-21 2015-12-21 Storage space allocation method, and storage device

Publications (1)

Publication Number Publication Date
WO2017107015A1 true WO2017107015A1 (en) 2017-06-29

Family

ID=59088810

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/098108 WO2017107015A1 (en) 2015-12-21 2015-12-21 Storage space allocation method, and storage device

Country Status (2)

Country Link
CN (1) CN107533435B (en)
WO (1) WO2017107015A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113688062A (en) * 2020-05-18 2021-11-23 北京市商汤科技开发有限公司 Method for storing data and related product
CN114115738A (en) * 2021-11-23 2022-03-01 烽火通信科技股份有限公司 Disk space management method and system based on distributed storage
CN114442927A (en) * 2021-12-22 2022-05-06 天翼云科技有限公司 Data storage space management method and device

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109669640B (en) * 2018-12-24 2023-05-23 浙江大华技术股份有限公司 Data storage method, device, electronic equipment and medium
CN110221781B (en) * 2019-06-04 2022-08-23 Oppo广东移动通信有限公司 Manufacturing method and device of disk fragments, storage medium and intelligent terminal
CN110688345A (en) * 2019-09-26 2020-01-14 重庆大学 Multi-granularity structured space management mechanism of memory file system
CN113485969B (en) * 2021-05-31 2022-05-03 荣耀终端有限公司 Storage fragmentation method and device, terminal and computer storage medium
CN113660338A (en) * 2021-08-17 2021-11-16 中国农业银行股份有限公司 Data interaction method, device and system and server

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101976223A (en) * 2010-10-09 2011-02-16 成都市华为赛门铁克科技有限公司 Thin provisioning method and device
CN102650931A (en) * 2012-04-01 2012-08-29 华为技术有限公司 Method and system for writing data
US20150169244A1 (en) * 2013-09-27 2015-06-18 Avalanche Technology, Inc. Storage processor managing nvme logically addressed solid state disk array

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8127096B1 (en) * 2007-07-19 2012-02-28 American Megatrends, Inc. High capacity thin provisioned storage server with advanced snapshot mechanism
CN102122284B (en) * 2010-01-08 2014-07-02 腾讯科技(深圳)有限公司 Compound document storage and read-write method and compound document storage and read-write device
CN104915146A (en) * 2014-03-14 2015-09-16 中兴通讯股份有限公司 Resource distribution method and device based on automatic thin provisioning

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101976223A (en) * 2010-10-09 2011-02-16 成都市华为赛门铁克科技有限公司 Thin provisioning method and device
CN102650931A (en) * 2012-04-01 2012-08-29 华为技术有限公司 Method and system for writing data
US20150169244A1 (en) * 2013-09-27 2015-06-18 Avalanche Technology, Inc. Storage processor managing nvme logically addressed solid state disk array

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113688062A (en) * 2020-05-18 2021-11-23 北京市商汤科技开发有限公司 Method for storing data and related product
CN114115738A (en) * 2021-11-23 2022-03-01 烽火通信科技股份有限公司 Disk space management method and system based on distributed storage
CN114115738B (en) * 2021-11-23 2023-12-26 烽火通信科技股份有限公司 Disk space management method and system based on distributed storage
CN114442927A (en) * 2021-12-22 2022-05-06 天翼云科技有限公司 Data storage space management method and device
CN114442927B (en) * 2021-12-22 2023-11-03 天翼云科技有限公司 Management method and device for data storage space

Also Published As

Publication number Publication date
CN107533435B (en) 2020-04-28
CN107533435A (en) 2018-01-02

Similar Documents

Publication Publication Date Title
WO2017107015A1 (en) Storage space allocation method, and storage device
CN110663019B (en) File system for Shingled Magnetic Recording (SMR)
EP3171277B1 (en) Method for managing files, distributed storage system and management node
CN110612511B (en) Selectively storing data into allocation regions using streams
US9459806B2 (en) Combining virtual mapping metadata and physical space mapping metadata
US9329792B2 (en) Storage thin provisioning and space reclamation
US8751547B2 (en) Multiple file system and/or multi-host single instance store techniques
WO2013004136A1 (en) Distributed storage method, device and system
JP7467593B2 (en) Resource allocation method, storage device, and storage system - Patents.com
CN109144406B (en) Metadata storage method, system and storage medium in distributed storage system
WO2019001020A1 (en) Storage space arrangement method, apparatus, and system based on distributed system
US20240086092A1 (en) Method for managing namespaces in a storage device and storage device employing the same
CN112631520A (en) Distributed block storage system, method, apparatus, device, and medium
US20160364268A1 (en) Computer system, management computer, and management method
US10228885B2 (en) Deallocating portions of data storage based on notifications of invalid data
US9606909B1 (en) Deallocating portions of provisioned data storage based on defined bit patterns indicative of invalid data
WO2023124423A1 (en) Storage space allocation method and apparatus, and terminal device and storage medium
CN104426965A (en) Self-management storage method and system
CN114047886A (en) NVME command processing method, system, electronic equipment and storage medium
US10168911B1 (en) Defragmentation of persistent main memory
US11144445B1 (en) Use of compression domains that are more granular than storage allocation units
US20200034445A1 (en) Techniques for limiting the maximum storage consumed by a file system without shrinking an underlying volume
US11886730B2 (en) Compression ratio-aware data deduplication

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: 15911015

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: 15911015

Country of ref document: EP

Kind code of ref document: A1