Simply copy the original file to virtualized storage, and use only this file. For small files, it will probably be the best and fastest solution. To give an example, let's say that any file smaller than 65536 bytes would be fully copied - use a power of two in any case. If file is growing above limit, see solution 2.
For big files, keep overwritten segments in virtualized storage, use them according to current file position when needed. Easiest way will be to split it in 65536 bytes chunks... You get the chunk number by shifting file's position by 16 to the right, and the position within the chunk is obtained by masking only the lower 16 bits.
So, your virtualized storage become a directory, storing chunk named trivially (chunk #2521 = 2521.chunk, for example).
When a write occurs, you start to copy the original data to a new chunk in virtualized storage, then you allow application to write inside.
Obviously, if file is growing, simply add chunks that will exist only in virtualized storage.
It's not perfect - you can use delta chunks instead of full ones, to save disk space - but it's a good start that can be optimized later. Also, it's quite easy to add versions, and keep trace of:
Various applications that use the file (keep multiple virtualized storages),
Successive launches (run #1 modifies start of file, run #2 modifies end of file, you keep both virtualizations and you can easily "revert" the last launch).
发布评论
评论(1)
两个解决方案:
只需将原始文件复制到虚拟化存储,仅使用此文件即可。对于小文件,它可能是最好,最快的解决方案。
举一个例子,假设任何小于65536字节的文件都将被完全复制 - 无论如何使用两个幂。
如果文件生长在极限上面,请参见解决方案2。
有关大文件,请在虚拟化存储中保留覆盖段,请在需要时根据当前的文件位置使用它们。最简单的方法是将其拆分为65536字节块...您通过将文件的位置移到右侧的位置将块数量从右侧转移16,并且仅通过掩盖较低的16位来获得块中的位置。
。
示例:
因此,您的虚拟化存储成为目录,存储零块(例如块#2521 =
2521.Chunk
)。当出现写入时,您开始将原始数据复制到虚拟化存储中的新块,然后您允许应用程序在内部写入。
显然,如果文件正在增长,只需添加仅在虚拟化存储中存在的块即可。
它不是完美的 - 您可以使用三角洲块而不是完整的块来节省磁盘空间 - 但这是一个很好的开始,可以在以后进行优化。
此外,添加版本非常容易,并保留以下内容:
Two solutions:
Simply copy the original file to virtualized storage, and use only this file. For small files, it will probably be the best and fastest solution.
To give an example, let's say that any file smaller than 65536 bytes would be fully copied - use a power of two in any case.
If file is growing above limit, see solution 2.
For big files, keep overwritten segments in virtualized storage, use them according to current file position when needed. Easiest way will be to split it in 65536 bytes chunks... You get the chunk number by shifting file's position by 16 to the right, and the position within the chunk is obtained by masking only the lower 16 bits.
Example:
So, your virtualized storage become a directory, storing chunk named trivially (chunk #2521 =
2521.chunk
, for example).When a write occurs, you start to copy the original data to a new chunk in virtualized storage, then you allow application to write inside.
Obviously, if file is growing, simply add chunks that will exist only in virtualized storage.
It's not perfect - you can use delta chunks instead of full ones, to save disk space - but it's a good start that can be optimized later.
Also, it's quite easy to add versions, and keep trace of: