Skip to content

Commit a3d1f54

Browse files
committed
Merge tag 'for-6.10-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs updates from David Sterba: "This update brings a few minor performance improvements, otherwise there's a lot of refactoring, cleanups and other sort of not user visible changes. Performance improvements: - inline b-tree locking functions, improvement in metadata-heavy changes - relax locking on a range that's being reflinked, allows read operations to run in parallel - speed up NOCOW write checks (throughput +9% on a sample test) - extent locking ranges have been reduced in several places, namely around delayed ref processing Core: - more page to folio conversions: - relocation - send - compression - inline extent handling - super block write and wait - extent_map structure optimizations: - reduced structure size - code simplifications - add shrinker for allocated objects, the numbers can go high and could exhaust memory on smaller systems (reported) as they may not get an opportunity to be freed fast enough - extent locking optimizations: - reduce locking ranges where it does not seem to be necessary and are safe due to other means of synchronization - potential improvements due to lower contention, allocation/freeing and state management operations of extent state tracking structures - delayed ref cleanups and simplifications - updated trace points - improved error handling, warnings and assertions - cleanups and refactoring, unification of error handling paths" * tag 'for-6.10-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: (122 commits) btrfs: qgroup: fix initialization of auto inherit array btrfs: count super block write errors in device instead of tracking folio error state btrfs: use the folio iterator in btrfs_end_super_write() btrfs: convert super block writes to folio in write_dev_supers() btrfs: convert super block writes to folio in wait_dev_supers() bio: Export bio_add_folio_nofail to modules btrfs: remove duplicate included header from fs.h btrfs: add a cached state to extent_clear_unlock_delalloc btrfs: push extent lock down in submit_one_async_extent btrfs: push lock_extent down in cow_file_range() btrfs: move can_cow_file_range_inline() outside of the extent lock btrfs: push lock_extent into cow_file_range_inline btrfs: push extent lock into cow_file_range btrfs: push extent lock into run_delalloc_cow btrfs: remove unlock_extent from run_delalloc_compressed btrfs: push extent lock down in run_delalloc_nocow btrfs: adjust while loop condition in run_delalloc_nocow btrfs: push extent lock into run_delalloc_nocow btrfs: push the extent lock into btrfs_run_delalloc_range btrfs: lock extent when doing inline extent in compression ...
2 parents 47e9bff + 0e39c9e commit a3d1f54

Some content is hidden

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

52 files changed

+2639
-2346
lines changed

block/bio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,7 @@ void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len,
11361136
WARN_ON_ONCE(off > UINT_MAX);
11371137
__bio_add_page(bio, &folio->page, len, off);
11381138
}
1139+
EXPORT_SYMBOL_GPL(bio_add_folio_nofail);
11391140

11401141
/**
11411142
* bio_add_folio - Attempt to add part of a folio to a bio.

fs/btrfs/backref.c

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static void update_share_count(struct share_check *sc, int oldcount,
261261
else if (oldcount < 1 && newcount > 0)
262262
sc->share_count++;
263263

264-
if (newref->root_id == sc->root->root_key.objectid &&
264+
if (newref->root_id == btrfs_root_id(sc->root) &&
265265
newref->wanted_disk_byte == sc->data_bytenr &&
266266
newref->key_for_search.objectid == sc->inum)
267267
sc->self_ref_count += newref->count;
@@ -769,7 +769,7 @@ static int resolve_indirect_refs(struct btrfs_backref_walk_ctx *ctx,
769769
continue;
770770
}
771771

772-
if (sc && ref->root_id != sc->root->root_key.objectid) {
772+
if (sc && ref->root_id != btrfs_root_id(sc->root)) {
773773
free_pref(ref);
774774
ret = BACKREF_FOUND_SHARED;
775775
goto out;
@@ -919,40 +919,38 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
919919
switch (node->type) {
920920
case BTRFS_TREE_BLOCK_REF_KEY: {
921921
/* NORMAL INDIRECT METADATA backref */
922-
struct btrfs_delayed_tree_ref *ref;
923922
struct btrfs_key *key_ptr = NULL;
923+
/* The owner of a tree block ref is the level. */
924+
int level = btrfs_delayed_ref_owner(node);
924925

