* [PATCH] btrfs scrub: extent_map reference not freed
@ 2011-03-17 18:56 Arne Jansen
2011-03-18 1:41 ` Li Zefan
0 siblings, 1 reply; 2+ messages in thread
From: Arne Jansen @ 2011-03-17 18:56 UTC (permalink / raw)
To: chris.mason, linux-btrfs; +Cc: idryomov
scrub_chunk failed to free all extent_maps it referenced, leading to a leak
of these maps on unmount.
Reported-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Arne Jansen <sensille@gmx.net>
---
fs/btrfs/scrub.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index ef59200..ee7671f 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1111,7 +1111,7 @@ static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev,
struct map_lookup *map;
struct extent_map *em;
int i;
- int ret;
+ int ret = -EINVAL;
read_lock(&map_tree->map_tree.lock);
em = lookup_extent_mapping(&map_tree->map_tree, chunk_offset, 1);
@@ -1122,19 +1122,22 @@ static noinline_for_stack int scrub_chunk(struct scrub_dev *sdev,
map = (struct map_lookup *)em->bdev;
if (em->start != chunk_offset)
- return -EINVAL;
+ goto out;
if (em->len < length)
- return -EINVAL;
+ goto out;
for (i = 0; i < map->num_stripes; ++i) {
if (map->stripes[i].dev == sdev->dev) {
ret = scrub_stripe(sdev, map, i, chunk_offset, length);
if (ret)
- return ret;
+ goto out;
}
}
- return 0;
+out:
+ free_extent_map(em);
+
+ return ret;
}
static noinline_for_stack
--
1.7.3.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs scrub: extent_map reference not freed
2011-03-17 18:56 [PATCH] btrfs scrub: extent_map reference not freed Arne Jansen
@ 2011-03-18 1:41 ` Li Zefan
0 siblings, 0 replies; 2+ messages in thread
From: Li Zefan @ 2011-03-18 1:41 UTC (permalink / raw)
To: Arne Jansen; +Cc: chris.mason, linux-btrfs, idryomov
Arne Jansen wrote:
> scrub_chunk failed to free all extent_maps it referenced, leading to a leak
> of these maps on unmount.
>
> Reported-by: Ilya Dryomov <idryomov@gmail.com>
> Signed-off-by: Arne Jansen <sensille@gmx.net>
I think it's better to fold those fix-up patches into your original scrub
patchset.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-18 1:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17 18:56 [PATCH] btrfs scrub: extent_map reference not freed Arne Jansen
2011-03-18 1:41 ` Li Zefan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).