IP Library Granted Patent US 10,331,349
Granted Patent B2
US 10,331,349 · App. 15/222,945 · Granted Jun 25, 2019

Shrinking virtual hard disk image

Inventors: Zhen-hua Song (Beijing, CN); Qian Wang (Hangzhou, CN); Jia Wan (Hangzhou, CN); Weicai Chen (Hangzhou, CN)
G06F3/0608G06F3/064G06F3/0623G06F3/0631G06F3/0643G06F3/0652G06F3/0665G06F3/0671G06F3/0674G06F16/162G06F16/1727G06F2206/1004
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 10,331,349
App. No.
15/222,945
Granted
Jun 25, 2019
Kind
B2
Abstract

The present disclosure introduces a method and an apparatus of shrinking virtual hard disk image file. The present techniques search a garbage data block in a file and revise a record of the garbage data block in a block allocation table (BAT). The file includes one or more data blocks and a BAT that records information of each data block. The garbage data block is a data block that does not store effective data. The present techniques move an effective data block subsequent to the garbage data block, revise a record of the effective data block in the BAT after the moving, and shrink a size of the file after the movement.

Claims (91)

1. A method performed by one or more processors configured with computer-executable instructions, the method comprising:

searching, among one or more data blocks, for a garbage data block in an image file, the image file including the one or more data blocks and a block allocation table (BAT) that records information of each data block, the garbage data block not storing effective data, and the image file including a set of files into a single file according to a certain format;

revising a record of the garbage data block in the BAT to indicate that there is no effective data stored in the garbage data block;

moving an effective data block from a position located subsequent to the garbage data block to a position of the garbage data block, the position located subsequent to the garbage data block being nearer to an end of the image file than the position of the garbage data block;

revising a record of a new location of the effective data block in the BAT after the moving; and

shrinking a size of the image file after the moving.

2. The method as recited in claim 1 , wherein each of the one or more data blocks includes:

one or more sectors, and

a bitmap that records information of each sector.

3. The method as recited in claim 2 , further comprising, prior to searching for the garbage data block:

searching for a particular sector, which is a garbage sector in the garbage data block; and

revising a record of the garbage sector in a particular bitmap, which is the bitmap associated with the garbage data block.

4. The method as recited in claim 3 , wherein the searching for the particular sector, which is the garbage sector in the garbage data block comprises:

searching for the bitmap associated with the garbage data block;

in response to a determination that a record corresponding to the particular sector in the bitmap associated with the garbage data block indicates that the particular sector stores data, determining a type of the image file,

wherein, when the type of the image file is determined to be a dynamic hard disk image file, the searching for the particular sector further comprises: determining that the particular sector in the particular bitmap is the garbage sector if data stored in the particular sector is not effective data, and

wherein, when the type of the image file is determined to be a differencing hard disk image file, the searching for the particular sector further comprises: determining that the particular sector in the particular bitmap is the garbage sector if data stored in the particular sector is the same as data stored in a corresponding sector with a same section location in a parent image file.

5. The method as recited in claim 4 , wherein the determining that the particular sector is the garbage sector if data stored in the particular sector is not effective data comprises determining that data stored in the particular sector are all 0.

6. The method as recited in claim 3 , wherein the searching for the particular sector, which is the garbage sector in the garbage data block comprises:

determining that the image file is a dynamic hard disk image file;

obtaining:

a source bitmap of a data block being searched, and

a block bitmap of the data block being searched, which block bitmap indicates whether a corresponding particular sector stores effective data; and

comparing each bit between the source bitmap and the block bitmap,

wherein, when a record of the particular sector in the source bitmap indicates that the particular sector stores effective data and a record of the corresponding particular sector in the block bitmap indicates that the corresponding particular sector does not store effective data, the searching for the particular sector further comprises: determining that the particular sector is the garbage sector.

7. The method as recited in claim 3 , wherein the searching the garbage sector in the garbage data block comprises:

determining that the image file is a differencing hard disk image file;

obtaining:

a source bitmap of a data block being searched,

a block bitmap of the data block being searched, which block bitmap indicates whether the first corresponding particular sector stores effective data, and

a parent bitmap of the data block being searched in a parent image file; and

comparing each bit between the source bitmap, the block bitmap, and the parent bitmap,

wherein, when a record of the particular sector in the source bitmap indicates that the particular sector stores effective data, a record of the first corresponding particular sector in the block bitmap indicates that the first corresponding particular sector does not store effective data, and a record of a second corresponding particular sector in the parent bitmap indicates that the second corresponding particular sector does not store effective data, the searching for the particular sector further comprises: determining that the particular sector is the garbage sector.

8. The method as recited in claim 7 , further comprising determining whether the record of the second corresponding particular sector in the parent bitmap does not store the effective data, including: reading a parent bitmap from the parent image file to a final ancestor image file,

wherein, when a bit corresponding to the second corresponding particular sector in any parent bitmap of the data block being searched indicates that the second corresponding particular sector stores the effective data, the determining whether the record of the second corresponding particular sector in the parent bitmap does not store the effective data further includes determining that the second corresponding particular sector in the parent image file stores the effective data; and

wherein, when a bit corresponding to the second corresponding particular sector in any parent bitmap of the data block being searched indicates that the second corresponding particular sector does not store the effective data, the determining whether the record of the second corresponding particular sector in the parent bitmap does not store the effective data further includes determining that the second corresponding particular sector in the parent image file does not store the effective data.

