WO2021047398A1 - 存储块回收方法、装置、存储介质及电子设备 - Google Patents

存储块回收方法、装置、存储介质及电子设备 Download PDF

Info

Publication number
WO2021047398A1
WO2021047398A1 PCT/CN2020/111763 CN2020111763W WO2021047398A1 WO 2021047398 A1 WO2021047398 A1 WO 2021047398A1 CN 2020111763 W CN2020111763 W CN 2020111763W WO 2021047398 A1 WO2021047398 A1 WO 2021047398A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage
storage block
memory
recyclable
thread
Prior art date
Application number
PCT/CN2020/111763
Other languages
English (en)
French (fr)
Inventor
彭冬炜
Original Assignee
Oppo广东移动通信有限公司
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 Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2021047398A1 publication Critical patent/WO2021047398A1/zh

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
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems
    • 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
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • 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
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0659Command handling arrangements, e.g. command buffers, queues, command scheduling
    • 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
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0676Magnetic disk device
    • 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
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation 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/5022Mechanisms to release resources
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • This application relates to the field of data storage, and in particular to a storage block recovery method, device, storage medium, and electronic equipment.
  • the storage space of the memory is very limited, and the limited storage space also stores data that has a very low frequency of access and may not even be accessed.
  • related technologies use a recycling mechanism to reclaim the storage blocks in the memory that store the above data, thereby releasing the storage resources of these storage blocks for continuing to store other data.
  • the present application provides a storage block recycling method, device, storage medium, and electronic equipment, which can not only recycle storage blocks, but also avoid unnecessary power consumption caused by periodic recycling.
  • the present application provides a storage block recycling method, which is applied to an electronic device, the electronic device includes a memory and a file system for managing the memory, and the storage block recycling method includes:
  • the present application provides a storage block recovery device, which is applied to an electronic device, the electronic device includes a memory and a file system for managing the memory, and the storage block recovery device includes:
  • the detection module is used to detect the recyclable storage blocks in the recyclable state in the memory
  • the judging module is used to judge whether the preset recovery condition is currently met according to the number of recoverable storage blocks;
  • the wake-up module is used to wake up the discarding thread of the file system if the preset recycling conditions are met;
  • the recycling module is used to control the memory recycling of recyclable storage blocks based on the discarding thread, and sleep the discarding thread.
  • the present application provides a storage medium on which a computer program is stored.
  • the computer program is called by a processor of an electronic device including a memory and a file system for managing the memory
  • the The processor executes the storage block recovery method provided in the embodiment of the present application.
  • the present application provides an electronic device including a processor, a memory, and a file system for managing the memory.
  • the memory stores a computer program
  • the processor uses the computer program by calling the computer program.
  • FIG. 1 is a schematic flowchart of a storage block recovery method provided by an embodiment of the present application.
  • Fig. 2 is a schematic diagram of a memory area divided in an embodiment of the present application.
  • FIG. 3 is another schematic flowchart of a storage block recovery method provided by an embodiment of the present application.
  • Fig. 4 is a schematic structural diagram of a storage block recovery device provided by an embodiment of the present application.
  • Fig. 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • Fig. 6 is another schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • Flash memory usually includes multiple storage blocks, which are managed by a file system (such as a flash file system) for read/write operations.
  • a file system such as a flash file system
  • the characteristic of the storage block is that it can perform write and read operations on part of the space of the storage block, but cannot be partially erased, and only the entire storage block can be erased. For this reason, the storage block needs to be erased as a whole to continue storing other data. This process is called the recovery of the storage block.
  • the existing recycling mechanism is triggered periodically. In many scenarios, when the recycling mechanism is triggered, there may be no recycling blocks that need to be recycled. This process wastes the power consumption of the electronic device and prevents the electronic device from entering low power consumption. status.
  • embodiments of the present application provide a storage block recycling method, storage block recycling device, storage medium, and electronic equipment, which abandon the periodic recycling mechanism and adopt an on-demand recycling mechanism to reduce the power consumption caused by the periodic recycling mechanism. waste.
  • the execution subject of the storage block recycling method may be the storage block recycling device provided in the embodiment of the present application, or an electronic device integrated with the storage block recycling device, where the storage block recycling device can be implemented in hardware or software.
  • the electronic device can be a computing device such as a laptop computer, a computer monitor containing an embedded computer, a tablet computer, a cell phone, a media player, or other handheld or portable electronic devices, smaller devices (such as wrist watch devices, Hanging devices, headsets or earpiece devices, devices embedded in glasses or other devices worn on the user’s head, or other wearable or micro devices), televisions, computer monitors that do not contain embedded computers, Game devices, navigation devices, embedded systems (such as systems in which electronic devices with displays are installed in kiosks or cars), etc.
  • a computing device such as a laptop computer, a computer monitor containing an embedded computer, a tablet computer, a cell phone, a media player, or other handheld or portable electronic devices, smaller devices (such as wrist watch devices, Hanging devices, headsets or earpiece devices, devices embedded in glasses or other devices worn on the user’s head, or other wearable or micro devices), televisions, computer monitors that do not contain embedded computers, Game devices, navigation devices, embedded systems (such as systems in which electronic devices with
  • the present application provides a storage block recycling method, which is applied to an electronic device, the electronic device including a memory and a file system for managing the storage, wherein the storage block recycling method includes:
  • the detecting the reclaimable storage block in the reclaimable state in the memory includes:
  • the controlling the memory to reclaim the reclaimable storage block based on the discarding thread includes:
  • the detecting the storage block recycling command generated by the file system includes:
  • the judging whether a preset recovery condition is currently met according to the number of recoverable storage blocks includes:
  • controlling the memory to reclaim the reclaimable storage block based on the discarding thread includes:
  • Predicting a target storage block in the recyclable storage block where the target storage block is a recyclable storage block storing target data that may be read again within a preset period of time;
  • the predicting the target storage block in the reclaimable storage block includes:
  • the target storage block is determined according to the reading time.
  • the method further includes:
  • controlling the memory to reclaim the reclaimable storage block based on the discarding thread includes:
  • the memory is controlled to directly erase the data in the recyclable storage block.
  • controlling the memory to reclaim the reclaimable storage block based on the discarding thread includes:
  • the memory is controlled to migrate valid data in the reclaimable storage block to another storage block, and the data in the reclaimable storage block is erased.
  • FIG. 1 is a schematic flowchart of a storage block recycling method provided by an embodiment of the application.
  • the storage block recycling method is applied to the electronic device provided in the embodiment of the present application, and the electronic device includes a memory.
  • the process of the storage block recycling method provided in the embodiment of the present application may be as follows:
  • the memory block is a memory cell block constituting the memory cell array in the memory.
  • the memory block is composed of multiple memory pages, the erasing operation is performed in the unit of the memory block, and the reading and writing (or programming) operations are performed in the unit of the memory page. Therefore, this application regards the storage block as the smallest unit of recycling.
  • the electronic device can detect the storage blocks in the recyclable state in the memory in real time, and record the storage blocks in the recyclable state as the recyclable storage blocks.
  • the electronic device counts the number of detected recyclable storage blocks in real time, and determines whether the preset reclaim condition is currently met according to the number of detected recyclable storage blocks.
  • the preset recovery conditions can be set by those of ordinary skill in the art based on experience. For example, it can be known from experience that when the accumulated recyclable storage blocks are too many, the memory performance will drop significantly. Therefore, it can be determined in advance that the memory performance will drop significantly.
  • the corresponding preset reclaim condition is set as follows: the number of detected reclaimable storage blocks reaches the preset number.
  • the thread is the smallest unit that the operating system of the electronic device can perform operation scheduling. It is included in the process and is the actual operation unit in the process.
  • a thread can be regarded as a single sequential control flow in a process. Multiple threads can be concurrent in a process, and each thread executes different tasks in parallel.
  • the discard thread (or discard thread) is a thread in the process corresponding to the file system, and is used to manage when the memory reclaims storage blocks.
  • the discarding thread is in a dormant state by default, and only wakes up when the memory needs to be controlled to reclaim storage blocks, so as to avoid unnecessary waste of power consumption.
  • the electronic device wakes up the discarding thread of the file system.
  • the electronic device continues to detect until the preset recycling conditions are met.
  • the electronic device controls the memory to reclaim the recyclable storage block based on the discarding thread. For example, when the memory reclaims the recyclable storage block, the data in the recyclable storage block can be directly erased to store other data. , You can also move the valid data in the reclaimable storage block to other storage blocks, and then erase the reclaimable storage block.
  • the discarding thread is not necessary to continue running. Therefore, the electronic device further sleeps the discarding thread, so that when the memory is required to reclaim the storage block next time, the discarding thread is awakened again to control the reclaimable memory. Reclaim storage blocks.
  • the recyclable storage blocks in the recyclable state are detected, and according to the number of recyclable storage blocks, it is determined whether the preset recycling conditions are currently met, and then when the preset recycling conditions are currently met , Wake up the discarding thread of the file system, control the memory to reclaim the recyclable storage block based on the discarding thread, and sleep the discarding thread.
  • this application does not trigger the recycling of storage blocks periodically, but only when it needs to be recycled. Not only can the storage blocks be recycled in time, but it can also avoid unnecessary periodic recycling. Power consumption.
  • detecting recyclable storage blocks in a recyclable state includes:
  • Recycling reclaimable storage blocks based on the control of the discarding thread includes:
  • the storage block recycling command generated by the file system is sent to the memory, so that the memory reclaims the recyclable storage block according to the storage block recycling command.
  • the file system is performing operations such as deleting data, writing data, or garbage collection, it will eventually enter the unified entry, that is, execute the "__create_discard_cmd function", and generate the storage block recovery command "discard cmd" through the "__create_discard_cmd function" ", used to indicate that a storage block of the memory is no longer in use and can be recycled.
  • the storage block recycling command may indicate that one storage block is no longer used, or may indicate that multiple storage blocks are no longer used.
  • the electronic device can directly detect the storage block recycling command generated by the file system, and determine the storage block that is no longer used according to the instruction of the storage block recycling command, and set the storage block that is no longer used as available. Reclaim storage blocks.
  • the electronic device when controlling the memory to reclaim recyclable storage blocks based on the discarding thread, can send the storage block recycling command generated by the file system to the memory based on the discarding thread, so that the memory responds to the storage block recycling command it receives.
  • the reclaimable storage block indicated by the storage block reclamation command is reclaimed to facilitate the storage of other data.
  • the "__issue_discard_cmd function" can be executed based on the discarding thread, so that the discarding thread sends the storage block recycling command that has been generated by the file system to the memory.
  • "detecting the storage block recycling command generated by the file system” includes:
  • the preset storage area may be the entire storage area of the memory, or may be a part of the storage area of the memory.
  • a part of the storage area in the memory is selected as the preset storage area that needs to be recycled, so that the file system only generates a storage block recycling command for the storage block in the preset storage area.
  • the electronic device can detect the storage block recovery command created by the file system for the preset storage area in the memory, so as to recover the storage block in the preset storage area when needed.
  • the electronic device may divide the memory into multiple storage areas according to the sequence of writing data of the storage blocks in the storage by the file system, and each storage area includes the same number of storage blocks. As a result, the electronic device sequentially uses the divided storage areas as a preset storage request that requires storage block recycling.
  • the electronic device divides the memory into 4 storage areas, namely storage area A, storage area B, storage area C, and storage area D.
  • the electronic device initially sets storage area A as a preset storage area. Recycling of storage blocks, when the recycling of storage blocks in storage area A is triggered and the recycling is completed, storage area B is set as a preset storage area to recycle storage blocks, and so on, the electronic device cycles storage areas A,
  • the storage area B, the storage area C, and the storage area D are set as a preset memory for the recovery of storage blocks.
  • "judging whether the preset recovery condition is currently met according to the number of reclaimable storage blocks” includes:
  • the remaining storage space capacity available for the file system is recorded as the first remaining storage space capacity
  • the remaining storage space capacity available for the memory is recorded as the second remaining storage space capacity.
  • the preset recovery conditions set in the embodiments of this application are:
  • the first remaining storage space capacity is less than the first preset space capacity
  • the second remaining space capacity is less than the second preset space capacity, where the second preset space capacity is less than the first preset space capacity, and the first preset space capacity is used To describe that the available storage space capacity of the file system is insufficient, the second preset space capacity is used to describe that the available storage space capacity of the memory is insufficient.
  • the storage space capacity is expressed as a percentage relative to the total storage space of the memory, assuming that the first preset space capacity is configured to be 30%, and the second preset space capacity is configured to be 20%, the electronic device is available in the file system
  • the first remaining storage space capacity is less than 30% of the total storage space capacity, and the second remaining storage space capacity available to the memory is less than 20% of the total storage space capacity, it is determined that the preset recycling condition is currently met and the storage block recycling is triggered.
  • controlling the memory to reclaim recyclable storage blocks based on the discarding thread includes:
  • the target storage block is the recyclable storage block that stores the target data that may be read again within a preset period of time;
  • the electronic device does not recycle all the recyclable storage blocks detected, and only selects a part of them for recycling.
  • the electronic device first predicts the target storage block in the recyclable storage block, and the target storage block is the recyclable storage block that stores the target data that may be read again within a preset period of time. For example, for a storage block, It is possible to predict whether the data stored in the storage block may be read again within a preset period of time according to the read law of the data stored in the storage block, and then determine whether the storage block is the target storage block.
  • the value of the preset duration can be configured by those of ordinary skill in the art according to actual needs, for example, it can be set to 1 natural day.
  • the electronic device After predicting the target storage block in the recyclable storage block, the electronic device marks the target storage block as an unrecyclable state, so that the target storage block is not recycled. Accordingly, the electronic device controls the memory recycling based on the discarding thread to remove the target storage block.
  • the electronic device controls the memory recycling based on the discarding thread to remove the target storage block.
  • a preset keyword is also added to the storage block recycling command corresponding to the target storage block, so that the storage block recycling command becomes invalid.
  • predicting the target storage block in the reclaimable storage block includes:
  • a prediction model is pre-trained in a machine learning manner, and the prediction model is used to predict the reading time when the stored data may be read again.
  • machine learning is a multi-disciplinary interdisciplinary, involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other subjects, usually including neural networks, belief networks, reinforcement learning, transfer learning, induction learning And other technologies.
  • the electronic device obtains the reading record of the sample data in advance, uses the time length between the last reading and the last reading as a label, and performs vectorization characterization after removing the reading record from the last reading record.
  • a training sample then build the initial neural network and the corresponding loss function.
  • train the built neural network with the goal of minimizing the loss function.
  • the training will be completed when the neural network converges, and the trained neural network will be completed.
  • the network is set as a predictive model.
  • the electronic device when predicting the target storage block in the recyclable storage block, can first call the pre-trained prediction model; then, for each recyclable storage block, the electronic device obtains the corresponding data stored in each recyclable storage block. Then, the electronic device vectorized to characterize the read record corresponding to the data stored in each recyclable storage block to obtain the read vector; then, the electronic device inputs the read vector corresponding to each recyclable storage block into The pre-trained prediction model obtains the reading time at which the data stored in each recyclable storage block output by the prediction model may be read again; then, the electronic device calculates the distance between the reading time corresponding to each recyclable storage block and the current time Remaining duration, the storage block with the remaining duration less than the preset duration is determined as the target storage block.
  • the storage block recovery method provided in the embodiment of the present application further includes:
  • the target storage block When the target data in the target storage block is not read after reaching the time of use, the target storage block is marked as a recyclable state, and the target data is backed up to the cloud storage server.
  • the electronic device may mark the target storage block as a recyclable state when the target data in the target storage block has not been read within a second preset time period after the time of use, so that the target storage block can meet the preset requirements next time.
  • the recovery condition is set, it is recovered by the memory.
  • the electronic device also backs up the target data to the cloud storage server, so that it can be obtained from the cloud storage server when it needs to be read later, so as to avoid loss of the target data.
  • the second preset duration can be set according to the available remaining space of the electronic device in the cloud storage server. For example, the greater the available remaining space, the shorter the second preset duration is set, the smaller the remaining space can be, and the second The longer the preset duration.
  • the preset keyword added in the storage block recycling command corresponding to the target storage block is also removed, so that the storage block recycling command is effective.
  • the storage block recovery method provided in the embodiment of the present application is described below by taking the memory of the electronic device as a flash memory and the file system as a flash file system as an example. Please refer to FIG. 3.
  • the process of the storage block recovery method may also be:
  • the electronic device detects the storage block recycling command generated by the flash file system, and sets the storage block indicated by the storage block recycling command as a recyclable storage block.
  • the storage block is a storage unit block constituting a storage cell array in the flash memory.
  • the memory block is composed of multiple memory pages, the erase operation is performed in units of memory blocks, and the read and write (or programming) operations are performed in units of memory pages. Therefore, this application regards the storage block as the smallest unit of recycling.
  • the flash file system is performing operations such as deleting data, writing data or garbage collection, it will eventually enter the unified entry, that is, execute the "__create_discard_cmd function", and generate the storage block recovery command "discard" through the "__create_discard_cmd function” cmd", used to indicate that a block of flash memory is no longer used and can be recycled.
  • the storage block recycling command may indicate that one storage block is no longer used, or may indicate that multiple storage blocks are no longer used.
  • the electronic device can directly detect the storage block recycling command generated by the flash file system, and determine the storage block that is no longer used according to the instruction of the storage block recycling command, and set the no longer used storage block as a recyclable storage block.
  • the electronic device counts the number of recyclable storage blocks, and determines the first remaining storage space capacity available for the flash file system and the second remaining storage space capacity available for the flash memory according to the number of reclaimable storage blocks.
  • the remaining storage space capacity available for the flash file system is recorded as the first remaining storage space capacity, and the remaining storage space capacity available for the flash memory is recorded as the second remaining storage space capacity.
  • the electronic device first counts the number of recyclable storage blocks, and accordingly determines the first remaining storage space capacity available for the flash file system, and determines the second remaining storage space capacity available for the flash memory.
  • the electronic device determines whether the first remaining storage space capacity is less than the first preset space capacity, and determines whether the second remaining space capacity is less than the second preset space capacity.
  • the electronic device wakes up the discarding thread of the flash file system.
  • the thread is the smallest unit that the operating system of the electronic device can perform operation scheduling. It is included in the process and is the actual operation unit in the process.
  • a thread can be regarded as a single sequential control flow in a process. Multiple threads can be concurrent in a process, and each thread executes different tasks in parallel.
  • the discard thread (or discard thread) is a thread in the process corresponding to the flash file system, which is used to manage when the flash memory reclaims storage blocks.
  • the embodiment of this application is configured with a first preset space capacity and a second preset space capacity, where the second preset space capacity is smaller than the first preset space capacity, and the first preset space capacity is used for description
  • the available storage space capacity of the flash file system is insufficient
  • the second preset space capacity is used to describe that the available storage space capacity of the flash memory is insufficient.
  • the electronic device determines whether the first remaining storage space capacity is less than the first preset space capacity, determines whether the second remaining space capacity is less than the second preset space capacity, and determines whether to trigger the flash memory to reclaim the storage block according to the judgment result, wherein , When the first remaining storage space capacity is less than the first preset space capacity, and the second remaining storage space capacity is less than the second preset space capacity, the electronic device determines to trigger the flash memory to reclaim the storage block, otherwise it determines not to trigger the flash memory to reclaim the storage Piece.
  • the storage space capacity is expressed as a percentage relative to the total storage space of the flash memory, assuming that the first preset space capacity is configured as 30% and the second preset space capacity is configured as 20%, the electronic device is in the flash file system
  • the flash memory is triggered to recycle storage blocks.
  • the discarding thread is in a dormant state by default, and only wakes up when the flash memory needs to be controlled to reclaim storage blocks, so as to avoid unnecessary waste of power consumption.
  • the electronic device wakes up the discarding thread of the flash file system.
  • the electronic device sends the storage block recycling command to the flash memory based on the discard thread, so that the flash memory reclaims the recyclable storage block in response to the storage block recycling command.
  • the electronic device After waking up the discarding thread, the electronic device sends the storage block recycling command generated by the flash file system to the flash memory based on the discarding thread, so that the flash memory responds to the storage block recycling command received by the flash memory and responds to the storage block recycling command indicating that the storage block recycling command can be recycled.
  • the storage block is recycled to facilitate the storage of other data.
  • the "__issue_discard_cmd function" can be executed based on the discard thread, so that the discard thread sends the storage block recycling command that has been generated by the flash file system to the flash memory.
  • the discarding thread is not necessary to continue running. Therefore, the electronic device further sleeps the discarding thread, so that the next time the flash memory needs to reclaim the storage block, the discarding thread is awakened again to control the flash memory. Memory reclamation can reclaim storage blocks.
  • the embodiment of the present application also provides a storage block recovery device.
  • FIG. 4 is a schematic structural diagram of a storage block recovery device provided by an embodiment of the application.
  • the storage block recovery device is applied to an electronic device that includes a memory and a file system for managing the storage.
  • the storage block recovery device includes a detection module 301, a judgment module 302, a wake-up module 303, and a recovery module 304, as follows:
  • the detection module 301 is used to detect recyclable storage blocks in a recyclable state in the memory
  • the judging module 302 is configured to judge whether the preset recovery condition is currently met according to the number of recoverable storage blocks;
  • the wake-up module 303 is configured to wake up the discarding thread of the file system if the preset recovery condition is met;
  • the recycling module 304 is configured to control the memory recycling of recyclable storage blocks based on the discarding thread, and sleep the discarding thread.
  • the detection module 301 when detecting a recyclable storage block in a recyclable state in the memory, the detection module 301 is used to:
  • the reclaiming module 304 is used to:
  • the storage block recycling command generated by the file system is sent to the memory, so that the memory reclaims the recyclable storage block according to the storage block recycling command.
  • the detecting module 301 when detecting the storage block recycling command generated by the file system, the detecting module 301 is used to:
  • the judging module 302 when judging whether the preset reclaiming condition is currently met according to the number of reclaimable storage blocks, is configured to:
  • the reclaiming module 304 when reclaiming reclaimable storage blocks based on the discarding thread control memory, the reclaiming module 304 is used to:
  • the target storage block is the reclaimable storage block that stores the target data that may be read again within a preset period of time;
  • the reclaiming module 304 when predicting the target storage block in the reclaimable storage block, is used to:
  • the reclaiming module 304 is further configured to:
  • the target storage block When the target data in the target storage block is not read after reaching the time of use, the target storage block is marked as a recyclable state, and the target data is backed up to the cloud storage server.
  • the storage block recovery device provided in this embodiment of the application belongs to the same concept as the storage block recovery method in the above embodiment, and any method provided in the embodiment of the storage block recovery method can be run on the storage block recovery device.
  • any method provided in the embodiment of the storage block recovery method can be run on the storage block recovery device.
  • the embodiment of the present application provides a computer-readable storage medium on which a computer program is stored.
  • the storage medium may be a magnetic disk, an optical disk, a read only memory (Read Only Memory, ROM,), or a random access device (Random Access Memory, RAM), etc.
  • An embodiment of the present application also provides an electronic device. Please refer to FIG. 5.
  • the electronic device includes a processor 401 and a memory 402.
  • the processor 401 and the memory 402 are electrically connected.
  • the processor 401 is the control center of the electronic device. It uses various interfaces and lines to connect the various parts of the entire electronic device. It executes the electronic device by running or loading the computer program stored in the memory 402 and calling the data stored in the memory 402. Various functions and process data. Wherein, the processor 401 runs a file system for managing the memory 402.
  • the memory 402 can be used to store software programs and modules.
  • the processor 401 executes various functional applications and data processing by running the computer programs and modules stored in the memory 402.
  • the memory 402 may mainly include a program storage area and a data storage area.
  • the program storage area may store an operating system, a computer program required by at least one function (such as a sound playback function, an image playback function, etc.), etc.; Data created by the use of electronic equipment, etc.
  • the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
  • the memory 402 may further include a memory controller to provide the processor 401 with access to the memory 402.
  • the processor 401 in the electronic device will load the instructions corresponding to the process of one or more computer programs into the memory 402 according to the following steps, and run the instructions by the processor 401 and store them in the memory 402
  • the computer program to achieve various functions, as follows:
  • the memory 402 reclaims recyclable storage blocks based on the discarding thread control, and sleeps the discarding thread.
  • FIG. 6 is another schematic structural diagram of the electronic device provided by an embodiment of the application. The difference from the electronic device shown in FIG. 5 is that the electronic device further includes components such as an input unit 403 and an output unit 404.
  • the input unit 403 can be used to receive inputted numbers, character information, or user characteristic information (such as fingerprints), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
  • user characteristic information such as fingerprints
  • the output unit 404 may be used to display information input by the user or information provided to the user, such as a screen.
  • the processor 401 is configured to execute:
  • the memory 402 reclaims recyclable storage blocks based on the discarding thread control, and sleeps the discarding thread.
  • the processor 401 executes:
  • the processor 401 is configured to:
  • the storage block recycling command generated by the file system is sent to the storage 402 based on the discarding thread, so that the storage 402 reclaims the recyclable storage block according to the storage block recycling command.
  • the processor 401 when detecting the storage block recycling command generated by the file system, the processor 401 executes:
  • the storage block recovery command created by the file system for the preset storage area in the memory 402 is detected.
  • the processor 401 executes:
  • the processor 401 executes:
  • the target storage block is the reclaimable storage block that stores the target data that may be read again within a preset period of time;
  • the target storage block is marked as an unrecyclable state, and the memory 402 is controlled based on the discarding thread to reclaim recyclable storage blocks other than the target storage block.
  • the processor 401 when predicting the target storage block in the reclaimable storage block, executes:
  • the processor 401 after controlling the memory 402 to reclaim recyclable storage blocks other than the target storage block based on the discarding thread, the processor 401 further executes:
  • the target storage block When the target data in the target storage block is not read after reaching the time of use, the target storage block is marked as a recyclable state, and the target data is backed up to the cloud storage server.
  • the electronic device provided in the embodiments of this application belongs to the same concept as the storage block recycling method in the above embodiments. Any method provided in the storage block recycling method embodiment can be run on the electronic device, and its specific implementation For details of the process, refer to the embodiment of the feature extraction method, which will not be repeated here.
  • the storage block recycling method of the embodiment of the present application ordinary testers in the field can understand that all or part of the process of implementing the storage block recycling method of the embodiment of the present application can be controlled by a computer program.
  • the computer program may be stored in a computer readable storage medium, such as stored in the memory of an electronic device, and executed by at least one processor in the electronic device, and may include, for example, a storage block The flow of the embodiment of the recovery method.
  • the storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, and the like.
  • the storage block recovery device of the embodiment of the present application its functional modules may be integrated into one processing chip, or each module may exist alone physically, or two or more modules may be integrated into one module.
  • the above-mentioned integrated modules can be implemented in the form of hardware or software function modules. If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer readable storage medium, such as a read-only memory, a magnetic disk or an optical disk, etc. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Software Systems (AREA)
  • Memory System (AREA)

Abstract

本申请实施例公开了一种存储块回收方法、装置、存储介质及电子设备,其中,通过侦测存储器中处于可回收状态的可回收存储块,并根据可回收存储块的数量判断当前是否满足预设回收条件,进而在当前满足预设回收条件时,唤醒文件系统的丢弃线程,基于该丢弃线程控制存储器回收可回收存储块,并休眠该丢弃线程。

Description

存储块回收方法、装置、存储介质及电子设备
本申请要求于2019年09月09日提交中国专利局、申请号为201910849305.2、发明名称为“存储块回收方法、装置、存储介质及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据存储领域,具体涉及一种存储块回收方法、装置、存储介质及电子设备。
背景技术
通常存储器的存储空间非常有限,在有限的存储空间中还会存储有访问频度非常低,甚至不会被访问的数据。为了提高存储器中存储空间的利用率以及读写性能,相关技术通过回收机制来对存储器中存储有上述数据的存储块进行回收,从而释放这些存储块的存储资源,用于继续存储其它数据。
发明内容
本申请提供了一种存储块回收方法、装置、存储介质及电子设备,不仅能够即使回收存储块,更能够避免周期性回收所带来的不必要功耗。
第一方面,本申请提供了一种存储块回收方法,应用于电子设备,所述电子设备包括存储器以及用于管理所述存储器的文件系统,所述存储块回收方法包括:
侦测所述存储器中处于可回收状态的可回收存储块;
根据所述可回收存储块的数量判断当前是否满足预设回收条件;
若满足所述预设回收条件,则唤醒所述文件系统的丢弃线程;
基于所述丢弃线程控制所述存储器回收所述可回收存储块,并休眠所述丢弃线程。
第二方面,本申请提供了一种存储块回收装置,应用于电子设备,所述电子设备包括存储器以及用于管理所述存储器的文件系统,所述存储块回收装置包括:
侦测模块,用于侦测存储器中处于可回收状态的可回收存储块;
判断模块,用于根据可回收存储块的数量判断当前是否满足预设回收条件;
唤醒模块,用于若满足预设回收条件,则唤醒文件系统的丢弃线程;
回收模块,用于基于丢弃线程控制存储器回收可回收存储块,并休眠丢弃线程。
第三方面,本申请提供了一种存储介质,其上存储有计算机程序,当所述计算机程序被包括存储器以及用于管理所述存储器的文件系统的电子设备的处理器调用时,使得所述处理器执行如本申请实施例提供的存储块回收方法。
第四方面,本申请提供了一种电子设备,包括处理器、存储器以及用于管理所述存储器的文件系统,所述存储器存储有计算机程序,且所述处理器通过调用所述计算机程序,用于执行如本申请实施例提供的存储块回收方法。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的存储块回收方法的一流程示意图。
图2是本申请实施例中划分的存储器区域的示意图。
图3是本申请实施例提供的存储块回收方法的另一流程示意图。
图4是本申请实施例提供的存储块回收装置的一结构示意图。
图5是本申请实施例提供的电子设备的一结构示意图。
图6是本申请实施例提供的电子设备的另一结构示意图。
具体实施方式
应当说明的是,本申请的原理是以实施在一适当的运算环境中来举例说明。以下的说明是基于所例示的本申请具体实施例,其不应被视为限制本申请未在此详述的其它具体实施例。
目前,电子设备通常采用闪存作为存储器以存储数据,比如安装应用程序,存储音乐、视频以及图片等。闪存通常包括多个存储块,由文件系统(比如闪存文件系统)进行读/写等操作的管理。其中,存储块的特点是能够对存储块的部分空间进行写入和读取操作,但是不能部分擦除,仅能将存储块整体进行擦除。为此,需要将存储块整体擦除,以便继续存储其它数据,该过程称为存储块的回收。然而,现有的回收机制是周期性的触发,在很多场景下,在触发回收机制时可能是没有回收块需要回收的,这个过程浪费了电子设备的功耗,并且阻止电子设备进入低功耗状态。
为此,本申请实施例提供一种存储块回收方法、存储块回收装置、存储介质以及电子设备,抛弃了周期回收机制,采用按需回收机制,以此来降低周期回收机制所造成的功耗浪费。其中,该存储块回收方法的执行主体可以是本申请实施例提供的存储块回收装置,或者集成了该存储块回收装置的电子设备,其中该存储块回收装置可以采用硬件或者软件的方式实现,电子设备可为计算设备诸如膝上型计算机、包含嵌入式计算机的计算机监视器、平板电脑、蜂窝电话、媒体播放器、或其他手持式或便携式电子设备、较小的设备(诸如腕表设备、挂式设备、耳机或听筒设备、被嵌入在眼镜中的设备或者佩戴在用户的头部上的其他设备,或其他可佩戴式或微型设备)、电视机、不包含嵌入式计算机的计算机显示器、游戏设备、导航设备、嵌入式系统(诸如其中具有显示器的电子设备被安装在信息亭或汽车中的系统)等。
本申请提供一种存储块回收方法,应用于电子设备,所述电子设备包括存储器以及用于管理所述存储器的文件系统,其中,所述存储块回收方法包括:
侦测所述存储器中处于可回收状态的可回收存储块;
根据所述可回收存储块的数量判断当前是否满足预设回收条件;
若满足所述预设回收条件,则唤醒所述文件系统的丢弃线程;
基于所述丢弃线程控制所述存储器回收所述可回收存储块,并休眠所述丢弃线程。
可选地,在一实施例中,所述侦测所述存储器中处于可回收状态的可回收存储块,包括:
侦测所述文件系统生成的存储块回收命令;
将所述存储块回收命令指示的存储块设为所述可回收存储块;
所述基于所述丢弃线程控制所述存储器回收所述可回收存储块,包括:
基于所述丢弃线程将所述存储块回收命令发送至所述存储器,使得所述存储器根据所述存储块回收命令回收所述可回收存储块。
可选地,在一实施例中,所述侦测所述文件系统生成的存储块回收命令,包括:
侦测所述文件系统创建的针对于所述存储器中预设存储区域的存储块回收命令。
可选地,在一实施例中,所述根据所述可回收存储块的数量判断当前是否满足预设回收条件,包括:
根据所述可回收存储块的数量确定所述文件系统可用的第一剩余存储空间容量,以及根据所述可回收存储块的数量确定所述存储器可用的第二剩余存储空间容量;
判断所述第一剩余存储空间容量是否小于第一预设空间容量,以及判断所述第二剩余存储空间容量是否小于第二预设空间容量,所述第二预设空间容量小于所述第一预设空间容量;
当所述第一剩余存储空间容量小于所述第一预设空间容量,且所述第二剩余存储空间容量小于所述第二预设空间容量时,判定当前满足所述预设回收条件。
可选地,在一实施例中,所述基于所述丢弃线程控制所述存储器回收所述可回收存储块,包括:
预测所述可回收存储块中的目标存储块,所述目标存储块为存储有预设时长内可能被再次读取的目标数据的可回收存储块;
将所述目标存储块标记为不可回收状态,并基于所述丢弃线程控制所述存储器回收除所述目标存储块之外的可回收存储块。
可选地,在一实施例中,所述预测所述可回收存储块中的目标存储块,包括:
获取所述可回收存储块中存储数据所对应的读取记录;
向量化表征所述读取记录,得到对应的读取向量;
将所述读取向量输入预先训练的预测模型进行预测,得到所述存储数据可能被再次读取的读取时刻;
根据所述读取时刻确定所述目标存储块。
可选地,在一实施例中,所述基于所述丢弃线程控制所述存储器回收除所述目标存储块之外的可回收存储块之后,还包括:
当所述目标数据在到达所述使用时刻后未被读取时,标记所述目标存储块为可回收状态,并将所述目标数据备份至云存储服务器。
可选地,在一实施例中,所述基于所述丢弃线程控制所述存储器回收所述可回收存储块,包括:
基于所述丢弃线程控制所述存储器直接擦除所述可回收存储块中的数据。
可选地,在一实施例中,所述基于所述丢弃线程控制所述存储器回收所述可回收存储块,包括:
基于所述丢弃线程控制所述存储器将所述可回收存储块中的有效数据迁移至其它存储块,并擦除所述可回收存储块中的数据。
请参照图1,图1为本申请实施例提供的存储块回收方法的流程示意图。该存储块回收方法应用于本申请实施例提供的电子设备,该电子设备包括存储器,如图1所示,本申请实施例提供的存储块回收方法的流程可以如下:
101,侦测存储器中处于可回收状态的可回收存储块。
应当说明的是,存储块为组成存储器中存储单元阵列的存储单元块。其中,存储块由多个存储页组成,擦除操作以存储块为单位进行,读取和写入(或称编程)操作以存储页为单位进行。因此,本申请将存储块作为回收的最小单位。
基于以上描述,电子设备可以实时侦测存储器中处于可回收状态的存储块,将处于可回收状态的存储块记为可回收存储块。
比如,在文件系统执行删除数据、写入数据以及执行垃圾回收等操作时均会产生新的可回收存储块。
102,根据可回收存储块的数量判断当前是否满足预设回收条件。
其中,电子设备实时统计已侦测到的可回收存储块的数量,并根据已侦测到的可回收存储块的数量判断当前是否满足预设回收条件。该预设回收条件可由本领域普通技术人员根据经验设置,比如,根据经验可知,当累积的可回收存储块过多时,将导致存储器性能明显跌落,因此,可以预先确定将导致存储器性能明显跌落的可回收存储块的目标数量,相应设置预设回收条件为:已侦测到的可回收存储块的数量达到该预设数量。
103,若满足预设回收条件,则唤醒文件系统的丢弃线程。
应当说明的是,线程是电子设备的操作系统能够进行运算调度的最小单位,它被包含在进程之中,是进程中的实际运作单位。一条线程可以看做是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每个线程并行执行不同的任务。本申请实施例中,丢弃线程(或称discard thread)是文件系统对应的进程中的一个线程,用来管理存储器何时回收存储块。
在本申请实施例中,丢弃线程默认处于休眠状态,仅在需要控制存储器回收存储块时唤醒,以避免不必要的功耗浪费。
相应的,在判定当前满足预设回收条件时,电子设备唤醒文件系统的丢弃线程。
此外,若未满足预设回收条件,则电子设备继续侦测,直至满足预设回收条件。
104,基于丢弃线程控制存储器回收可回收存储块,并休眠丢弃线程。
当唤醒丢弃线程之后,电子设备即基于该丢弃线程控制存储器回收可回收存储块,比如,存储器在回收可回收存储块时,可以直接擦除可回收存储块中的数据,从而用于存储其它数据,还可以将可回收存储块中的有效数据迁移至其它存储块后,再擦除可回收存储块。
如上所述,在存储器回收可回收存储块之后,丢弃线程没有继续运行的必要,因此,电子设备进一步休眠丢弃线程,从而在下一次需要存储器回收存储块时,再次唤醒丢弃线程,以控制存储器回收可回收存储块。
由上可知,本申请实施例中通过侦测存储器中处于可回收状态的可回收存储块,并根据可回收存储块的数量判断当前是否满足预设回收条件,进而在当前满足预设回收条件时,唤醒文件系统的丢弃线程, 基于该丢弃线程控制存储器回收可回收存储块,并休眠该丢弃线程。相比于相关技术,本申请中并不会周期性的触发存储块的回收,而是在需要回收时才进行回收,不仅能够及时回收存储块,更能够避免周期性回收所带来的不必要功耗。
在一实施例中,“侦测存储器中处于可回收状态的可回收存储块”,包括:
(1)侦测文件系统生成的存储块回收命令;
(2)将存储块回收命令指示的存储块设为可回收存储块;
“基于丢弃线程控制存储器回收可回收存储块”,包括:
(3)基于丢弃线程将文件系统生成的存储块回收命令发送至存储器,使得存储器根据存储块回收命令回收可回收存储块。
应当说明的是,文件系统无论是在执行删除数据、写入数据还是垃圾回收等操作时,最终都会进入统一入口,即执行“__create_discard_cmd函数”,通过“__create_discard_cmd函数”生成存储块回收命令“discard cmd”,用于指示存储器某存储块已经不再使用了,可以进行回收。其中,存储块回收命令可以指示一个存储块已经不再使用,也可以指示多个存储块已经不再使用。
因此,在本申请实施例中,电子设备可以直接侦测文件系统生成的存储块回收命令,并根据存储块回收命令的指示确定不再使用的存储块,将不再使用的存储块设为可回收存储块。
相应的,在基于丢弃线程控制存储器回收可回收存储块时,电子设备可以基于丢弃线程将文件系统已生成的存储块回收命令发送至存储器,使得存储器响应于其接收到的存储块回收命令,对存储块回收命令指示的可回收存储块进行回收,以便于存储其它数据。比如,可以基于丢弃线程执行“__issue_discard_cmd函数”,使得丢弃线程将文件系统已经生成的存储块回收命令发送至存储器。
在一实施例中,“侦测文件系统生成的存储块回收命令”,包括:
侦测文件系统创建的针对于存储器中预设存储区域的存储块回收命令。
其中,预设存储区域可以存储器的全部存储区域,也可以为存储器的部分存储区域。
示例性的,本申请实施例中选择存储器中的一部分存储区域作为需要进行回收的预设存储区域,从而使得文件系统仅生成对该预设存储区域内存储块的存储块回收命令。相应的,电子设备可以侦测文件系统创建的针对于存储器中预设存储区域的存储块回收命令,从而在需要时对该预设存储区域内的存储块进行回收。
其中,电子设备可以根据文件系统对存储器中存储块的写数据的先后顺序,将存储器划分为多个存储区域,每一存储区域包括相同数量的存储块。由此,电子设备依次将划分的存储区域作为需要进行存储块回收的预设存储请求。
比如,请参照图2,电子设备将存储器划分为4个存储区域,分别为存储区域A、存储区域B、存储区域C、存储区域D,电子设备初始将存储区域A设为预设存储区域进行存储块的回收,当触发对存储区域A中存储块的回收并完成回收之后,在将存储区域B设为预设存储区域进行存储块的回收,以此类推,电子设备循环将存储区域A、存储区域B、存储区域C、存储区域D设为预设存储器进行存储块的回收。
在一实施例中,“根据可回收存储块的数量判断当前是否满足预设回收条件”,包括:
(1)根据可回收存储块的数量确定文件系统可用的第一剩余存储空间容量,以及根据可回收存储块的数量确定存储器可用的第二剩余存储空间容量;
(2)判断第一剩余存储空间容量是否小于第一预设空间容量,以及判断第二剩余存储空间容量是否小于第二预设空间容量,第二预设空间容量大于第一预设空间容量;
(3)当第一剩余存储空间容量小于第一预设空间容量,且第二剩余存储空间容量小于第二预设空间容量时,判定当前满足预设回收条件。
应当说明的是,对于某些可回收存储块而言,其对于文件系统是可用的,但是对于存储器是不可用的,由此使得文件系统可用的剩余存储空间容量是大于存储器可用的剩余存储空间容量。为便于区分,本申请实施例中将文件系统可用的剩余存储空间容量记为第一剩余存储空间容量,将存储器可用的剩余存储空间容量记为第二剩余存储空间容量。此外,本申请实施例中设置预设回收条件为:
第一剩余存储空间容量小于第一预设空间容量,且第二剩余空间容量小于第二预设空间容量,其中第二预设空间容量小于第一预设空间容量,第一预设空间容量用于描述文件系统可用的存储空间容量不足,第二预设空间容量用于描述存储器可用的存储空间容量不足。
比如,若以相对于存储器总存储空间的百分比表示存储空间容量,假设第一预设空间容量被配置为30%,第二预设空间容量被配置为20%,则电子设备在文件系统可用的第一剩余存储空间容量小于30%总存储空间容量,且存储器可用的第二剩余存储空间容量小于20%总存储空间容量时,判定当前满足预设回收条件,触发进行存储块的回收。
在一实施例中,“基于丢弃线程控制存储器回收可回收存储块”,包括:
(1)预测可回收存储块中的目标存储块,目标存储块为存储有预设时长内可能被再次读取的目标数据的可回收存储块;
(2)将目标存储块标记为不可回收状态,基于丢弃线程控制存储器回收除目标存储块之外的可回收存储块。
应当说明的是,在本申请实施例中,电子设备并不对侦测到的所有可回收存储块进行回收,仅筛选出其中的一部分进行回收。
其中,电子设备首先预测可回收存储块中的目标存储块,该目标存储块为存储有预设时长内可能被再次读取的目标数据的可回收存储块,比如,对于以存储块而言,可以根据该存储块中存储数据的读取规律预测是否可能在预设时长内被再次读取,进而确定该存储块是否为目标存储块。其中,预设时长的取值可由本领域普通技术人员根据实际需要进行配置,比如,可以设置为1个自然日。
当预测出可回收存储块中的目标存储块之后,电子设备将该目标存储块标记为不可回收状态,从而不对目标存储块进行回收,相应的,电子设备基于丢弃线程控制存储器回收除目标存储块之外的可回收存储块,具体可参照以上实施例中的相关描述,此处不再赘述。
在一实施例中,在将目标存储块标记为不可回收状态时,还在该目标存储块对应的存储块回收命令中添加预设关键字,使得该存储块回收命令失效。
在一实施例中,“预测可回收存储块中的目标存储块”,包括:
(1)获取可回收存储块中存储数据所对应的读取记录;
(2)向量化表征读取记录,得到对应的读取向量;
(3)将读取向量输入预先训练的预测模型进行预测,得到存储数据可能被再次读取的读取时刻;
(4)根据读取时刻确定目标存储块。
应当说明的是,本申请实施例中预先采用机器学习的方式训练有预测模型,该预测模型用于预测存储数据可能被再次读取的读取时刻。
其中,机器学习是一门多领域交叉学科,涉及概率论、统计学、逼近论、凸分析、算法复杂度理论等多门学科,通常包括神经网络、置信网络、强化学习、迁移学习、归纳学习等技术。
示例性的,电子设备预先获取样本数据的读取记录,将其中最后一读取和上一次读取之间的时长作为标签,将读取记录去除最后一次读取的记录后进行向量化表征,作为训练样本,然后构建初始的神经网络以及对应的损失函数,根据训练样本以及对应的标签,以最小化损失函数为目标训练构建的神经网络,直至神经网络收敛时完成训练,将完成训练的神经网络设为预测模型。
这样,在预测可回收存储块中的目标存储块时,电子设备可以首先调用预先训练的预测模型;然后,对于每一可回收存储块,电子设备获取到每一可回收存储块中存储数据对应的读取记录;然后,电子设备向量化表征每一可回收存储块中存储数据对应的读取记录,得到读取向量;然后,电子设备将每一可回收存储块对应的读取向量输入到预先训练的预测模型,得到预测模型输出的每一可回收存储块中存储数据可能被再次读取的读取时刻;然后,电子设备计算每一可回收存储块对应的读取时刻距离当前时刻的剩余时长,将剩余时长小于预设时长的存储块确定为目标存储块。
在一实施例中,本申请实施例提供的存储块回收方法还包括:
当目标存储块中的目标数据在到达使用时刻后未被读取时,标记目标存储块为可回收状态,并将目标数据备份至云存储服务器。
比如,电子设备可以当目标存储块中的目标数据在到达使用时刻后的第二预设时长内未被读取时,标记目标存储块为可回收状态,使得该目标存储块能够在下一次满足预设回收条件时被存储器回收。
此外,电子设备还将目标数据备份至云存储服务器,以便之后需要读取时能够从云存储器服务器获取,避免目标数据丢失。
应当说明的是,第二预设时长可根据电子设备在云存储服务器的可用剩余空间设置,比如,可用剩余空间越大,设置第二预设时长越短,可以剩余空间越小,设置第二预设时长越长。
在一实施例中,在将目标存储块标记为可回收状态时,还移除在该目标存储块对应的存储块回收命令中添加的预设关键字,使得该存储块回收命令有效。
以下以电子设备的存储器为闪存存储器,文件系统为闪存文件系统为例对本申请实施例提供的存储块回收方法进行说明,请参照图3,该存储块回收方法的流程还可以为:
在201中,电子设备侦测闪存文件系统生成的存储块回收命令,并将存储块回收命令指示的存储块 设为可回收存储块。
其中,存储块为组成闪存存储器中存储单元阵列的存储单元块。其中,存储块由多个存储页组成,擦除操作以存储块为单位进行,读取和写入(或称编程)操作以存储页为单位进行。因此,本申请将存储块作为回收的最小单位。
应当说明的是,闪存文件系统无论是在执行删除数据、写入数据还是垃圾回收等操作时,最终都会进入统一入口,即执行“__create_discard_cmd函数”,通过“__create_discard_cmd函数”生成存储块回收命令“discard cmd”,用于指示闪存存储器某存储块已经不再使用了,可以进行回收。其中,存储块回收命令可以指示一个存储块已经不再使用,也可以指示多个存储块已经不再使用。
相应的,电子设备可以直接侦测闪存文件系统生成的存储块回收命令,并根据存储块回收命令的指示确定不再使用的存储块,将不再使用的存储块设为可回收存储块。
在202中,电子设备统计可回收存储块的数量,并根据可回收的存储块的数量确定闪存文件系统可用的第一剩余存储空间容量,以及确定闪存存储器可用的第二剩余存储空间容量。
应当说明的是,对于某些可回收存储块而言,其对于闪存文件系统是可用的,但是对于闪存存储器是不可用的,由此使得闪存文件系统可用的剩余存储空间容量是大于闪存存储器可用的剩余存储空间容量。为便于区分,本申请实施例中将闪存文件系统可用的剩余存储空间容量记为第一剩余存储空间容量,将闪存存储器可用的剩余存储空间容量记为第二剩余存储空间容量。
其中,电子设备首先统计可回收存储块的数量,并据此确定出闪存文件系统可用的第一剩余存储空间容量,以及确定出闪存存储器可用的第二剩余存储空间容量。
在203中,电子设备判断第一剩余存储空间容量是否小于第一预设空间容量,以及判断第二剩余空间容量是否小于第二预设空间容量。
在204中,当第一剩余存储空间容量小于第一预设空间容量,且第二剩余存储空间容量小于第二预设空间容量时,电子设备唤醒闪存文件系统的丢弃线程。
其中,线程是电子设备的操作系统能够进行运算调度的最小单位,它被包含在进程之中,是进程中的实际运作单位。一条线程可以看做是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每个线程并行执行不同的任务。本申请实施例中,丢弃线程(或称discard thread)是闪存文件系统对应的进程中的一个线程,用来管理闪存存储器何时回收存储块。
应当说明的是,本申请实施例中配置有第一预设空间容量和第二预设空间容量,其中第二预设空间容量小于第一预设空间容量,第一预设空间容量用于描述闪存文件系统可用的存储空间容量不足,第二预设空间容量用于描述闪存存储器可用的存储空间容量不足。
其中,电子设备判断第一剩余存储空间容量是否小于第一预设空间容量,以及判断第二剩余空间容量是否小于第二预设空间容量,并根据判断结果确定是否触发闪存存储器回收存储块,其中,当第一剩余存储空间容量小于第一预设空间容量,且第二剩余存储空间容量小于第二预设空间容量时,电子设备判定触发闪存存储器回收存储块,否则判定不触发闪存存储器回收存储块。
比如,若以相对于闪存存储器总存储空间的百分比表示存储空间容量,假设第一预设空间容量被配 置为30%,第二预设空间容量被配置为20%,则电子设备在闪存文件系统可用的第一剩余存储空间容量小于30%总存储空间容量,且闪存存储器可用的第二剩余存储空间容量小于20%总存储空间容量时,触发闪存存储器进行存储块的回收。
在本申请实施例中,丢弃线程默认处于休眠状态,仅在需要控制闪存存储器回收存储块时唤醒,以避免不必要的功耗浪费。由此,当第一剩余存储空间容量小于第一预设空间容量,且第二剩余存储空间容量小于第二预设空间容量时,电子设备唤醒闪存文件系统的丢弃线程。
在205中,电子设备基于丢弃线程将存储块回收命令发送至闪存存储器,使得闪存存储器响应于存储块回收命令而回收可回收存储块。
在唤醒丢弃线程之后,电子设备基于丢弃线程将闪存文件系统已生成的存储块回收命令发送至闪存存储器,使得闪存存储器响应于其接收到的存储块回收命令,对存储块回收命令指示的可回收存储块进行回收,以便于存储其它数据。比如,可以基于丢弃线程执行“__issue_discard_cmd函数”,使得丢弃线程将闪存文件系统已经生成的存储块回收命令发送至闪存存储器。
如上所述,在闪存存储器回收可回收存储块之后,丢弃线程没有继续运行的必要,因此,电子设备进一步休眠丢弃线程,从而在下一次需要闪存存储器回收存储块时,再次唤醒丢弃线程,以控制闪存存储器回收可回收存储块。
本申请实施例还提供一种存储块回收装置。请参照图4,图4为本申请实施例提供的存储块回收装置的结构示意图。其中该存储块回收装置应用于电子设备,该电子设备包括存储器以及用于管理存储器的文件系统,该存储块回收装置包括侦测模块301、判断模块302、唤醒模块303以及回收模块304,如下:
侦测模块301,用于侦测存储器中处于可回收状态的可回收存储块;
判断模块302,用于根据可回收存储块的数量判断当前是否满足预设回收条件;
唤醒模块303,用于若满足预设回收条件,则唤醒文件系统的丢弃线程;
回收模块304,用于基于丢弃线程控制存储器回收可回收存储块,并休眠丢弃线程。
在一实施例中,在侦测存储器中处于可回收状态的可回收存储块时,侦测模块301用于:
侦测文件系统生成的存储块回收命令;
将存储块回收命令指示的存储块设为可回收存储块;
而在基于丢弃线程控制存储器回收可回收存储块时,回收模块304用于:
基于丢弃线程将文件系统生成的存储块回收命令发送至存储器,使得存储器根据存储块回收命令回收可回收存储块。
在一实施例中,在侦测文件系统生成的存储块回收命令时,侦测模块301用于:
侦测文件系统创建的针对于存储器中预设存储区域的存储块回收命令。
在一实施例中,在根据可回收存储块的数量判断当前是否满足预设回收条件时,判断模块302用于:
根据可回收存储块的数量确定文件系统可用的第一剩余存储空间容量,以及根据可回收存储块的数 量确定存储器可用的第二剩余存储空间容量;
判断第一剩余存储空间容量是否小于第一预设空间容量,以及判断第二剩余存储空间容量是否小于第二预设空间容量,第二预设空间容量大于第一预设空间容量;
当第一剩余存储空间容量小于第一预设空间容量,且第二剩余存储空间容量小于第二预设空间容量时,判定当前满足预设回收条件。
在一实施例中,在基于丢弃线程控制存储器回收可回收存储块时,回收模块304用于:
预测可回收存储块中的目标存储块,目标存储块为存储有预设时长内可能被再次读取的目标数据的可回收存储块;
将目标存储块标记为不可回收状态,基于丢弃线程控制存储器回收除目标存储块之外的可回收存储块。
在一实施例中,在预测可回收存储块中的目标存储块时,回收模块304用于:
获取可回收存储块中存储数据所对应的读取记录;
向量化表征读取记录,得到对应的读取向量;
将读取向量输入预先训练的预测模型进行预测,得到存储数据可能被再次读取的读取时刻;
根据读取时刻确定目标存储块。
在一实施例中,在基于丢弃线程控制存储器回收除目标存储块之外的可回收存储块之后,回收模块304还用于:
当目标存储块中的目标数据在到达使用时刻后未被读取时,标记目标存储块为可回收状态,并将目标数据备份至云存储服务器。
应当说明的是,本申请实施例提供的存储块回收装置与上文实施例中的存储块回收方法属于同一构思,在存储块回收装置上可以运行存储块回收方法实施例中提供的任一方法,其具体实现过程详见存储块回收方法实施例,此处不再赘述。
本申请实施例提供一种计算机可读的存储介质,其上存储有计算机程序,当其存储的计算机程序在计算机上执行时,使得计算机执行如本申请实施例提供的存储块回收方法中的步骤。其中,存储介质可以是磁碟、光盘、只读存储器(Read Only Memory,ROM,)或者随机存取器(Random Access Memory,RAM)等。
本申请实施例还提供一种电子设备,请参照图5,电子设备包括处理器401和存储器402,其中,处理器401与存储器402电性连接。
处理器401是电子设备的控制中心,利用各种接口和线路连接整个电子设备的各个部分,通过运行或加载存储在存储器402内的计算机程序,以及调用存储在存储器402内的数据,执行电子设备的各种功能并处理数据。其中,处理器401运行有用于管理存储器402的文件系统。
存储器402可用于存储软件程序以及模块,处理器401通过运行存储在存储器402的计算机程序以 及模块,从而执行各种功能应用以及数据处理。存储器402可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的计算机程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据电子设备的使用所创建的数据等。此外,存储器402可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器402还可以包括存储器控制器,以提供处理器401对存储器402的访问。
在本申请实施例中,电子设备中的处理器401会按照如下的步骤,将一个或一个以上的计算机程序的进程对应的指令加载到存储器402中,并由处理器401运行存储在存储器402中的计算机程序,从而实现各种功能,如下:
侦测存储器402中处于可回收状态的可回收存储块;
根据可回收存储块的数量判断当前是否满足预设回收条件;
若满足预设回收条件,则唤醒文件系统的丢弃线程;
基于丢弃线程控制存储器402回收可回收存储块,并休眠丢弃线程。
请参照图6,图6为本申请实施例提供的电子设备的另一结构示意图,与图5所示电子设备的区别在于,电子设备还包括输入单元403和输出单元404等组件。
其中,输入单元403可用于接收输入的数字、字符信息或用户特征信息(比如指纹),以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入等。
输出单元404可用于显示由用户输入的信息或提供给用户的信息,如屏幕。
在本申请实施例中,处理器401通过调用存储器402中的计算机程序,用于执行:
侦测存储器402中处于可回收状态的可回收存储块;
根据可回收存储块的数量判断当前是否满足预设回收条件;
若满足预设回收条件,则唤醒文件系统的丢弃线程;
基于丢弃线程控制存储器402回收可回收存储块,并休眠丢弃线程。
在一实施例中,在侦测存储器402中处于可回收状态的可回收存储块时,处理器401执行:
侦测文件系统生成的存储块回收命令;
将存储块回收命令指示的存储块设为可回收存储块;
而在基于丢弃线程控制存储器402回收可回收存储块时,处理器401用于:
基于丢弃线程将文件系统生成的存储块回收命令发送至存储器402,使得存储器402根据存储块回收命令回收可回收存储块。
在一实施例中,在侦测文件系统生成的存储块回收命令时,处理器401执行:
侦测文件系统创建的针对于存储器402中预设存储区域的存储块回收命令。
在一实施例中,在根据可回收存储块的数量判断当前是否满足预设回收条件时,处理器401执行:
根据可回收存储块的数量确定文件系统可用的第一剩余存储空间容量,以及根据可回收存储块的数量确定存储器402可用的第二剩余存储空间容量;
判断第一剩余存储空间容量是否小于第一预设空间容量,以及判断第二剩余存储空间容量是否小于 第二预设空间容量,第二预设空间容量大于第一预设空间容量;
当第一剩余存储空间容量小于第一预设空间容量,且第二剩余存储空间容量小于第二预设空间容量时,判定当前满足预设回收条件。
在一实施例中,在基于丢弃线程控制存储器402回收可回收存储块时,处理器401执行:
预测可回收存储块中的目标存储块,目标存储块为存储有预设时长内可能被再次读取的目标数据的可回收存储块;
将目标存储块标记为不可回收状态,基于丢弃线程控制存储器402回收除目标存储块之外的可回收存储块。
在一实施例中,在预测可回收存储块中的目标存储块时,处理器401执行:
获取可回收存储块中存储数据所对应的读取记录;
向量化表征读取记录,得到对应的读取向量;
将读取向量输入预先训练的预测模型进行预测,得到存储数据可能被再次读取的读取时刻;
根据读取时刻确定目标存储块。
在一实施例中,在基于丢弃线程控制存储器402回收除目标存储块之外的可回收存储块之后,处理器401还执行:
当目标存储块中的目标数据在到达使用时刻后未被读取时,标记目标存储块为可回收状态,并将目标数据备份至云存储服务器。
应当说明的是,本申请实施例提供的电子设备与上文实施例中的存储块回收方法属于同一构思,在电子设备上可以运行存储块回收方法实施例中提供的任一方法,其具体实现过程详见特征提取方法实施例,此处不再赘述。
需要说明的是,对本申请实施例的存储块回收方法而言,本领域普通测试人员可以理解实现本申请实施例的存储块回收方法的全部或部分流程,是可以通过计算机程序来控制相关的硬件来完成,所述计算机程序可存储于一计算机可读取存储介质中,如存储在电子设备的存储器中,并被该电子设备内的至少一个处理器执行,在执行过程中可包括如存储块回收方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储器、随机存取记忆体等。
对本申请实施例的存储块回收装置而言,其各功能模块可以集成在一个处理芯片中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中,所述存储介质譬如为只读存储器,磁盘或光盘等。
以上对本申请实施例所提供的一种存储块回收方法、装置、存储介质及电子设备进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。

Claims (20)

  1. 一种存储块回收方法,应用于电子设备,所述电子设备包括存储器以及用于管理所述存储器的文件系统,其中,所述存储块回收方法包括:
    侦测所述存储器中处于可回收状态的可回收存储块;
    根据所述可回收存储块的数量判断当前是否满足预设回收条件;
    若满足所述预设回收条件,则唤醒所述文件系统的丢弃线程;
    基于所述丢弃线程控制所述存储器回收所述可回收存储块,并休眠所述丢弃线程。
  2. 根据权利要求1所述的存储块回收方法,其中,所述侦测所述存储器中处于可回收状态的可回收存储块,包括:
    侦测所述文件系统生成的存储块回收命令;
    将所述存储块回收命令指示的存储块设为所述可回收存储块;
    所述基于所述丢弃线程控制所述存储器回收所述可回收存储块,包括:
    基于所述丢弃线程将所述存储块回收命令发送至所述存储器,使得所述存储器根据所述存储块回收命令回收所述可回收存储块。
  3. 根据权利要求2所述的存储块回收方法,其中,所述侦测所述文件系统生成的存储块回收命令,包括:
    侦测所述文件系统创建的针对于所述存储器中预设存储区域的存储块回收命令。
  4. 根据权利要求1所述的存储块回收方法,其中,所述根据所述可回收存储块的数量判断当前是否满足预设回收条件,包括:
    根据所述可回收存储块的数量确定所述文件系统可用的第一剩余存储空间容量,以及根据所述可回收存储块的数量确定所述存储器可用的第二剩余存储空间容量;
    判断所述第一剩余存储空间容量是否小于第一预设空间容量,以及判断所述第二剩余存储空间容量是否小于第二预设空间容量,所述第二预设空间容量小于所述第一预设空间容量;
    当所述第一剩余存储空间容量小于所述第一预设空间容量,且所述第二剩余存储空间容量小于所述第二预设空间容量时,判定当前满足所述预设回收条件。
  5. 根据权利要求1所述的存储块回收方法,其中,所述基于所述丢弃线程控制所述存储器回收所述可回收存储块,包括:
    预测所述可回收存储块中的目标存储块,所述目标存储块为存储有预设时长内可能被再次读取的目标数据的可回收存储块;
    将所述目标存储块标记为不可回收状态,并基于所述丢弃线程控制所述存储器回收除所述目标存储块之外的可回收存储块。
  6. 根据权利要求5所述的存储块回收方法,其中,所述预测所述可回收存储块中的目标存储块,包括:
    获取所述可回收存储块中存储数据所对应的读取记录;
    向量化表征所述读取记录,得到对应的读取向量;
    将所述读取向量输入预先训练的预测模型进行预测,得到所述存储数据可能被再次读取的读取时刻;
    根据所述读取时刻确定所述目标存储块。
  7. 根据权利要求5所述的存储块回收方法,其中,所述基于所述丢弃线程控制所述存储器回收除所述目标存储块之外的可回收存储块之后,还包括:
    当所述目标数据在到达所述使用时刻后未被读取时,标记所述目标存储块为可回收状态,并将所述目标数据备份至云存储服务器。
  8. 根据权利要求1所述的存储块回收方法,其中,所述基于所述丢弃线程控制所述存储器回收所述可回收存储块,包括:
    基于所述丢弃线程控制所述存储器直接擦除所述可回收存储块中的数据。
  9. 根据权利要求1所述的存储块回收方法,其中,所述基于所述丢弃线程控制所述存储器回收所述可回收存储块,包括:
    基于所述丢弃线程控制所述存储器将所述可回收存储块中的有效数据迁移至其它存储块,并擦除所述可回收存储块中的数据。
  10. 一种存储块回收装置,应用于电子设备,其中,所述电子设备包括存储器以及用于管理所述存储器的文件系统,所述存储块回收装置包括:
    侦测模块,用于侦测存储器中处于可回收状态的可回收存储块;
    判断模块,用于根据可回收存储块的数量判断当前是否满足预设回收条件;
    唤醒模块,用于若满足预设回收条件,则唤醒文件系统的丢弃线程;
    回收模块,用于基于丢弃线程控制存储器回收可回收存储块,并休眠丢弃线程。
  11. 一种存储介质,其上存储有计算机程序,其中,当所述计算机程序被包括存储器以及用于管理所述存储器的文件系统的电子设备的处理器调用时,使得所述处理器执行:
    侦测所述存储器中处于可回收状态的可回收存储块;
    根据所述可回收存储块的数量判断当前是否满足预设回收条件;
    若满足所述预设回收条件,则唤醒所述文件系统的丢弃线程;
    基于所述丢弃线程控制所述存储器回收所述可回收存储块,并休眠所述丢弃线程。
  12. 一种电子设备,其中,包括处理器、存储器以及用于管理所述存储器的文件系统,所述存储器存储有计算机程序,且所述处理器通过调用所述计算机程序,用于执行:
    侦测所述存储器中处于可回收状态的可回收存储块;
    根据所述可回收存储块的数量判断当前是否满足预设回收条件;
    若满足所述预设回收条件,则唤醒所述文件系统的丢弃线程;
    基于所述丢弃线程控制所述存储器回收所述可回收存储块,并休眠所述丢弃线程。
  13. 根据权利要求12所述的电子设备,其中,在侦测所述存储器中处于可回收状态的可回收存储块 时,所述处理器用于执行:
    侦测所述文件系统生成的存储块回收命令;
    将所述存储块回收命令指示的存储块设为所述可回收存储块;
    所述基于所述丢弃线程控制所述存储器回收所述可回收存储块,包括:
    基于所述丢弃线程将所述存储块回收命令发送至所述存储器,使得所述存储器根据所述存储块回收命令回收所述可回收存储块。
  14. 根据权利要求13所述的电子设备,其中,在侦测所述文件系统生成的存储块回收命令时,所述处理器用于执行:
    侦测所述文件系统创建的针对于所述存储器中预设存储区域的存储块回收命令。
  15. 根据权利要求12所述的电子设备,其中,在根据所述可回收存储块的数量判断当前是否满足预设回收条件时,所述处理器用于执行:
    根据所述可回收存储块的数量确定所述文件系统可用的第一剩余存储空间容量,以及根据所述可回收存储块的数量确定所述存储器可用的第二剩余存储空间容量;
    判断所述第一剩余存储空间容量是否小于第一预设空间容量,以及判断所述第二剩余存储空间容量是否小于第二预设空间容量,所述第二预设空间容量小于所述第一预设空间容量;
    当所述第一剩余存储空间容量小于所述第一预设空间容量,且所述第二剩余存储空间容量小于所述第二预设空间容量时,判定当前满足所述预设回收条件。
  16. 根据权利要求12所述的电子设备,其中,在基于所述丢弃线程控制所述存储器回收所述可回收存储块时,所述处理器用于执行:
    预测所述可回收存储块中的目标存储块,所述目标存储块为存储有预设时长内可能被再次读取的目标数据的可回收存储块;
    将所述目标存储块标记为不可回收状态,并基于所述丢弃线程控制所述存储器回收除所述目标存储块之外的可回收存储块。
  17. 根据权利要求16所述的电子设备,其中,在预测所述可回收存储块中的目标存储块时,所述处理器用于执行:
    获取所述可回收存储块中存储数据所对应的读取记录;
    向量化表征所述读取记录,得到对应的读取向量;
    将所述读取向量输入预先训练的预测模型进行预测,得到所述存储数据可能被再次读取的读取时刻;
    根据所述读取时刻确定所述目标存储块。
  18. 根据权利要求16所述的电子设备,其中,在基于所述丢弃线程控制所述存储器回收除所述目标存储块之外的可回收存储块之后,所述处理器还用于执行:
    当所述目标数据在到达所述使用时刻后未被读取时,标记所述目标存储块为可回收状态,并将所述目标数据备份至云存储服务器。
  19. 根据权利要求12所述的电子设备,其中,在基于所述丢弃线程控制所述存储器回收所述可回收存储块时,所述处理器用于执行:
    基于所述丢弃线程控制所述存储器直接擦除所述可回收存储块中的数据。
  20. 根据权利要求12所述的电子设备,其中,在基于所述丢弃线程控制所述存储器回收所述可回收存储块时,所述处理器用于执行:
    基于所述丢弃线程控制所述存储器将所述可回收存储块中的有效数据迁移至其它存储块,并擦除所述可回收存储块中的数据。
PCT/CN2020/111763 2019-09-09 2020-08-27 存储块回收方法、装置、存储介质及电子设备 WO2021047398A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910849305.2A CN110647294B (zh) 2019-09-09 2019-09-09 存储块回收方法、装置、存储介质及电子设备
CN201910849305.2 2019-09-09

Publications (1)

Publication Number Publication Date
WO2021047398A1 true WO2021047398A1 (zh) 2021-03-18

Family

ID=69010398

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/111763 WO2021047398A1 (zh) 2019-09-09 2020-08-27 存储块回收方法、装置、存储介质及电子设备

Country Status (2)

Country Link
CN (1) CN110647294B (zh)
WO (1) WO2021047398A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114741326A (zh) * 2022-03-21 2022-07-12 阿里巴巴(中国)有限公司 数据处理方法以及装置

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110647294B (zh) * 2019-09-09 2022-03-25 Oppo广东移动通信有限公司 存储块回收方法、装置、存储介质及电子设备
CN114063885B (zh) * 2020-07-31 2024-07-09 伊姆西Ip控股有限责任公司 用于管理存储空间的方法、设备和计算机程序产品
CN116236000A (zh) * 2021-12-08 2023-06-09 比亚迪精密制造有限公司 电子烟的数据存储控制方法、电子烟及计算机可读存储介质

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060069850A1 (en) * 2004-09-30 2006-03-30 Rudelic John C Methods and apparatus to perform a reclaim operation in a nonvolatile memory
CN102033945A (zh) * 2010-12-21 2011-04-27 中兴通讯股份有限公司 一种回收脏块的方法及装置
CN102855092A (zh) * 2012-08-10 2013-01-02 浪潮(北京)电子信息产业有限公司 存储局域网中存储空间的管理方法和装置
CN102968279A (zh) * 2012-11-13 2013-03-13 浪潮电子信息产业股份有限公司 一种存储系统自动精简配置的方法
CN106802772A (zh) * 2016-12-30 2017-06-06 北京联想核芯科技有限公司 数据回收的方法、装置及固态硬盘
CN109254850A (zh) * 2018-09-30 2019-01-22 深圳市万普拉斯科技有限公司 存储器资源管理方法及系统
CN109558244A (zh) * 2018-12-03 2019-04-02 郑州云海信息技术有限公司 垃圾信息回收方法、装置、设备及计算机可读存储介质
CN110647294A (zh) * 2019-09-09 2020-01-03 Oppo(重庆)智能科技有限公司 存储块回收方法、装置、存储介质及电子设备

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102982180B (zh) * 2012-12-18 2016-08-03 华为技术有限公司 数据存储方法及设备
CN104462148B (zh) * 2013-09-24 2018-02-16 浙江大华技术股份有限公司 一种数据存储管理方法及装置
US20150163223A1 (en) * 2013-12-09 2015-06-11 International Business Machines Corporation Managing Resources In A Distributed Computing Environment
CN105718530B (zh) * 2016-01-15 2020-02-04 上海磁宇信息科技有限公司 文件存储系统及其文件存储控制方法
CN107229414B (zh) * 2016-03-24 2020-01-17 杭州海康威视数字技术股份有限公司 存储空间回收方法及装置
CN107807797B (zh) * 2017-11-17 2021-03-23 北京联想超融合科技有限公司 数据写入的方法、装置及服务器
CN109992402B (zh) * 2017-12-29 2021-07-09 Oppo广东移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质
CN108268322B (zh) * 2018-02-26 2022-07-01 北京小米移动软件有限公司 内存优化的方法、装置及计算机可读存储介质
CN109634762B (zh) * 2018-12-19 2021-06-18 北京达佳互联信息技术有限公司 一种数据回收方法、装置、电子设备及存储介质

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060069850A1 (en) * 2004-09-30 2006-03-30 Rudelic John C Methods and apparatus to perform a reclaim operation in a nonvolatile memory
CN102033945A (zh) * 2010-12-21 2011-04-27 中兴通讯股份有限公司 一种回收脏块的方法及装置
CN102855092A (zh) * 2012-08-10 2013-01-02 浪潮(北京)电子信息产业有限公司 存储局域网中存储空间的管理方法和装置
CN102968279A (zh) * 2012-11-13 2013-03-13 浪潮电子信息产业股份有限公司 一种存储系统自动精简配置的方法
CN106802772A (zh) * 2016-12-30 2017-06-06 北京联想核芯科技有限公司 数据回收的方法、装置及固态硬盘
CN109254850A (zh) * 2018-09-30 2019-01-22 深圳市万普拉斯科技有限公司 存储器资源管理方法及系统
CN109558244A (zh) * 2018-12-03 2019-04-02 郑州云海信息技术有限公司 垃圾信息回收方法、装置、设备及计算机可读存储介质
CN110647294A (zh) * 2019-09-09 2020-01-03 Oppo(重庆)智能科技有限公司 存储块回收方法、装置、存储介质及电子设备

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114741326A (zh) * 2022-03-21 2022-07-12 阿里巴巴(中国)有限公司 数据处理方法以及装置

Also Published As

Publication number Publication date
CN110647294B (zh) 2022-03-25
CN110647294A (zh) 2020-01-03

Similar Documents

Publication Publication Date Title
WO2021047398A1 (zh) 存储块回收方法、装置、存储介质及电子设备
CN111158910B (zh) 内存管理方法、装置、存储介质及电子设备
US8880775B2 (en) System and method of garbage collection in a memory device
CN103123604B (zh) 跟踪数据处理系统的内存使用的方法
JP4495172B2 (ja) 電源状態に応じて不揮発性メモリのブロック回収を行う装置およびその方法
CN104850435B (zh) 电源管理控制器与方法
CN111274039B (zh) 内存回收方法、装置、存储介质及电子设备
US8898350B2 (en) Multi-bus architecture for mass storage system-on-chip controllers
KR20130021625A (ko) 메모리 상태 변화에 따른 단말기 운용 방법 및 이를 지원하는 단말기
CN1963762A (zh) 堆栈管理系统及方法
Zhang et al. CRFTL: cache reallocation-based page-level flash translation layer for smartphones
CN109491592B (zh) 存储设备及其数据写入方法、存储装置
CN103246609A (zh) 一种闪存存储设备中冷热数据区分管理的方法及装置
WO2022156600A1 (zh) 缓冲区容量的调整方法、装置、电子设备及可读存储介质
CN111475299B (zh) 内存分配方法、装置、存储介质及电子设备
CN114968839A (zh) 硬盘垃圾回收方法、装置、设备及计算机可读存储介质
CN115509953A (zh) 内存回收方法及其装置
CN115481127A (zh) 数据库的数据存储方法、存储介质与设备
CN109189739B (zh) 缓存空间回收方法和装置
CN113867633A (zh) 基于dram与nvm的异构混合内存数据处理方法、系统及存储介质
CN113485642A (zh) 数据缓存方法及装置
WO2023236930A1 (zh) 基于ion分配器的内存分配方法、装置、电子设备和可读存储介质
CN104516472A (zh) 处理器和数据处理方法
US20210004272A1 (en) Electronic device and method for controlling same
CN103176813A (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: 20862524

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

Country of ref document: EP

Kind code of ref document: A1