Commit 06697042 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'for-5.8-rc6-tag' of...

Merge tag 'for-5.8-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into master

Pull btrfs fixes from David Sterba:
 "A few resouce leak fixes from recent patches, all are stable material.

  The problems have been observed during testing or have a reproducer"

* tag 'for-5.8-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: fix mount failure caused by race with umount
  btrfs: fix page leaks after failure to lock page for delalloc
  btrfs: qgroup: fix data leak caused by race between writeback and truncate
  btrfs: fix double free on ulist after backref resolution failure
parents 6a343656 48cfa61b
...@@ -1461,6 +1461,7 @@ static int btrfs_find_all_roots_safe(struct btrfs_trans_handle *trans, ...@@ -1461,6 +1461,7 @@ static int btrfs_find_all_roots_safe(struct btrfs_trans_handle *trans,
if (ret < 0 && ret != -ENOENT) { if (ret < 0 && ret != -ENOENT) {
ulist_free(tmp); ulist_free(tmp);
ulist_free(*roots); ulist_free(*roots);
*roots = NULL;
return ret; return ret;
} }
node = ulist_next(tmp, &uiter); node = ulist_next(tmp, &uiter);
......
...@@ -1999,7 +1999,8 @@ static int __process_pages_contig(struct address_space *mapping, ...@@ -1999,7 +1999,8 @@ static int __process_pages_contig(struct address_space *mapping,
if (!PageDirty(pages[i]) || if (!PageDirty(pages[i]) ||
pages[i]->mapping != mapping) { pages[i]->mapping != mapping) {
unlock_page(pages[i]); unlock_page(pages[i]);
put_page(pages[i]); for (; i < ret; i++)
put_page(pages[i]);
err = -EAGAIN; err = -EAGAIN;
goto out; goto out;
} }
......
...@@ -8123,20 +8123,17 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset, ...@@ -8123,20 +8123,17 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset,
/* /*
* Qgroup reserved space handler * Qgroup reserved space handler
* Page here will be either * Page here will be either
* 1) Already written to disk * 1) Already written to disk or ordered extent already submitted
* In this case, its reserved space is released from data rsv map * Then its QGROUP_RESERVED bit in io_tree is already cleaned.
* and will be freed by delayed_ref handler finally. * Qgroup will be handled by its qgroup_record then.
* So even we call qgroup_free_data(), it won't decrease reserved * btrfs_qgroup_free_data() call will do nothing here.
* space. *
* 2) Not written to disk * 2) Not written to disk yet
* This means the reserved space should be freed here. However, * Then btrfs_qgroup_free_data() call will clear the QGROUP_RESERVED
* if a truncate invalidates the page (by clearing PageDirty) * bit of its io_tree, and free the qgroup reserved data space.
* and the page is accounted for while allocating extent * Since the IO will never happen for this page.
* in btrfs_check_data_free_space() we let delayed_ref to
* free the entire extent.
*/ */
if (PageDirty(page)) btrfs_qgroup_free_data(inode, NULL, page_start, PAGE_SIZE);
btrfs_qgroup_free_data(inode, NULL, page_start, PAGE_SIZE);
if (!inode_evicting) { if (!inode_evicting) {
clear_extent_bit(tree, page_start, page_end, EXTENT_LOCKED | clear_extent_bit(tree, page_start, page_end, EXTENT_LOCKED |
EXTENT_DELALLOC | EXTENT_DELALLOC_NEW | EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
......
...@@ -7051,6 +7051,14 @@ int btrfs_read_chunk_tree(struct btrfs_fs_info *fs_info) ...@@ -7051,6 +7051,14 @@ int btrfs_read_chunk_tree(struct btrfs_fs_info *fs_info)
mutex_lock(&uuid_mutex); mutex_lock(&uuid_mutex);
mutex_lock(&fs_info->chunk_mutex); mutex_lock(&fs_info->chunk_mutex);
/*
* It is possible for mount and umount to race in such a way that
* we execute this code path, but open_fs_devices failed to clear
* total_rw_bytes. We certainly want it cleared before reading the
* device items, so clear it here.
*/
fs_info->fs_devices->total_rw_bytes = 0;
/* /*
* Read all device items, and then all the chunk items. All * Read all device items, and then all the chunk items. All
* device items are found before any chunk item (their object id * device items are found before any chunk item (their object id
......
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