Skip to content

Commit 547635c

Browse files
committed
Merge tag 'for-6.6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs updates from David Sterba: "No new features, the bulk of the changes are fixes, refactoring and cleanups. The notable fix is the scrub performance restoration after rewrite in 6.4, though still only partial. Fixes: - scrub performance drop due to rewrite in 6.4 partially restored: - do IO grouping by blg_plug/blk_unplug again - avoid unnecessary tree searches when processing stripes, in extent and checksum trees - the drop is noticeable on fast PCIe devices, -66% and restored to -33% of the original - backports to 6.4 planned - handle more corner cases of transaction commit during orphan cleanup or delayed ref processing - use correct fsid/metadata_uuid when validating super block - copy directory permissions and time when creating a stub subvolume Core: - debugging feature integrity checker deprecated, to be removed in 6.7 - in zoned mode, zones are activated just before the write, making error handling easier, now the overcommit mechanism can be enabled again which improves performance by avoiding more frequent flushing - v0 extent handling completely removed, deprecated long time ago - error handling improvements - tests: - extent buffer bitmap tests - pinned extent splitting tests - cleanups and refactoring: - compression writeback - extent buffer bitmap - space flushing, ENOSPC handling" * tag 'for-6.6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: (110 commits) btrfs: zoned: skip splitting and logical rewriting on pre-alloc write btrfs: tests: test invalid splitting when skipping pinned drop extent_map btrfs: tests: add a test for btrfs_add_extent_mapping btrfs: tests: add extent_map tests for dropping with odd layouts btrfs: scrub: move write back of repaired sectors to scrub_stripe_read_repair_worker() btrfs: scrub: don't go ordered workqueue for dev-replace btrfs: scrub: fix grouping of read IO btrfs: scrub: avoid unnecessary csum tree search preparing stripes btrfs: scrub: avoid unnecessary extent tree search preparing stripes btrfs: copy dir permission and time when creating a stub subvolume btrfs: remove pointless empty list check when reading delayed dir indexes btrfs: drop redundant check to use fs_devices::metadata_uuid btrfs: compare the correct fsid/metadata_uuid in btrfs_validate_super btrfs: use the correct superblock to compare fsid in btrfs_validate_super btrfs: simplify memcpy either of metadata_uuid or fsid btrfs: add a helper to read the superblock metadata_uuid btrfs: remove v0 extent handling btrfs: output extra debug info if we failed to find an inline backref btrfs: move the !zoned assert into run_delalloc_cow btrfs: consolidate the error handling in run_delalloc_nocow ...
2 parents f678c89 + c02d35d commit 547635c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2280
-1686
lines changed

fs/btrfs/Kconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ config BTRFS_FS_POSIX_ACL
4949
If you don't know what Access Control Lists are, say N
5050

5151
config BTRFS_FS_CHECK_INTEGRITY
52-
bool "Btrfs with integrity check tool compiled in (DANGEROUS)"
52+
bool "Btrfs with integrity check tool compiled in (DEPRECATED)"
5353
depends on BTRFS_FS
5454
help
55+
This feature has been deprecated and will be removed in 6.7.
56+
5557
Adds code that examines all block write requests (including
5658
writes of the super block). The goal is to verify that the
5759
state of the filesystem on disk is always consistent, i.e.,

fs/btrfs/accessors.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#ifndef BTRFS_ACCESSORS_H
44
#define BTRFS_ACCESSORS_H
55

6+
#include <linux/stddef.h>
7+
68
struct btrfs_map_token {
79
struct extent_buffer *eb;
810
char *kaddr;
@@ -34,13 +36,13 @@ static inline void put_unaligned_le8(u8 val, void *p)
3436
read_extent_buffer(eb, (char *)(result), \
3537
((unsigned long)(ptr)) + \
3638
offsetof(type, member), \
37-
sizeof(((type *)0)->member)))
39+
sizeof_field(type, member)))
3840

3941
#define write_eb_member(eb, ptr, type, member, result) (\
4042
write_extent_buffer(eb, (char *)(result), \
4143
((unsigned long)(ptr)) + \
4244
offsetof(type, member), \
43-
sizeof(((type *)0)->member)))
45+
sizeof_field(type, member)))
4446

