On Tue, May 18, 2010 at 09:40:28PM +0800, Yan, Zheng wrote: > On Sat, Mar 20, 2010 at 12:24 PM, Sean Bartell > <wingedtachik...@gmail.com> wrote: > > An extent_io_tree is used for all free space information. This allows > > removal of ext2_alloc_block and ext2_free_block, and makes > > create_ext2_image less ext2-specific.
> > + ret = ext2_cache_free_extents(ext2_fs, &orig_free_tree); > > + if (ret) { > > + fprintf(stderr, "error during cache_free_extents %d\n", > > ret); > > + goto fail; > > + } > > + /* preserve first 64KiB, just in case */ > > + clear_extent_dirty(&orig_free_tree, 0, BTRFS_SUPER_INFO_OFFSET - 1, > > 0); > > + > > + ret = copy_dirtiness(&free_tree, &orig_free_tree); > > + if (ret) { > > + fprintf(stderr, "error during copy_dirtiness %d\n", ret); > > + goto fail; > > + } > extent_io_tree is not very space efficient. caching free space in > several places is not good. I prefer adding a function that checks > if a given block is used to the 'convert_fs' structure. Good point. I'll change cache_free_extents to something like int (*iterate_used_extents)(struct convert_fs *fs, u64 start, u64 end, void *priv, int (*cb)(u64 start, u64 end)) create_image_file_range and do_convert should work well with a callback. This also opens up the possibility of finding free extents incrementally: call iterate_used_extents on the first GB, then custom_alloc_extent will call it on the next GB once free space runs out. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html