Commit 0a2a1330 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-4.13-part3' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba:
 "Fixes addressing problems reported by users, and there's one more
  regression fix"

* 'for-4.13-part3' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: round down size diff when shrinking/growing device
  Btrfs: fix early ENOSPC due to delalloc
  btrfs: fix lockup in find_free_extent with read-only block groups
  Btrfs: fix dir item validation when replaying xattr deletes
parents 9583f1c9 0e4324a4
...@@ -4825,10 +4825,6 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info, u64 to_reclaim, ...@@ -4825,10 +4825,6 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info, u64 to_reclaim,
else else
flush = BTRFS_RESERVE_NO_FLUSH; flush = BTRFS_RESERVE_NO_FLUSH;
spin_lock(&space_info->lock); spin_lock(&space_info->lock);
if (can_overcommit(fs_info, space_info, orig, flush, false)) {
spin_unlock(&space_info->lock);
break;
}
if (list_empty(&space_info->tickets) && if (list_empty(&space_info->tickets) &&
list_empty(&space_info->priority_tickets)) { list_empty(&space_info->priority_tickets)) {
spin_unlock(&space_info->lock); spin_unlock(&space_info->lock);
...@@ -7589,6 +7585,10 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, ...@@ -7589,6 +7585,10 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
u64 offset; u64 offset;
int cached; int cached;
/* If the block group is read-only, we can skip it entirely. */
if (unlikely(block_group->ro))
continue;
btrfs_grab_block_group(block_group, delalloc); btrfs_grab_block_group(block_group, delalloc);
search_start = block_group->key.objectid; search_start = block_group->key.objectid;
...@@ -7624,8 +7624,6 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, ...@@ -7624,8 +7624,6 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
if (unlikely(block_group->cached == BTRFS_CACHE_ERROR)) if (unlikely(block_group->cached == BTRFS_CACHE_ERROR))
goto loop; goto loop;
if (unlikely(block_group->ro))
goto loop;
/* /*
* Ok we want to try and use the cluster allocator, so * Ok we want to try and use the cluster allocator, so
...@@ -7839,6 +7837,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, ...@@ -7839,6 +7837,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
failed_alloc = false; failed_alloc = false;
BUG_ON(index != get_block_group_index(block_group)); BUG_ON(index != get_block_group_index(block_group));
btrfs_release_block_group(block_group, delalloc); btrfs_release_block_group(block_group, delalloc);
cond_resched();
} }
up_read(&space_info->groups_sem); up_read(&space_info->groups_sem);
......
...@@ -2153,8 +2153,7 @@ static int replay_xattr_deletes(struct btrfs_trans_handle *trans, ...@@ -2153,8 +2153,7 @@ static int replay_xattr_deletes(struct btrfs_trans_handle *trans,
u32 this_len = sizeof(*di) + name_len + data_len; u32 this_len = sizeof(*di) + name_len + data_len;
char *name; char *name;
ret = verify_dir_item(fs_info, path->nodes[0], ret = verify_dir_item(fs_info, path->nodes[0], i, di);
path->slots[0], di);
if (ret) { if (ret) {
ret = -EIO; ret = -EIO;
goto out; goto out;
......
...@@ -2702,7 +2702,7 @@ int btrfs_grow_device(struct btrfs_trans_handle *trans, ...@@ -2702,7 +2702,7 @@ int btrfs_grow_device(struct btrfs_trans_handle *trans,
mutex_lock(&fs_info->chunk_mutex); mutex_lock(&fs_info->chunk_mutex);
old_total = btrfs_super_total_bytes(super_copy); old_total = btrfs_super_total_bytes(super_copy);
diff = new_size - device->total_bytes; diff = round_down(new_size - device->total_bytes, fs_info->sectorsize);
if (new_size <= device->total_bytes || if (new_size <= device->total_bytes ||
device->is_tgtdev_for_dev_replace) { device->is_tgtdev_for_dev_replace) {
...@@ -4406,7 +4406,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size) ...@@ -4406,7 +4406,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
u64 diff; u64 diff;
new_size = round_down(new_size, fs_info->sectorsize); new_size = round_down(new_size, fs_info->sectorsize);
diff = old_size - new_size; diff = round_down(old_size - new_size, fs_info->sectorsize);
if (device->is_tgtdev_for_dev_replace) if (device->is_tgtdev_for_dev_replace)
return -EINVAL; return -EINVAL;
......
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