2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-16 01:04:08 +08:00

Merge branch 'for-linus-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs

Pull btrfs fixes from Chris Mason:
 "We have three small fixes queued up in my for-linus-4.11 branch"

* 'for-linus-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  Btrfs: fix an integer overflow check
  btrfs: Change qgroup_meta_rsv to 64bit
  Btrfs: bring back repair during read
This commit is contained in:
Linus Torvalds 2017-03-31 17:58:48 -07:00
commit fe8e12b503
6 changed files with 45 additions and 30 deletions

View File

@ -1259,7 +1259,7 @@ struct btrfs_root {
atomic_t will_be_snapshoted; atomic_t will_be_snapshoted;
/* For qgroup metadata space reserve */ /* For qgroup metadata space reserve */
atomic_t qgroup_meta_rsv; atomic64_t qgroup_meta_rsv;
}; };
static inline u32 btrfs_inode_sectorsize(const struct inode *inode) static inline u32 btrfs_inode_sectorsize(const struct inode *inode)
{ {

View File

@ -1342,7 +1342,7 @@ static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
atomic_set(&root->orphan_inodes, 0); atomic_set(&root->orphan_inodes, 0);
atomic_set(&root->refs, 1); atomic_set(&root->refs, 1);
atomic_set(&root->will_be_snapshoted, 0); atomic_set(&root->will_be_snapshoted, 0);
atomic_set(&root->qgroup_meta_rsv, 0); atomic64_set(&root->qgroup_meta_rsv, 0);
root->log_transid = 0; root->log_transid = 0;
root->log_transid_committed = -1; root->log_transid_committed = -1;
root->last_log_commit = 0; root->last_log_commit = 0;

View File

@ -2584,26 +2584,36 @@ static void end_bio_extent_readpage(struct bio *bio)
if (tree->ops) { if (tree->ops) {
ret = tree->ops->readpage_io_failed_hook(page, mirror); ret = tree->ops->readpage_io_failed_hook(page, mirror);
if (!ret && !bio->bi_error) if (ret == -EAGAIN) {
uptodate = 1; /*
} else { * Data inode's readpage_io_failed_hook() always
/* * returns -EAGAIN.
* The generic bio_readpage_error handles errors the *
* following way: If possible, new read requests are * The generic bio_readpage_error handles errors
* created and submitted and will end up in * the following way: If possible, new read
* end_bio_extent_readpage as well (if we're lucky, not * requests are created and submitted and will
* in the !uptodate case). In that case it returns 0 and * end up in end_bio_extent_readpage as well (if
* we just go on with the next page in our bio. If it * we're lucky, not in the !uptodate case). In
* can't handle the error it will return -EIO and we * that case it returns 0 and we just go on with
* remain responsible for that page. * the next page in our bio. If it can't handle
*/ * the error it will return -EIO and we remain
ret = bio_readpage_error(bio, offset, page, start, end, * responsible for that page.
mirror); */
if (ret == 0) { ret = bio_readpage_error(bio, offset, page,
uptodate = !bio->bi_error; start, end, mirror);
offset += len; if (ret == 0) {
continue; uptodate = !bio->bi_error;
offset += len;
continue;
}
} }
/*
* metadata's readpage_io_failed_hook() always returns
* -EIO and fixes nothing. -EIO is also returned if
* data inode error could not be fixed.
*/
ASSERT(ret == -EIO);
} }
readpage_ok: readpage_ok:
if (likely(uptodate)) { if (likely(uptodate)) {

View File

@ -10523,9 +10523,9 @@ out_inode:
} }
__attribute__((const)) __attribute__((const))
static int dummy_readpage_io_failed_hook(struct page *page, int failed_mirror) static int btrfs_readpage_io_failed_hook(struct page *page, int failed_mirror)
{ {
return 0; return -EAGAIN;
} }
static const struct inode_operations btrfs_dir_inode_operations = { static const struct inode_operations btrfs_dir_inode_operations = {
@ -10570,7 +10570,7 @@ static const struct extent_io_ops btrfs_extent_io_ops = {
.submit_bio_hook = btrfs_submit_bio_hook, .submit_bio_hook = btrfs_submit_bio_hook,
.readpage_end_io_hook = btrfs_readpage_end_io_hook, .readpage_end_io_hook = btrfs_readpage_end_io_hook,
.merge_bio_hook = btrfs_merge_bio_hook, .merge_bio_hook = btrfs_merge_bio_hook,
.readpage_io_failed_hook = dummy_readpage_io_failed_hook, .readpage_io_failed_hook = btrfs_readpage_io_failed_hook,
/* optional callbacks */ /* optional callbacks */
.fill_delalloc = run_delalloc_range, .fill_delalloc = run_delalloc_range,

View File

@ -2948,20 +2948,20 @@ int btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes,
ret = qgroup_reserve(root, num_bytes, enforce); ret = qgroup_reserve(root, num_bytes, enforce);
if (ret < 0) if (ret < 0)
return ret; return ret;
atomic_add(num_bytes, &root->qgroup_meta_rsv); atomic64_add(num_bytes, &root->qgroup_meta_rsv);
return ret; return ret;
} }
void btrfs_qgroup_free_meta_all(struct btrfs_root *root) void btrfs_qgroup_free_meta_all(struct btrfs_root *root)
{ {
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
int reserved; u64 reserved;
if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) || if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) ||
!is_fstree(root->objectid)) !is_fstree(root->objectid))
return; return;
reserved = atomic_xchg(&root->qgroup_meta_rsv, 0); reserved = atomic64_xchg(&root->qgroup_meta_rsv, 0);
if (reserved == 0) if (reserved == 0)
return; return;
btrfs_qgroup_free_refroot(fs_info, root->objectid, reserved); btrfs_qgroup_free_refroot(fs_info, root->objectid, reserved);
@ -2976,8 +2976,8 @@ void btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes)
return; return;
BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize)); BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize));
WARN_ON(atomic_read(&root->qgroup_meta_rsv) < num_bytes); WARN_ON(atomic64_read(&root->qgroup_meta_rsv) < num_bytes);
atomic_sub(num_bytes, &root->qgroup_meta_rsv); atomic64_sub(num_bytes, &root->qgroup_meta_rsv);
btrfs_qgroup_free_refroot(fs_info, root->objectid, num_bytes); btrfs_qgroup_free_refroot(fs_info, root->objectid, num_bytes);
} }

View File

@ -6305,8 +6305,13 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
goto out; goto out;
} }
/*
* Check that we don't overflow at later allocations, we request
* clone_sources_count + 1 items, and compare to unsigned long inside
* access_ok.
*/
if (arg->clone_sources_count > if (arg->clone_sources_count >
ULLONG_MAX / sizeof(*arg->clone_sources)) { ULONG_MAX / sizeof(struct clone_root) - 1) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }