Skip to content

Commit e4cc148

Browse files
fdmananakdave
authored andcommitted
btrfs: fix extent map logging bit not cleared for split maps after dropping range
At btrfs_drop_extent_map_range() we are clearing the EXTENT_FLAG_LOGGING bit on a 'flags' variable that was not initialized. This makes static checkers complain about it, so initialize the 'flags' variable before clearing the bit. In practice this has no consequences, because EXTENT_FLAG_LOGGING should not be set when btrfs_drop_extent_map_range() is called, as an fsync locks the inode in exclusive mode, locks the inode's mmap semaphore in exclusive mode too and it always flushes all delalloc. Also add a comment about why we clear EXTENT_FLAG_LOGGING on a copy of the flags of the split extent map. Reported-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/linux-btrfs/Y%2FyipSVozUDEZKow@kili/ Fixes: db21370 ("btrfs: drop extent map range more efficiently") Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 95cd356 commit e4cc148

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/btrfs/extent_map.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,13 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end,
763763
goto next;
764764
}
765765

766+
flags = em->flags;
766767
clear_bit(EXTENT_FLAG_PINNED, &em->flags);
768+
/*
769+
* In case we split the extent map, we want to preserve the
770+
* EXTENT_FLAG_LOGGING flag on our extent map, but we don't want
771+
* it on the new extent maps.
772+
*/
767773
clear_bit(EXTENT_FLAG_LOGGING, &flags);
768774
modified = !list_empty(&em->list);
769775

@@ -774,7 +780,6 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end,
774780
if (em->start >= start && em_end <= end)
775781
goto remove_em;
776782

777-
flags = em->flags;
778783
gen = em->generation;
779784
compressed = test_bit(EXTENT_FLAG_COMPRESSED, &em->flags);
780785

0 commit comments

Comments
 (0)