Skip to content

Commit e84d960

Browse files
committed
Merge tag 'for-6.19-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: - with large folios in use, fix partial incorrect update of a reflinked range - fix potential deadlock in iget when lookup fails and eviction is needed - in send, validate inline extent type while detecting file holes - fix memory leak after an error when creating a space info - remove zone statistics from sysfs again, the output size limitations make it unusable, we'll do it in another way in another release - test fixes: - return proper error codes from block remapping tests - fix tree root leaks in qgroup tests after errors * tag 'for-6.19-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: remove zoned statistics from sysfs btrfs: fix memory leaks in create_space_info() error paths btrfs: invalidate pages instead of truncate after reflinking btrfs: update the Kconfig string for CONFIG_BTRFS_EXPERIMENTAL btrfs: send: check for inline extents in range_is_hole_in_parent() btrfs: tests: fix return 0 on rmap test failure btrfs: tests: fix root tree leak in btrfs_test_qgroups() btrfs: release path before iget_failed() in btrfs_read_locked_inode()
2 parents 47622aa + 437cc60 commit e84d960

8 files changed

Lines changed: 41 additions & 68 deletions

File tree

fs/btrfs/Kconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ config BTRFS_EXPERIMENTAL
115115

116116
- extent tree v2 - complex rework of extent tracking
117117

118-
- large folio support
118+
- large folio and block size (> page size) support
119+
120+
- shutdown ioctl and auto-degradation support
121+
122+
- asynchronous checksum generation for data writes
119123

120124
If unsure, say N.

fs/btrfs/inode.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4180,6 +4180,15 @@ static int btrfs_read_locked_inode(struct btrfs_inode *inode, struct btrfs_path
41804180

41814181
return 0;
41824182
out:
4183+
/*
4184+
* We may have a read locked leaf and iget_failed() triggers inode
4185+
* eviction which needs to release the delayed inode and that needs
4186+
* to lock the delayed inode's mutex. This can cause a ABBA deadlock
4187+
* with a task running delayed items, as that require first locking
4188+
* the delayed inode's mutex and then modifying its subvolume btree.
4189+
* So release the path before iget_failed().
4190+
*/
4191+
btrfs_release_path(path);
41834192
iget_failed(vfs_inode);
41844193
return ret;
41854194
}

fs/btrfs/reflink.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
705705
struct inode *src = file_inode(file_src);
706706
struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
707707
int ret;
708-
int wb_ret;
709708
u64 len = olen;
710709
u64 bs = fs_info->sectorsize;
711710
u64 end;
@@ -750,25 +749,29 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
750749
btrfs_lock_extent(&BTRFS_I(inode)->io_tree, destoff, end, &cached_state);
751750
ret = btrfs_clone(src, inode, off, olen, len, destoff, 0);
752751
btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, destoff, end, &cached_state);
752+
if (ret < 0)
753+
return ret;
753754

754755
/*
755756
* We may have copied an inline extent into a page of the destination
756-
* range, so wait for writeback to complete before truncating pages
757+
* range, so wait for writeback to complete before invalidating pages
757758
* from the page cache. This is a rare case.
758759
*/
759-
wb_ret = btrfs_wait_ordered_range(BTRFS_I(inode), destoff, len);
760-
ret = ret ? ret : wb_ret;
760+
ret = btrfs_wait_ordered_range(BTRFS_I(inode), destoff, len);
761+
if (ret < 0)
762+
return ret;
763+
761764
/*
762-
* Truncate page cache pages so that future reads will see the cloned
763-
* data immediately and not the previous data.
765+
* Invalidate page cache so that future reads will see the cloned data
766+
* immediately and not the previous data.
764767
*/
765-
truncate_inode_pages_range(&inode->i_data,
766-
round_down(destoff, PAGE_SIZE),
767-
round_up(destoff + len, PAGE_SIZE) - 1);
768+
ret = filemap_invalidate_inode(inode, false, destoff, end);
769+
if (ret < 0)
770+
return ret;
768771

