主权项 |
1. A method comprising:
associating a first version of a file with a first file mapping structure and a first data block; creating a second version of the file in response to a first opening, by a processing device, of the file for write access; allocating, by the processing device, a second file mapping structure and a second data block to the second version of the file and copying content of the first file mapping structure to the second file mapping structure; updating a pointer of the second file mapping structure to point to the first file mapping structure; updating a pointer of the first file mapping structure to point directly to the second file mapping structure, wherein the first file mapping structure and the second file mapping structure are associated to each other in two directions and create two versions of the file; associating, by the processing device, each of the first data block and the second data block to a corresponding bitmap, with a set bit in the corresponding bitmap indicating whether the corresponding data block belongs only to a prior version file mapping structure; maintaining a list of the pointers ordered by a respective access time; and reviewing the list in an order of least recently accessed to most recently accessed and the bitmap to identify a data block to repurpose. |