Commit fe8e12b5 authored by Linus Torvalds's avatar Linus Torvalds

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
parents f9799ad2 41a75a6e
...@@ -1259,7 +1259,7 @@ struct btrfs_root { ...@@ -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)
{ {
......
...@@ -1342,7 +1342,7 @@ static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info, ...@@ -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;
......
...@@ -2584,27 +2584,37 @@ static void end_bio_extent_readpage(struct bio *bio) ...@@ -2584,27 +2584,37 @@ 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 {
/* /*
* The generic bio_readpage_error handles errors the * Data inode's readpage_io_failed_hook() always
* following way: If possible, new read requests are * returns -EAGAIN.
* created and submitted and will end up in *
* end_bio_extent_readpage as well (if we're lucky, not * The generic bio_readpage_error handles errors
* in the !uptodate case). In that case it returns 0 and * the following way: If possible, new read
* we just go on with the next page in our bio. If it * requests are created and submitted and will
* can't handle the error it will return -EIO and we * end up in end_bio_extent_readpage as well (if
* remain responsible for that page. * we're lucky, not in the !uptodate case). In
*/ * that case it returns 0 and we just go on with
ret = bio_readpage_error(bio, offset, page, start, end, * the next page in our bio. If it can't handle
mirror); * the error it will return -EIO and we remain
* responsible for that page.
*/
ret = bio_readpage_error(bio, offset, page,
start, end, mirror);
if (ret == 0) { if (ret == 0) {
uptodate = !bio->bi_error; uptodate = !bio->bi_error;
offset += len; offset += len;
continue; 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)) {
loff_t i_size = i_size_read(inode); loff_t i_size = i_size_read(inode);
......
...@@ -10523,9 +10523,9 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -10523,9 +10523,9 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
} }
__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 = { ...@@ -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,
......
...@@ -2948,20 +2948,20 @@ int btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes, ...@@ -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) ...@@ -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);
} }
......
...@@ -6305,8 +6305,13 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) ...@@ -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;
} }
......
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