769772
btrfs_btree_balance_dirty(fs_info);
770773

771-
return ret;
774+
return 0;
772775
}
773776

774777
static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,

fs/btrfs/send.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6383,6 +6383,8 @@ static int range_is_hole_in_parent(struct send_ctx *sctx,
63836383
extent_end = btrfs_file_extent_end(path);
63846384
if (extent_end <= start)
63856385
goto next;
6386+
if (btrfs_file_extent_type(leaf, fi) == BTRFS_FILE_EXTENT_INLINE)
6387+
return 0;
63866388
if (btrfs_file_extent_disk_bytenr(leaf, fi) == 0) {
63876389
search_start = extent_end;
63886390
goto next;

fs/btrfs/space-info.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,18 +306,22 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags)
306306
0);
307307

308308
if (ret)
309-
return ret;
309+
goto out_free;
310310
}
311311

312312
ret = btrfs_sysfs_add_space_info_type(space_info);
313313
if (ret)
314-
return ret;
314+
goto out_free;
315315

316316
list_add(&space_info->list, &info->space_info);
317317
if (flags & BTRFS_BLOCK_GROUP_DATA)
318318
info->data_sinfo = space_info;
319319

320320
return ret;
321+
322+
out_free:
323+
kfree(space_info);
324+
return ret;
321325
}
322326

323327
int btrfs_init_space_info(struct btrfs_fs_info *fs_info)

fs/btrfs/sysfs.c

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "misc.h"
2727
#include "fs.h"
2828
#include "accessors.h"
29-
#include "zoned.h"
3029

