Skip to content

Commit

Permalink
Merge tag 'for-4.18-rc5-tag' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/kdave/linux

Pull btrfs fixes from David Sterba:
 "Three regression fixes. They're few-liners and fixing some corner
  cases missed in the origial patches"

* tag 'for-4.18-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: scrub: Don't use inode page cache in scrub_handle_errored_block()
  btrfs: fix use-after-free of cmp workspace pages
  btrfs: restore uuid_mutex in btrfs_open_devices
  • Loading branch information
Linus Torvalds committed Jul 18, 2018
2 parents 47f7dc4 + 665d495 commit 04a1320
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3327,11 +3327,13 @@ static void btrfs_cmp_data_free(struct cmp_pages *cmp)
if (pg) {
unlock_page(pg);
put_page(pg);
cmp->src_pages[i] = NULL;
}
pg = cmp->dst_pages[i];
if (pg) {
unlock_page(pg);
put_page(pg);
cmp->dst_pages[i] = NULL;
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions fs/btrfs/scrub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,11 +1151,6 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
return ret;
}

if (sctx->is_dev_replace && !is_metadata && !have_csum) {
sblocks_for_recheck = NULL;
goto nodatasum_case;
}

/*
* read all mirrors one after the other. This includes to
* re-read the extent or metadata block that failed (that was
Expand Down Expand Up @@ -1268,13 +1263,19 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
goto out;
}

if (!is_metadata && !have_csum) {
/*
* NOTE: Even for nodatasum case, it's still possible that it's a
* compressed data extent, thus scrub_fixup_nodatasum(), which write
* inode page cache onto disk, could cause serious data corruption.
*
* So here we could only read from disk, and hope our recovery could
* reach disk before the newer write.
*/
if (0 && !is_metadata && !have_csum) {
struct scrub_fixup_nodatasum *fixup_nodatasum;

WARN_ON(sctx->is_dev_replace);

nodatasum_case:

/*
* !is_metadata and !have_csum, this means that the data
* might not be COWed, that it might be modified
Expand Down
2 changes: 2 additions & 0 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
{
int ret;

mutex_lock(&uuid_mutex);
mutex_lock(&fs_devices->device_list_mutex);
if (fs_devices->opened) {
fs_devices->opened++;
Expand All @@ -1155,6 +1156,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
ret = open_fs_devices(fs_devices, flags, holder);
}
mutex_unlock(&fs_devices->device_list_mutex);
mutex_unlock(&uuid_mutex);

return ret;
}
Expand Down

0 comments on commit 04a1320

Please sign in to comment.