4547
#define DECLARE_BTRFS_SETGET_BITS(bits) \
4648
u##bits btrfs_get_token_##bits(struct btrfs_map_token *token, \
@@ -62,25 +64,25 @@ DECLARE_BTRFS_SETGET_BITS(64)
6264
static inline u##bits btrfs_##name(const struct extent_buffer *eb, \
6365
const type *s) \
6466
{ \
65-
static_assert(sizeof(u##bits) == sizeof(((type *)0))->member); \
67+
static_assert(sizeof(u##bits) == sizeof_field(type, member)); \
6668
return btrfs_get_##bits(eb, s, offsetof(type, member)); \
6769
} \
6870
static inline void btrfs_set_##name(const struct extent_buffer *eb, type *s, \
6971
u##bits val) \
7072
{ \
71-
static_assert(sizeof(u##bits) == sizeof(((type *)0))->member); \
73+
static_assert(sizeof(u##bits) == sizeof_field(type, member)); \
7274
btrfs_set_##bits(eb, s, offsetof(type, member), val); \
7375
} \
7476
static inline u##bits btrfs_token_##name(struct btrfs_map_token *token, \
7577
const type *s) \
7678
{ \
77-
static_assert(sizeof(u##bits) == sizeof(((type *)0))->member); \
79+
static_assert(sizeof(u##bits) == sizeof_field(type, member)); \
7880
return btrfs_get_token_##bits(token, s, offsetof(type, member));\
7981
} \
8082
static inline void btrfs_set_token_##name(struct btrfs_map_token *token,\
8183
type *s, u##bits val) \
8284
{ \
83-
static_assert(sizeof(u##bits) == sizeof(((type *)0))->member); \
85+
static_assert(sizeof(u##bits) == sizeof_field(type, member)); \
8486
btrfs_set_token_##bits(token, s, offsetof(type, member), val); \
8587
}
8688

@@ -111,17 +113,14 @@ static inline void btrfs_set_##name(type *s, u##bits val) \
111113
static inline u64 btrfs_device_total_bytes(const struct extent_buffer *eb,
112114
struct btrfs_dev_item *s)
113115
{
114-
static_assert(sizeof(u64) ==
115-
sizeof(((struct btrfs_dev_item *)0))->total_bytes);
116-
return btrfs_get_64(eb, s, offsetof(struct btrfs_dev_item,
117-
total_bytes));
116+
static_assert(sizeof(u64) == sizeof_field(struct btrfs_dev_item, total_bytes));
117+
return btrfs_get_64(eb, s, offsetof(struct btrfs_dev_item, total_bytes));
118118
}
119119
static inline void btrfs_set_device_total_bytes(const struct extent_buffer *eb,
120120
struct btrfs_dev_item *s,
121121
u64 val)
122122
{
123-
static_assert(sizeof(u64) ==
124-
sizeof(((struct btrfs_dev_item *)0))->total_bytes);
123+
static_assert(sizeof(u64) == sizeof_field(struct btrfs_dev_item, total_bytes));
125124
WARN_ON(!IS_ALIGNED(val, eb->fs_info->sectorsize));
126125
btrfs_set_64(eb, s, offsetof(struct btrfs_dev_item, total_bytes), val);
127126
}

fs/btrfs/backref.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3373,7 +3373,6 @@ int btrfs_backref_add_tree_node(struct btrfs_backref_cache *cache,
33733373
struct btrfs_key *node_key,
33743374
struct btrfs_backref_node *cur)
33753375
{
3376-
struct btrfs_fs_info *fs_info = cache->fs_info;
33773376
struct btrfs_backref_edge *edge;
33783377
struct btrfs_backref_node *exist;
33793378
int ret;
@@ -3462,25 +3461,21 @@ int btrfs_backref_add_tree_node(struct btrfs_backref_cache *cache,
34623461
ret = handle_direct_tree_backref(cache, &key, cur);
34633462
if (ret < 0)
34643463
goto out;
3465-
continue;
3466-
} else if (unlikely(key.type == BTRFS_EXTENT_REF_V0_KEY)) {
3467-
ret = -EINVAL;
3468-
btrfs_print_v0_err(fs_info);
3469-
btrfs_handle_fs_error(fs_info, ret, NULL);
3470-
goto out;
3471-
} else if (key.type != BTRFS_TREE_BLOCK_REF_KEY) {
3472-
continue;
3464+
} else if (key.type == BTRFS_TREE_BLOCK_REF_KEY) {
3465+
/*
3466+
* key.type == BTRFS_TREE_BLOCK_REF_KEY, inline ref
3467+
* offset means the root objectid. We need to search
3468+
* the tree to get its parent bytenr.
3469+
*/
3470+
ret = handle_indirect_tree_backref(cache, path, &key, node_key,
3471+
cur);
3472+
if (ret < 0)
3473+
goto out;
34733474
}
3474-
34753475
/*
3476-
* key.type == BTRFS_TREE_BLOCK_REF_KEY, inline ref offset
3477-
* means the root objectid. We need to search the tree to get
3478-
* its parent bytenr.
3476+
* Unrecognized tree backref items (if it can pass tree-checker)
3477+
* would be ignored.
34793478
*/
3480-
ret = handle_indirect_tree_backref(cache, path, &key, node_key,
3481-
cur);
3482-
if (ret < 0)
3483-
goto out;
34843479
}
34853480
ret = 0;
34863481
cur->checked = 1;

fs/btrfs/block-group.c

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,20 @@ static void fragment_free_space(struct btrfs_block_group *block_group)
504504
#endif
505505

506506
/*
507-
* This is only called by btrfs_cache_block_group, since we could have freed
508-
* extents we need to check the pinned_extents for any extents that can't be
509-
* used yet since their free space will be released as soon as the transaction
510-
* commits.
507+
* Add a free space range to the in memory free space cache of a block group.
508+
* This checks if the range contains super block locations and any such
509+
* locations are not added to the free space cache.
510+
*
511+
* @block_group: The target block group.
512+
* @start: Start offset of the range.
513+
* @end: End offset of the range (exclusive).
514+
* @total_added_ret: Optional pointer to return the total amount of space
515+
* added to the block group's free space cache.
516+
*
517+
* Returns 0 on success or < 0 on error.
511518
*/
512-
int add_new_free_space(struct btrfs_block_group *block_group, u64 start, u64 end,
513-
u64 *total_added_ret)
519+
int btrfs_add_new_free_space(struct btrfs_block_group *block_group, u64 start,
520+
u64 end, u64 *total_added_ret)
514521
{
515522
struct btrfs_fs_info *info = block_group->fs_info;
516523
u64 extent_start, extent_end, size;
@@ -520,11 +527,10 @@ int add_new_free_space(struct btrfs_block_group *block_group, u64 start, u64 end
520527
*total_added_ret = 0;
521528

522529
while (start < end) {
523-
ret = find_first_extent_bit(&info->excluded_extents, start,
524-
&extent_start, &extent_end,
525-
EXTENT_DIRTY | EXTENT_UPTODATE,
526-
NULL);
527-
if (ret)
530+
if (!find_first_extent_bit(&info->excluded_extents, start,
531+
&extent_start, &extent_end,
532+
EXTENT_DIRTY | EXTENT_UPTODATE,
533+
NULL))
528534
break;
529535

530536
if (extent_start <= start) {
@@ -799,8 +805,8 @@ static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl)
799805
key.type == BTRFS_METADATA_ITEM_KEY) {
800806
u64 space_added;
801807

802-
ret = add_new_free_space(block_group, last, key.objectid,
803-
&space_added);
808+
ret = btrfs_add_new_free_space(block_group, last,
809+
key.objectid, &space_added);
804810
if (ret)
805811
goto out;
806812
total_found += space_added;
@@ -821,14 +827,20 @@ static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl)
821827
path->slots[0]++;
822828
}
823829

824-
ret = add_new_free_space(block_group, last,
825-
block_group->start + block_group->length,
826-
NULL);
830+
ret = btrfs_add_new_free_space(block_group, last,
831+
block_group->start + block_group->length,
832+
NULL);
827833
out:
828834
btrfs_free_path(path);
829835
return ret;
830836
}
831837

838+
static inline void btrfs_free_excluded_extents(const struct btrfs_block_group *bg)
839+
{
840+
clear_extent_bits(&bg->fs_info->excluded_extents, bg->start,
841+
bg->start + bg->length - 1, EXTENT_UPTODATE);
842+
}
843+
832844
static noinline void caching_thread(struct btrfs_work *work)
833845
{
834846
struct btrfs_block_group *block_group;
@@ -2098,8 +2110,9 @@ static int exclude_super_stripes(struct btrfs_block_group *cache)
20982110
if (cache->start < BTRFS_SUPER_INFO_OFFSET) {
20992111
stripe_len = BTRFS_SUPER_INFO_OFFSET - cache->start;
21002112
cache->bytes_super += stripe_len;
2101-
ret = btrfs_add_excluded_extent(fs_info, cache->start,
2102-
stripe_len);
2113+
ret = set_extent_bit(&fs_info->excluded_extents, cache->start,
2114+
cache->start + stripe_len - 1,
2115+
EXTENT_UPTODATE, NULL);
21032116
if (ret)
21042117
return ret;
21052118
}
@@ -2125,8 +2138,9 @@ static int exclude_super_stripes(struct btrfs_block_group *cache)
21252138
cache->start + cache->length - logical[nr]);
21262139

21272140
cache->bytes_super += len;
2128-
ret = btrfs_add_excluded_extent(fs_info, logical[nr],
2129-
len);
2141+
ret = set_extent_bit(&fs_info->excluded_extents, logical[nr],
2142+
logical[nr] + len - 1,
2143+
EXTENT_UPTODATE, NULL);
21302144
if (ret) {
21312145
kfree(logical);
21322146
return ret;
@@ -2319,8 +2333,8 @@ static int read_one_block_group(struct btrfs_fs_info *info,
23192333
btrfs_free_excluded_extents(cache);
23202334
} else if (cache->used == 0) {
23212335
cache->cached = BTRFS_CACHE_FINISHED;
2322-
ret = add_new_free_space(cache, cache->start,
2323-
cache->start + cache->length, NULL);
2336+
ret = btrfs_add_new_free_space(cache, cache->start,
2337+
cache->start + cache->length, NULL);
23242338
btrfs_free_excluded_extents(cache);
23252339
if (ret)
23262340
goto error;
@@ -2767,7 +2781,7 @@ struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *tran
27672781
return ERR_PTR(ret);
27682782
}
27692783

2770-
ret = add_new_free_space(cache, chunk_offset, chunk_offset + size, NULL);
2784+
ret = btrfs_add_new_free_space(cache, chunk_offset, chunk_offset + size, NULL);
27712785
btrfs_free_excluded_extents(cache);
27722786
if (ret) {
27732787
btrfs_put_block_group(cache);
@@ -4075,7 +4089,7 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
40754089

40764090
if (IS_ERR(ret_bg)) {
40774091
ret = PTR_ERR(ret_bg);
4078-
} else if (from_extent_allocation) {
4092+
} else if (from_extent_allocation && (flags & BTRFS_BLOCK_GROUP_DATA)) {
40794093
/*
40804094
* New block group is likely to be used soon. Try to activate
40814095
* it now. Failure is OK for now.
@@ -4273,6 +4287,17 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
42734287
struct btrfs_caching_control *caching_ctl;
42744288
struct rb_node *n;
42754289

4290+
if (btrfs_is_zoned(info)) {
4291+
if (info->active_meta_bg) {
4292+
btrfs_put_block_group(info->active_meta_bg);
4293+
info->active_meta_bg = NULL;
4294+
}
4295+
if (info->active_system_bg) {
4296+
btrfs_put_block_group(info->active_system_bg);
4297+
info->active_system_bg = NULL;
4298+
}
4299+
}
4300+
42764301
write_lock(&info->block_group_cache_lock);
42774302
while (!list_empty(&info->caching_block_groups)) {
42784303
caching_ctl = list_entry(info->caching_block_groups.next,

fs/btrfs/block-group.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ int btrfs_cache_block_group(struct btrfs_block_group *cache, bool wait);
291291
void btrfs_put_caching_control(struct btrfs_caching_control *ctl);
292292
struct btrfs_caching_control *btrfs_get_caching_control(
293293
struct btrfs_block_group *cache);
294-
int add_new_free_space(struct btrfs_block_group *block_group,
295-
u64 start, u64 end, u64 *total_added_ret);
294+
int btrfs_add_new_free_space(struct btrfs_block_group *block_group,
295+
u64 start, u64 end, u64 *total_added_ret);
296296
struct btrfs_trans_handle *btrfs_start_trans_remove_block_group(
297297
struct btrfs_fs_info *fs_info,
298298
const u64 chunk_offset);

fs/btrfs/btrfs_inode.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,8 @@ int btrfs_prealloc_file_range_trans(struct inode *inode,
498498
u64 start, u64 num_bytes, u64 min_size,
499499
loff_t actual_len, u64 *alloc_hint);
500500
int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page,
501-
u64 start, u64 end, int *page_started,
502-
unsigned long *nr_written, struct writeback_control *wbc);
501+
u64 start, u64 end, struct writeback_control *wbc);
503502
int btrfs_writepage_cow_fixup(struct page *page);
504-
void btrfs_writepage_endio_finish_ordered(struct btrfs_inode *inode,
505-
struct page *page, u64 start,
506-
u64 end, bool uptodate);
507503
int btrfs_encoded_io_compression_from_extent(struct btrfs_fs_info *fs_info,
508504
int compress_type);
509505
int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode,

fs/btrfs/delayed-inode.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,9 +1736,6 @@ int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
17361736
int over = 0;
17371737
unsigned char d_type;
17381738

1739-
if (list_empty(ins_list))
1740-
return 0;
1741-
17421739
/*
17431740
* Changing the data of the delayed item is impossible. So
17441741
* we needn't lock them. And we have held i_mutex of the

fs/btrfs/dev-replace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,9 @@ static int btrfs_set_target_alloc_state(struct btrfs_device *srcdev,
792792

793793
lockdep_assert_held(&srcdev->fs_info->chunk_mutex);
794794

795-
while (!find_first_extent_bit(&srcdev->alloc_state, start,
796-
&found_start, &found_end,
797-
CHUNK_ALLOCATED, &cached_state)) {
795+
while (find_first_extent_bit(&srcdev->alloc_state, start,
796+
&found_start, &found_end,
797+
CHUNK_ALLOCATED, &cached_state)) {
798798
ret = set_extent_bit(&tgtdev->alloc_state, found_start,
799799
found_end, CHUNK_ALLOCATED, NULL);
800800
if (ret)

0 commit comments

Comments
 (0)