3130
/*
3231
* Structure name Path
@@ -1189,56 +1188,6 @@ static ssize_t btrfs_commit_stats_store(struct kobject *kobj,
11891188
}
11901189
BTRFS_ATTR_RW(, commit_stats, btrfs_commit_stats_show, btrfs_commit_stats_store);
11911190

1192-
static ssize_t btrfs_zoned_stats_show(struct kobject *kobj,
1193-
struct kobj_attribute *a, char *buf)
1194-
{
1195-
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
1196-
struct btrfs_block_group *bg;
1197-
size_t ret = 0;
1198-
1199-
1200-
if (!btrfs_is_zoned(fs_info))
1201-
return ret;
1202-
1203-
spin_lock(&fs_info->zone_active_bgs_lock);
1204-
ret += sysfs_emit_at(buf, ret, "active block-groups: %zu\n",
1205-
list_count_nodes(&fs_info->zone_active_bgs));
1206-
spin_unlock(&fs_info->zone_active_bgs_lock);
1207-
1208-
mutex_lock(&fs_info->reclaim_bgs_lock);
1209-
spin_lock(&fs_info->unused_bgs_lock);
1210-
ret += sysfs_emit_at(buf, ret, "\treclaimable: %zu\n",
1211-
list_count_nodes(&fs_info->reclaim_bgs));
1212-
ret += sysfs_emit_at(buf, ret, "\tunused: %zu\n",
1213-
list_count_nodes(&fs_info->unused_bgs));
1214-
spin_unlock(&fs_info->unused_bgs_lock);
1215-
mutex_unlock(&fs_info->reclaim_bgs_lock);
1216-
1217-
ret += sysfs_emit_at(buf, ret, "\tneed reclaim: %s\n",
1218-
str_true_false(btrfs_zoned_should_reclaim(fs_info)));
1219-
1220-
if (fs_info->data_reloc_bg)
1221-
ret += sysfs_emit_at(buf, ret,
1222-
"data relocation block-group: %llu\n",
1223-
fs_info->data_reloc_bg);
1224-
if (fs_info->treelog_bg)
1225-
ret += sysfs_emit_at(buf, ret,
1226-
"tree-log block-group: %llu\n",
1227-
fs_info->treelog_bg);
1228-
1229-
spin_lock(&fs_info->zone_active_bgs_lock);
1230-
ret += sysfs_emit_at(buf, ret, "active zones:\n");
1231-
list_for_each_entry(bg, &fs_info->zone_active_bgs, active_bg_list) {
1232-
ret += sysfs_emit_at(buf, ret,
1233-
"\tstart: %llu, wp: %llu used: %llu, reserved: %llu, unusable: %llu\n",
1234-
bg->start, bg->alloc_offset, bg->used,
1235-
bg->reserved, bg->zone_unusable);
1236-
}
1237-
spin_unlock(&fs_info->zone_active_bgs_lock);
1238-
return ret;
1239-
}
1240-
BTRFS_ATTR(, zoned_stats, btrfs_zoned_stats_show);
1241-
12421191
static ssize_t btrfs_clone_alignment_show(struct kobject *kobj,
12431192
struct kobj_attribute *a, char *buf)
12441193
{
@@ -1651,7 +1600,6 @@ static const struct attribute *btrfs_attrs[] = {
16511600
BTRFS_ATTR_PTR(, bg_reclaim_threshold),
16521601
BTRFS_ATTR_PTR(, commit_stats),
16531602
BTRFS_ATTR_PTR(, temp_fsid),
1654-
BTRFS_ATTR_PTR(, zoned_stats),
16551603
#ifdef CONFIG_BTRFS_EXPERIMENTAL
16561604
BTRFS_ATTR_PTR(, offload_csum),
16571605
#endif

fs/btrfs/tests/extent-map-tests.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,19 +1059,22 @@ static int test_rmap_block(struct btrfs_fs_info *fs_info,
10591059

10601060
if (out_stripe_len != BTRFS_STRIPE_LEN) {
10611061
test_err("calculated stripe length doesn't match");
1062+
ret = -EINVAL;
10621063
goto out;
10631064
}
10641065

10651066
if (out_ndaddrs != test->expected_mapped_addr) {
10661067
for (i = 0; i < out_ndaddrs; i++)
10671068
test_msg("mapped %llu", logical[i]);
10681069
test_err("unexpected number of mapped addresses: %d", out_ndaddrs);
1070+
ret = -EINVAL;
10691071
goto out;
10701072
}
10711073

10721074
for (i = 0; i < out_ndaddrs; i++) {
10731075
if (logical[i] != test->mapped_logical[i]) {
10741076
test_err("unexpected logical address mapped");
1077+
ret = -EINVAL;
10751078
goto out;
10761079
}
10771080
}

fs/btrfs/tests/qgroup-tests.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,11 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
517517
tmp_root->root_key.objectid = BTRFS_FS_TREE_OBJECTID;
518518
root->fs_info->fs_root = tmp_root;
519519
ret = btrfs_insert_fs_root(root->fs_info, tmp_root);
520+
btrfs_put_root(tmp_root);
520521
if (ret) {
521522
test_err("couldn't insert fs root %d", ret);
522523
goto out;
523524
}
524-
btrfs_put_root(tmp_root);
525525

526526
tmp_root = btrfs_alloc_dummy_root(fs_info);
527527
if (IS_ERR(tmp_root)) {
@@ -532,11 +532,11 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
532532

533533
tmp_root->root_key.objectid = BTRFS_FIRST_FREE_OBJECTID;
534534
ret = btrfs_insert_fs_root(root->fs_info, tmp_root);
535+
btrfs_put_root(tmp_root);
535536
if (ret) {
536-
test_err("couldn't insert fs root %d", ret);
537+
test_err("couldn't insert subvolume root %d", ret);
537538
goto out;
538539
}
539-
btrfs_put_root(tmp_root);
540540

541541
test_msg("running qgroup tests");
542542
ret = test_no_shared_qgroup(root, sectorsize, nodesize);

0 commit comments

Comments
 (0)