Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85db36cf authored by Chris Mason's avatar Chris Mason
Browse files

Btrfs: fix inode cache writeout



The code to fix stalls during free spache cache IO wasn't using
the correct root when waiting on the IO for inode caches.  This
is only a problem when the inode cache is enabled with

mount -o inode_cache

This fixes the inode cache writeout to preserve any error values and
makes sure not to override the root when inode cache writeout is done.

Reported-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent e082f563
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -1149,6 +1149,7 @@ int btrfs_wait_cache_io(struct btrfs_root *root,
	if (!inode)
		return 0;

	if (block_group)
		root = root->fs_info->tree_root;

	/* Flush the dirty pages in the cache file. */
@@ -3463,9 +3464,12 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root,
	if (!btrfs_test_opt(root, INODE_MAP_CACHE))
		return 0;

	memset(&io_ctl, 0, sizeof(io_ctl));
	ret = __btrfs_write_out_cache(root, inode, ctl, NULL, &io_ctl,
				      trans, path, 0) ||
		btrfs_wait_cache_io(root, trans, NULL, &io_ctl, path, 0);
				      trans, path, 0);
	if (!ret)
		ret = btrfs_wait_cache_io(root, trans, NULL, &io_ctl, path, 0);

	if (ret) {
		btrfs_delalloc_release_metadata(inode, inode->i_size);
#ifdef DEBUG