925926
if (head->extent_op && head->extent_op->update_key) {
926927
btrfs_disk_key_to_cpu(&key, &head->extent_op->key);
927928
key_ptr = &key;
928929
}
929930

930-
ref = btrfs_delayed_node_to_tree_ref(node);
931-
ret = add_indirect_ref(fs_info, preftrees, ref->root,
932-
key_ptr, ref->level + 1,
933-
node->bytenr, count, sc,
934-
GFP_ATOMIC);
931+
ret = add_indirect_ref(fs_info, preftrees, node->ref_root,
932+
key_ptr, level + 1, node->bytenr,
933+
count, sc, GFP_ATOMIC);
935934
break;
936935
}
937936
case BTRFS_SHARED_BLOCK_REF_KEY: {
938-
/* SHARED DIRECT METADATA backref */
939-
struct btrfs_delayed_tree_ref *ref;
940-
941-
ref = btrfs_delayed_node_to_tree_ref(node);
937+
/*
938+
* SHARED DIRECT METADATA backref
939+
*
940+
* The owner of a tree block ref is the level.
941+
*/
942+
int level = btrfs_delayed_ref_owner(node);
942943

943-
ret = add_direct_ref(fs_info, preftrees, ref->level + 1,
944-
ref->parent, node->bytenr, count,
944+
ret = add_direct_ref(fs_info, preftrees, level + 1,
945+
node->parent, node->bytenr, count,
945946
sc, GFP_ATOMIC);
946947
break;
947948
}
948949
case BTRFS_EXTENT_DATA_REF_KEY: {
949950
/* NORMAL INDIRECT DATA backref */
950-
struct btrfs_delayed_data_ref *ref;
951-
ref = btrfs_delayed_node_to_data_ref(node);
952-
953-
key.objectid = ref->objectid;
951+
key.objectid = btrfs_delayed_ref_owner(node);
954952
key.type = BTRFS_EXTENT_DATA_KEY;
955-
key.offset = ref->offset;
953+
key.offset = btrfs_delayed_ref_offset(node);
956954

957955
/*
958956
* If we have a share check context and a reference for
@@ -972,18 +970,14 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
972970
if (sc && count < 0)
973971
sc->have_delayed_delete_refs = true;
974972

975-
ret = add_indirect_ref(fs_info, preftrees, ref->root,
973+
ret = add_indirect_ref(fs_info, preftrees, node->ref_root,
976974
&key, 0, node->bytenr, count, sc,
977975
GFP_ATOMIC);
978976
break;
979977
}
980978
case BTRFS_SHARED_DATA_REF_KEY: {
981979
/* SHARED DIRECT FULL backref */
982-
struct btrfs_delayed_data_ref *ref;
983-
984-
ref = btrfs_delayed_node_to_data_ref(node);
985-
986-
ret = add_direct_ref(fs_info, preftrees, 0, ref->parent,
980+
ret = add_direct_ref(fs_info, preftrees, 0, node->parent,
987981
node->bytenr, count, sc,
988982
GFP_ATOMIC);
989983
break;
@@ -2629,7 +2623,7 @@ static int iterate_inode_refs(u64 inum, struct inode_fs_paths *ipath)
26292623
btrfs_debug(fs_root->fs_info,
26302624
"following ref at offset %u for inode %llu in tree %llu",
26312625
cur, found_key.objectid,
2632-
fs_root->root_key.objectid);
2626+
btrfs_root_id(fs_root));
26332627
ret = inode_to_path(parent, name_len,
26342628
(unsigned long)(iref + 1), eb, ipath);
26352629
if (ret)
@@ -3361,7 +3355,7 @@ static int handle_indirect_tree_backref(struct btrfs_trans_handle *trans,
33613355
if (btrfs_node_blockptr(eb, path->slots[level]) != cur->bytenr) {
33623356
btrfs_err(fs_info,
33633357
"couldn't find block (%llu) (level %d) in tree (%llu) with key (%llu %u %llu)",
3364-
cur->bytenr, level - 1, root->root_key.objectid,
3358+
cur->bytenr, level - 1, btrfs_root_id(root),
33653359
tree_key->objectid, tree_key->type, tree_key->offset);
33663360
btrfs_put_root(root);
33673361
ret = -ENOENT;

fs/btrfs/block-rsv.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
341341
read_lock(&fs_info->global_root_lock);
342342
rbtree_postorder_for_each_entry_safe(root, tmp, &fs_info->global_root_tree,
343343
rb_node) {
344-
if (root->root_key.objectid == BTRFS_EXTENT_TREE_OBJECTID ||
345-
root->root_key.objectid == BTRFS_CSUM_TREE_OBJECTID ||
346-
root->root_key.objectid == BTRFS_FREE_SPACE_TREE_OBJECTID) {
344+
if (btrfs_root_id(root) == BTRFS_EXTENT_TREE_OBJECTID ||
345+
btrfs_root_id(root) == BTRFS_CSUM_TREE_OBJECTID ||
346+
btrfs_root_id(root) == BTRFS_FREE_SPACE_TREE_OBJECTID) {
347347
num_bytes += btrfs_root_used(&root->root_item);
348348
min_items++;
349349
}
@@ -406,7 +406,7 @@ void btrfs_init_root_block_rsv(struct btrfs_root *root)
406406
{
407407
struct btrfs_fs_info *fs_info = root->fs_info;
408408

409-
switch (root->root_key.objectid) {
409+
switch (btrfs_root_id(root)) {
410410
case BTRFS_CSUM_TREE_OBJECTID:
411411
case BTRFS_EXTENT_TREE_OBJECTID:
412412
case BTRFS_FREE_SPACE_TREE_OBJECTID:
@@ -468,8 +468,7 @@ static struct btrfs_block_rsv *get_block_rsv(
468468

469469
if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) ||
470470
(root == fs_info->uuid_root) ||
471-
(trans->adding_csums &&
472-
root->root_key.objectid == BTRFS_CSUM_TREE_OBJECTID))
471+
(trans->adding_csums && btrfs_root_id(root) == BTRFS_CSUM_TREE_OBJECTID))
473472
block_rsv = trans->block_rsv;
474473

475474
if (!block_rsv)

fs/btrfs/btrfs_inode.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,11 @@ static inline void btrfs_set_inode_last_sub_trans(struct btrfs_inode *inode)
381381
}
382382

383383
/*
384-
* Should be called while holding the inode's VFS lock in exclusive mode or in a
385-
* context where no one else can access the inode concurrently (during inode
386-
* creation or when loading an inode from disk).
384+
* Should be called while holding the inode's VFS lock in exclusive mode, or
385+
* while holding the inode's mmap lock (struct btrfs_inode::i_mmap_lock) in
386+
* either shared or exclusive mode, or in a context where no one else can access
387+
* the inode concurrently (during inode creation or when loading an inode from
388+
* disk).
387389
*/
388390
static inline void btrfs_set_inode_full_sync(struct btrfs_inode *inode)
389391
{
@@ -496,7 +498,6 @@ void btrfs_merge_delalloc_extent(struct btrfs_inode *inode, struct extent_state
496498
void btrfs_split_delalloc_extent(struct btrfs_inode *inode,
497499
struct extent_state *orig, u64 split);
498500
void btrfs_set_range_writeback(struct btrfs_inode *inode, u64 start, u64 end);
499-
vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf);
500501
void btrfs_evict_inode(struct inode *inode);
501502
struct inode *btrfs_alloc_inode(struct super_block *sb);
502503
void btrfs_destroy_inode(struct inode *inode);
@@ -544,6 +545,7 @@ ssize_t btrfs_dio_read(struct kiocb *iocb, struct iov_iter *iter,
544545
size_t done_before);
545546
struct iomap_dio *btrfs_dio_write(struct kiocb *iocb, struct iov_iter *iter,
546547
size_t done_before);
548+
struct btrfs_inode *btrfs_find_first_inode(struct btrfs_root *root, u64 min_ino);
547549

548550
extern const struct dentry_operations btrfs_dentry_operations;
549551

0 commit comments

Comments
 (0)