Commit b16d011e authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Reword dodgy comments in alloc_extent_buffer

Commit eb14ab8e ("Btrfs: fix page->private races") fixed a genuine
race between extent buffer initialisation and btree_releasepage.
Unfortunately as the code has evolved the comments weren't changed which
made them slightly wrong and they weren't very clear in the fist place.
Fix this by (hopefully) rewording them in a more approachable manner.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 28187ae5
...@@ -5009,8 +5009,11 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -5009,8 +5009,11 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
uptodate = 0; uptodate = 0;
/* /*
* see below about how we avoid a nasty race with release page * We can't unlock the pages just yet since the extent buffer
* and why we unlock later * hasn't been properly inserted in the radix tree, this
* opens a race with btree_releasepage which can free a page
* while we are still filling in all pages for the buffer and
* we could crash.
*/ */
} }
if (uptodate) if (uptodate)
...@@ -5039,13 +5042,9 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -5039,13 +5042,9 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
set_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags); set_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags);
/* /*
* there is a race where release page may have * Now it's safe to unlock the pages because any calls to
* tried to find this extent buffer in the radix * btree_releasepage will correctly detect that a page belongs to a
* but failed. It will tell the VM it is safe to * live buffer and won't free them prematurely.
* reclaim the, and it will clear the page private bit.
* We must make sure to set the page private bit properly
* after the extent buffer is in the radix tree so
* it doesn't get lost
*/ */
for (i = 0; i < num_pages; i++) for (i = 0; i < num_pages; i++)
unlock_page(eb->pages[i]); unlock_page(eb->pages[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment