Skip to content

Commit 0a2a133

Browse files
committed
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
2 parents 9583f1c + 0e4324a commit 0a2a133

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

fs/btrfs/extent-tree.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4825,10 +4825,6 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info, u64 to_reclaim,
48254825
else
48264826
flush = BTRFS_RESERVE_NO_FLUSH;
48274827
spin_lock(&space_info->lock);
4828-
if (can_overcommit(fs_info, space_info, orig, flush, false)) {
4829-
spin_unlock(&space_info->lock);
4830-
break;
4831-
}
48324828
if (list_empty(&space_info->tickets) &&
48334829
list_empty(&space_info->priority_tickets)) {
48344830
spin_unlock(&space_info->lock);
@@ -7589,6 +7585,10 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
75897585
u64 offset;
75907586
int cached;
75917587

7588+
/* If the block group is read-only, we can skip it entirely. */
7589+
if (unlikely(block_group->ro))
7590+
continue;
7591+
75927592
btrfs_grab_block_group(block_group, delalloc);
75937593
search_start = block_group->key.objectid;
75947594

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

76257625
if (unlikely(block_group->cached == BTRFS_CACHE_ERROR))
76267626
goto loop;
7627-
if (unlikely(block_group->ro))
7628-
goto loop;
76297627

76307628
/*
76317629
* 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,
78397837
failed_alloc = false;
78407838
BUG_ON(index != get_block_group_index(block_group));
78417839
btrfs_release_block_group(block_group, delalloc);
7840+
cond_resched();
78427841
}
78437842
up_read(&space_info->groups_sem);
78447843

fs/btrfs/tree-log.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,8 +2153,7 @@ static int replay_xattr_deletes(struct btrfs_trans_handle *trans,
21532153
u32 this_len = sizeof(*di) + name_len + data_len;
21542154
char *name;
21552155

2156-
ret = verify_dir_item(fs_info, path->nodes[0],
2157-
path->slots[0], di);
2156+
ret = verify_dir_item(fs_info, path->nodes[0], i, di);
21582157
if (ret) {
21592158
ret = -EIO;
21602159
goto out;

fs/btrfs/volumes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,7 +2702,7 @@ int btrfs_grow_device(struct btrfs_trans_handle *trans,
27022702

27032703
mutex_lock(&fs_info->chunk_mutex);
27042704
old_total = btrfs_super_total_bytes(super_copy);
2705-
diff = new_size - device->total_bytes;
2705+
diff = round_down(new_size - device->total_bytes, fs_info->sectorsize);
27062706

27072707
if (new_size <= device->total_bytes ||
27082708
device->is_tgtdev_for_dev_replace) {
@@ -4406,7 +4406,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
44064406
u64 diff;
44074407

44084408
new_size = round_down(new_size, fs_info->sectorsize);
4409-
diff = old_size - new_size;
4409+
diff = round_down(old_size - new_size, fs_info->sectorsize);
44104410

44114411
if (device->is_tgtdev_for_dev_replace)
44124412
return -EINVAL;

0 commit comments

Comments
 (0)