WO2020000734A1 - 存储对象的空间管理方法、装置、计算机装置及存储介质 - Google Patents
存储对象的空间管理方法、装置、计算机装置及存储介质 Download PDFInfo
- Publication number
- WO2020000734A1 WO2020000734A1 PCT/CN2018/108126 CN2018108126W WO2020000734A1 WO 2020000734 A1 WO2020000734 A1 WO 2020000734A1 CN 2018108126 W CN2018108126 W CN 2018108126W WO 2020000734 A1 WO2020000734 A1 WO 2020000734A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- storage
- space
- target
- stored
- storage unit
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0604—Improving or facilitating administration, e.g. storage management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/0644—Management of space entities, e.g. partitions, extents, pools
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
Definitions
- the present application relates to the field of storage technology, and in particular, to a method, a device, a computer device, and a storage medium for allocating a storage object.
- This application provides a space management method for a storage object.
- the method includes:
- This application also provides a space management device for storing objects, where the device includes:
- a first obtaining module configured to receive a space management instruction and obtain a target storage space managed by the space management instruction
- a second acquisition module configured to acquire a stored object in the target storage space, a storage unit of the stored object, and an idle storage unit;
- a saving module configured to save the stored object, a storage unit of the stored object, and the idle storage unit in a key-value database
- An allocation module is configured to allocate a storage space for the newly added storage object according to the idle storage unit if an instruction for allocating a storage space for the newly added storage object is received.
- the present application also provides a computer device including a memory and a processor, where the memory is configured to store at least one instruction, and the processor is configured to execute the at least one instruction to implement the storage described in any embodiment.
- a computer device including a memory and a processor, where the memory is configured to store at least one instruction, and the processor is configured to execute the at least one instruction to implement the storage described in any embodiment.
- Object space management method Object space management method.
- the present application also provides a non-volatile readable storage medium, characterized in that the non-volatile readable storage medium stores at least one instruction, which is implemented in any embodiment when the at least one instruction is executed by a processor.
- the space management method for a storage object is also provided.
- the present application obtains a target storage space managed by the space management instruction by receiving a space management instruction, and acquires a stored object in the target storage space, a storage unit of the stored object, and free space.
- a storage unit storing the stored object, the storage unit of the stored object, and the free storage unit in a key-value database; if an instruction to allocate storage space for a new storage object is received, according to the free storage unit Allocate storage space for the newly added storage object. Because the storage objects in the target storage space are stored in the key-value database, because the key-value database has the characteristics of rapid search, the storage space information of the stored objects can be quickly obtained, and the storage space information of the storage objects can be improved. The purpose of speed.
- the free storage units in the target storage space can be quickly obtained, so when the storage space is allocated, the storage space can be allocated quickly and accurately, and the purpose of realizing the storage space allocation of the newly added storage objects in time is achieved.
- this application does not need to record the storage space information of the storage object in the memory or hard disk, does not occupy too much memory, and avoids reducing system performance.
- FIG. 1 is a flowchart of a space management method for a storage object according to an embodiment of the present application
- FIG. 2 is a functional block diagram of a storage object space management apparatus according to an embodiment of the present application.
- FIG. 3 is a schematic structural diagram of a computer device according to a preferred embodiment of a method for implementing space management of a storage object according to the present application.
- FIG. 1 is a flowchart of a space management method for a storage object according to an embodiment of the present application. According to different requirements, the sequence of steps in this flowchart can be changed, and some steps can be omitted.
- managing the storage objects includes, but is not limited to, storing storage space information (also referred to as address space information) of the storage objects and allocating storage space for the storage objects.
- the target storage space is a virtual storage space or a physical storage space where data can be stored.
- the target storage space may be one or more disks.
- S12 Acquire a stored object in the target storage space, a storage unit of the stored object, and an idle storage unit.
- obtaining the stored object in the target storage space may be obtaining the name of the stored object in the target storage space, or information such as the size of the stored object.
- the obtaining the storage space of the stored object may specifically be obtaining a storage address of the stored object stored in the target storage space.
- the above-mentioned free storage unit is a storage unit in which no storage object is stored in the target storage space.
- Obtaining the free storage unit may specifically be obtaining an address of a storage unit in the target storage space that does not store a storage object and can perform object storage.
- a target storage space can be divided into several storage units, and a stored object can occupy one or more storage units according to its size.
- the acquiring a stored object in the target storage space, a storage unit of the stored object, and an idle storage unit includes:
- the storage unit is a storage unit included in the target storage space.
- the above number may be a number in the form of numbers, letters, and the like, and is used to identify each storage unit.
- the storage units included in the target storage space are numbered, the stored objects in the target storage space, the storage unit numbers of the stored objects, and the numbers of the free storage units are obtained.
- the storage units in the target storage space are divided in the following manner:
- a basic unit that performs space management according to the target storage space divides the target storage space into a plurality of storage units.
- the size of the foregoing acquisition target storage space may specifically be the total capacity of the acquisition target storage space.
- the basic unit for performing space management of the target storage space may specifically be a minimum operation unit when performing operations such as allocation and storage on the target storage space.
- the basic unit for performing space management of the target storage space may be a preset unit.
- the basic unit for performing space management of the target storage space is 1 MB.
- the above-mentioned basic unit for space management according to the target storage space divides the target storage space into several storage units. Specifically, the target storage space is divided into several storage units, and the size of each storage unit is equal to the basic unit of the target storage space for space management. .
- the target storage space is a disk with a size of 1GB. If the basic unit for space management of the disk is 1MB, the disk is divided into 1024 storage units.
- the target storage space is a disk with a size of 500MB. If the basic unit of the disk for space storage is 5MB, the disk is divided into 100 storage units.
- the numbering the storage units included in the target storage space may be assigning a number to each of the divided storage units.
- the basic unit for determining the target storage space for space management includes:
- a basic unit for space management of the target storage space is determined according to a size of a target storage object of the target storage space.
- the above target storage object may be a storage object to be stored in the target storage space.
- the basic unit of the target storage space for space management may be determined as 10M.
- the basic unit is divided according to the size of the target storage object of the target storage space, and the division of the basic unit for space management of the target storage space is prevented from being too large or too small, which is conducive to space management.
- a key-value database is also called a kv (key-value) storage database.
- the kv database is a non-relational database.
- the data in the key-value database is organized, indexed, and stored in the form of key-value pairs.
- the object name of the stored object and the storage address of the stored object can be recorded in the key-value database.
- the key-value database is used for storage, which conforms to the organization form of the data to be saved. After storing through the kv database, you can also quickly search from the kv database.
- the key-value database is used to save the stored objects in the target storage space, the storage units of the stored objects, and the free storage units. There is no need to record in memory. It releases more resources for memory and does not need to go to memory frequently. Query in the system, which improves the performance of the system. In addition, according to the characteristics of data stored in the key-value database and the characteristics of fast search, the information in the key-value database can be quickly accessed, so that which storage units in the target storage space are occupied and which storage units are not occupied can be quickly obtained.
- the key-value database is LevelDB or RocksDB.
- LevelDB is an open source key-value database, so it is easier to obtain in practical applications.
- Using LevelDB has the advantages of low cost and high efficiency.
- LevelDB both key and value can be byte arrays of any length. And, it can be stored in the dictionary order of keys, or in other custom order. In the LevelDB database, you can also quickly search for data.
- both key and value can be byte arrays of any length.
- RocksDB supports efficient search and range search, supports high load random read, high load update operation, or a combination of the two. Therefore, using RocksDB can support fast reading and writing of storage space information in the target storage space.
- step S12 obtains a stored object in the target storage space, a storage unit of the stored object, and an idle storage unit
- the method includes: numbering the storage units included in the target storage space; and acquiring the target storage space. The number of stored objects in the storage, the number of storage units of the stored objects, and the number of free storage units;
- step S13 storing the stored object, the storage unit of the stored object, and the idle storage unit in a key-value database includes:
- the stored object, the number of the storage unit of the stored object, and the number of the free storage unit are stored in a key-value database.
- the object name of the stored object is a
- the number of the storage unit occupied by a is (1,5,8)
- a and the number of the storage unit occupied by it are stored in the key-value in the form of key-value In the database, specifically, it can be saved as a-> (1,5,8) in the key-value database.
- the storage objects of the storage units storing other numbers are empty.
- bitmap can also be saved in the kv database, and whether or not each storage unit has stored a storage object can be recorded through the bitmap.
- a bitmap is a data structure.
- each bit can be set to 0 or 1 to indicate a meaning.
- a bitmap is saved in the kv database, where 0 indicates that the location is not occupied (that is, no object is stored), and 1 indicates that the location is occupied (that is, the object is stored).
- the newly added storage object is a storage object that is applied for storage in the target storage space.
- the information of the free storage unit (such as the number or address of the free storage unit) can be obtained directly from the key-value database, and There is no need to find which storage units are empty one by one.
- any free storage unit can be assigned to the new storage object.
- the newly added storage object and the storage unit allocated to it can be stored in a key-value database.
- an instruction to allocate storage space for the newly added storage object is triggered.
- the allocating storage space for the newly added storage object according to the idle storage unit includes:
- each storage unit may specifically be the size of a storage unit of a basic unit where the target storage space is space-managed. Therefore, based on the size of the newly added storage object, it is possible to calculate how many storage units are needed to store the newly added storage object.
- the size of the newly added storage object is 5MB and the size of each storage unit in the target storage is 1MB, then 5 storage units are required to store the new storage object, that is, the number of storage units to be stored is 5.
- consecutively-numbered free storage units can be allocated to newly added storage objects.
- the storage units with the numbers 20 to 25 can be allocated to the newly added storage objects for storage.
- allocating continuous storage units to newly added storage objects is beneficial to improving the efficiency of data storage and reading.
- the method further includes:
- the information of the released storage object is updated in the key value database.
- the release of the storage object includes removing the storage object from the current storage location and deleting the storage object from the target storage space.
- the object name of the stored object is a
- the number of the storage unit occupied by a is (1,5,8). If it is detected that the stored object a is released, a-> ( 1,5,8) Information deleted.
- the information in the key-value database is updated, so that the latest information is always stored in the key-value database, which is beneficial to improving the obtained target storage space.
- the authenticity of the information stored in it is beneficial to improving the obtained target storage space.
- the space management method for a storage object obtains a target storage space managed by the space management instruction by receiving a space management instruction; obtaining a stored object in the target storage space, a storage unit of the stored object, and Idle storage unit; storing the stored object, the storage unit of the stored object, and the idle storage unit in a key-value database; if an instruction to allocate storage space for a newly added storage object is received, according to the idle storage The unit allocates storage space for the newly added storage object. Because the storage objects in the target storage space are stored in the key-value database, because the key-value database has the characteristics of rapid search, the storage space information of the stored objects can be quickly obtained, and the storage space information of the storage objects can be improved. The purpose of speed.
- the free storage units in the target storage space can be quickly obtained, so when the storage space is allocated, the storage space can be allocated quickly and accurately, and the purpose of realizing the storage space allocation of the newly added storage objects in a timely manner is achieved.
- this application does not need to record the storage space information of the storage object in the memory or hard disk, does not occupy too much memory, and avoids reducing system performance.
- FIG. 2 is a functional module diagram of a storage object space management apparatus according to an embodiment of the present application.
- the space management device for storing objects includes a first acquisition module 210, a second acquisition module 220, a storage module 230, and an allocation module 240.
- the module referred to in the present application refers to a series of computer-readable instruction segments that can be executed by a processor of a computer device and can perform fixed functions, and is stored in a memory of the computer device. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
- the first obtaining module 210 is configured to receive a space management instruction and obtain a target storage space instructed to be managed by the space management instruction.
- the device described in this application can be used to manage storage objects in a storage space.
- managing the storage objects includes, but is not limited to, storing storage space information (also referred to as address space information) of the storage objects and allocating storage space for the storage objects.
- the target storage space is a virtual storage space or a physical storage space where data can be stored.
- the target storage space may be one or more disks.
- the second obtaining module 220 is configured to obtain a stored object in the target storage space, a storage unit of the stored object, and an idle storage unit.
- obtaining the stored object in the target storage space may be obtaining the name of the stored object in the target storage space, or information such as the size of the stored object.
- the obtaining the storage space of the stored object may specifically be obtaining a storage address of the stored object stored in the target storage space.
- the above-mentioned free storage unit is a storage unit in which no storage object is stored in the target storage space.
- Obtaining the free storage unit may specifically be obtaining an address of a storage unit in the target storage space that does not store a storage object and can perform object storage.
- a target storage space can be divided into several storage units, and a stored object can occupy one or more storage units according to its size.
- the second obtaining module is specifically configured to include: numbering storage units included in the target storage space; obtaining a stored object in the target storage space, the The number of the storage unit of the stored object and the number of the free storage unit;
- the storage unit is a storage unit included in the target storage space.
- the above number may be a number in the form of numbers, letters, and the like, and is used to identify each storage unit.
- the storage units included in the target storage space are numbered, the stored objects in the target storage space, the storage unit numbers of the stored objects, and the numbers of the free storage units are obtained.
- the apparatus further includes: a division module.
- the dividing module is used for dividing the storage unit in the target storage space.
- the division module can be used for:
- a basic unit that performs space management according to the target storage space divides the target storage space into a plurality of storage units.
- the size of the foregoing acquisition target storage space may specifically be the total capacity of the acquisition target storage space.
- the basic unit for performing space management of the target storage space may specifically be a minimum operation unit when performing operations such as allocation and storage on the target storage space.
- the basic unit for performing space management of the target storage space may be a preset unit.
- the basic unit for performing space management of the target storage space is 1 MB.
- the above-mentioned basic unit for space management according to the target storage space divides the target storage space into several storage units. Specifically, the target storage space is divided into several storage units, and the size of each storage unit is equal to the basic unit for the space management .
- the target storage space is a disk with a size of 1GB. If the basic unit for space management of the disk is 1MB, the disk is divided into 1024 storage units.
- the target storage space is a disk with a size of 500MB. If the basic unit of the disk for space storage is 5MB, the disk is divided into 100 storage units.
- the numbering the storage units included in the target storage space may be assigning a number to each of the divided storage units.
- the basic unit for determining the target storage space for space management by the dividing module may include:
- a basic unit for space management of the target storage space is determined according to a size of a target storage object of the target storage space.
- the above target storage object may be a storage object to be stored in the target storage space.
- the basic unit of the target storage space for space management may be determined as 10M.
- the basic unit is divided according to the size of the target storage object of the target storage space, and the division of the basic unit for space management of the target storage space is prevented from being too large or too small, which is conducive to space management.
- the saving module 230 is configured to save the stored object, a storage unit of the stored object, and the idle storage unit in a key-value database.
- a key-value database is also called a kv (key-value) storage database.
- the kv database is a non-relational database.
- the data in the key-value database is organized, indexed, and stored in the form of key-value pairs.
- the object name of the stored object and the storage address of the stored object can be recorded in the key-value database.
- the key-value database is used for storage, which conforms to the organization form of the data to be saved. After storing through the kv database, you can also quickly search from the kv database.
- the key-value database is used to save the stored objects in the target storage space, the storage units of the stored objects, and the free storage units. There is no need to record in memory. It releases more resources for memory and does not need to go to memory frequently. Query in the system, which improves the performance of the system. In addition, according to the characteristics of data stored in the key-value database and the characteristics of fast search, the information in the key-value database can be quickly accessed, so that which storage units in the target storage space are occupied and which storage units are not occupied can be quickly obtained.
- the key-value database is LevelDB or RocksDB.
- LevelDB is an open source key-value database, so it is easier to obtain in practical applications.
- Using LevelDB has the advantages of low cost and high efficiency.
- LevelDB both key and value can be byte arrays of any length. And, it can be stored in the dictionary order of keys, or in other custom order. In the LevelDB database, you can also quickly search for data.
- both key and value can be byte arrays of any length.
- RocksDB supports efficient search and range search, supports high load random read, high load update operation, or a combination of the two. Therefore, using RocksDB can support fast reading and writing of storage space information in the target storage space.
- the second acquiring module is specifically configured to: number the storage units included in the target storage space; acquire the stored objects in the target storage space, the storage unit numbers of the stored objects, and the free storage unit Numbering;
- the saving module 230 is specifically configured to save the stored object, the number of the storage unit of the stored object, and the number of the idle storage unit in a key-value database.
- the object name of the stored object is a
- the number of the storage unit occupied by a is (1,5,8)
- a and the number of the storage unit occupied by it are stored in the key-value in the form of key-value In the database, specifically, it can be saved as a-> (1,5,8) in the key-value database.
- the storage objects of the storage units storing other numbers are empty.
- bitmap can also be saved in the kv database, and whether or not each storage unit has stored a storage object can be recorded through the bitmap.
- a bitmap is a data structure.
- each bit can be set to 0 or 1 to indicate a meaning.
- a bitmap is saved in the kv database, where 0 indicates that the location is not occupied (that is, no object is stored), and 1 indicates that the location is occupied (that is, the object is stored).
- the allocation module 240 is configured to allocate a storage space for the newly added storage object according to the idle storage unit if an instruction for allocating a storage space for the newly added storage object is received.
- the newly added storage object is a storage object that is applied for storage in the target storage space.
- the information of the free storage unit (such as the number or address of the free storage unit) can be obtained directly from the key-value database, and There is no need to find which storage units are empty one by one.
- any free storage unit can be assigned to the new storage object.
- the newly added storage object and the storage unit allocated to it can be stored in a key-value database.
- an instruction to allocate storage space for the newly added storage object is triggered.
- the allocation module allocates storage space for the newly added storage object according to the idle storage unit, including:
- each storage unit may specifically be the size of a storage unit of a basic unit where the target storage space is space-managed. Therefore, based on the size of the newly added storage object, it is possible to calculate how many storage units are needed to store the newly added storage object.
- the size of the newly added storage object is 5MB and the size of each storage unit in the target storage is 1MB, then 5 storage units are required to store the new storage object, that is, the number of storage units to be stored is 5.
- consecutively-numbered free storage units can be allocated to newly added storage objects.
- the storage units with the numbers 20 to 25 can be allocated to the newly added storage objects for storage.
- allocating continuous storage units to newly added storage objects is beneficial to improving the efficiency of data storage and reading.
- the apparatus further includes an update module, and the update module is further configured to:
- the information of the released storage object is updated in the key value database.
- the release of the storage object includes removing the storage object from the current storage location and deleting the storage object from the target storage space.
- the object name of the stored object is a
- the number of the storage unit occupied by a is (1,5,8). If it is detected that the stored object a is released, a-> ( 1,5,8) Information deleted.
- the information in the key-value database is updated, so that the latest information is always stored in the key-value database, which is beneficial to improving the obtained target storage space.
- the authenticity of the information stored in it is beneficial to improving the obtained target storage space.
- the space management device for a storage object receives a space management instruction through a first acquisition module, and acquires a target storage space managed by the space management instruction.
- the second acquisition module acquires a stored object, a storage space in the target storage space.
- the storage unit and the free storage unit of the stored object are described; the storage module saves the stored object, the storage unit of the stored object, and the free storage unit in a key value database; if it receives an allocation for a new storage object According to the storage space instruction, the allocation module allocates storage space for the newly added storage object according to the free storage unit.
- the storage space information of the stored objects can be quickly obtained, and the storage space information of the storage objects can be improved.
- the purpose of speed the free storage units in the target storage space can be quickly obtained, so when the storage space is allocated, the storage space can be allocated quickly and accurately, and the purpose of realizing the storage space allocation of the newly added storage objects in a timely manner is achieved.
- this application does not need to record the storage space information of the storage object in the memory or hard disk, does not occupy too much memory, and avoids reducing system performance.
- the above integrated unit implemented in the form of a software functional module may be stored in a non-volatile readable storage medium.
- the software function module is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) or a processor to execute the methods described in the embodiments of the present application. Some steps.
- FIG. 3 is a schematic structural diagram of a computer device according to a preferred embodiment of a method for implementing space management of a storage object in the present application.
- the computer device includes at least one transmitting device 31, at least one memory 32, at least one processor 33, at least one receiving device 34, and at least one communication bus.
- the communication bus is used to implement connection and communication between these components.
- the computer device is a device capable of automatically performing numerical calculation and / or information processing in accordance with an instruction set or stored in advance.
- the hardware includes, but is not limited to, a microprocessor and an Application Specific Integrated Circuit (ASIC). , Programmable Gate Array (Field-Programmable Gate Array, FPGA), Digital Processor (Digital Signal Processor, DSP), Embedded Equipment, etc.
- the computer device may further include a network device and / or a user device.
- the network device includes, but is not limited to, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on Cloud Computing, where the cloud computing is distributed computing A super virtual computer consisting of a set of loosely coupled computers.
- the computer device may be, but is not limited to, any electronic product that can perform human-computer interaction with a user through a keyboard, a touch pad, or a voice control device, for example, a terminal such as a tablet computer, a smartphone, or a monitoring device.
- the network where the computer device is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), and the like.
- VPN Virtual Private Network
- the receiving device 34 and the sending device 31 may be wired sending ports, or may be wireless devices, for example, including an antenna device, for performing data communication with other devices.
- the memory 32 is configured to store program code.
- the memory 32 may be a circuit having a storage function in an integrated circuit without a physical object, such as a RAM (Random-Access Memory, Random Access Memory), a FIFO (First In First Out, FIFO) and the like.
- the memory 32 may also be a physical memory, such as a memory stick, a TF card (Trans-flash Card), a smart media card, a secure digital card, and a flash memory card. (flash card) and other storage devices.
- the processor 33 may include one or more microprocessors and digital processors.
- the processor 33 may call the program code stored in the memory 32 to perform related functions. For example, each unit described in FIG. 3 is a program code stored in the memory 32 and executed by the processor 33 to implement a space management method for a storage object.
- the processor 33 is also called a central processing unit (CPU, Central Processing Unit), which is a very large-scale integrated circuit, which is a computing core (Core) and a control core (Control Unit).
- CPU Central Processing Unit
- Core computing core
- Control Unit Control Unit
- the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the objective of the solution of this embodiment.
- each functional module in each embodiment of the present application may be integrated into one processing unit, or each unit may exist separately physically, or two or more units may be integrated into one unit.
- the integrated unit can be implemented in the form of hardware, or in the form of hardware plus software functional modules.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Human Computer Interaction (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
一种存储对象的空间管理方法、空间管理装置、计算机装置和存储介质,该方法包括:接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间(S11);获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元(S12);在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元(S13);若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元为所述新增存储对象分配存储空间(S14)。该方法可以提高获取存储对象的存储空间信息的速度,从而能够及时的对新增的存储对象进行存储空间分配。
Description
本申请要求于2018年06月28日提交中国专利局,申请号为201810689511.7发明名称为“存储对象的空间管理方法、装置、计算机装置及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及存储技术领域,尤其涉及一种存储对象的空间分配方法、装置、计算机装置及存储介质。
在计算机中,通常需要对各类型的文件进行存储,或者对应用程序分配的对象进行存储。此时,需要对文件的存储地址进行分配或者对对象的存储地址进行分配。当可存储空间较大,存储的内容较多时,可能无法及时的为存储对象进行空间分配,因此,亟需一种有效管理和快速分配存储空间的机制。
发明内容
鉴于以上内容,有必要提供一种存储对象的空间管理方法、装置、计算机装置及存储介质,可以提高获取存储对象的存储空间信息的速度,从而能够及时的对新增的存储对象进行存储空间分配。
本申请提供一种存储对象的空间管理方法,所述方法包括:
接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间;
获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元;
在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元;
若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元 为所述新增存储对象分配存储空间。
本申请还提供一种存储对象的空间管理装置,所述装置包括:
第一获取模块,用于接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间;
第二获取模块,用于获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元;
保存模块,用于在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元;
分配模块,用于若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元为所述新增存储对象分配存储空间。
本申请还提供一种计算机装置,所述计算机装置包括存储器及处理器,所述存储器用于存储至少一个指令,所述处理器用于执行所述至少一个指令以实现任意实施例中所述的存储对象的空间管理方法。
本申请还提供一种非易失性可读存储介质,其特征在于,所述非易失性可读存储介质存储有至少一个指令,所述至少一个指令被处理器执行时实现任意实施例中所述的存储对象的空间管理方法。
由以上技术方案看出,本申请通过接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间;获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元;在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元;若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元为所述新增存储对象分配存储空间。由于将目标存储空间中的存储对象都保存在键值数据库中,由于键值数据库具有查找迅速的特点,所以,可以快速的获取已存储对象的存储空间信息,实现提高获取存储对象的存储空间信息的速度的目的。并且,根据键值数据库能快速获取目标存储空间中的空闲存储单元,所以分配存储空间时,能快速准确的分配存储空间,实现及时的对新增的存储对象进行存储空间分配的目的。
同时,本申请无需将存储对象的存储空间信息记录在内存或硬盘中,不会占用过多内存,避免降低系统性能。
图1是本申请实施例提供的一种存储对象的空间管理方法的流程图;
图2是本申请实施例提供的存储对象的空间管理装置的功能模块图;
图3是本申请实现存储对象的空间管理方法的较佳实施例的计算机装置的结构示意图。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
为使本申请的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本申请作进一步详细的说明。
如图1所示,图1为本申请实施例提供的一种存储对象的空间管理方法的流程图。根据不同的需求,该流程图中步骤的顺序可以改变,某些步骤可以省略。
S11,接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间。
本申请所述的方法可用于存储空间中对存储对象进行管理。具体的,对存储对象进行管理包括但不限于对存储对象的存储空间信息(也称为地址空间信息)进行保存和为存储对象分配存储空间。
上述目标存储空间是可以进行数据存储的虚拟存储空间或者物理存储空间,例如上述目标存储空间可以为一个或多个磁盘。
S12:获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元。
其中,获取目标存储空间中的已存储对象可以是获取已存储对象在目标存储空间中已存储对象的名称,或者已存储对象的大小等信息。
上述获取已存储对象的存储空间具体可以是获取已存储对象在目标存储空间中所存储的存储地址。
上述空闲存储单元是目标存储空间中没有存放存储对象的存储单元。
获取空闲存储单元具体可以是获取目标存储空间中的没有存放存储对象, 且可进行对象存储的存储单元的地址。
通常,对于一个目标存储空间可以划分为若干存储单元,已存储对象可以根据其大小占用一个或多个存储单元。
可选的,在本申请另一实施例中,所述获取所述目标存储空间中已存储对象、所述已存储对象的存储单元以及空闲存储单元,包括:
将所述目标存储空间包含的存储单元进行编号;
获取所述目标存储空间中已存储对象、所述已存储对象的存储单元的编号以及空闲存储单元的编号;
上述存储单元,是目标存储空间中所包括的存储单元。
上述编号可以是数字、字母等形式的编号,用于对每个存储单元进行标识。
则在对目标存储空间包含的存储单元进行编号之后,获取目标存储空间中已存储对象、所述已存储对象的存储单元的编号以及空闲存储单元的编号。
可选的,在本申请另一实施例中,所述目标存储空间中的存储单元通过如下方式划分:
获取所述目标存储空间的大小,确定所述目标存储空间进行空间管理的基本单元;
根据所述目标存储空间进行空间管理的基本单元将所述目标存储空间划分为若干存储单元。
上述获取目标存储空间的大小具体可以是获取目标存储空间的总容量。
上述目标存储空间进行空间管理的基本单元,具体可以是对目标存储空间进行分配、存储等操作时的最小操作单元。
上述目标存储空间进行空间管理的基本单元可以为预设单元,例如,目标存储空间进行空间管理的基本单元为1MB。
上述根据目标存储空间进行空间管理的基本单元将目标存储空间划分为若干存储单元具体是:将目标存储空间划分为若干个存储单元,每个存储单元的大小等于目标存储空间进行空间管理的基本单元。
例如,目标存储空间为一块磁盘,该磁盘的大小为1GB。若该磁盘进行空间管理的基本单元为1MB,则将该磁盘划分为1024个存储单元。
又比如,目标存储空间为一块磁盘,该磁盘的大小为500MB。若该磁盘 进行空间存储的基本单元为5MB,则将该磁盘划分为100个存储单元。
则上述将目标存储空间包含的存储单元进行编号可以是对划分后的每个存储单元赋予一个编号。
进一步地,所述确定所述目标存储空间进行空间管理的基本单元包括:
获取所述目标存储空间的目标存储对象的大小;
根据所述目标存储空间的目标存储对象的大小确定所述目标存储空间进行空间管理的基本单元。
上述目标存储对象可以是将要存储在目标存储空间的存储对象。
例如,目标存储对象都为10M以上的数据,则目标存储空间进行空间管理的基本单元可以确定为10M。
在本实施例中,根据目标存储空间的目标存储对象的大小进行基本单元的划分,避免将目标存储空间进行空间管理的基本单元划分的过大或者过小,有利于进行空间管理。
S13:在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元。
其中,键值数据库,也称为kv(key-value)存储数据库。kv数据库是一种非关系型数据库,键值数据库中的数据按照键值对的形式进行组织、索引和存储。
具体的,可以在键值数据库中记录已存储对象的对象名称,以及已存储对象的存储地址。
由于已存储对象和已存储对象的存储单元是一种一一对应的数据组织形式,因此使用键值数据库进行保存,符合要保存的数据的组织形式。在通过kv数据库进行存储以后,也可以快速的从kv数据库中进行查找。
通过键值数据库对目标存储空间中的已存储对象、已存储对象的存储单元以及空闲存储单元进行保存,不需要在内存中记录,为内存释放了更多的资源,也不需要频繁的去内存中进行查询,提高了系统的性能。并且,根据键值数据库存储数据的特点以及快速查找的特点,可以快速的访问键值数据库中的信息,从而可以快速的获取到目标存储空间中哪些存储单元被占用,哪些存储单元未被占用。
可选的,所述键值数据库为LevelDB或者RocksDB。
其中,上述LevelDB是一种开源的键值数据库,因此在实际应用中更容易获得,使用LevelDB具有低成本高效率的优点。
在LevelDB中,key和value都可以是任意长度的字节数组。并且,可以按照key的字典顺序存储,也可以按照其他自定义的顺序存储。在LevelDB数据库中,也可以快读的进行数据的查找。
在RocksDB中,key和value都可以是任意长度的字节数组。并且,RocksDB支持高效的查找和范围搜索,支持高负载的随机读、高负载的更新操作或两者的结合。因此,使用RocksDB能支持对于目标存储空间中的存储空间信息的快速读写。
同时,若步骤S12获取所述目标存储空间中已存储对象、所述已存储对象的存储单元以及空闲存储单元,包括:将所述目标存储空间包含的存储单元进行编号;获取所述目标存储空间中已存储对象、所述已存储对象的存储单元的编号以及空闲存储单元的编号;
则步骤S13在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元,包括:
在键值数据库中保存所述已存储对象、所述已存储对象的存储单元的编号以及所述空闲存储单元的编号。
例如,已存储对象的对象名称为a,a所占用的存储单元的编号为(1,5,8),则将a以及其所占用的存储单元的编号通过key-value的形式保存在键值数据库中,具体的,在键值数据库中可以保存为a->(1,5,8)。并且,保存其他编号的存储单元的存储对象为空。
同时,也可以在kv数据库中保存一个bitmap,通过bitmap记录每个存储单元是否已经存储了存储对象。
具体的,bitmap是一种数据结构,在bitmap中,每一位可以置为0或者1,用来表示一个含义。例如,在kv数据库中保存一个bitmap,其中0表示该位置未被占用(即没有存储任何对象),其中1表示该位置已被占用(即已存储对象)。
S14,若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元为所述新增存储对象分配存储空间。
上述新增存储对象是申请在目标存储空间进行存储的存储对象。
由于已经在键值数据库中保存了目标存储空间中已存储的存储单元,以及空闲存储单元,因此可以从键值数据库中直接获得空闲存储单元的信息(如空闲存储单元的编号或者地址),而无需一一查找哪些存储单元为空。
在为新增存储对象分配存储单元时,可以将任意空闲的存储单元分配给新增存储对象。
同时,在将某一个或者多个存储空间分配给新增存储对象之后,可以将新增存储对象以及为其分配的存储单元保存在键值数据库中。
优选的,若接收到存储文件的指令或者接收到运行程序时新建对象的指令,触发为新增存储对象分配存储空间的指令。
由于当要保存文件,或者是运行程序新建对象时,可能需要开辟新的存储空间进行存储。因此,此时为新增存储对象分配存储空间的指令,从而为需要存储的对象分配存储空间。
可选的,在本申请另一实施例中,所述根据所述空闲存储单元为所述新增存储对象分配存储空间,包括:
获取所述新增存储对象的大小以及所述目标存储空间中每个存储单元的大小;
根据所述新增存储对象的大小以及所述目标存储空间中每个存储单元的大小计算待存储单元数量;
根据所述待存储单元数量从所述空闲存储单元中为所述新增存储对象分配连续的存储单元。
上述每个存储单元的大小具体可以是目标存储空间进行空间管理的基本单元的存储单元的大小。因此,根据新增存储对象的大小可以计算存储该新增存储对象一共需要多少个存储单元。
例如,新增存储对象的大小为5MB,目标存储之中每个存储单元的大小为1MB,则存储该新增存储对象需要5个存储单元,即待存储单元数量为5。
在进行存储单元的分配时,可以将连续编号的空闲存储单元分配给新增存储对象。
例如,空闲存储单元的编号为20至30,则在分配时,可以将编号为20至25的存储单元分配给新增存储对象进行存储。
在本实施例中,为新增存储对象分配连续的存储单元有利于提高数据存 储和读取的效率。
可选的,在本申请另一实施例中,所述方法还包括:
若检测到所述目标存储中存在已存储对象被释放,在所述键值数据库中更新已释放的存储对象的信息。
其中,存储对象被释放包括存储对象从当前存储位置移除、从目标存储空间中删除。
例如,已存储对象的对象名称为a,a所占用的存储单元的编号为(1,5,8),若检测到已存储对象a被释放之后,将键值数据库中保存的a->(1,5,8)信息删除。
在本实施例中,在已使用的存储空间的存储对象被释放之后,对键值数据库中的信息进行更新,使得键值数据库中始终保存最新的信息,有利于提高获取到的目标存储空间之中存储信息的真实性。
本申请提供的存储对象的空间管理方法通过接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间;获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元;在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元;若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元为所述新增存储对象分配存储空间。由于将目标存储空间中的存储对象都保存在键值数据库中,由于键值数据库具有查找迅速的特点,所以,可以快速的获取已存储对象的存储空间信息,实现提高获取存储对象的存储空间信息的速度的目的。并且,根据键值数据库能快速获取目标存储空间中的空闲存储单元,所以分配存储空间时,能快速准确的分配存储空间,实现及时的对新增的存储对象进行存储空间分配的目的。
同时,本申请无需将存储对象的存储空间信息记录在内存或硬盘中,不会占用过多内存,避免降低系统性能。
如图2所示,图2为本申请实施例提供的存储对象的空间管理装置的功能模块图。所述存储对象的空间管理装置包括第一获取模块210、第二获取模块220、保存模块230、和分配模块240。本申请所称的模块是指一种能够被计算机装置的处理器所执行并且能够完成固定功能的一系列计算机可读指令段,其存储在计算机装置的存储器中。在本实施例中,关于各模块的功能 将在后续的实施例中详述。
第一获取模块210,用于接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间。
本申请所述的装置可用于存储空间中对存储对象进行管理。具体的,对存储对象进行管理包括但不限于对存储对象的存储空间信息(也称为地址空间信息)进行保存和为存储对象分配存储空间。
上述目标存储空间是可以进行数据存储的虚拟存储空间或者物理存储空间,例如上述目标存储空间可以为一个或多个磁盘。
第二获取模块220,用于获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元。
其中,获取目标存储空间中的已存储对象可以是获取已存储对象在目标存储空间中已存储对象的名称,或者已存储对象的大小等信息。
上述获取已存储对象的存储空间具体可以是获取已存储对象在目标存储空间中所存储的存储地址。
上述空闲存储单元是目标存储空间中没有存放存储对象的存储单元。
获取空闲存储单元具体可以是获取目标存储空间中的没有存放存储对象,且可进行对象存储的存储单元的地址。
通常,对于一个目标存储空间可以划分为若干存储单元,已存储对象可以根据其大小占用一个或多个存储单元。
可选的,在本申请另一实施例中,所述第二获取模块具体用于包括:将所述目标存储空间包含的存储单元进行编号;获取所述目标存储空间中已存储对象、所述已存储对象的存储单元的编号以及空闲存储单元的编号;
上述存储单元,是目标存储空间中所包括的存储单元。
上述编号可以是数字、字母等形式的编号,用于对每个存储单元进行标识。
则在对目标存储空间包含的存储单元进行编号之后,获取目标存储空间中已存储对象、所述已存储对象的存储单元的编号以及空闲存储单元的编号。
可选的,在本申请另一实施例中,所述装置还包括:划分模块。划分模块用于对目标存储空间中的存储单元进行划分。
具体的,划分模块可用于:
获取所述目标存储空间的大小,确定所述目标存储空间进行空间管理的基本单元;
根据所述目标存储空间进行空间管理的基本单元将所述目标存储空间划分为若干存储单元。
上述获取目标存储空间的大小具体可以是获取目标存储空间的总容量。
上述目标存储空间进行空间管理的基本单元,具体可以是对目标存储空间进行分配、存储等操作时的最小操作单元。
上述目标存储空间进行空间管理的基本单元可以为预设单元,例如,目标存储空间进行空间管理的基本单元为1MB。
上述根据目标存储空间进行空间管理的基本单元将目标存储空间划分为若干存储单元具体是:将目标存储空间划分为若干个存储单元,每个存储单元的大小等于目标存储空间进行空间管理的基本单元。
例如,目标存储空间为一块磁盘,该磁盘的大小为1GB。若该磁盘进行空间管理的基本单元为1MB,则将该磁盘划分为1024个存储单元。
又比如,目标存储空间为一块磁盘,该磁盘的大小为500MB。若该磁盘进行空间存储的基本单元为5MB,则将该磁盘划分为100个存储单元。
则上述将目标存储空间包含的存储单元进行编号可以是对划分后的每个存储单元赋予一个编号。
进一步地,所述划分模块确定所述目标存储空间进行空间管理的基本单元可包括:
获取所述目标存储空间的目标存储对象的大小;
根据所述目标存储空间的目标存储对象的大小确定所述目标存储空间进行空间管理的基本单元。
上述目标存储对象可以是将要存储在目标存储空间的存储对象。
例如,目标存储对象都为10M以上的数据,则目标存储空间进行空间管理的基本单元可以确定为10M。
在本实施例中,根据目标存储空间的目标存储对象的大小进行基本单元的划分,避免将目标存储空间进行空间管理的基本单元划分的过大或者过小,有利于进行空间管理。
保存模块230,用于在键值数据库中保存所述已存储对象、所述已存储 对象的存储单元以及所述空闲存储单元。
其中,键值数据库,也称为kv(key-value)存储数据库。kv数据库是一种非关系型数据库,键值数据库中的数据按照键值对的形式进行组织、索引和存储。
具体的,可以在键值数据库中记录已存储对象的对象名称,以及已存储对象的存储地址。
由于已存储对象和已存储对象的存储单元是一种一一对应的数据组织形式,因此使用键值数据库进行保存,符合要保存的数据的组织形式。在通过kv数据库进行存储以后,也可以快速的从kv数据库中进行查找。
通过键值数据库对目标存储空间中的已存储对象、已存储对象的存储单元以及空闲存储单元进行保存,不需要在内存中记录,为内存释放了更多的资源,也不需要频繁的去内存中进行查询,提高了系统的性能。并且,根据键值数据库存储数据的特点以及快速查找的特点,可以快速的访问键值数据库中的信息,从而可以快速的获取到目标存储空间中哪些存储单元被占用,哪些存储单元未被占用。
可选的,所述键值数据库为LevelDB或者RocksDB。
其中,上述LevelDB是一种开源的键值数据库,因此在实际应用中更容易获得,使用LevelDB具有低成本高效率的优点。
在LevelDB中,key和value都可以是任意长度的字节数组。并且,可以按照key的字典顺序存储,也可以按照其他自定义的顺序存储。在LevelDB数据库中,也可以快读的进行数据查找。
在RocksDB中,key和value都可以是任意长度的字节数组。并且,RocksDB支持高效的查找和范围搜索,支持高负载的随机读、高负载的更新操作或两者的结合。因此,使用RocksDB能支持对于目标存储空间中的存储空间信息的快速读写。
同时,若第二获取模块具体用于:将所述目标存储空间包含的存储单元进行编号;获取所述目标存储空间中已存储对象、所述已存储对象的存储单元的编号以及空闲存储单元的编号;
则保存模块230具体用于:在键值数据库中保存所述已存储对象、所述已存储对象的存储单元的编号以及所述空闲存储单元的编号。
例如,已存储对象的对象名称为a,a所占用的存储单元的编号为(1,5,8),则将a以及其所占用的存储单元的编号通过key-value的形式保存在键值数据库中,具体的,在键值数据库中可以保存为a->(1,5,8)。并且,保存其他编号的存储单元的存储对象为空。
同时,也可以在kv数据库中保存一个bitmap,通过bitmap记录每个存储单元是否已经存储了存储对象。
具体的,bitmap是一种数据结构,在bitmap中,每一位可以置为0或者1,用来表示一个含义。例如,在kv数据库中保存一个bitmap,其中0表示该位置未被占用(即没有存储任何对象),其中1表示该位置已被占用(即已存储对象)。
分配模块240,用于若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元为所述新增存储对象分配存储空间。
上述新增存储对象是申请在目标存储空间进行存储的存储对象。
由于已经在键值数据库中保存了目标存储空间中已存储的存储单元,以及空闲存储单元,因此可以从键值数据库中直接获得空闲存储单元的信息(如空闲存储单元的编号或者地址),而无需一一查找哪些存储单元为空。
在为新增存储对象分配存储单元时,可以将任意空闲的存储单元分配给新增存储对象。
同时,在将某一个或者多个存储空间分配给新增存储对象之后,可以将新增存储对象以及为其分配的存储单元保存在键值数据库中。
优选的,若接收到存储文件的指令或者接收到运行程序时新建对象的指令,触发为新增存储对象分配存储空间的指令。
由于当要保存文件,或者是运行程序新建对象时,可能需要开辟新的存储空间进行存储。因此,此时为新增存储对象分配存储空间的指令,从而为需要存储的对象分配存储空间。
可选的,在本申请另一实施例中,所述分配模块根据所述空闲存储单元为所述新增存储对象分配存储空间,包括:
获取所述新增存储对象的大小以及所述目标存储空间中每个存储单元的大小;
根据所述新增存储对象的大小以及所述目标存储空间中每个存储单元的 大小计算待存储单元数量;
根据所述待存储单元数量从所述空闲存储单元中为所述新增存储对象分配连续的存储单元。
上述每个存储单元的大小具体可以是目标存储空间进行空间管理的基本单元的存储单元的大小。因此,根据新增存储对象的大小可以计算存储该新增存储对象一共需要多少个存储单元。
例如,新增存储对象的大小为5MB,目标存储之中每个存储单元的大小为1MB,则存储该新增存储对象需要5个存储单元,即待存储单元数量为5。
在进行存储单元的分配时,可以将连续编号的空闲存储单元分配给新增存储对象。
例如,空闲存储单元的编号为20至30,则在分配时,可以将编号为20至25的存储单元分配给新增存储对象进行存储。
在本实施例中,为新增存储对象分配连续的存储单元有利于提高数据存储和读取的效率。
可选的,在本申请另一实施例中,所述装置还包括更新模块,所述更新模块还用于:
若检测到所述目标存储中存在已存储对象被释放,在所述键值数据库中更新已释放的存储对象的信息。
其中,存储对象被释放包括存储对象从当前存储位置移除、从目标存储空间中删除。
例如,已存储对象的对象名称为a,a所占用的存储单元的编号为(1,5,8),若检测到已存储对象a被释放之后,将键值数据库中保存的a->(1,5,8)信息删除。
在本实施例中,在已使用的存储空间的存储对象被释放之后,对键值数据库中的信息进行更新,使得键值数据库中始终保存最新的信息,有利于提高获取到的目标存储空间之中存储信息的真实性。
本申请提供的存储对象的空间管理装置通过第一获取模块接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间;第二获取模块获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元;保存模块在键值数据库中保存所述已存储对象、所述已存储对象的 存储单元以及所述空闲存储单元;若接收到为新增存储对象分配存储空间的指令,分配模块根据所述空闲存储单元为所述新增存储对象分配存储空间。由于将目标存储空间中的存储对象都保存在键值数据库中,由于键值数据库具有查找迅速的特点,所以,可以快速的获取已存储对象的存储空间信息,实现提高获取存储对象的存储空间信息的速度的目的。并且,根据键值数据库能快速获取目标存储空间中的空闲存储单元,所以分配存储空间时,能快速准确的分配存储空间,实现及时的对新增的存储对象进行存储空间分配的目的。
同时,本申请无需将存储对象的存储空间信息记录在内存或硬盘中,不会占用过多内存,避免降低系统性能。
上述以软件功能模块的形式实现的集成的单元,可以存储在一个非易失性可读取存储介质中。上述软件功能模块存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本申请各个实施例所述方法的部分步骤。
如图3所示,图3是本申请实现存储对象的空间管理方法的较佳实施例的计算机装置的结构示意图。所述计算机装置包括至少一个发送装置31、至少一个存储器32、至少一个处理器33、至少一个接收装置34以及至少一个通信总线。其中,所述通信总线用于实现这些组件之间的连接通信。
所述计算机装置是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程门阵列(Field-Programmable Gate Array,FPGA)、数字处理器(Digital Signal Processor,DSP)、嵌入式设备等。所述计算机装置还可包括网络设备和/或用户设备。其中,所述网络设备包括但不限于单个网络服务器、多个网络服务器组成的服务器组或基于云计算(Cloud Computing)的由大量主机或网络服务器构成的云,其中,云计算是分布式计算的一种,由一群松散耦合的计算机集组成的一个超级虚拟计算机。
所述计算机装置可以是,但不限于任何一种可与用户通过键盘、触摸板或声控设备等方式进行人机交互的电子产品,例如,平板电脑、智能手机、监控设备等终端。
所述计算机装置所处的网络包括,但不限于互联网、广域网、城域网、局域网、虚拟专用网络(Virtual Private Network,VPN)等。
其中,所述接收装置34和所述发送装置31可以是有线发送端口,也可以为无线设备,例如包括天线装置,用于与其他设备进行数据通信。
所述存储器32用于存储程序代码。所述存储器32可以是集成电路中没有实物形式的具有存储功能的电路,如RAM(Random-Access Memory,随机存取存储器)、FIFO(First In First Out,先进先出存储器)等。或者,所述存储器32也可以是具有实物形式的存储器,如内存条、TF卡(Trans-flash Card)、智能媒体卡(smart media card)、安全数字卡(secure digital card)、快闪存储器卡(flash card)等储存设备等等。
所述处理器33可以包括一个或者多个微处理器、数字处理器。所述处理器33可调用存储器32中存储的程序代码以执行相关的功能。例如,图3中所述的各个单元是存储在所述存储器32中的程序代码,并由所述处理器33所执行,以实现一种存储对象的空间管理方法。所述处理器33又称中央处理器(CPU,Central Processing Unit),是一块超大规模的集成电路,是运算核心(Core)和控制核心(Control Unit)。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其他的具体形式实 现本申请。因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本申请内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第二等词语用来表示名称,而并不表示任何特定的顺序。
最后应说明的是,以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。
Claims (20)
- 一种存储对象的空间管理方法,其特征在于,所述方法包括:接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间;获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元;在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元;若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元为所述新增存储对象分配存储空间。
- 如权利要求1所述的方法,其特征在于,所述根据所述空闲存储单元为所述新增存储对象分配存储空间,包括:获取所述新增存储对象的大小以及所述目标存储空间中每个存储单元的大小;根据所述新增存储对象的大小以及所述目标存储空间中每个存储单元的大小计算待存储单元数量;根据所述待存储单元数量从所述空闲存储单元中为所述新增存储对象分配连续的存储单元。
- 如权利要求1所述的方法,其特征在于,所述方法还包括:若检测到所述目标存储中存在已存储对象被释放,在所述键值数据库中更新已释放的存储对象的信息。
- 如权利要求1所述的方法,其特征在于,所述键值数据库为LevelDB或者RocksDB。
- 如权利要求1至4中任一项所述的方法,其特征在于,所述获取所述目标存储空间中已存储对象、所述已存储对象的存储单元以及空闲存储单元,包括:将所述目标存储空间包含的存储单元进行编号;获取所述目标存储空间中已存储对象、所述已存储对象的存储单元的编号以及空闲存储单元的编号;则所述在键值数据库中保存所述已存储对象、所述已存储对象的存储单 元以及所述空闲存储单元,包括:在键值数据库中保存所述已存储对象、所述已存储对象的存储单元的编号以及所述空闲存储单元的编号。
- 如权利要求5所述的方法,其特征在于,所述目标存储空间中的存储单元通过如下方式划分:获取所述目标存储空间的大小,确定所述目标存储空间进行空间管理的基本单元;根据所述目标存储空间进行空间管理的基本单元将所述目标存储空间划分为若干存储单元。
- 如权利要求6中任一项所述的方法,其特征在于,所述确定所述目标存储空间进行空间管理的基本单元包括:获取所述目标存储空间的目标存储对象的大小;根据所述目标存储空间的目标存储对象的大小确定所述目标存储空间进行空间管理的基本单元。
- 一种存储对象的空间管理装置,其特征在于,所述装置包括:第一获取模块,用于接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间;第二获取模块,用于获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元;保存模块,用于在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元;分配模块,用于若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元为所述新增存储对象分配存储空间。
- 一种计算机装置,其特征在于,所述计算机装置包括存储器及处理器,所述存储器用于存储至少一个指令,所述处理器用于执行所述至少一个指令以实现以下步骤:接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间;获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元;在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及 所述空闲存储单元;若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元为所述新增存储对象分配存储空间。
- 如权利要求9所述的计算机装置,其特征在于,所述根据所述空闲存储单元为所述新增存储对象分配存储空间,包括:获取所述新增存储对象的大小以及所述目标存储空间中每个存储单元的大小;根据所述新增存储对象的大小以及所述目标存储空间中每个存储单元的大小计算待存储单元数量;根据所述待存储单元数量从所述空闲存储单元中为所述新增存储对象分配连续的存储单元。
- 如权利要求9所述的计算机装置,其特征在于,所述处理器还用于执行所述至少一个指令以实现以下步骤:若检测到所述目标存储中存在已存储对象被释放,在所述键值数据库中更新已释放的存储对象的信息。
- 如权利要求9至11中任一项所述的计算机装置,其特征在于,所述获取所述目标存储空间中已存储对象、所述已存储对象的存储单元以及空闲存储单元,包括:将所述目标存储空间包含的存储单元进行编号;获取所述目标存储空间中已存储对象、所述已存储对象的存储单元的编号以及空闲存储单元的编号;则所述在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元,包括:在键值数据库中保存所述已存储对象、所述已存储对象的存储单元的编号以及所述空闲存储单元的编号。
- 如权利要求12所述的计算机装置,其特征在于,所述目标存储空间中的存储单元通过如下方式划分:获取所述目标存储空间的大小,确定所述目标存储空间进行空间管理的基本单元;根据所述目标存储空间进行空间管理的基本单元将所述目标存储空间划 分为若干存储单元。
- 如权利要求13中任一项所述的计算机装置,其特征在于,所述确定所述目标存储空间进行空间管理的基本单元包括:获取所述目标存储空间的目标存储对象的大小;根据所述目标存储空间的目标存储对象的大小确定所述目标存储空间进行空间管理的基本单元。
- 一种非易失性可读存储介质,其上存储有计算机指令,其特征在于,所述计算机指令被处理器执行时实现以下步骤:接收空间管理指令,获取所述空间管理指令指示管理的目标存储空间;获取所述目标存储空间中的已存储对象、所述已存储对象的存储单元以及空闲存储单元;在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元;若接收到为新增存储对象分配存储空间的指令,根据所述空闲存储单元为所述新增存储对象分配存储空间。
- 如权利要求15所述的存储介质,其特征在于,所述根据所述空闲存储单元为所述新增存储对象分配存储空间,包括:获取所述新增存储对象的大小以及所述目标存储空间中每个存储单元的大小;根据所述新增存储对象的大小以及所述目标存储空间中每个存储单元的大小计算待存储单元数量;根据所述待存储单元数量从所述空闲存储单元中为所述新增存储对象分配连续的存储单元。
- 如权利要求15所述的存储介质,其特征在于,所述计算机指令被处理器执行时还实现以下步骤:若检测到所述目标存储中存在已存储对象被释放,在所述键值数据库中更新已释放的存储对象的信息。
- 如权利要求15至17中任一项所述的存储介质,其特征在于,所述获取所述目标存储空间中已存储对象、所述已存储对象的存储单元以及空闲存储单元,包括:将所述目标存储空间包含的存储单元进行编号;获取所述目标存储空间中已存储对象、所述已存储对象的存储单元的编号以及空闲存储单元的编号;则所述在键值数据库中保存所述已存储对象、所述已存储对象的存储单元以及所述空闲存储单元,包括:在键值数据库中保存所述已存储对象、所述已存储对象的存储单元的编号以及所述空闲存储单元的编号。
- 如权利要求18所述的存储介质,其特征在于,所述目标存储空间中的存储单元通过如下方式划分:获取所述目标存储空间的大小,确定所述目标存储空间进行空间管理的基本单元;根据所述目标存储空间进行空间管理的基本单元将所述目标存储空间划分为若干存储单元。
- 如权利要求19中任一项所述的存储介质,其特征在于,所述确定所述目标存储空间进行空间管理的基本单元包括:获取所述目标存储空间的目标存储对象的大小;根据所述目标存储空间的目标存储对象的大小确定所述目标存储空间进行空间管理的基本单元。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810689511.7A CN109086002A (zh) | 2018-06-28 | 2018-06-28 | 存储对象的空间管理方法、装置、计算机装置及存储介质 |
| CN201810689511.7 | 2018-06-28 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020000734A1 true WO2020000734A1 (zh) | 2020-01-02 |
Family
ID=64834784
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2018/108126 Ceased WO2020000734A1 (zh) | 2018-06-28 | 2018-09-27 | 存储对象的空间管理方法、装置、计算机装置及存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109086002A (zh) |
| WO (1) | WO2020000734A1 (zh) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112631658B (zh) * | 2021-01-13 | 2022-11-15 | 成都国科微电子有限公司 | 指令发送方法、芯片和电子设备 |
| CN114296658B (zh) * | 2021-12-31 | 2024-06-21 | 深圳市兆珑科技有限公司 | 一种存储空间分配方法、装置、终端设备及存储介质 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103268318A (zh) * | 2013-04-16 | 2013-08-28 | 华中科技大学 | 一种强一致性的分布式键值数据库系统及其读写方法 |
| CN104424119A (zh) * | 2013-08-26 | 2015-03-18 | 联想(北京)有限公司 | 存储空间配置方法和装置 |
| CN104778264A (zh) * | 2015-04-22 | 2015-07-15 | 北京科电高技术公司 | 一种键值数据库的内存分配方法 |
| CN105224677A (zh) * | 2015-10-16 | 2016-01-06 | 上海晶赞科技发展有限公司 | 一种数据库操作方法及装置 |
| CN107357794A (zh) * | 2016-05-10 | 2017-11-17 | 北京京东尚科信息技术有限公司 | 优化键值数据库的数据存储结构的方法和装置 |
| CN107967122A (zh) * | 2017-11-22 | 2018-04-27 | 郑州云海信息技术有限公司 | 一种块设备的数据写入方法、装置及介质 |
Family Cites Families (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101162441B (zh) * | 2007-11-09 | 2010-10-13 | 华为技术有限公司 | 数据的存取装置和方法 |
| CN101556557B (zh) * | 2009-05-14 | 2011-03-23 | 浙江大学 | 一种基于对象存储设备的对象文件组织方法 |
| JP5778779B2 (ja) * | 2011-12-21 | 2015-09-16 | 株式会社日立製作所 | 計算機システム、及び管理システム |
| CN102915340A (zh) * | 2012-02-29 | 2013-02-06 | 浙江工商大学 | 一种扩展的基于b+树对象文件系统 |
| CN103064639B (zh) * | 2012-12-28 | 2016-08-03 | 华为技术有限公司 | 数据存储方法及装置 |
| CN105630410B (zh) * | 2015-12-03 | 2018-08-07 | 上海磁宇信息科技有限公司 | 使用非易失随机读写存储芯片动态管理文件存储区的方法 |
| CN106874459B (zh) * | 2017-02-14 | 2020-07-10 | 北京奇虎科技有限公司 | 流式数据存储方法及装置 |
| CN107861685A (zh) * | 2017-06-20 | 2018-03-30 | 平安科技(深圳)有限公司 | 基于写时复制的虚拟磁盘写入方法及装置、存储介质 |
| CN107229429B (zh) * | 2017-06-27 | 2020-06-16 | 苏州浪潮智能科技有限公司 | 一种存储空间管理方法及装置 |
-
2018
- 2018-06-28 CN CN201810689511.7A patent/CN109086002A/zh active Pending
- 2018-09-27 WO PCT/CN2018/108126 patent/WO2020000734A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103268318A (zh) * | 2013-04-16 | 2013-08-28 | 华中科技大学 | 一种强一致性的分布式键值数据库系统及其读写方法 |
| CN104424119A (zh) * | 2013-08-26 | 2015-03-18 | 联想(北京)有限公司 | 存储空间配置方法和装置 |
| CN104778264A (zh) * | 2015-04-22 | 2015-07-15 | 北京科电高技术公司 | 一种键值数据库的内存分配方法 |
| CN105224677A (zh) * | 2015-10-16 | 2016-01-06 | 上海晶赞科技发展有限公司 | 一种数据库操作方法及装置 |
| CN107357794A (zh) * | 2016-05-10 | 2017-11-17 | 北京京东尚科信息技术有限公司 | 优化键值数据库的数据存储结构的方法和装置 |
| CN107967122A (zh) * | 2017-11-22 | 2018-04-27 | 郑州云海信息技术有限公司 | 一种块设备的数据写入方法、装置及介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109086002A (zh) | 2018-12-25 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11558487B2 (en) | Methods and systems for stream-processing of biomedical data | |
| CN105933376B (zh) | 一种数据操作方法,服务器及存储系统 | |
| CN104462225B (zh) | 一种数据读取的方法、装置及系统 | |
| US11003625B2 (en) | Method and apparatus for operating on file | |
| US8751763B1 (en) | Low-overhead deduplication within a block-based data storage | |
| US20160179581A1 (en) | Content-aware task assignment in distributed computing systems using de-duplicating cache | |
| WO2021218038A1 (zh) | 一种存储系统、内存管理方法和管理节点 | |
| EP2933733A1 (en) | Data processing method and device in distributed file storage system | |
| US11226778B2 (en) | Method, apparatus and computer program product for managing metadata migration | |
| CN108804031A (zh) | 最佳记录查找 | |
| US10191857B1 (en) | Machine learning for metadata cache management | |
| CN107665095B (zh) | 存储器空间管理的设备、方法及可读存储介质 | |
| CN106294190A (zh) | 一种存储空间管理方法及装置 | |
| CN111381779A (zh) | 数据处理方法、装置、设备及存储介质 | |
| CN107368260A (zh) | 基于分布式系统的存储空间整理方法、装置及系统 | |
| JP2018516409A (ja) | ファイルストレージにおけるインデックス付け実施方法及びシステム | |
| WO2017107015A1 (zh) | 存储空间的分配方法及存储设备 | |
| US9430492B1 (en) | Efficient scavenging of data and metadata file system blocks | |
| US20240220334A1 (en) | Data processing method in distributed system, and related system | |
| EP2621143A1 (en) | Information processing apparatus, distributed processing system, and distributed processing method | |
| CN110147203A (zh) | 一种文件管理方法、装置、电子设备及存储介质 | |
| CN111857539A (zh) | 用于管理存储系统的方法、设备和计算机程序产品 | |
| CN110162395B (zh) | 一种内存分配的方法及装置 | |
| CN108304259B (zh) | 内存管理方法及系统 | |
| WO2024169158A1 (zh) | 一种存储系统、数据访问方法、装置及设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18924312 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: 18924312 Country of ref document: EP Kind code of ref document: A1 |