Commit ed8c4913da4951957bf8afc788522788881ff405

Authored by Josef Bacik
Committed by Chris Mason
1 parent 8ca15e05e6

Btrfs: make sure the backref walker catches all refs to our extent

Because we don't mess with the offset into the extent for compressed we will
properly find both extents for this case

[extent a][extent b][rest of extent a]

but because we already added a ref for the front half we won't add the inode
information for the second half.  This causes us to leak that memory and not
print out the other offset when we do logical-resolve.  So fix this by calling
ulist_add_merge and then add our eie to the existing entry if there is one.
With this patch we get both offsets out of logical-resolve.  With this and the
other 2 patches I've sent we now pass btrfs/276 on my vm with compress-force=lzo
set.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>

Showing 1 changed file with 14 additions and 11 deletions Side-by-side Diff

... ... @@ -196,7 +196,7 @@
196 196 struct extent_buffer *eb;
197 197 struct btrfs_key key;
198 198 struct btrfs_file_extent_item *fi;
199   - struct extent_inode_elem *eie = NULL;
  199 + struct extent_inode_elem *eie = NULL, *old = NULL;
200 200 u64 disk_byte;
201 201  
202 202 if (level != 0) {
... ... @@ -230,6 +230,7 @@
230 230  
231 231 if (disk_byte == wanted_disk_byte) {
232 232 eie = NULL;
  233 + old = NULL;
233 234 if (extent_item_pos) {
234 235 ret = check_extent_in_eb(&key, eb, fi,
235 236 *extent_item_pos,
236 237  
... ... @@ -237,18 +238,20 @@
237 238 if (ret < 0)
238 239 break;
239 240 }
240   - if (!ret) {
241   - ret = ulist_add(parents, eb->start,
242   - (uintptr_t)eie, GFP_NOFS);
243   - if (ret < 0)
244   - break;
245   - if (!extent_item_pos) {
246   - ret = btrfs_next_old_leaf(root, path,
247   - time_seq);
248   - continue;
249   - }
  241 + if (ret > 0)
  242 + goto next;
  243 + ret = ulist_add_merge(parents, eb->start,
  244 + (uintptr_t)eie,
  245 + (u64 *)&old, GFP_NOFS);
  246 + if (ret < 0)
  247 + break;
  248 + if (!ret && extent_item_pos) {
  249 + while (old->next)
  250 + old = old->next;
  251 + old->next = eie;
250 252 }
251 253 }
  254 +next:
252 255 ret = btrfs_next_old_item(root, path, time_seq);
253 256 }
254 257