Skip to content

Commit b930c26

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: Btrfs: fix meta data raid-repair merge problem Btrfs: skip allocation attempt from empty cluster Btrfs: skip block groups without enough space for a cluster Btrfs: start search for new cluster at the beginning Btrfs: reset cluster's max_size when creating bitmap Btrfs: initialize new bitmaps' list Btrfs: fix oops when calling statfs on readonly device Btrfs: Don't error on resizing FS to same size Btrfs: fix deadlock on metadata reservation when evicting a inode Fix URL of btrfs-progs git repository in docs btrfs scrub: handle -ENOMEM from init_ipath()
2 parents 11d814a + f4a8e65 commit b930c26

File tree

9 files changed

+60
-25
lines changed

9 files changed

+60
-25
lines changed

Documentation/filesystems/btrfs.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ IRC network.
6363
Userspace tools for creating and manipulating Btrfs file systems are
6464
available from the git repository at the following location:
6565

66-
http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git
67-
git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git
66+
http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs.git
67+
git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git
6868

6969
These include the following tools:
7070

fs/btrfs/ctree.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,6 +2369,9 @@ int btrfs_block_rsv_check(struct btrfs_root *root,
23692369
int btrfs_block_rsv_refill(struct btrfs_root *root,
23702370
struct btrfs_block_rsv *block_rsv,
23712371
u64 min_reserved);
2372+
int btrfs_block_rsv_refill_noflush(struct btrfs_root *root,
2373+
struct btrfs_block_rsv *block_rsv,
2374+
u64 min_reserved);
23722375
int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv,
23732376
struct btrfs_block_rsv *dst_rsv,
23742377
u64 num_bytes);

fs/btrfs/extent-tree.c

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3888,9 +3888,9 @@ int btrfs_block_rsv_check(struct btrfs_root *root,
38883888
return ret;
38893889
}
38903890

