Btrfs: fix find_free_dev_extent() malfunction in case device tree has hole
PATCH 1/1 Btrfs: fix find_free_dev_extent() malfunction in case device tree has hole
If device tree has hole, find_free_dev_extent() cannot find available address properly.
The example below, has one BIG hole in device tree, and can only allocate just one chunk in a transaction.
item 9 key (1 DEV_EXTENT 273841913856) itemoff 15811 itemsize 48
dev extent chunk_tree 3
chunk objectid 256 chunk offset 272759783424 length 1073741824
item 10 key (1 DEV_EXTENT 1071632089088) itemoff 15763 itemsize 48
dev extent chunk_tree 3
chunk objectid 256 chunk offset 1070549958656 length 1073741824
item 11 key (1 DEV_EXTENT 1072705830912) itemoff 15715 itemsize 48
dev extent chunk_tree 3
chunk objectid 256 chunk offset 1071623700480 length--- fs/btrfs/volumes.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
fs/btrfs/volumes.c +11 -4
@@ -1060,6 +1060,7 @@ static int contains_pending_extent(struct btrfs_trans_handle *trans,struct extent_map *em;struct list_head *search_list = &trans->transaction->pending_chunks;int ret =0 ; +u64 physical_start = *start; again:list_for_each_entry (em, search_list, list) {
@@ -1070,9 +1071,9 @@ again:for (i =0 ; i < map->num_stripes; i++) {if (map->stripes[i].dev != device)continue ; -if (map->stripes[i].physical >= *start + len || +if (map->stripes[i].physical >= physical_start + len || map->stripes[i].physical + em->orig_block_len <= - *start) + physical_start)continue ; *start = map->stripes[i].physical + em->orig_block_len;
@@ -1195,8 +1196,14 @@ again:*/ if (contains_pending_extent (trans, device, &search_start, - hole_size)) - hole_size =0 ; + hole_size)) { +if (key.offset >= search_start) + hole_size = key_offset - search_start; +else { +WARN_ON (1 ); + hole_size =0 ; + } + }if (hole_size > max_hole_size) { max_hole_start = search_start;
Signature · 1 line
1.9.1
Hi,
Found a problem compile testing this.
hole_size = key_offset - search_start;
Should not that be key.offset ?
TIA
Ed Tomlinson
Quoted 63 lines · Forrest Liu
If device tree has hole,
find_free_dev_extent()cannot find available address properly.The example below, has one BIG hole in device tree, and can only allocate just one chunk in a transaction.
item 9 key (1 DEV_EXTENT 273841913856) itemoff 15811 itemsize 48 dev extent chunk_tree 3 chunk objectid 256 chunk offset 272759783424 length 1073741824 item 10 key (1 DEV_EXTENT 1071632089088) itemoff 15763 itemsize 48 dev extent chunk_tree 3 chunk objectid 256 chunk offset 1070549958656 length 1073741824 item 11 key (1 DEV_EXTENT 1072705830912) itemoff 15715 itemsize 48 dev extent chunk_tree 3 chunk objectid 256 chunk offset 1071623700480 lengthSigned-off-by Forrest Liu <[email protected]>--- fs/btrfs/volumes.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)fs/btrfs/volumes.c +1
-0@@ -1060,6 +1060,7 @@ static int contains_pending_extent(structbtrfs_trans_handle *trans, struct extent_map *em;struct list_head *search_list = &trans->transaction->pending_chunks;int ret =0 ; +u64 physical_start = *start; again:fs/btrfs/volumes.c +10
-4list_for_each_entry (em, search_list, list) {@@ -1070,9 +1071,9 @@ again:for (i =0 ; i < map->num_stripes; i++) {if (map->stripes[i].dev != device)continue ; -if (map->stripes[i].physical >= *start + len || +if (map->stripes[i].physical >= physical_start + len || map->stripes[i].physical + em->orig_block_len <= - *start) + physical_start)continue ; *start = map->stripes[i].physical + em->orig_block_len;@@ -1195,8 +1196,14 @@ again:*/ if (contains_pending_extent (trans, device, &search_start, - hole_size)) - hole_size =0 ; + hole_size)) { +if (key.offset >= search_start) + hole_size = key_offset - search_start; +else { +WARN_ON (1 ); + hole_size =0 ; + } + }if (hole_size > max_hole_size) { max_hole_start = search_start;
On Monday, February 2, 2015 9:39:06 AM EST, Ed Tomlinson wrote:
Hi
Booting a kernel with the three patches:
[PATCH] Btrfs: fix find_free_dev_extent() malfunction in case device tree has hole [PATCH] Btrfs: btrfs_release_extent_buffer_page() didn't free pages of dummy extent [PATCH] Btrfs: fix BUG_ON in btrfs_orphan_add() when delete unused block group
generates lots of opps here (I hate to post an anemic report but my serial console was not recording so I do not have the opps). They occured when starting X and, If I read them correctly, had something to do with extents.
Anyone else?
Thanks
Ed Tomlinson
Quoted 28 lines
Hi,
Found a problem compile testing this.
hole_size=key_offset-search_start;Should not that be key.offset ?
TIA
Ed TomlinsonQuoted 7 lines · Forrest Liu
If device tree has hole,
find_free_dev_extent()cannot find available address properly.The example below, has one BIG hole in device tree, and can only allocate just one chunk in a transaction.
item 9 key (1 DEV_EXTENT 273841913856) itemoff 15811 itemsize 48 ...--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
2015-02-03 2:40 GMT+08:00 Ed Tomlinson <[email protected]>:
Quoted 12 lines · Ed Tomlinson
Hi
Booting a kernel with the three patches:
[PATCH] Btrfs: fixfind_free_dev_extent()malfunction in case device tree has hole
[PATCH] Btrfs:btrfs_release_extent_buffer_page()didn't free pages of dummy extent
[PATCH] Btrfs: fixBUG_ONinbtrfs_orphan_add()when delete unused block group
Quoted 4 lines
generates lots of opps here (I hate to post an anemic report but my serial console was not recording so I do not have the opps). They occured when starting X and, If I read them correctly, had something to do with extents.
My fault, i should test these patches before i submit these patches. The oops was caused by patch
"Btrfs: btrfs_release_extent_buffer_page() didn't free pages of dummy extent"
I will resend these patches after test on linux-3.19-rc7.
Thanks
Forrest
Quoted 35 lines
Anyone else?
Thanks
Ed TomlinsonQuoted 29 lines
Hi,
Found a problem compile testing this.
hole_size=key_offset-search_start;Should not that be key.offset ?
TIA
Ed TomlinsonQuoted 8 lines · Forrest Liu
If device tree has hole,
find_free_dev_extent()cannot find available address properly.The example below, has one BIG hole in device tree, and can only allocate just one chunk in a transaction.
item 9 key (1 DEV_EXTENT 273841913856) itemoff 15811 itemsize 48 ...--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
Its a great idea to test the patches before submitting. However I think its even more importent to tell us the state of testing. eg. this is an RFC or in production in abc's kernel, and this version is untested or has been compile tested, boot tested, improves xfstests (before x failures out of z, after the patch the number of failures was y, where y<x).
A little bit of info like this will help those of us using the info in the lists and should aid getting your patches into the kernel faster.
Thanks
Ed
Quoted 30 lines · Forrest Liu
2015-02-03 2:40 GMT+08:00 Ed Tomlinson <[email protected]>:
Quoted 7 lines · Ed Tomlinson
Hi
Booting a kernel with the three patches:
[PATCH] Btrfs: fixfind_free_dev_extent()malfunction in case device tree has hole ...My fault, i should test these patches before i submit these patches. The oops was caused by patch
"Btrfs:btrfs_release_extent_buffer_page()didn't free pages of dummy extent"I will resend these patches after test on linux-3.19-rc7.
Thanks
ForrestQuoted 5 lines
Anyone else?
Thanks
Ed Tomlinson
...--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 35 lines · Forrest Liu
If device tree has hole,
find_free_dev_extent()cannot find available address properly.The example below, has one BIG hole in device tree, and can only allocate just one chunk in a transaction.
item 9 key (1 DEV_EXTENT 273841913856) itemoff 15811 itemsize 48 dev extent chunk_tree 3 chunk objectid 256 chunk offset 272759783424 length 1073741824 item 10 key (1 DEV_EXTENT 1071632089088) itemoff 15763 itemsize 48 dev extent chunk_tree 3 chunk objectid 256 chunk offset 1070549958656 length 1073741824 item 11 key (1 DEV_EXTENT 1072705830912) itemoff 15715 itemsize 48 dev extent chunk_tree 3 chunk objectid 256 chunk offset 1071623700480 lengthSigned-off-by Forrest Liu <[email protected]>--- fs/btrfs/volumes.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)fs/btrfs/volumes.c +1
-0@@ -1060,6 +1060,7 @@ static int contains_pending_extent(struct btrfs_trans_handle *trans,struct extent_map *em;struct list_head *search_list = &trans->transaction->pending_chunks;int ret =0 ; +u64 physical_start = *start; again:list_for_each_entry (em, search_list, list) {@@ -1070,9 +1071,9 @@ again:for (i =0 ; i < map->num_stripes; i++) {
fs/btrfs/volumes.c again: · line 1079
Quoted 10 lines
fs/btrfs/volumes.c +2
-2if (map->stripes[i].dev != device)continue ; -if (map->stripes[i].physical >= *start + len || +if (map->stripes[i].physical >= physical_start + len || map->stripes[i].physical + em->orig_block_len <= - *start) + physical_start)continue ; *start = map->stripes[i].physical + em->orig_block_len;
This part looks good.
fs/btrfs/volumes.c again: · line 1204
Quoted 12 lines
fs/btrfs/volumes.c +6
-2@@ -1195,8 +1196,14 @@ again:*/ if (contains_pending_extent (trans, device, &search_start, - hole_size)) - hole_size =0 ; + hole_size)) { +if (key.offset >= search_start) + hole_size = key_offset - search_start; +else { +WARN_ON (1 ); + hole_size =0 ;
I'd prefer WARN_ON_ONCE(1) since key.offset should not be less than search_start by design.
Other looks good.
Thanks,
-liubo
Quoted 12 lines
fs/btrfs/volumes.c +2
-0+ } + }if (hole_size > max_hole_size) { max_hole_start = search_start;Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html