9. The method as recited in claim 1 , wherein the effective data block in the position subsequent to the garbage data block is a particular effective data block that has a position after the position of the garbage data block in a physical storage space of the image file.

10. The method as recited in claim 1 , wherein the moving the effective data block from a position located subsequent to the garbage data block comprises copying data in the effective data block to the position of the garbage data block.

11. The method as recited in claim 1 , wherein the shrinking the size of the image file after the moving comprises:

forming an unused space at an end of the image file after the moving;

cutting the unused space from the image file; and

obtaining an image file whose size is reduced.

12. An apparatus comprising:

a garbage data block searching module that

searches, among one or more data blocks, for a garbage data block in an image file, the image file including the one or more data blocks and a block allocation table (BAT) that records information of each data block, the garbage data block not storing effective data, and the image file including a set of files into a single file according to a certain format, and

revises a record corresponding to the garbage data block in the BAT to indicate that there is no effective data stored in the garbage data block;

a data moving module that

moves an effective data block from a position located subsequent to the garbage data block to a position of the garbage data block, the position located subsequent to the garbage data block being nearer to an end of the image file than the position of the garbage data block, and

revises a record of a new location of the effective data block in the BAT after the effective data block is moved; and

a file shrinking module that shrinks the image file after the movement of data blocks is completed.

13. The apparatus as recited in claim 12 , wherein each of the one or more data blocks includes:

one or more sectors, and

a bitmap that records information of each sector.

14. The apparatus as recited in claim 13 , wherein the apparatus further includes a garbage sector searching module that

searches for a particular bitmap of the data block being searched, and

determines if the data block being searched, sectors of which are all indicated as garbage sectors according to records of the sectors in the bitmap, is the garbage data block.

15. The apparatus as recited in claim 14 , wherein the garbage sector searching module includes:

a bitmap searching sub-module that

searches the particular bitmap in the data block being searched of the image file, and

when a record to a particular sector in the bitmap indicates that there is data stored in the particular sector, triggers a determination sub-module; and

the determination sub-module that determines a type of the image file,

wherein, when the type of the image file is determined to be a dynamic hard disk image file, in response to a determination that data in the particular sector is not effective data, the determination sub-module further determines the particular sector to be the garbage sector, and

wherein, when the type of the image file is determined to be a differencing hard disk image file, in response to a determination that data stored in the particular sector is the same as data stored in a corresponding particular sector with a same sector location in a parent image file, the determination sub-module further determines the particular sector to be the garbage sector.

16. The apparatus as recited in claim 14 wherein, when determined that the image file is a dynamic hard disk image file, the garbage sector searching module includes:

an obtaining sub-module that obtains:

a source bitmap of the data block being searched of the image file, and

a block bitmap of the data block being searched, which block bitmap indicates whether the corresponding particular sector stores effective data; and

a comparison sub-module that:

compares every bit between the source bitmap and the block bitmap, and

when a record of the particular sector in the source bitmap indicates that the particular sector stores effective data while a record of the corresponding particular sector in the block bitmap indicates that the corresponding particular sector does not store effective data, determines the particular sector to be the garbage sector.

17. The apparatus as recited in claim 14 , wherein, when determined that the image file is a differencing hard disk image file, the garbage sector searching module includes:

an obtaining sub-module that obtains:

a source bitmap of the data block being searched of the image file,

a block bitmap of the data block being searched, which block bitmap indicates whether a first corresponding particular sector stores effective data, and

a parent bitmap of the same data block being searched in the ancestor image file; and

a comparison sub-module that:

compares each bit between the source bitmap, the block bitmap, and the parent bitmap, and

when a record of the particular sector in the source bitmap indicates that the particular sector stores effective data while a record of a second corresponding particular sector in the parent bitmap indicates that the second corresponding particular sector does not store effective data and a record of the first corresponding particular sector in the block bitmap indicates that the first corresponding particular sector does not store effective data, determines the particular sector to be the garbage sector.

18. The apparatus as recited in claim 12 , wherein the file shrinking module:

forms an unused space at an end of the image file after the moving,

cuts the unused space from the image file, and

obtains an image file with reduced size.

19. A memory comprising computer-executable instructions executable by a processor that, when executed by the processor, cause the processor to perform operations comprising:

searching, among one or more data blocks, for a garbage data block in an image file, the image file including the one or more data blocks and a block allocation table (BAT) that records information of each data block, the garbage data block not storing effective data, and the image file including a set of files into a single file according to a certain format;

revising a record of the garbage data block in the BAT to indicate that there is no effective data stored in the garbage data block;

moving an effective data block from a position located subsequent to the garbage data block to a position of the garbage data block, the position located subsequent to the garbage data block being nearer to an end of the image file than the position of the garbage data block;

revising a record of a new location of the effective data block in the BAT after the moving; and

shrinking a size of the image file after the moving.

20. The memory as recited in claim 19 , wherein each of the one or more data blocks includes:

one or more sectors, and

a bitmap that records information of each sector.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Apr 21, 2026
From: ALIBABA GROUP HOLDING LIMITED
To: CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PRIVATE LIMITED
Reel/Frame 075478/0225 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded May 10, 2019
From: SONG, ZHEN-HUA; CHEN, WEICAI; WANG, QIAN; WAN, JIA
To: ALIBABA GROUP HOLDING LIMITED
Reel/Frame 049134/0959 →
Priority Claims (1)
CN 2011 1 0228838 · Aug 10, 2011 · national
Continuity (2)
Continuation 13571773 · Aug 10, 2012
Related Publication 20160335018A1 · Nov 17, 2016