]>
Commit | Line | Data |
---|---|---|
dfbc6f9b GKH |
1 | From 55237a5f2431a72435e3ed39e4306e973c0446b7 Mon Sep 17 00:00:00 2001 |
2 | From: Liu Bo <bo.li.liu@oracle.com> | |
3 | Date: Thu, 25 Jan 2018 11:02:52 -0700 | |
4 | Subject: Btrfs: fix extent state leak from tree log | |
5 | ||
6 | From: Liu Bo <bo.li.liu@oracle.com> | |
7 | ||
8 | commit 55237a5f2431a72435e3ed39e4306e973c0446b7 upstream. | |
9 | ||
10 | It's possible that btrfs_sync_log() bails out after one of the two | |
11 | btrfs_write_marked_extents() which convert extent state's state bit into | |
12 | EXTENT_NEED_WAIT from EXTENT_DIRTY/EXTENT_NEW, however only EXTENT_DIRTY | |
13 | and EXTENT_NEW are searched by free_log_tree() so that those extent states | |
14 | with EXTENT_NEED_WAIT lead to memory leak. | |
15 | ||
16 | cc: <stable@vger.kernel.org> | |
17 | Signed-off-by: Liu Bo <bo.li.liu@oracle.com> | |
18 | Reviewed-by: Josef Bacik <jbacik@fb.com> | |
19 | Signed-off-by: David Sterba <dsterba@suse.com> | |
20 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
21 | ||
22 | --- | |
23 | fs/btrfs/tree-log.c | 5 +++-- | |
24 | 1 file changed, 3 insertions(+), 2 deletions(-) | |
25 | ||
26 | --- a/fs/btrfs/tree-log.c | |
27 | +++ b/fs/btrfs/tree-log.c | |
28 | @@ -3047,13 +3047,14 @@ static void free_log_tree(struct btrfs_t | |
29 | ||
30 | while (1) { | |
31 | ret = find_first_extent_bit(&log->dirty_log_pages, | |
32 | - 0, &start, &end, EXTENT_DIRTY | EXTENT_NEW, | |
33 | + 0, &start, &end, | |
34 | + EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT, | |
35 | NULL); | |
36 | if (ret) | |
37 | break; | |
38 | ||
39 | clear_extent_bits(&log->dirty_log_pages, start, end, | |
40 | - EXTENT_DIRTY | EXTENT_NEW); | |
41 | + EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT); | |
42 | } | |
43 | ||
44 | /* |