mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 02:50:43 +00:00
btrfs: assert extent_map bdevs and lookup_map and split
This is a preparatory patch for removing extent_map::bdev. There's some
history behind the code so this is only precaution to catch if things
break before the actual removal happens.
Logically, comparing a raw low-level block device (bdev) does not make
sense for extent maps (high-level objects). This had no effect in
practice but was quite confusing in the code. The lookup_map is set iff
EXTENT_FLAG_FS_MAPPING is set.
The two pointers were stored in the same bytes and used potentially in
two meanings. Now they're split, so the asserts are in place to check
that the condition will not change.
The lookup map pointer misused bdev, this has been changed in commit
95617d6932
("btrfs: cleanup, stop casting for extent_map->lookup
everywhere") to the explicit type. But the semantics hasn't changed and
bdev was not actually used to decide if maps are mergeable.
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
32ab3d1b4d
commit
c3e14909d3
2 changed files with 9 additions and 2 deletions
|
@ -214,9 +214,16 @@ static int mergable_maps(struct extent_map *prev, struct extent_map *next)
|
||||||
ASSERT(next->block_start != EXTENT_MAP_DELALLOC &&
|
ASSERT(next->block_start != EXTENT_MAP_DELALLOC &&
|
||||||
prev->block_start != EXTENT_MAP_DELALLOC);
|
prev->block_start != EXTENT_MAP_DELALLOC);
|
||||||
|
|
||||||
|
if (prev->map_lookup || next->map_lookup)
|
||||||
|
ASSERT(test_bit(EXTENT_FLAG_FS_MAPPING, &prev->flags) &&
|
||||||
|
test_bit(EXTENT_FLAG_FS_MAPPING, &next->flags));
|
||||||
|
|
||||||
|
if (prev->bdev || next->bdev)
|
||||||
|
ASSERT(prev->bdev == next->bdev);
|
||||||
|
|
||||||
if (extent_map_end(prev) == next->start &&
|
if (extent_map_end(prev) == next->start &&
|
||||||
prev->flags == next->flags &&
|
prev->flags == next->flags &&
|
||||||
prev->bdev == next->bdev &&
|
prev->map_lookup == next->map_lookup &&
|
||||||
((next->block_start == EXTENT_MAP_HOLE &&
|
((next->block_start == EXTENT_MAP_HOLE &&
|
||||||
prev->block_start == EXTENT_MAP_HOLE) ||
|
prev->block_start == EXTENT_MAP_HOLE) ||
|
||||||
(next->block_start == EXTENT_MAP_INLINE &&
|
(next->block_start == EXTENT_MAP_INLINE &&
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct extent_map {
|
||||||
u64 block_len;
|
u64 block_len;
|
||||||
u64 generation;
|
u64 generation;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
union {
|
struct {
|
||||||
struct block_device *bdev;
|
struct block_device *bdev;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue