Messages in this thread | | | Date | Fri, 1 Aug 2014 12:58:16 -0400 | Subject | Re: Help with btrfs_zero_range function | From | Nick Krause <> |
| |
Please forget my other questions , seems the only work to make punch hole work for zero range is to make a function like the one I am pasting below for zero range and change the calls to punch range to zero range as the other parts of the function can be the same from my reading. Regards Nick static int find_first_non_hole(struct inode *inode, u64 *start, u64 *len) { struct extent_map *em; int ret = 0;
em = btrfs_get_extent(inode, NULL, 0, *start, *len, 0); if (IS_ERR_OR_NULL(em)) { if (!em) ret = -ENOMEM; else ret = PTR_ERR(em); return ret; }
/* Hole or vacuum extent(only exists in no-hole mode) */ if (em->block_start == EXTENT_MAP_HOLE) { ret = 1; *len = em->start + em->len > *start + *len ? 0 : *start + *len - em->start - em->len; *start = em->start + em->len; } free_extent_map(em); return ret; }
| |