Commit 115f9146f7020a1e249248ff53bf5685bafba20e

Authored by Josef Bacik
Committed by Greg Kroah-Hartman
1 parent 37ea7a1f6b

Btrfs: do not move em to modified list when unpinning

commit a28046956c71985046474283fa3bcd256915fb72 upstream.

We use the modified list to keep track of which extents have been modified so we
know which ones are candidates for logging at fsync() time.  Newly modified
extents are added to the list at modification time, around the same time the
ordered extent is created.  We do this so that we don't have to wait for ordered
extents to complete before we know what we need to log.  The problem is when
something like this happens

log extent 0-4k on inode 1
copy csum for 0-4k from ordered extent into log
sync log
commit transaction
log some other extent on inode 1
ordered extent for 0-4k completes and adds itself onto modified list again
log changed extents
see ordered extent for 0-4k has already been logged
	at this point we assume the csum has been copied
sync log
crash

On replay we will see the extent 0-4k in the log, drop the original 0-4k extent
which is the same one that we are replaying which also drops the csum, and then
we won't find the csum in the log for that bytenr.  This of course causes us to
have errors about not having csums for certain ranges of our inode.  So remove
the modified list manipulation in unpin_extent_cache, any modified extents
should have been added well before now, and we don't want them re-logged.  This
fixes my test that I could reliably reproduce this problem with.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 0 additions and 2 deletions Side-by-side Diff

fs/btrfs/extent_map.c
... ... @@ -287,8 +287,6 @@
287 287 if (!em)
288 288 goto out;
289 289  
290   - if (!test_bit(EXTENT_FLAG_LOGGING, &em->flags))
291   - list_move(&em->list, &tree->modified_extents);
292 290 em->generation = gen;
293 291 clear_bit(EXTENT_FLAG_PINNED, &em->flags);
294 292 em->mod_start = em->start;