[go: up one dir, main page]

CN104462403A - File intercepting method and device - Google Patents

File intercepting method and device Download PDF

Info

Publication number
CN104462403A
CN104462403A CN201410763438.5A CN201410763438A CN104462403A CN 104462403 A CN104462403 A CN 104462403A CN 201410763438 A CN201410763438 A CN 201410763438A CN 104462403 A CN104462403 A CN 104462403A
Authority
CN
China
Prior art keywords
data
written
address
data block
file
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.)
Granted
Application number
CN201410763438.5A
Other languages
Chinese (zh)
Other versions
CN104462403B (en
Inventor
叶茂
杨忠兵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201410763438.5A priority Critical patent/CN104462403B/en
Publication of CN104462403A publication Critical patent/CN104462403A/en
Priority to PCT/CN2015/096468 priority patent/WO2016091124A1/en
Application granted granted Critical
Publication of CN104462403B publication Critical patent/CN104462403B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Human Computer Interaction (AREA)
  • Information Transfer Between Computers (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明提供一种文件截断方法和装置。方法包括:接收客户端发送的文件截断指令,所述指令包括待截断文件的标识,所述待截断文件包括数据块,所述指令用于指示释放所述数据块的空间;根据所述标识确定所述待截断文件;对所述待截断文件加锁;创建所述待截断文件对应的位图;所述位图创建之后,对所述待截断文件解锁;在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,并在所述位图记录所述数据块的标识,以及记录所述数据块的空间已释放。本发明的文件截断方法和装置,能够快速对用户返回截断成功,解决了现有文件截断过程太慢影响其它操作的问题。

The invention provides a file truncation method and device. The method includes: receiving a file truncation instruction sent by a client, the instruction including an identifier of the file to be truncated, the file to be truncated including a data block, the instruction being used to instruct to release the space of the data block; determining according to the identifier The file to be truncated; locking the file to be truncated; creating a bitmap corresponding to the file to be truncated; after the bitmap is created, unlocking the file to be truncated; sending the file to the client After the instruction response message, release the space of the data block, record the identifier of the data block in the bitmap, and record that the space of the data block has been released. The file truncation method and device of the present invention can quickly return the truncation success to the user, and solve the problem that the existing file truncation process is too slow and affects other operations.

Description

文件截断方法和装置File truncation method and device

技术领域technical field

本发明实施例涉及计算机技术,尤其涉及一种文件截断方法和装置。The embodiment of the present invention relates to computer technology, in particular to a file truncation method and device.

背景技术Background technique

截断是指删除文件中的数据,但不删除文件的操作。文件系统存在很多截断的操作,例如对在编辑文档时,插入字符的过程就需要截断操作。图1为一个文件的数据块结构示意图,如图1所示,文件系统的数据块一般按树状结构组织,每个椭圆表示一个数据块,该文件包括8个数据块(编号为0-7)和6个间接块,其中8个数据块也称为叶子块。截断操作时需要把涉及到的数据块都释放掉,例如,原文件的大小为100MB,若截断到1MB,则1MB至100MB之间的数据块都会被释放;若截断到0MB,则原文件中所有的数据块都会被释放掉。当文件系统收到一个要求把图1所示的文件截断到0的指令后,先对文件加锁,使得在截断期间该文件不被更改,即用户在该期间不能对该文件进行读写操作;再释放所有的数据块以及间接块,具体操作为遍历该文件的组织结构,查找要释放的块的地址,包括叶子块与间接块,并释放这些叶子块与间接块,将其挂回空闲队列;然后对该文件解锁,并向用户返回截断成功的消息。Truncation is the act of deleting data from a file without deleting the file. There are many truncation operations in the file system. For example, when editing a document, the process of inserting characters requires a truncation operation. Figure 1 is a schematic diagram of the data block structure of a file. As shown in Figure 1, the data blocks of the file system are generally organized in a tree structure, and each ellipse represents a data block. The file includes 8 data blocks (numbered 0-7 ) and 6 indirect blocks, of which 8 data blocks are also called leaf blocks. During the truncation operation, all the data blocks involved need to be released. For example, if the size of the original file is 100MB, if it is truncated to 1MB, all data blocks between 1MB and 100MB will be released; if it is truncated to 0MB, the original file will be All data blocks will be freed. When the file system receives an instruction to truncate the file shown in Figure 1 to 0, it first locks the file so that the file will not be changed during the truncation period, that is, the user cannot read and write the file during this period ;Release all data blocks and indirect blocks. The specific operation is to traverse the organizational structure of the file, find the address of the block to be released, including leaf blocks and indirect blocks, release these leaf blocks and indirect blocks, and hang them back to idle queue; the file is then unlocked and a successful truncation message is returned to the user.

可以看出,现有技术的截断方法,在截断期间文件都被加锁,而加锁会导致其它的操作无法对该文件加锁而挂住,导致该文件不能被访问,不便于用户操作,也会影响业务的成功率,尤其是当文件较大时,例如文件大小为几十个GB,则块的释放会很慢,而这期间其他操作又无法对该文件进行访问,对于网络存储技术(Network Storage Technologies,简称:NAS)场景有可能导致客户端操作超时,从而造成业务中断。It can be seen that in the truncation method of the prior art, the file is locked during the truncation period, and the locking will cause other operations to be unable to lock the file and hang up, causing the file to be inaccessible, which is inconvenient for the user to operate. It will also affect the success rate of the business, especially when the file is large, for example, the file size is tens of GB, the block release will be very slow, and other operations cannot access the file during this period. For network storage technology (Network Storage Technologies, referred to as: NAS) scenarios may cause client operations to time out, resulting in business interruption.

发明内容Contents of the invention

本发明实施例提供一种文件截断方法和装置,以克服现有技术的文件截断占用时间过长,影响其他业务的成功率的问题。Embodiments of the present invention provide a file truncation method and device to overcome the problem in the prior art that file truncation takes too long and affects the success rate of other services.

第一方面,本发明实施例提供一种文件截断方法,包括:In a first aspect, an embodiment of the present invention provides a file truncation method, including:

接收客户端发送的文件截断指令,所述指令包括待截断文件的标识,所述待截断文件包括数据块,所述指令用于指示释放所述数据块的空间;receiving a file truncation instruction sent by the client, the instruction including an identifier of the file to be truncated, the file to be truncated including a data block, and the instruction is used to instruct to release the space of the data block;

根据所述标识确定所述待截断文件;determining the file to be truncated according to the identifier;

对所述待截断文件加锁;Lock the file to be truncated;

创建所述待截断文件对应的位图;Create a bitmap corresponding to the file to be truncated;

所述位图创建之后,对所述待截断文件解锁;After the bitmap is created, unlock the file to be truncated;

在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,并在所述位图用于记录所述数据块的标识,以及记录所述数据块的空间已释放。After the response message of the instruction is sent to the client, the space of the data block is released, and the identifier of the data block is recorded in the bitmap, and the space of the data block is released.

在第一方面的第一种可能的实现方式中,在所述释放所述数据块的空间之后,所述方法还包括:In a first possible implementation manner of the first aspect, after releasing the space of the data block, the method further includes:

接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;receiving the write data instruction sent by the client, the write data instruction includes the data to be written and the address of the data to be written, the address of the data to be written includes the identifier of the data block and the address of the data to be written write the position of the data in the data block;

根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap;

将所述待写入数据写入所述待写入数据的地址对应的存储空间中。Writing the data to be written into the storage space corresponding to the address of the data to be written.

在第一方面的第二种可能的实现方式中,在所述释放所述数据块的空间之前,所述方法还包括:In a second possible implementation manner of the first aspect, before releasing the space of the data block, the method further includes:

接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;receiving the write data instruction sent by the client, the write data instruction includes the data to be written and the address of the data to be written, the address of the data to be written includes the identifier of the data block and the address of the data to be written write the position of the data in the data block;

根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;determining that the space of the data block has not been released according to the address of the data to be written and the bitmap;

在释放所述数据块的空间后,将所述待写入数据写入所述待写入数据的地址对应的存储空间中。After the space of the data block is released, the data to be written is written into the storage space corresponding to the address of the data to be written.

根据第一方面的第二种可能的实现方式,在第三种可能的实现方式中,在所述在释放所述数据块的空间后,将所述待写入数据写入所述待写入数据的地址对应的存储空间中之前,还包括:According to the second possible implementation of the first aspect, in the third possible implementation, after releasing the space of the data block, writing the data to be written into the Before the storage space corresponding to the address of the data, it also includes:

将所述待写入数据和全零数据组合后的数据写入缓存,所述组合后的数据的大小与所述数据块的大小相同,所述组合后的数据包括所述待写入数据,所述待写入数据在所述组合后的数据中的位置与所述待写入数据的地址在所述数据块中的位置相同;Writing the combined data of the data to be written and all-zero data into the cache, the size of the combined data is the same as the size of the data block, the combined data includes the data to be written, The position of the data to be written in the combined data is the same as the address of the data to be written in the data block;

所述将所述待写入数据写入所述待写入数据的地址对应的存储空间中,包括:从所述缓存中读取所述组合后的数据,写入所述数据块所在的存储空间中。The writing the data to be written into the storage space corresponding to the address of the data to be written includes: reading the combined data from the cache, and writing the data into the storage where the data block is located. in space.

根据第一方面的第一种可能的实现方式,在第四种可能的实现方式中,还包括:According to the first possible implementation of the first aspect, the fourth possible implementation further includes:

接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;receiving a read data command sent by the client, where the read data command includes the address of the data to be written;

根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap;

从所述待写入数据的地址对应的存储空间中获得所述待写入数据;Obtaining the data to be written from the storage space corresponding to the address of the data to be written;

将所述待写入数据发送给所述客户端。Send the data to be written to the client.

根据第一方面的第二种或第三种可能的实现方式,在第五种可能的实现方式中,还包括:According to the second or third possible implementation of the first aspect, in a fifth possible implementation, it further includes:

接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;receiving a read data command sent by the client, where the read data command includes the address of the data to be written;

根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;determining that the space of the data block has not been released according to the address of the data to be written and the bitmap;

向所述客户端发送所述读数据指令的响应消息,所述响应消息用于指示无数据。Sending a response message of the read data command to the client, where the response message is used to indicate that there is no data.

第二方面,本发明实施例提供一种文件截断装置,包括:In a second aspect, an embodiment of the present invention provides a file truncation device, including:

接收模块,用于接收客户端发送的文件截断指令,所述指令包括待截断文件的标识,所述待截断文件包括数据块,所述指令用于指示释放所述数据块的空间;The receiving module is configured to receive a file truncation instruction sent by the client, the instruction includes an identifier of the file to be truncated, the file to be truncated includes a data block, and the instruction is used to instruct to release the space of the data block;

处理模块,用于:Processing modules for:

根据所述标识确定所述待截断文件;determining the file to be truncated according to the identifier;

对所述待截断文件加锁;Lock the file to be truncated;

创建所述待截断文件对应的位图;Create a bitmap corresponding to the file to be truncated;

所述位图创建之后,对所述待截断文件解锁;After the bitmap is created, unlock the file to be truncated;

在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,并在所述位图用于记录所述数据块的标识,以及记录所述数据块的空间已释放。After the response message of the instruction is sent to the client, the space of the data block is released, and the identifier of the data block is recorded in the bitmap, and the space of the data block is released.

在第二方面的第一种可能的实现方式中,所述接收模块,还用于:在所述释放所述数据块的空间之后,接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;In a first possible implementation manner of the second aspect, the receiving module is further configured to: after releasing the space of the data block, receive a write data instruction sent by the client, the write data The instruction includes data to be written and an address of the data to be written, and the address of the data to be written includes an identifier of the data block and a position of the data to be written in the data block;

所述处理模块还用于:The processing module is also used to:

根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap;

将所述待写入数据写入所述待写入数据的地址对应的存储空间中。Writing the data to be written into the storage space corresponding to the address of the data to be written.

在第二方面的第二种可能的实现方式中,所述接收模块,还用于:In a second possible implementation manner of the second aspect, the receiving module is further configured to:

在所述释放所述数据块的空间之前,接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;Before releasing the space of the data block, receiving the write data instruction sent by the client, the write data instruction includes the data to be written and the address of the data to be written, and the address of the data to be written The address includes the identifier of the data block and the position of the data to be written in the data block;

所述处理模块还用于:The processing module is also used to:

根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;determining that the space of the data block has not been released according to the address of the data to be written and the bitmap;

在释放所述数据块的空间后,将所述待写入数据写入所述待写入数据的地址对应的存储空间中。After the space of the data block is released, the data to be written is written into the storage space corresponding to the address of the data to be written.

根据第二方面的第二种可能的实现方式,在第三种可能的实现方式中,所述处理模块,还用于:According to the second possible implementation of the second aspect, in the third possible implementation, the processing module is further configured to:

将所述待写入数据和全零数据组合后的数据写入缓存,所述组合后的数据的大小与所述数据块的大小相同,所述组合后的数据包括所述待写入数据,所述待写入数据在所述组合后的数据中的位置与所述待写入数据的地址在所述数据块中的位置相同;Writing the combined data of the data to be written and all-zero data into the cache, the size of the combined data is the same as the size of the data block, the combined data includes the data to be written, The position of the data to be written in the combined data is the same as the address of the data to be written in the data block;

所述将所述待写入数据写入所述待写入数据的地址对应的存储空间中,包括:从所述缓存中读取所述组合后的数据,写入所述数据块所在的存储空间中。The writing the data to be written into the storage space corresponding to the address of the data to be written includes: reading the combined data from the cache, and writing the data into the storage where the data block is located. in space.

根据第二方面的第一种可能的实现方式,在第四种可能的实现方式中,所述接收模块,还用于:According to the first possible implementation of the second aspect, in a fourth possible implementation, the receiving module is further configured to:

接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;receiving a read data command sent by the client, where the read data command includes the address of the data to be written;

所述处理模块还用于:The processing module is also used to:

根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap;

从所述待写入数据的地址对应的存储空间中获得所述待写入数据;Obtaining the data to be written from the storage space corresponding to the address of the data to be written;

还包括发送模块,用于将所述待写入数据发送给所述客户端。It also includes a sending module, configured to send the data to be written to the client.

根据第二方面的第二种或第三种可能的实现方式,在第五种可能的实现方式中,所述接收模块,还用于:According to the second or third possible implementation of the second aspect, in a fifth possible implementation, the receiving module is further configured to:

接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;receiving a read data command sent by the client, where the read data command includes the address of the data to be written;

所述处理模块还用于:根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;The processing module is further configured to: determine that the space of the data block has not been released according to the address of the data to be written and the bitmap;

所述发送模块还用于:向所述客户端发送所述读数据指令的响应消息,所述响应消息用于指示无数据。The sending module is further configured to: send a response message of the read data instruction to the client, where the response message is used to indicate that there is no data.

本发明实施例提供的文件截断方法和装置,通过所述位图创建之后,对所述待截断文件解锁,在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,然后在所述位图记录所述数据块的标识,以及记录所述数据块的空间已释放的信息在记录截断过程的进度之后就向用户返回截断成功的消息,并将截断任务转入后台运行,由于对待截断文件解锁的步骤在释放所述数据块的空间的步骤之前,使得在实际释放数据块的空间的过程中能够支持新的对文件的访问操作,从而能够快速对用户返回截断成功,提高了便利性,并解决了现有文件系统截断过程太慢影响其它操作的问题,并提高了便利性。In the file truncation method and device provided by the embodiments of the present invention, the file to be truncated is unlocked after the bitmap is created, and the space of the data block is released after sending a response message of the instruction to the client. , then record the identifier of the data block in the bitmap, and record the information that the space of the data block has been released. After recording the progress of the truncation process, a message of truncation success is returned to the user, and the truncation task is transferred to the background Running, because the step of unlocking the file to be truncated is before the step of releasing the space of the data block, so that new access operations to the file can be supported during the process of actually releasing the space of the data block, so that the truncation success can be quickly returned to the user , improve the convenience, and solve the problem that the existing file system truncation process is too slow to affect other operations, and improve the convenience.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description These are some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained according to these drawings without any creative effort.

图1为一个文件的数据块结构示意图;Fig. 1 is a schematic diagram of a data block structure of a file;

图2为本发明文件截断方法实施例一的流程图;FIG. 2 is a flow chart of Embodiment 1 of the file truncation method of the present invention;

图3为基于本发明的文件截断方法,在释放所述数据块的空间已完成时写入数据的方法实施例的流程图;Fig. 3 is based on the file truncation method of the present invention, the flow chart of the method embodiment of writing data when releasing the space of described data block has been completed;

图4为基于本发明的文件截断方法,在释放所述数据块的空间未完成时写入数据的方法实施例的流程图;4 is a flow chart of a method embodiment of writing data when releasing the space of the data block is not completed based on the file truncation method of the present invention;

图5为图4所示实施例中示例性的4号块的空间分布示意图;FIG. 5 is a schematic diagram of the spatial distribution of an exemplary block No. 4 in the embodiment shown in FIG. 4;

图6为基于本发明的文件截断方法,在释放所述数据块的空间已完成时读数据的方法实施例的流程图;6 is a flow chart of a method embodiment of reading data when releasing the space of the data block has been completed based on the file truncation method of the present invention;

图7为基于本发明的文件截断方法,在释放所述数据块的空间未完成时读数据的方法实施例的流程图;7 is a flow chart of a method embodiment of reading data when releasing the space of the data block is not completed based on the file truncation method of the present invention;

图8为本发明文件截断装置实施例一的结构示意图;FIG. 8 is a schematic structural diagram of Embodiment 1 of the file truncation device of the present invention;

图9为本发明件截断装置实施例二的结构示意图;Fig. 9 is a schematic structural view of Embodiment 2 of the piece cutting device of the present invention;

图10为本发明件截断装置实施例三的结构示意图。Fig. 10 is a schematic structural diagram of Embodiment 3 of the piece cutting device of the present invention.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments It is a part of embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.

图2为本发明文件截断方法实施例一的流程图,如图2所示,本实施例的方法可以包括:Fig. 2 is a flowchart of Embodiment 1 of the file truncation method of the present invention. As shown in Fig. 2, the method of this embodiment may include:

步骤201、接收客户端发送的文件截断指令,所述指令包括待截断文件的标识,所述待截断文件包括数据块,所述指令用于指示释放所述数据块的空间。Step 201: Receive a file truncation instruction sent by a client, the instruction includes an identifier of the file to be truncated, the file to be truncated includes a data block, and the instruction is used to instruct to release the space of the data block.

步骤202、根据所述标识确定所述待截断文件。Step 202. Determine the file to be truncated according to the identifier.

步骤203、对所述待截断文件加锁。Step 203, lock the file to be truncated.

步骤204、创建所述待截断文件对应的位图。Step 204, creating a bitmap corresponding to the file to be truncated.

步骤205、所述位图创建之后,对所述待截断文件解锁。Step 205, after the bitmap is created, unlock the file to be truncated.

现有技术中需要将待截断的数据块全部释放之后才将待截断文件解锁的方案,而在本实施例中,步骤205在创建位图之后就对所述待截断文件解锁,使得其他操作能够对该文件进行操作。In the prior art, it is necessary to release all the data blocks to be truncated before unlocking the file to be truncated. In this embodiment, step 205 unlocks the file to be truncated after creating the bitmap, so that other operations can be performed. Operate on the file.

步骤206、在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,并在所述位图记录所述数据块的标识,以及记录所述数据块的空间已释放。Step 206, after sending the response message of the instruction to the client, release the space of the data block, record the identifier of the data block in the bitmap, and record that the space of the data block has been released .

其中,步骤203和步骤204并没有先后顺序,该两个步骤也可以同时进行。步骤204中的位图用于记录截断过程的进度。Wherein, there is no sequence between step 203 and step 204, and these two steps can also be performed at the same time. The bitmap in step 204 is used to record the progress of the truncation process.

可选地,步骤204的位图创建之后,还可以将所述位图记录在保电内存中,即存储在非易失性内存中。或者,还可以进行镜像等备份处理,以保证所述位图不被丢失。Optionally, after the bitmap is created in step 204, the bitmap may also be recorded in a power-saving memory, that is, stored in a non-volatile memory. Alternatively, backup processing such as mirroring may also be performed to ensure that the bitmap is not lost.

并且,该位图任务需要持久化,并根据数据块释放的进度进行更新。Moreover, the bitmap task needs to be persistent and updated according to the progress of data block release.

本实施例的方法,文件系统在收到文件截断指令后,只要创建或初始化所述待截断文件对应的位图之后就对所述待截断文件解锁,并且在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间。这里,释放所述数据块的空间的操作可以由后台执行,对客户端不可见。在实际执行释放数据块的空间的操作时,在所述位图记录所述数据块的标识,以及记录所述数据块的空间已释放的信息,例如每释放掉一个数据块的空间就可以在位图里标记为0。In the method of this embodiment, after the file system receives the file truncation instruction, it unlocks the file to be truncated as long as the bitmap corresponding to the file to be truncated is created or initialized, and sends the instruction to the client After the response message, release the space of the data block. Here, the operation of releasing the space of the data block may be performed in the background, and is invisible to the client. When actually performing the operation of releasing the space of the data block, record the identifier of the data block in the bitmap, and record the information that the space of the data block has been released, for example, each time the space of a data block is released, it can be Marked as 0 in the bitmap.

本实施例的方法,通过在所述位图创建之后,对所述待截断文件解锁,在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,然后在所述位图记录所述数据块的标识,以及记录所述数据块的空间已释放的信息,由于对待截断文件解锁的步骤在释放所述数据块的空间的步骤之前,使得在实际释放数据块的空间的过程中能够支持新的对文件的访问操作,从而能够解决现有文件系统截断过程太慢影响其它操作的问题,并提高了便利性。In the method of this embodiment, after the bitmap is created, the file to be truncated is unlocked, and after a response message of the instruction is sent to the client, the space of the data block is released, and then in the The bitmap records the identification of the data block, and records the information that the space of the data block has been released, because the step of unlocking the file to be truncated is before the step of releasing the space of the data block, so that the space of the data block is actually released The new file access operation can be supported in the process, so as to solve the problem that the truncation process of the existing file system is too slow and affect other operations, and improve the convenience.

由于在返回截断成功的消息时,实际上具体的释放数据块的操作并没有完成,如果在后台进行释放时,又收到访问数据的指令,这时存在两种情况,第一种情况下,虽然整个截断过程未完成,但是待访问的数据块已经释放完成,这种情况只要确认该数据块已经释放完成,对数据的访问可以与一般的数据访问相同,不需要其他的额外处理;第二种情况下,待访问的数据块还没有被释放,则优先释放该待访问的数据块,并且,写入数据的操作与读数据的操作也不相同,下面分别对不同情况下的数据访问过程进行描述。Since the specific operation of releasing the data block has not been completed when the successful truncation message is returned, if an instruction to access the data is received when the release is performed in the background, there are two situations. In the first case, Although the entire truncation process is not completed, the data block to be accessed has been released. In this case, as long as it is confirmed that the data block has been released, the access to the data can be the same as the general data access, and no other additional processing is required; the second In this case, if the data block to be accessed has not been released, the data block to be accessed is released first, and the operation of writing data is different from the operation of reading data. The following describes the data access process in different cases to describe.

图3为基于本发明的文件截断方法,在释放所述数据块的空间已完成时写入数据的方法实施例的流程图,如图3所示,本实施例的方法可以包括:Fig. 3 is based on the file truncation method of the present invention, the flowchart of the method embodiment of writing data when releasing the space of described data block has been completed, as shown in Fig. 3, the method of this embodiment may include:

步骤301、接收客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置。Step 301: Receive the write data instruction sent by the client, the write data instruction includes the data to be written and the address of the data to be written, and the address of the data to be written includes the identifier of the data block and the address of the data to be written. The position of the data to be written in the data block.

通常数据块的空间较大,而待写入数据所需的空间仅占数据块的空间的一部分,因此,待写入数据的地址包括通常需要包括所述数据块的标识和所述待写入数据在所述数据块中的位置。Generally, the space of the data block is large, and the space required for the data to be written only accounts for a part of the space of the data block. Therefore, the address of the data to be written includes the identifier of the data block and the The location of the data within the data block.

步骤302、根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放。Step 302. Determine that the space of the data block has been released according to the address of the data to be written and the bitmap.

步骤303、将所述待写入数据写入所述待写入数据的地址对应的存储空间中。Step 303, writing the data to be written into the storage space corresponding to the address of the data to be written.

本实施例的数据写入方法,在写入数据之前先查询位图,确定所述数据块的空间已被释放,然后再将所述待写入数据写入所述待写入数据的地址对应的存储空间中,即使在整个文件截断过程未结束时,也能够保证写入过程的正常进行。In the data writing method of this embodiment, before writing data, first query the bitmap, determine that the space of the data block has been released, and then write the data to be written into the address corresponding to the data to be written In the storage space, even when the entire file truncation process is not over, the normal progress of the writing process can be guaranteed.

图4为基于本发明的文件截断方法,在释放所述数据块的空间未完成时写入数据的方法实施例的流程图,如图4所示,本实施例的方法可以包括:Fig. 4 is based on the file truncation method of the present invention, the flowchart of the method embodiment of writing data when releasing the space of the data block is not completed, as shown in Fig. 4, the method of this embodiment may include:

步骤401、接收客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置。Step 401: Receive the write data instruction sent by the client, the write data instruction includes the data to be written and the address of the data to be written, the address of the data to be written includes the identifier of the data block and the address of the data to be written The position of the data to be written in the data block.

步骤402、根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放。Step 402. Determine according to the address of the data to be written and the bitmap that the space of the data block has not been released.

接下来,可以在释放所述数据块的空间后,将所述待写入数据写入所述待写入数据的地址对应的存储空间中。Next, after the space of the data block is released, the data to be written may be written into the storage space corresponding to the address of the data to be written.

可选地,在具体实现时,在执行释放所述数据块的空间,将所述待写入数据写入所述待写入数据的地址对应的存储空间中的步骤之前,还可以先执行如下的可选步骤403:Optionally, in specific implementation, before performing the steps of releasing the space of the data block and writing the data to be written into the storage space corresponding to the address of the data to be written, the following steps may also be performed first Optional step for 403:

步骤403、将所述待写入数据和全零数据组合后的数据写入缓存,所述组合后的数据的大小与所述数据块的大小相同,所述组合后的数据包括所述待写入数据,所述待写入数据在所述组合后的数据中的位置与所述待写入数据的地址在所述数据块中的位置相同。Step 403, write the combined data of the data to be written and the all-zero data into the cache, the size of the combined data is the same as the size of the data block, and the combined data includes the data to be written input data, the position of the data to be written in the combined data is the same as the address of the data to be written in the data block.

这时,在释放所述数据块的空间后,将所述待写入数据写入所述待写入数据的地址对应的存储空间中的步骤具体可以为:At this time, after releasing the space of the data block, the step of writing the data to be written into the storage space corresponding to the address of the data to be written may specifically be:

步骤404、从所述缓存中读取所述组合后的数据,写入所述数据块所在的存储空间中。Step 404, read the combined data from the cache, and write it into the storage space where the data block is located.

具体地,将所述待写入数据和全零数据组合后的数据写入缓存,所述组合后的数据的大小与所述数据块的大小相同,所述组合后的数据包括所述待写入数据,所述待写入数据在所述组合后的数据中的位置与所述待写入数据的地址在所述数据块中的位置相同,是指,将所述待写入的数据块采用全零页面表示,与待写入的数据进行组合,组合的结果可以是所述缓存中产生三个页面,分别为:所述数据块的首地址至所述待写入数据在所述数据块中的位置之间的空间所对应的全零页面,待写入数据对应的页面和所述待写入数据在所述数据块中的位置至所述数据块的尾地址之间空间对应的全零页面。Specifically, the combined data of the data to be written and all-zero data is written into the cache, the size of the combined data is the same as the size of the data block, and the combined data includes the data to be written input data, the position of the data to be written in the combined data is the same as the address of the data to be written in the data block, which means that the data block to be written It is represented by an all-zero page and combined with the data to be written. The result of the combination can be that three pages are generated in the cache, which are: the first address of the data block to the data to be written in the data The all-zero page corresponding to the space between the positions in the block, the page corresponding to the data to be written and the space between the position of the data to be written in the data block and the end address of the data block All zero pages.

步骤404中,当缓存数据写入磁盘时,全零页面会转换成截断操作。In step 404, when the cache data is written to the disk, the all-zero page will be converted into a truncation operation.

下面以一个具体的实施例说明待写入的数据块的空间还未释放情况的具体操作。设文件系统组织结构如图1所示,数据块为0~7,每个块的大小为1GB,截断指示为要求截断为0,初始的截断过程进度,即截断位图为11111111,一般的截断任务为从后往前进行,因此,当截断到5时,截断位图为11111000,如果这时收到指令:在4号块中写入大小为4KB的数据,其4KB的数据起始于4号块中首地址之后128KB的位置。这时写入操作可以如图4的方法进行,其中,步骤402具体为检测位图,根据位图确定4号块没有被释放。这时可以优先释放该4号块,步骤403的写入缓存的操作,其具体包括:The specific operation in the case that the space of the data block to be written has not been released is described below with a specific embodiment. Assume the organizational structure of the file system as shown in Figure 1, the data blocks are 0~7, and the size of each block is 1GB. The task is carried out from the back to the front. Therefore, when truncating to 5, the truncated bitmap is 11111000. If an instruction is received at this time: write data with a size of 4KB in block 4, and the 4KB data starts at 4 The position of 128KB after the first address in the number block. At this time, the write operation can be performed as shown in FIG. 4 , wherein step 402 is specifically to detect the bitmap, and determine that block No. 4 has not been released according to the bitmap. At this time, the No. 4 block can be released first, and the operation of writing into the cache in step 403 specifically includes:

将待写入的4KB数据和全零数据进行组合。缓存将产生三个页面:待写入数据之前空间对应的全零页面,待写入的4KB数据对应的页面和待写入数据之后空间对应的全零页面。Combine the 4KB data to be written and all zero data. The cache will generate three pages: an all-zero page corresponding to the space before the data to be written, a page corresponding to the 4KB data to be written, and an all-zero page corresponding to the space after the data to be written.

设该4号块的大小为1GB,例如,该1GB的区域表示的位置是从文件的50GB至51GB之间的区域,写入的4KB的数据位于50GB+128KB的位置,这时,缓存产生的三个页面分别为:[50GB,128KB]、[(50GB+128KB),4KB]、[(50GB+128KB+4K),(1GB-128KB-4KB)],其中,中括号中的第一项表示区域的起始位置,第二项(逗号之后的项)表示该区域的长度。Assume that the size of block No. 4 is 1GB. For example, the 1GB area represents the area from 50GB to 51GB of the file, and the 4KB data written is located at the position of 50GB+128KB. At this time, the cache generated The three pages are: [50GB, 128KB], [(50GB+128KB), 4KB], [(50GB+128KB+4K), (1GB-128KB-4KB)], where the first item in square brackets means The starting position of the region, the second item (the item after the comma) indicates the length of the region.

该4号块的空间分布如图5所示,图5为图4所示实施例中示例性的4号块的空间分布示意图。其中,阴影部分为待写入的4KB数据,阴影部分前后两个空白部分为两个全零页面,阴影部分的起始位置为所述待写入数据的地址包括的述待写入数据在所述数据块中的位置,本实施例中为50GB+128KB,即阴影部分左侧的全零页面的长度为128KB。The spatial distribution of the No. 4 block is shown in FIG. 5 , which is a schematic diagram of the exemplary spatial distribution of the No. 4 block in the embodiment shown in FIG. 4 . Wherein, the shaded part is 4KB data to be written, and the two blank parts before and after the shaded part are two all-zero pages, and the starting position of the shaded part is that the data to be written included in the address of the data to be written is in the The position in the above data block is 50GB+128KB in this embodiment, that is, the length of the all-zero page on the left side of the shaded part is 128KB.

全零页面是一种特殊的页面,用于表示一种释放动作,当缓存数据存入磁盘时,会将所述全零页面转换成截断操作,并把所述数据块和与所述数据块对应的间接块对应的空间全部释放掉。在缓存中数据存入磁盘时,会针对全零页面作特殊的处理,如[50GB,128KB]这个全零页面表示要把文件的从50GB起始往后128KB的区域分配的空间释放掉;[(50GB+128KB+4K),(1GB-128KB-4KB)]表示把文件50GB+128KB+4K位置起51GB-128KB-4KB长度之内的区域空间释放掉;[(50GB+128KB),4KB]区域是用户实际待写入数据的区域。这样,最终存入磁盘的就是4KB的待写入数据。The all-zero page is a special page used to indicate a release action. When the cached data is stored on the disk, the all-zero page will be converted into a truncation operation, and the data block will be combined with the data block The space corresponding to the corresponding indirect block is all released. When the data in the cache is stored on the disk, special processing will be done for the all-zero page, such as [50GB, 128KB] this all-zero page means that the space allocated from the 50GB to the last 128KB area of the file will be released; [ (50GB+128KB+4K), (1GB-128KB-4KB)] means to release the area within the length of 51GB-128KB-4KB from the position of 50GB+128KB+4K of the file; [(50GB+128KB), 4KB] area It is the area where the user actually writes data. In this way, what is finally stored on the disk is 4KB of data to be written.

本实施例的方法,可以应用于待访问的数据块还没有被释放,而有收到写数据指令的情况,通过在写入数据之前优先释放该数据块,然后进行写入的操作完成写入任务,从而保证了写入操作的正常进行。The method of this embodiment can be applied to the case where the data block to be accessed has not been released yet and a write data instruction is received, by releasing the data block first before writing data, and then performing a write operation to complete the write task, thus ensuring the normal progress of the write operation.

图6为基于本发明的文件截断方法,在释放所述数据块的空间已完成时读数据的方法实施例的流程图,如图6所示,本实施例的方法可以包括:Fig. 6 is based on the file truncation method of the present invention, the flow chart of the method embodiment of reading data when releasing the space of the data block has been completed, as shown in Fig. 6, the method of this embodiment may include:

步骤601、接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址。Step 601. Receive a data read command sent by the client, where the read data command includes the address of the data to be written.

其中,本实施例的场景为对于某个文件的截断的操作转入后台执行时的接收到读数据的指令,此时该文件的数据块空间释放并未完成。步骤601的读数据指令是指前述的图3或图4所对应的实施例中写入的数据,因此,读数据指令中包括的地址对应于前述实施例中的待写入数据的地址。Wherein, the scenario of this embodiment is when the truncation operation of a certain file is transferred to the background for execution, and the command to read data is received, and the release of the data block space of the file has not been completed at this time. The read data instruction in step 601 refers to the data written in the aforementioned embodiment corresponding to FIG. 3 or FIG. 4 , therefore, the address included in the read data instruction corresponds to the address of the data to be written in the aforementioned embodiment.

步骤602、根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放。Step 602. Determine according to the address of the data to be written and the bitmap that the space of the data block has been released.

步骤603、从所述待写入数据的地址对应的存储空间中获得所述待写入数据。Step 603. Obtain the data to be written from the storage space corresponding to the address of the data to be written.

步骤604、将所述待写入数据发送给所述客户端。Step 604. Send the data to be written to the client.

相比于现有技术的读数据方法,本实施例的读数据方法在获取读数据指令中要求的数据之前,增加了查看位图,确认所述数据块的空间是否已被释放的步骤,从而保证了即使在整个文件的截断未完成时,也能够执行读数据的操作。Compared with the data reading method in the prior art, the data reading method of this embodiment adds the step of checking the bitmap to confirm whether the space of the data block has been released before obtaining the data required in the data reading instruction, thereby It is guaranteed that the operation of reading data can be performed even when the truncation of the entire file is not completed.

图7为基于本发明的文件截断方法,在释放所述数据块的空间未完成时读数据的方法实施例的流程图,如图7所示,本实施例的方法可以包括:FIG. 7 is a flow chart of a method embodiment of reading data when releasing the space of the data block is not completed based on the file truncation method of the present invention. As shown in FIG. 7, the method of this embodiment may include:

步骤701、接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址。Step 701. Receive a data read command sent by the client, where the read data command includes the address of the data to be written.

其中,本实施例的场景为对于某个文件的截断的操作转入后台执行时的接收到读数据的指令,此时该文件的数据块空间释放并未完成。步骤701的读数据指令是指前述的图3或图4所对应的实施例中写入的数据,因此,读数据指令中包括的地址对应于前述实施例中的待写入数据的地址。Wherein, the scenario of this embodiment is when the truncation operation of a certain file is transferred to the background for execution, and the command to read data is received, and the release of the data block space of the file has not been completed at this time. The read data instruction in step 701 refers to the data written in the aforementioned embodiment corresponding to FIG. 3 or FIG. 4 , therefore, the address included in the read data instruction corresponds to the address of the data to be written in the aforementioned embodiment.

步骤702、根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放。Step 702. Determine according to the address of the data to be written and the bitmap that the space of the data block has not been released.

步骤703、向所述客户端发送所述读数据指令的响应消息,所述响应消息用于指示无数据。Step 703: Send a response message of the read data instruction to the client, where the response message is used to indicate that there is no data.

相比于现有技术的读数据方法,本实施例的读数据方法在获取读数据指令中要求的数据之前,增加了查看位图,确认所述数据块的空间是否已被释放的步骤,本实施例中,由于数据块的空间未被释放,因此向客户端返回无数据的指示。Compared with the data reading method in the prior art, the data reading method in this embodiment adds a step of checking the bitmap to confirm whether the space of the data block has been released before obtaining the data required in the data reading instruction. In an embodiment, since the space of the data block has not been released, an indication of no data is returned to the client.

结合上述各个实施例,通过把文件截断操作转变为后台执行的释放数据块的空间的任务,并通过位图记录释放数据块的空间的过程的进度,能够快速对所述待截断文件解锁,并向所述客户端发送所述指令的响应消息,从用户感知的角度,加快了大文件的截断操作,能够更快的响应数据块的应用;对于NAS场景,对于数据量较大的文件的截断命令不容易超时,从而提高了业务的成功率;同时,采用位图记录,例如位图日志(log)的方式,保证数据块空间释放、写入数据和读数据这些操作之间的独立性,不会因为数据块空间释放过程影响读数据和写入数据的执行。In combination with the above-mentioned embodiments, by converting the file truncation operation into a task of releasing the space of the data block executed in the background, and recording the progress of the process of releasing the space of the data block through the bitmap, the file to be truncated can be quickly unlocked, and Sending the response message of the instruction to the client, from the perspective of user perception, speeds up the truncation operation of large files, and can respond to the application of data blocks faster; for NAS scenarios, the truncation of files with a large amount of data Commands are not easy to time out, thereby improving the success rate of business; at the same time, bitmap records, such as bitmap logs (log), are used to ensure the independence of data block space release, writing data and reading data. The execution of reading and writing data will not be affected by the data block space release process.

图8为本发明文件截断装置实施例一的结构示意图,本实施例的装置可以为设置在计算机、服务器、智能手机或者其他电子产品上,如图8所示,本实施例的文件截断装置800可以包括:接收模块801和处理模块802,其中,FIG. 8 is a schematic structural diagram of Embodiment 1 of the file truncation device of the present invention. The device of this embodiment may be installed on a computer, server, smart phone or other electronic products. As shown in FIG. 8 , the file truncation device 800 of this embodiment May include: a receiving module 801 and a processing module 802, wherein,

接收模块801,可以用于接收客户端发送的文件截断指令,所述指令包括待截断文件的标识,所述待截断文件包括数据块,所述指令用于指示释放所述数据块的空间;The receiving module 801 may be configured to receive a file truncation instruction sent by the client, the instruction includes an identifier of the file to be truncated, the file to be truncated includes a data block, and the instruction is used to instruct to release the space of the data block;

处理模块802,可以用于:The processing module 802 can be used for:

根据所述标识确定所述待截断文件;determining the file to be truncated according to the identifier;

对所述待截断文件加锁;Lock the file to be truncated;

创建所述待截断文件对应的位图;Create a bitmap corresponding to the file to be truncated;

所述位图创建之后,对所述待截断文件解锁;After the bitmap is created, unlock the file to be truncated;

在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,并在所述位图用于记录所述数据块的标识,以及记录所述数据块的空间已释放。After the response message of the instruction is sent to the client, the space of the data block is released, and the identifier of the data block is recorded in the bitmap, and the space of the data block is released.

可选地,在一个场景中,所述接收模块801,还用于在所述释放所述数据块的空间之后,接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;Optionally, in one scenario, the receiving module 801 is further configured to receive a write data instruction sent by the client after releasing the space of the data block, the write data instruction includes data and the address of the data to be written, the address of the data to be written includes the identification of the data block and the position of the data to be written in the data block;

所述处理模块802还用于:The processing module 802 is also used for:

根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap;

将所述待写入数据写入所述待写入数据的地址对应的存储空间中。Writing the data to be written into the storage space corresponding to the address of the data to be written.

可选地,在另一场景中,所述接收模块801,还可以用于在所述释放所述数据块的空间之前,接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;Optionally, in another scenario, the receiving module 801 may also be configured to receive a write data instruction sent by the client before releasing the space of the data block, the write data instruction includes Writing data and the address of the data to be written, the address of the data to be written includes the identification of the data block and the position of the data to be written in the data block;

所述处理模块802,还用于:The processing module 802 is further configured to:

根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;determining that the space of the data block has not been released according to the address of the data to be written and the bitmap;

在释放所述数据块的空间后,将所述待写入数据写入所述待写入数据的地址对应的存储空间中。After the space of the data block is released, the data to be written is written into the storage space corresponding to the address of the data to be written.

可选地,所述处理模块802还可以用于:Optionally, the processing module 802 may also be used to:

将所述待写入数据和全零数据组合后的数据写入缓存,所述组合后的数据的大小与所述数据块的大小相同,所述组合后的数据包括所述待写入数据,所述待写入数据在所述组合后的数据中的位置与所述待写入数据的地址在所述数据块中的位置相同;Writing the combined data of the data to be written and all-zero data into the cache, the size of the combined data is the same as the size of the data block, the combined data includes the data to be written, The position of the data to be written in the combined data is the same as the address of the data to be written in the data block;

所述将所述待写入数据写入所述待写入数据的地址对应的存储空间中,包括:从所述缓存中读取所述组合后的数据,写入所述数据块所在的存储空间中。The writing the data to be written into the storage space corresponding to the address of the data to be written includes: reading the combined data from the cache, and writing the data into the storage where the data block is located. in space.

本实施例的装置,可以用于执行图2~4所示方法实施例的技术方案,其实现原理类似,此处不再赘述。The device of this embodiment can be used to implement the technical solutions of the method embodiments shown in FIGS. 2 to 4 , and its implementation principles are similar, so details are not repeated here.

本实施例的装置,通过所述位图创建之后,对所述待截断文件解锁,在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,然后在所述位图记录所述数据块的标识,以及记录所述数据块的空间已释放的信息在记录截断过程的进度之后就向用户返回截断成功的消息,并将截断任务转入后台运行,由于对待截断文件解锁的步骤在释放所述数据块的空间的步骤之前,使得在实际释放数据块的空间的过程中能够支持新的对文件的访问操作,从而能够快速对用户返回截断成功,提高了便利性,并解决了现有文件系统截断过程太慢影响其它操作的问题,并提高了便利性。并且,在实际释放数据块的空间的过程中,写数据的操作能够顺利进行。The device in this embodiment unlocks the file to be truncated after the bitmap is created, and releases the space of the data block after sending a response message of the instruction to the client, and then in the bitmap Figure records the identification of the data block, and records the information that the space of the data block has been released. After recording the progress of the truncation process, a truncation success message will be returned to the user, and the truncation task will be transferred to the background. Since the file to be truncated The step of unlocking is before the step of releasing the space of the data block, so that new access operations to the file can be supported during the process of actually releasing the space of the data block, so that the truncation success can be quickly returned to the user, and the convenience is improved. It also solves the problem that the truncation process of the existing file system is too slow and affects other operations, and improves convenience. Moreover, in the process of actually releasing the space of the data block, the operation of writing data can be carried out smoothly.

图9为本发明件截断装置实施例二的结构示意图,本实施例的所述文件截断装置900,在图8所示实施例的基础上,还可以包括发送模块803。FIG. 9 is a schematic structural diagram of Embodiment 2 of the file truncation device of the present invention. The file truncation device 900 of this embodiment may further include a sending module 803 on the basis of the embodiment shown in FIG. 8 .

在一个场景中,所述接收模块801,还可以用于接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;In one scenario, the receiving module 801 may also be configured to receive a read data instruction sent by the client, where the read data instruction includes the address of the data to be written;

所述处理模块802还可以用于:The processing module 802 may also be used for:

根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap;

从所述待写入数据的地址对应的存储空间中获得所述待写入数据;Obtaining the data to be written from the storage space corresponding to the address of the data to be written;

所述发送模块803可以用于将所述待写入数据发送给所述客户端。The sending module 803 may be configured to send the data to be written to the client.

可选地,在另一场景中,所述接收模块801,还用于:Optionally, in another scenario, the receiving module 801 is further configured to:

接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;receiving a read data command sent by the client, where the read data command includes the address of the data to be written;

所述处理模块802还用于:根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;The processing module 802 is further configured to: determine according to the address of the data to be written and the bitmap that the space of the data block has not been released;

所述发送模块803还用于:向所述客户端发送所述读数据指令的响应消息,所述响应消息用于指示无数据。The sending module 803 is further configured to: send a response message of the read data instruction to the client, where the response message is used to indicate that there is no data.

本实施例的装置,可以用于执行图6、7所示方法实施例的技术方案,其实现原理类似,此处不再赘述。The device of this embodiment can be used to implement the technical solutions of the method embodiments shown in FIGS. 6 and 7 , and the implementation principles thereof are similar, and details are not repeated here.

本实施例的装置,通过所述位图创建之后,对所述待截断文件解锁,在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,然后在所述位图记录所述数据块的标识,以及记录所述数据块的空间已释放的信息在记录截断过程的进度之后就向用户返回截断成功的消息,并将截断任务转入后台运行,由于对待截断文件解锁的步骤在释放所述数据块的空间的步骤之前,使得在实际释放数据块的空间的过程中能够支持新的对文件的访问操作,从而能够快速对用户返回截断成功,提高了便利性,并解决了现有文件系统截断过程太慢影响其它操作的问题,并提高了便利性。并且,在实际释放数据块的空间的过程中,读数据的操作能够顺利进行。The device in this embodiment unlocks the file to be truncated after the bitmap is created, and releases the space of the data block after sending a response message of the instruction to the client, and then in the bitmap Figure records the identification of the data block, and records the information that the space of the data block has been released. After recording the progress of the truncation process, a truncation success message will be returned to the user, and the truncation task will be transferred to the background. Since the file to be truncated The step of unlocking is before the step of releasing the space of the data block, so that new access operations to the file can be supported during the process of actually releasing the space of the data block, so that the truncation success can be quickly returned to the user, and the convenience is improved. It also solves the problem that the truncation process of the existing file system is too slow and affects other operations, and improves convenience. Moreover, in the process of actually releasing the space of the data block, the operation of reading data can be carried out smoothly.

图10为本发明文件截断装置实施例三的结构示意图,本实施例的文件截断装置可以为计算机、服务器、智能手机或者其他电子产品,可以用于执行图2~4、6~7所示任一方法实施例的方法,如图10所示,本实施例的文件截断装置1000可以包括:接口电路1001和处理器1002,图中还示出了存储器1003和总线1004,该处理器1002、接口电路1001和存储器1003通过总线1004连接并完成相互间的通信。FIG. 10 is a schematic structural diagram of Embodiment 3 of the file truncation device of the present invention. The file truncation device of this embodiment can be a computer, server, smart phone or other electronic products, and can be used to perform any of the tasks shown in FIGS. 2-4, 6-7. The method of a method embodiment, as shown in FIG. 10, the file truncation apparatus 1000 of this embodiment may include: an interface circuit 1001 and a processor 1002, and a memory 1003 and a bus 1004 are also shown in the figure. The processor 1002, interface The circuit 1001 and the memory 1003 are connected through a bus 1004 and communicate with each other.

该总线1004可以是工业标准体系结构(Industry Standard Architecture,ISA)总线、外部设备互连(Peripheral Component,PCI)总线或扩展工业标准体系结构(Extended Industry Standard Architecture,EISA)总线等。该总线1004可以分为地址总线、数据总线、控制总线等。为便于表示,图10中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The bus 1004 may be an Industry Standard Architecture (Industry Standard Architecture, ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (Extended Industry Standard Architecture, EISA) bus, etc. The bus 1004 can be divided into address bus, data bus, control bus and so on. For ease of representation, only one thick line is used in FIG. 10 , but it does not mean that there is only one bus or one type of bus.

存储器1003用于存储可执行程序代码,该程序代码包括计算机操作指令。存储器1003可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。The memory 1003 is used for storing executable program codes, and the program codes include computer operation instructions. The memory 1003 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

处理器1002可以是一个中央处理器(Central Processing Unit,CPU),或者是特定集成电路(Application Specific Integrated Circuit,ASIC),或者是被配置成实施本发明实施例的一个或多个集成电路。The processor 1002 may be a central processing unit (Central Processing Unit, CPU), or a specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.

其中,接口电路1001,可以用于接收客户端发送的文件截断指令,所述指令包括待截断文件的标识,所述待截断文件包括数据块,所述指令用于指示释放所述数据块的空间;Wherein, the interface circuit 1001 may be configured to receive a file truncation instruction sent by the client, the instruction includes the identifier of the file to be truncated, the file to be truncated includes a data block, and the instruction is used to instruct to release the space of the data block ;

处理器1002,可以用于:The processor 1002 can be used for:

根据所述标识确定所述待截断文件;determining the file to be truncated according to the identifier;

对所述待截断文件加锁;Lock the file to be truncated;

创建所述待截断文件对应的位图;Create a bitmap corresponding to the file to be truncated;

所述位图创建之后,对所述待截断文件解锁;After the bitmap is created, unlock the file to be truncated;

在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,并在所述位图用于记录所述数据块的标识,以及记录所述数据块的空间已释放。After the response message of the instruction is sent to the client, the space of the data block is released, and the identifier of the data block is recorded in the bitmap, and the space of the data block is released.

可选地,在一个场景中,接口电路1001,还用于在所述释放所述数据块的空间之后,接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;Optionally, in one scenario, the interface circuit 1001 is further configured to receive a write data instruction sent by the client after releasing the space of the data block, the write data instruction includes data to be written and The address of the data to be written, the address of the data to be written includes the identifier of the data block and the position of the data to be written in the data block;

所述处理器1002还用于:The processor 1002 is also used for:

根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap;

将所述待写入数据写入所述待写入数据的地址对应的存储空间中。Writing the data to be written into the storage space corresponding to the address of the data to be written.

可选地,在另一场景中,所述接口电路1001,还可以用于在所述释放所述数据块的空间之前,接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;Optionally, in another scenario, the interface circuit 1001 may also be configured to receive a write data instruction sent by the client before releasing the space of the data block, the write data instruction includes waiting Writing data and the address of the data to be written, the address of the data to be written includes the identification of the data block and the position of the data to be written in the data block;

所述处理器1002,还用于:The processor 1002 is further configured to:

根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;determining that the space of the data block has not been released according to the address of the data to be written and the bitmap;

在释放所述数据块的空间后,将所述待写入数据写入所述待写入数据的地址对应的存储空间中。After the space of the data block is released, the data to be written is written into the storage space corresponding to the address of the data to be written.

可选地,所述处理器1002还可以用于:Optionally, the processor 1002 may also be used to:

将所述待写入数据和全零数据组合后的数据写入缓存,所述组合后的数据的大小与所述数据块的大小相同,所述组合后的数据包括所述待写入数据,所述待写入数据在所述组合后的数据中的位置与所述待写入数据的地址在所述数据块中的位置相同;Writing the combined data of the data to be written and all-zero data into the cache, the size of the combined data is the same as the size of the data block, the combined data includes the data to be written, The position of the data to be written in the combined data is the same as the address of the data to be written in the data block;

所述将所述待写入数据写入所述待写入数据的地址对应的存储空间中,包括:从所述缓存中读取所述组合后的数据,写入所述数据块所在的存储空间中。The writing the data to be written into the storage space corresponding to the address of the data to be written includes: reading the combined data from the cache, and writing the data into the storage where the data block is located. in space.

在一个场景中,所述接口电路1001,还可以用于接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;In one scenario, the interface circuit 1001 may also be configured to receive a read data instruction sent by the client, where the read data instruction includes the address of the data to be written;

所述处理器1002还可以用于:The processor 1002 may also be used for:

根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap;

从所述待写入数据的地址对应的存储空间中获得所述待写入数据;Obtaining the data to be written from the storage space corresponding to the address of the data to be written;

所述接口电路1001可以用于将所述待写入数据发送给所述客户端。The interface circuit 1001 may be configured to send the data to be written to the client.

可选地,在另一场景中,所述接口电路1001,还用于:Optionally, in another scenario, the interface circuit 1001 is also used to:

接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;receiving a read data command sent by the client, where the read data command includes the address of the data to be written;

所述处理器1001还用于:根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;The processor 1001 is further configured to: determine according to the address of the data to be written and the bitmap that the space of the data block has not been released;

所述接口电路1001还用于:向所述客户端发送所述读数据指令的响应消息,所述响应消息用于指示无数据。The interface circuit 1001 is further configured to: send a response message of the read data command to the client, where the response message is used to indicate that there is no data.

本实施例的装置,通过所述位图创建之后,对所述待截断文件解锁,在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,然后在所述位图记录所述数据块的标识,以及记录所述数据块的空间已释放的信息在记录截断过程的进度之后就向用户返回截断成功的消息,并将截断任务转入后台运行,由于对待截断文件解锁的步骤在释放所述数据块的空间的步骤之前,使得在实际释放数据块的空间的过程中能够支持新的对文件的访问操作,从而能够快速对用户返回截断成功,提高了便利性,并解决了现有文件系统截断过程太慢影响其它操作的问题,并提高了便利性。并且,在实际释放数据块的空间的过程中,写数据和读数据的操作能够顺利进行。The device in this embodiment unlocks the file to be truncated after the bitmap is created, and releases the space of the data block after sending a response message of the instruction to the client, and then in the bitmap Figure records the identification of the data block, and records the information that the space of the data block has been released. After recording the progress of the truncation process, a truncation success message will be returned to the user, and the truncation task will be transferred to the background. Since the file to be truncated The step of unlocking is before the step of releasing the space of the data block, so that new access operations to the file can be supported during the process of actually releasing the space of the data block, so that the truncation success can be quickly returned to the user, and the convenience is improved. It also solves the problem that the truncation process of the existing file system is too slow and affects other operations, and improves convenience. Moreover, during the process of actually releasing the space of the data block, the operations of writing data and reading data can be carried out smoothly.

本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps for implementing the above method embodiments can be completed by program instructions and related hardware. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the above-mentioned method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other various media that can store program codes.

最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, rather than limiting them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: It is still possible to modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the various embodiments of the present invention. scope.

Claims (12)

1.一种文件截断方法,其特征在于,包括:1. A file truncation method, characterized in that, comprising: 接收客户端发送的文件截断指令,所述指令包括待截断文件的标识,所述待截断文件包括数据块,所述指令用于指示释放所述数据块的空间;receiving a file truncation instruction sent by the client, the instruction including an identifier of the file to be truncated, the file to be truncated including a data block, and the instruction is used to instruct to release the space of the data block; 根据所述标识确定所述待截断文件;determining the file to be truncated according to the identifier; 对所述待截断文件加锁;Lock the file to be truncated; 创建所述待截断文件对应的位图;Create a bitmap corresponding to the file to be truncated; 所述位图创建之后,对所述待截断文件解锁;After the bitmap is created, unlock the file to be truncated; 在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,并在所述位图记录所述数据块的标识,以及记录所述数据块的空间已释放。After sending the response message of the instruction to the client, release the space of the data block, record the identifier of the data block in the bitmap, and record that the space of the data block has been released. 2.根据权利要求1所述的方法,其特征在于,在所述释放所述数据块的空间之后,所述方法还包括:2. The method according to claim 1, characterized in that, after releasing the space of the data block, the method further comprises: 接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;receiving the write data instruction sent by the client, the write data instruction includes the data to be written and the address of the data to be written, the address of the data to be written includes the identifier of the data block and the address of the data to be written write the position of the data in the data block; 根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap; 将所述待写入数据写入所述待写入数据的地址对应的存储空间中。Writing the data to be written into the storage space corresponding to the address of the data to be written. 3.根据权利要求1所述的方法,其特征在于,在所述释放所述数据块的空间之前,所述方法还包括:3. The method according to claim 1, wherein, before releasing the space of the data block, the method further comprises: 接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;receiving the write data instruction sent by the client, the write data instruction includes the data to be written and the address of the data to be written, the address of the data to be written includes the identifier of the data block and the address of the data to be written write the position of the data in the data block; 根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;determining that the space of the data block has not been released according to the address of the data to be written and the bitmap; 在释放所述数据块的空间后,将所述待写入数据写入所述待写入数据的地址对应的存储空间中。After the space of the data block is released, the data to be written is written into the storage space corresponding to the address of the data to be written. 4.根据权利要求3所述的方法,其特征在于,在所述在释放所述数据块的空间后,将所述待写入数据写入所述待写入数据的地址对应的存储空间中之前,还包括:4. The method according to claim 3, characterized in that, after releasing the space of the data block, writing the data to be written into the storage space corresponding to the address of the data to be written Previously, also included: 将所述待写入数据和全零数据组合后的数据写入缓存,所述组合后的数据的大小与所述数据块的大小相同,所述组合后的数据包括所述待写入数据,所述待写入数据在所述组合后的数据中的位置与所述待写入数据的地址在所述数据块中的位置相同;Writing the combined data of the data to be written and all-zero data into the cache, the size of the combined data is the same as the size of the data block, the combined data includes the data to be written, The position of the data to be written in the combined data is the same as the address of the data to be written in the data block; 所述将所述待写入数据写入所述待写入数据的地址对应的存储空间中,包括:从所述缓存中读取所述组合后的数据,写入所述数据块所在的存储空间中。The writing the data to be written into the storage space corresponding to the address of the data to be written includes: reading the combined data from the cache, and writing the data into the storage where the data block is located. in space. 5.根据权利要求2所述的方法,其特征在于,还包括:5. The method of claim 2, further comprising: 接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;receiving a read data command sent by the client, where the read data command includes the address of the data to be written; 根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap; 从所述待写入数据的地址对应的存储空间中获得所述待写入数据;Obtaining the data to be written from the storage space corresponding to the address of the data to be written; 将所述待写入数据发送给所述客户端。Send the data to be written to the client. 6.根据权利要求3或4所述的方法,其特征在于,还包括:6. The method according to claim 3 or 4, further comprising: 接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;receiving a read data command sent by the client, where the read data command includes the address of the data to be written; 根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;determining that the space of the data block has not been released according to the address of the data to be written and the bitmap; 向所述客户端发送所述读数据指令的响应消息,所述响应消息用于指示无数据。Sending a response message of the read data command to the client, where the response message is used to indicate that there is no data. 7.一种文件截断装置,其特征在于,包括:7. A file truncation device, characterized in that, comprising: 接收模块,用于接收客户端发送的文件截断指令,所述指令包括待截断文件的标识,所述待截断文件包括数据块,所述指令用于指示释放所述数据块的空间;The receiving module is configured to receive a file truncation instruction sent by the client, the instruction includes an identifier of the file to be truncated, the file to be truncated includes a data block, and the instruction is used to instruct to release the space of the data block; 处理模块,用于:Processing modules for: 根据所述标识确定所述待截断文件;determining the file to be truncated according to the identifier; 对所述待截断文件加锁;Lock the file to be truncated; 创建所述待截断文件对应的位图;Create a bitmap corresponding to the file to be truncated; 所述位图创建之后,对所述待截断文件解锁;After the bitmap is created, unlock the file to be truncated; 在向所述客户端发送所述指令的响应消息之后,释放所述数据块的空间,并在所述位图记录所述数据块的标识,以及记录所述数据块的空间已释放。After sending the response message of the instruction to the client, release the space of the data block, record the identifier of the data block in the bitmap, and record that the space of the data block has been released. 8.根据权利要求7所述的装置,其特征在于,所述接收模块,还用于:在所述释放所述数据块的空间之后,接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;8. The device according to claim 7, wherein the receiving module is further configured to: after releasing the space of the data block, receive a write data instruction sent by the client, and the write The data instruction includes the data to be written and the address of the data to be written, and the address of the data to be written includes the identifier of the data block and the position of the data to be written in the data block; 所述处理模块还用于:The processing module is also used to: 根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap; 将所述待写入数据写入所述待写入数据的地址对应的存储空间中。Writing the data to be written into the storage space corresponding to the address of the data to be written. 9.根据权利要求7所述的装置,其特征在于,所述接收模块,还用于:9. The device according to claim 7, wherein the receiving module is also used for: 在所述释放所述数据块的空间之前,接收所述客户端发送的写数据指令,所述写数据指令包括待写入数据以及所述待写入数据的地址,所述待写入数据的地址包括所述数据块的标识和所述待写入数据在所述数据块中的位置;Before releasing the space of the data block, receiving the write data instruction sent by the client, the write data instruction includes the data to be written and the address of the data to be written, and the address of the data to be written The address includes the identifier of the data block and the position of the data to be written in the data block; 所述处理模块还用于:The processing module is also used to: 根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;determining that the space of the data block has not been released according to the address of the data to be written and the bitmap; 在释放所述数据块的空间后,将所述待写入数据写入所述待写入数据的地址对应的存储空间中。After the space of the data block is released, the data to be written is written into the storage space corresponding to the address of the data to be written. 10.根据权利要求9所述的装置,其特征在于,所述处理模块,还用于:10. The device according to claim 9, wherein the processing module is further used for: 将所述待写入数据和全零数据组合后的数据写入缓存,所述组合后的数据的大小与所述数据块的大小相同,所述组合后的数据包括所述待写入数据,所述待写入数据在所述组合后的数据中的位置与所述待写入数据的地址在所述数据块中的位置相同;Writing the combined data of the data to be written and all-zero data into the cache, the size of the combined data is the same as the size of the data block, the combined data includes the data to be written, The position of the data to be written in the combined data is the same as the address of the data to be written in the data block; 所述将所述待写入数据写入所述待写入数据的地址对应的存储空间中,包括:从所述缓存中读取所述组合后的数据,写入所述数据块所在的存储空间中。The writing the data to be written into the storage space corresponding to the address of the data to be written includes: reading the combined data from the cache, and writing the data into the storage where the data block is located. in space. 11.根据权利要求8所述的装置,其特征在于,所述接收模块,还用于:11. The device according to claim 8, wherein the receiving module is also used for: 接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;receiving a read data command sent by the client, where the read data command includes the address of the data to be written; 所述处理模块还用于:The processing module is also used to: 根据所述待写入数据的地址和所述位图确定所述数据块的空间已被释放;determining that the space of the data block has been released according to the address of the data to be written and the bitmap; 从所述待写入数据的地址对应的存储空间中获得所述待写入数据;Obtaining the data to be written from the storage space corresponding to the address of the data to be written; 还包括发送模块,用于将所述待写入数据发送给所述客户端。It also includes a sending module, configured to send the data to be written to the client. 12.根据权利要求8或9所述的装置,其特征在于,所述接收模块,还用于:12. The device according to claim 8 or 9, wherein the receiving module is also used for: 接收所述客户端发送的读数据指令,所述读数据指令包括所述待写入数据的地址;receiving a read data command sent by the client, where the read data command includes the address of the data to be written; 所述处理模块还用于:根据所述待写入数据的地址和所述位图确定所述数据块的空间没有被释放;The processing module is further configured to: determine that the space of the data block has not been released according to the address of the data to be written and the bitmap; 所述发送模块还用于:向所述客户端发送所述读数据指令的响应消息,所述响应消息用于指示无数据。The sending module is further configured to: send a response message of the read data instruction to the client, where the response message is used to indicate that there is no data.
CN201410763438.5A 2014-12-11 2014-12-11 File truncation method and apparatus Active CN104462403B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201410763438.5A CN104462403B (en) 2014-12-11 2014-12-11 File truncation method and apparatus
PCT/CN2015/096468 WO2016091124A1 (en) 2014-12-11 2015-12-04 File intercepting method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410763438.5A CN104462403B (en) 2014-12-11 2014-12-11 File truncation method and apparatus

Publications (2)

Publication Number Publication Date
CN104462403A true CN104462403A (en) 2015-03-25
CN104462403B CN104462403B (en) 2018-03-02

Family

ID=52908438

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410763438.5A Active CN104462403B (en) 2014-12-11 2014-12-11 File truncation method and apparatus

Country Status (2)

Country Link
CN (1) CN104462403B (en)
WO (1) WO2016091124A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105243101A (en) * 2015-09-17 2016-01-13 浪潮(北京)电子信息产业有限公司 Method and system for multiple controllers to perform concurrent access to same data compressed file
WO2016091124A1 (en) * 2014-12-11 2016-06-16 华为技术有限公司 File intercepting method and device
CN108595287A (en) * 2018-04-27 2018-09-28 新华三技术有限公司成都分公司 Data truncation method and device based on correcting and eleting codes

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108989429A (en) * 2018-07-19 2018-12-11 平安科技(深圳)有限公司 The method, apparatus of real-time update page data, electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5202971A (en) * 1987-02-13 1993-04-13 International Business Machines Corporation System for file and record locking between nodes in a distributed data processing environment maintaining one copy of each file lock
CA2096508C (en) * 1992-05-26 2000-01-25 David Robert Allum Mail encoding and processing system
CN103733187A (en) * 2011-08-10 2014-04-16 微软公司 Token based file operations

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104462403B (en) * 2014-12-11 2018-03-02 华为技术有限公司 File truncation method and apparatus

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5202971A (en) * 1987-02-13 1993-04-13 International Business Machines Corporation System for file and record locking between nodes in a distributed data processing environment maintaining one copy of each file lock
CA2096508C (en) * 1992-05-26 2000-01-25 David Robert Allum Mail encoding and processing system
CN103733187A (en) * 2011-08-10 2014-04-16 微软公司 Token based file operations

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016091124A1 (en) * 2014-12-11 2016-06-16 华为技术有限公司 File intercepting method and device
CN105243101A (en) * 2015-09-17 2016-01-13 浪潮(北京)电子信息产业有限公司 Method and system for multiple controllers to perform concurrent access to same data compressed file
CN105243101B (en) * 2015-09-17 2019-05-10 浪潮(北京)电子信息产业有限公司 Method and system for concurrent access to the same data compressed file by multiple controllers
CN108595287A (en) * 2018-04-27 2018-09-28 新华三技术有限公司成都分公司 Data truncation method and device based on correcting and eleting codes
CN108595287B (en) * 2018-04-27 2021-11-05 新华三技术有限公司成都分公司 Data truncation method and device based on erasure codes

Also Published As

Publication number Publication date
WO2016091124A1 (en) 2016-06-16
CN104462403B (en) 2018-03-02

Similar Documents

Publication Publication Date Title
EP2879040B1 (en) Data storage method, data storage apparatus, and storage device
US9792345B1 (en) Parallel database mirroring
CN108460045B (en) Snapshot processing method and distributed block storage system
US9823974B1 (en) Excluding files in a block based backup
CN107562915A (en) Read the method, apparatus and equipment and computer-readable recording medium of small documents
CN104360914B (en) Incremental snapshot method and apparatus
US10298649B2 (en) Guaranteeing stream exclusivity in a multi-tenant environment
CN104462403B (en) File truncation method and apparatus
CN105955845A (en) Data recovery method and device
CN107885613A (en) A kind of method for writing data based on RAID5, device and medium
CN106528338A (en) A remote data replication method, storage device and storage system
CN106598508A (en) Solid-state hard disc and write-in arbitrating method and system thereof
CN106406750A (en) Data operation method and system
CN103473258A (en) Cloud storage file system
CN109347899B (en) Method of writing log data in distributed storage system
CN105183384A (en) Direct erasure correction implementation method and device
CN111177105A (en) Mass file writing method, device, system and medium of distributed file system
CN105608150A (en) Business data processing method and system
CN106406760A (en) Direct erasure code optimization method and system based on cloud storage
CN105893198A (en) Method and device for testing KVM stability
US10706012B2 (en) File creation
CN112286869A (en) Snapshot creating method and device
CN105068765A (en) Log processing method and system based on key value database
CN104571952A (en) Method for separately processing data reading and writing requests and metadata reading and writing requests
CN105912277B (en) The method that file system list writes log is realized in virtual machine image

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant