Skip to content

Commit

Permalink
Merge branch 'for-4.13-part3' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/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
  • Loading branch information
Linus Torvalds committed Jul 28, 2017
2 parents 9583f1c + 0e4324a commit 0a2a133
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
11 changes: 5 additions & 6 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -4825,10 +4825,6 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info, u64 to_reclaim,
else
flush = BTRFS_RESERVE_NO_FLUSH;
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) &&
list_empty(&space_info->priority_tickets)) {
spin_unlock(&space_info->lock);
Expand Down Expand Up @@ -7589,6 +7585,10 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
u64 offset;
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);
search_start = block_group->key.objectid;

Expand Down Expand Up @@ -7624,8 +7624,6 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,

if (unlikely(block_group->cached == BTRFS_CACHE_ERROR))
goto loop;
if (unlikely(block_group->ro))
goto loop;

/*
* Ok we want to try and use the cluster allocator, so
Expand Down Expand Up @@ -7839,6 +7837,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
failed_alloc = false;
BUG_ON(index != get_block_group_index(block_group));
btrfs_release_block_group(block_group, delalloc);
cond_resched();
}
up_read(&space_info->groups_sem);

Expand Down
3 changes: 1 addition & 2 deletions fs/btrfs/tree-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -2153,8 +2153,7 @@ static int replay_xattr_deletes(struct btrfs_trans_handle *trans,
u32 this_len = sizeof(*di) + name_len + data_len;
char *name;

ret = verify_dir_item(fs_info, path->nodes[0],
path->slots[0], di);
ret = verify_dir_item(fs_info, path->nodes[0], i, di);
if (ret) {
ret = -EIO;
goto out;
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2702,7 +2702,7 @@ int btrfs_grow_device(struct btrfs_trans_handle *trans,

mutex_lock(&fs_info->chunk_mutex);
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 ||
device->is_tgtdev_for_dev_replace) {
Expand Down Expand Up @@ -4406,7 +4406,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
u64 diff;

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)
return -EINVAL;
Expand Down

0 comments on commit 0a2a133

Please sign in to comment.