Method for distributing and reclaiming idle blocks of file

An allocation method and a technology of free blocks, applied in special data processing applications, instruments, electrical digital data processing, etc., can solve the problems of disk space waste, time-consuming, long time to obtain a free block, etc., to save memory and save storage Space, the effect of rapid initialization process

CN101692252BActive Publication Date: 2014-03-26SHANGHAI BAOSIGHT SOFTWARE CO LTD
6 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Publication Date
2014-03-26

Smart Images

  • Figure 1
    Figure 1
  • Figure 2
    Figure 2
  • Figure 3
    Figure 3
Patent Text Reader

Abstract

The invention discloses a method for distributing and reclaiming idle blocks of a file. The distributing method comprises the following steps: dividing the file into N file blocks according to the preset size, and numbering the file blocks; using K file blocks in the N file blocks as index blocks, and connecting the index blocks by adopting a bidirectional link table; storing a previous index block sequence number of the index block, a rear index block sequence number and the number of the idle blocks managed by the index block into the index blocks; and distributing the idle blocks managed by the index block in turn according to the order of the index blocks in the bidirectional link table, and correspondingly modifying information stored in the index blocks. The reclaiming method comprises the following steps: reclaiming the idle blocks in turn by the index blocks according to the order of the index blocks in the bidirectional link table, and correspondingly modifying the information stored in the index blocks. The method is particularly suitable for application situations with high real-time requirements. The method can save a large amount of storage space in the storage of mass historical data of the real-time database, and meanwhile can ensure the real-time response of the real-time database to the data due to extremely high idle block distribution speed.
Need to check novelty before this filing date? Find Prior Art

Description

technical field

[0001] The invention belongs to the technical field of data storage and management, in particular to a method for allocating and reclaiming free blocks of files. Background technique

[0002] In the field of data storage and management, data is usually written into files in blocks of a certain size, and then data indexes are established for data blocks. For example, operating systems and databases usually use B+ trees or Hash functions to establish data indexes for data blocks. The above process requires a file free block management system. When data is to be written to the file, the free block management system allocates a free block to the user, and the user writes the data into the obtained free block, and then adds the address of the block to the data index; When the user wants to release a certain data block, the address of the data block is removed from the data index, and the removed data block is handed over to the free block management system for rec...

Examples

Embodiment 1

[0047]A method for allocating free blocks of a file. The file is divided into N file blocks according to a preset size, and the file blocks are numbered. K of the N file blocks are used as index blocks. The index blocks are connected by a two-way linked list, and the index blocks are Stores the index block number of the index block, the index block number of the index block and the number of free blocks managed by the index block, according to the order of the index block in the doubly linked list, the free blocks managed by the index block are allocated in turn, and the index is modified accordingly The information stored in the block.

[0048] Wherein, a reserved block is set among the N file blocks, and the sequence number of the previous index block in the first index block and the sequence number of the post index block in the last index block among the index blocks are the sequence numbers of the reserved blocks.

[0049] Wherein, when there is no managed free block in t...

Embodiment 2

[0062] A method for reclaiming free blocks of a file. The file is divided into N file blocks according to a preset size, and the file blocks are numbered. K of the N file blocks are used as index blocks. The index blocks are connected by a two-way linked list, and the index blocks are Stores the index block number of the index block, the index block number of the index block and the number of free blocks managed by the index block, according to the order of the index block in the doubly linked list, the index block reclaims the free block in turn, and modifies the index block accordingly information stored in .

[0063] Wherein, a reserved block is set in the N file blocks, and the index blocks are connected by a doubly linked list, the sequence number of the front index block in the first index block in the index block and the rear index block in the last index block The sequence number is the sequence number of the reserved block.

[0064] Wherein, when the index block is f...