Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 263095
b: refs/heads/master
c: 38c01b9
h: refs/heads/master
i:
  263093: d5833fa
  263091: 8a7242f
  263087: c23d13c
v: v3
  • Loading branch information
liubo authored and Chris Mason committed Aug 17, 2011
1 parent 50cd112 commit 8405af1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 34f3e4f23ca3d259fe078f62a128d97ca83508ef
refs/heads/master: 38c01b9605923cfdff5413e0a12e58ee8d962257
17 changes: 13 additions & 4 deletions trunk/fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ int find_free_dev_extent(struct btrfs_trans_handle *trans,

max_hole_start = search_start;
max_hole_size = 0;
hole_size = 0;

if (search_start >= search_end) {
ret = -ENOSPC;
Expand Down Expand Up @@ -945,7 +946,14 @@ int find_free_dev_extent(struct btrfs_trans_handle *trans,
cond_resched();
}

hole_size = search_end- search_start;
/*
* At this point, search_start should be the end of
* allocated dev extents, and when shrinking the device,
* search_end may be smaller than search_start.
*/
if (search_end > search_start)
hole_size = search_end - search_start;

if (hole_size > max_hole_size) {
max_hole_start = search_start;
max_hole_size = hole_size;
Expand Down Expand Up @@ -2447,9 +2455,10 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
total_avail = device->total_bytes - device->bytes_used;
else
total_avail = 0;
/* avail is off by max(alloc_start, 1MB), but that is the same
* for all devices, so it doesn't hurt the sorting later on
*/

/* If there is no space on this device, skip it. */
if (total_avail == 0)
continue;

ret = find_free_dev_extent(trans, device,
max_stripe_size * dev_stripes,
Expand Down

0 comments on commit 8405af1

Please sign in to comment.