mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 00:39:48 +00:00
btrfs: move page locking from lock_extent_buffer_for_io to write_one_eb
Locking the pages in lock_extent_buffer_for_io only for the non-subpage case is very confusing. Move it to write_one_eb to mirror the subpage case and simplify the code. Now lock_extent_buffer_for_io does not leave all the pages locked and each is individually locked/unlocked in write_one_eb. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
50b21d7a06
commit
81a79b6ae4
1 changed files with 1 additions and 14 deletions
|
@ -1636,7 +1636,6 @@ static noinline_for_stack bool lock_extent_buffer_for_io(struct extent_buffer *e
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = eb->fs_info;
|
struct btrfs_fs_info *fs_info = eb->fs_info;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
int i;
|
|
||||||
|
|
||||||
btrfs_tree_lock(eb);
|
btrfs_tree_lock(eb);
|
||||||
while (test_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags)) {
|
while (test_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags)) {
|
||||||
|
@ -1664,20 +1663,7 @@ static noinline_for_stack bool lock_extent_buffer_for_io(struct extent_buffer *e
|
||||||
} else {
|
} else {
|
||||||
spin_unlock(&eb->refs_lock);
|
spin_unlock(&eb->refs_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
btrfs_tree_unlock(eb);
|
btrfs_tree_unlock(eb);
|
||||||
|
|
||||||
/*
|
|
||||||
* Either we don't need to submit any tree block, or we're submitting
|
|
||||||
* subpage eb.
|
|
||||||
* Subpage metadata doesn't use page locking at all, so we can skip
|
|
||||||
* the page locking.
|
|
||||||
*/
|
|
||||||
if (!ret || fs_info->nodesize < PAGE_SIZE)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
for (i = 0; i < num_extent_pages(eb); i++)
|
|
||||||
lock_page(eb->pages[i]);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1960,6 +1946,7 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,
|
||||||
for (i = 0; i < num_pages; i++) {
|
for (i = 0; i < num_pages; i++) {
|
||||||
struct page *p = eb->pages[i];
|
struct page *p = eb->pages[i];
|
||||||
|
|
||||||
|
lock_page(p);
|
||||||
clear_page_dirty_for_io(p);
|
clear_page_dirty_for_io(p);
|
||||||
set_page_writeback(p);
|
set_page_writeback(p);
|
||||||
submit_extent_page(&bio_ctrl, disk_bytenr, p, PAGE_SIZE, 0);
|
submit_extent_page(&bio_ctrl, disk_bytenr, p, PAGE_SIZE, 0);
|
||||||
|
|
Loading…
Reference in a new issue