3891-
int btrfs_block_rsv_refill(struct btrfs_root *root,
3892-
struct btrfs_block_rsv *block_rsv,
3893-
u64 min_reserved)
3891+
static inline int __btrfs_block_rsv_refill(struct btrfs_root *root,
3892+
struct btrfs_block_rsv *block_rsv,
3893+
u64 min_reserved, int flush)
38943894
{
38953895
u64 num_bytes = 0;
38963896
int ret = -ENOSPC;
@@ -3909,7 +3909,7 @@ int btrfs_block_rsv_refill(struct btrfs_root *root,
39093909
if (!ret)
39103910
return 0;
39113911

3912-
ret = reserve_metadata_bytes(root, block_rsv, num_bytes, 1);
3912+
ret = reserve_metadata_bytes(root, block_rsv, num_bytes, flush);
39133913
if (!ret) {
39143914
block_rsv_add_bytes(block_rsv, num_bytes, 0);
39153915
return 0;
@@ -3918,6 +3918,20 @@ int btrfs_block_rsv_refill(struct btrfs_root *root,
39183918
return ret;
39193919
}
39203920

3921+
int btrfs_block_rsv_refill(struct btrfs_root *root,
3922+
struct btrfs_block_rsv *block_rsv,
3923+
u64 min_reserved)
3924+
{
3925+
return __btrfs_block_rsv_refill(root, block_rsv, min_reserved, 1);
3926+
}
3927+
3928+
int btrfs_block_rsv_refill_noflush(struct btrfs_root *root,
3929+
struct btrfs_block_rsv *block_rsv,
3930+
u64 min_reserved)
3931+
{
3932+
return __btrfs_block_rsv_refill(root, block_rsv, min_reserved, 0);
3933+
}
3934+
39213935
int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv,
39223936
struct btrfs_block_rsv *dst_rsv,
39233937
u64 num_bytes)
@@ -5265,7 +5279,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
52655279
spin_lock(&block_group->free_space_ctl->tree_lock);
52665280
if (cached &&
52675281
block_group->free_space_ctl->free_space <
5268-
num_bytes + empty_size) {
5282+
num_bytes + empty_cluster + empty_size) {
52695283
spin_unlock(&block_group->free_space_ctl->tree_lock);
52705284
goto loop;
52715285
}
@@ -5286,12 +5300,10 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
52865300
* people trying to start a new cluster
52875301
*/
52885302
spin_lock(&last_ptr->refill_lock);
5289-
if (last_ptr->block_group &&
5290-
(last_ptr->block_group->ro ||
5291-
!block_group_bits(last_ptr->block_group, data))) {
5292-
offset = 0;
5303+
if (!last_ptr->block_group ||
5304+
last_ptr->block_group->ro ||
5305+
!block_group_bits(last_ptr->block_group, data))
52935306
goto refill_cluster;
5294-
}
52955307

52965308
offset = btrfs_alloc_from_cluster(block_group, last_ptr,
52975309
num_bytes, search_start);
@@ -5342,7 +5354,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
53425354
/* allocate a cluster in this block group */
53435355
ret = btrfs_find_space_cluster(trans, root,
53445356
block_group, last_ptr,
5345-
offset, num_bytes,
5357+
search_start, num_bytes,
53465358
empty_cluster + empty_size);
53475359
if (ret == 0) {
53485360
/*

fs/btrfs/extent_io.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,21 +2287,34 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
22872287
if (!uptodate) {
22882288
int failed_mirror;
22892289
failed_mirror = (int)(unsigned long)bio->bi_bdev;
2290-
if (tree->ops && tree->ops->readpage_io_failed_hook)
2291-
ret = tree->ops->readpage_io_failed_hook(
2292-
bio, page, start, end,
2293-
failed_mirror, state);
2294-
else
2295-
ret = bio_readpage_error(bio, page, start, end,
2296-
failed_mirror, NULL);
2290+
/*
2291+
* The generic bio_readpage_error handles errors the
2292+
* following way: If possible, new read requests are
2293+
* created and submitted and will end up in
2294+
* end_bio_extent_readpage as well (if we're lucky, not
2295+
* in the !uptodate case). In that case it returns 0 and
2296+
* we just go on with the next page in our bio. If it
2297+
* can't handle the error it will return -EIO and we
2298+
* remain responsible for that page.
2299+
*/
2300+
ret = bio_readpage_error(bio, page, start, end,
2301+
failed_mirror, NULL);
22972302
if (ret == 0) {
2303+
error_handled:
22982304
uptodate =
22992305
test_bit(BIO_UPTODATE, &bio->bi_flags);
23002306
if (err)
23012307
uptodate = 0;
23022308
uncache_state(&cached);
23032309
continue;
23042310
}
2311+
if (tree->ops && tree->ops->readpage_io_failed_hook) {
2312+
ret = tree->ops->readpage_io_failed_hook(
2313+
bio, page, start, end,
2314+
failed_mirror, state);
2315+
if (ret == 0)
2316+
goto error_handled;
2317+
}
23052318
}
23062319

23072320
if (uptodate) {

fs/btrfs/free-space-cache.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,7 @@ static void add_new_bitmap(struct btrfs_free_space_ctl *ctl,
14701470
{
14711471
info->offset = offset_to_bitmap(ctl, offset);
14721472
info->bytes = 0;
1473+
INIT_LIST_HEAD(&info->list);
14731474
link_free_space(ctl, info);
14741475
ctl->total_bitmaps++;
14751476

@@ -2319,6 +2320,7 @@ static int btrfs_bitmap_cluster(struct btrfs_block_group_cache *block_group,
23192320

23202321
if (!found) {
23212322
start = i;
2323+
cluster->max_size = 0;
23222324
found = true;
23232325
}
23242326

fs/btrfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3490,7 +3490,7 @@ void btrfs_evict_inode(struct inode *inode)
34903490
* doing the truncate.
34913491
*/
34923492
while (1) {
3493-
ret = btrfs_block_rsv_refill(root, rsv, min_size);
3493+
ret = btrfs_block_rsv_refill_noflush(root, rsv, min_size);
34943494

34953495
/*
34963496
* Try and steal from the global reserve since we will

fs/btrfs/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root,
12781278
}
12791279
ret = btrfs_grow_device(trans, device, new_size);
12801280
btrfs_commit_transaction(trans, root);
1281-
} else {
1281+
} else if (new_size < old_size) {
12821282
ret = btrfs_shrink_device(device, new_size);
12831283
}
12841284

fs/btrfs/scrub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root, void *ctx)
256256
btrfs_release_path(swarn->path);
257257

258258
ipath = init_ipath(4096, local_root, swarn->path);
259+
if (IS_ERR(ipath)) {
260+
ret = PTR_ERR(ipath);
261+
ipath = NULL;
262+
goto err;
263+
}
259264
ret = paths_from_inode(inum, ipath);
260265

261266
if (ret < 0)

fs/btrfs/super.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
10571057
int i = 0, nr_devices;
10581058
int ret;
10591059

1060-
nr_devices = fs_info->fs_devices->rw_devices;
1060+
nr_devices = fs_info->fs_devices->open_devices;
10611061
BUG_ON(!nr_devices);
10621062

10631063
devices_info = kmalloc(sizeof(*devices_info) * nr_devices,
@@ -1079,8 +1079,8 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
10791079
else
10801080
min_stripe_size = BTRFS_STRIPE_LEN;
10811081

1082-
list_for_each_entry(device, &fs_devices->alloc_list, dev_alloc_list) {
1083-
if (!device->in_fs_metadata)
1082+
list_for_each_entry(device, &fs_devices->devices, dev_list) {
1083+
if (!device->in_fs_metadata || !device->bdev)
10841084
continue;
10851085

10861086
avail_space = device->total_bytes - device->bytes_used;

0 commit comments

Comments
 (0)