Skip to content

Commit 7696286

Browse files
committed
Merge tag 'for-6.19-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs updates from David Sterba: "Features: - shutdown ioctl support (needs CONFIG_BTRFS_EXPERIMENTAL for now): - set filesystem state as being shut down (also named going down in other filesystems), where all active operations return EIO and this cannot be changed until unmount - pending operations are attempted to be finished but error messages may still show up depending on where exactly the shutdown happened - scrub (and device replace) vs suspend/hibernate: - a running scrub will prevent suspend, which can be annoying as suspend is an immediate request and scrub is not critical - filesystem freezing before suspend was not sufficient as the problem was in process freezing - behaviour change: on suspend scrub and device replace are cancelled, where scrub can record the last state and continue from there; the device replace has to be restarted from the beginning - zone stats exported in sysfs, from the perspective of the filesystem this includes active, reclaimable, relocation etc zones Performance: - improvements when processing space reservation tickets by optimizing locking and shrinking critical sections, cumulative improvements in lockstat numbers show +15% Notable fixes: - use vmalloc fallback when allocating bios as high order allocations can happen with wide checksums (like sha256) - scrub will always track the last position of progress so it's not starting from zero after an error Core: - under experimental config, checksum calculations are offloaded to process context, simplifies locking and allows to remove compression write worker kthread(s): - speed improvement in direct IO throughput with buffered IO fallback is +15% when not offloaded but this is more related to internal crypto subsystem improvements - this will be probably default in the future removing the sysfs tunable - (experimental) block size > page size updates: - support more operations when not using large folios (encoded read/write and send) - raid56 - more preparations for fscrypt support Other: - more conversions to auto-cleaned variables - parameter cleanups and removals - extended warning fixes - improved printing of structured values like keys - lots of other cleanups and refactoring" * tag 'for-6.19-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: (147 commits) btrfs: remove unnecessary inode key in btrfs_log_all_parents() btrfs: remove redundant zero/NULL initializations in btrfs_alloc_root() btrfs: remaining BTRFS_PATH_AUTO_FREE conversions btrfs: send: do not allocate memory for xattr data when checking it exists btrfs: send: add unlikely to all unexpected overflow checks btrfs: reduce arguments to btrfs_del_inode_ref_in_log() btrfs: remove root argument from btrfs_del_dir_entries_in_log() btrfs: use test_and_set_bit() in btrfs_delayed_delete_inode_ref() btrfs: don't search back for dir inode item in INO_LOOKUP_USER btrfs: don't rewrite ret from inode_permission btrfs: add orig_logical to btrfs_bio for encryption btrfs: disable verity on encrypted inodes btrfs: disable various operations on encrypted inodes btrfs: remove redundant level reset in btrfs_del_items() btrfs: simplify leaf traversal after path release in btrfs_next_old_leaf() btrfs: optimize balance_level() path reference handling btrfs: factor out root promotion logic into promote_child_to_root() btrfs: raid56: remove the "_step" infix btrfs: raid56: enable bs > ps support btrfs: raid56: prepare finish_parity_scrub() to support bs > ps cases ...
2 parents cc25df3 + 9e0e657 commit 7696286

74 files changed

Lines changed: 2773 additions & 2298 deletions

Some content is hidden

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

fs/btrfs/accessors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/string.h>
1313
#include <linux/mm.h>
1414
#include <uapi/linux/btrfs_tree.h>
15+
#include "fs.h"
1516
#include "extent_io.h"
1617

1718
struct extent_buffer;

fs/btrfs/acl.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
#include "ctree.h"
1515
#include "xattr.h"
1616
#include "acl.h"
17+
#include "misc.h"
1718

1819
struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu)
1920
{
2021
int size;
2122
const char *name;
22-
char *value = NULL;
23+
char AUTO_KFREE(value);
2324
struct posix_acl *acl;
2425

2526
if (rcu)
@@ -49,7 +50,6 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu)
4950
acl = NULL;
5051
else
5152
acl = ERR_PTR(size);
52-
kfree(value);
5353

5454
return acl;
5555
}
@@ -59,7 +59,7 @@ int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
5959
{
6060
int ret, size = 0;
6161
const char *name;
62-
char *value = NULL;
62+
char AUTO_KFREE(value);
6363

6464
switch (type) {
6565
case ACL_TYPE_ACCESS:
@@ -85,28 +85,23 @@ int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
8585
nofs_flag = memalloc_nofs_save();
8686
value = kmalloc(size, GFP_KERNEL);
8787
memalloc_nofs_restore(nofs_flag);
88-
if (!value) {
89-
ret = -ENOMEM;
90-
goto out;
91-
}
88+
if (!value)
89+
return -ENOMEM;
9290

9391
ret = posix_acl_to_xattr(&init_user_ns, acl, value, size);
9492
if (ret < 0)
95-
goto out;
93+
return ret;
9694
}
9795

9896
if (trans)
9997
ret = btrfs_setxattr(trans, inode, name, value, size, 0);
10098
else
10199
ret = btrfs_setxattr_trans(inode, name, value, size, 0);
100+
if (ret < 0)
101+
return ret;
102102

103-
out:
104-
kfree(value);
105-
106-
if (!ret)
107-
set_cached_acl(inode, type, acl);
108-
109-
return ret;
103+
set_cached_acl(inode, type, acl);
104+
return 0;
110105
}
111106

112107
int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,

fs/btrfs/backref.c

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,9 @@ static int resolve_indirect_ref(struct btrfs_backref_walk_ctx *ctx,
666666
ret = btrfs_search_old_slot(root, &search_key, path, ctx->time_seq);
667667

668668
btrfs_debug(ctx->fs_info,
669-
"search slot in root %llu (level %d, ref count %d) returned %d for key (%llu %u %llu)",
670-
ref->root_id, level, ref->count, ret,
671-
ref->key_for_search.objectid, ref->key_for_search.type,
672-
ref->key_for_search.offset);
669+
"search slot in root %llu (level %d, ref count %d) returned %d for key " BTRFS_KEY_FMT,
670+
ref->root_id, level, ref->count, ret,
671+
BTRFS_KEY_FMT_VALUE(&ref->key_for_search));
673672
if (ret < 0)
674673
goto out;
675674

@@ -1409,12 +1408,12 @@ static int find_parent_nodes(struct btrfs_backref_walk_ctx *ctx,
14091408
if (!path)
14101409
return -ENOMEM;
14111410
if (!ctx->trans) {
1412-
path->search_commit_root = 1;
1413-
path->skip_locking = 1;
1411+
path->search_commit_root = true;
1412+
path->skip_locking = true;
14141413
}
14151414

14161415
if (ctx->time_seq == BTRFS_SEQ_LAST)
1417-
path->skip_locking = 1;
1416+
path->skip_locking = true;
14181417

14191418
again:
14201419
head = NULL;
@@ -1561,7 +1560,7 @@ static int find_parent_nodes(struct btrfs_backref_walk_ctx *ctx,
15611560

15621561
btrfs_release_path(path);
15631562

1564-
ret = add_missing_keys(ctx->fs_info, &preftrees, path->skip_locking == 0);
1563+
ret = add_missing_keys(ctx->fs_info, &preftrees, !path->skip_locking);
15651564
if (ret)
15661565
goto out;
15671566

@@ -2786,7 +2785,7 @@ struct btrfs_data_container *init_data_container(u32 total_bytes)
27862785
* allocates space to return multiple file system paths for an inode.
27872786
* total_bytes to allocate are passed, note that space usable for actual path
27882787
* information will be total_bytes - sizeof(struct inode_fs_paths).
2789-
* the returned pointer must be freed with free_ipath() in the end.
2788+
* the returned pointer must be freed with __free_inode_fs_paths() in the end.
27902789
*/
27912790
struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root,
27922791
struct btrfs_path *path)
@@ -2811,14 +2810,6 @@ struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root,
28112810
return ifp;
28122811
}
28132812

2814-
void free_ipath(struct inode_fs_paths *ipath)
2815-
{
2816-
if (!ipath)
2817-
return;
2818-
kvfree(ipath->fspath);
2819-
kfree(ipath);
2820-
}
2821-
28222813
struct btrfs_backref_iter *btrfs_backref_iter_alloc(struct btrfs_fs_info *fs_info)
28232814
{
28242815
struct btrfs_backref_iter *ret;
@@ -2834,8 +2825,8 @@ struct btrfs_backref_iter *btrfs_backref_iter_alloc(struct btrfs_fs_info *fs_inf
28342825
}
28352826

28362827
/* Current backref iterator only supports iteration in commit root */
2837-
ret->path->search_commit_root = 1;
2838-
ret->path->skip_locking = 1;
2828+
ret->path->search_commit_root = true;
2829+
ret->path->skip_locking = true;
28392830
ret->fs_info = fs_info;
28402831

28412832
return ret;
@@ -3308,8 +3299,8 @@ static int handle_indirect_tree_backref(struct btrfs_trans_handle *trans,
33083299
level = cur->level + 1;
33093300

33103301
/* Search the tree to find parent blocks referring to the block */
3311-
path->search_commit_root = 1;
3312-
path->skip_locking = 1;
3302+
path->search_commit_root = true;
3303+
path->skip_locking = true;
33133304
path->lowest_level = level;
33143305
ret = btrfs_search_slot(NULL, root, tree_key, path, 0, 0);
33153306
path->lowest_level = 0;
@@ -3323,9 +3314,9 @@ static int handle_indirect_tree_backref(struct btrfs_trans_handle *trans,
33233314
eb = path->nodes[level];
33243315
if (btrfs_node_blockptr(eb, path->slots[level]) != cur->bytenr) {
33253316
btrfs_err(fs_info,
3326-
"couldn't find block (%llu) (level %d) in tree (%llu) with key (%llu %u %llu)",
3317+
"couldn't find block (%llu) (level %d) in tree (%llu) with key " BTRFS_KEY_FMT,
33273318
cur->bytenr, level - 1, btrfs_root_id(root),
3328-
tree_key->objectid, tree_key->type, tree_key->offset);
3319+
BTRFS_KEY_FMT_VALUE(tree_key));
33293320
btrfs_put_root(root);
33303321
ret = -ENOENT;
33313322
goto out;

fs/btrfs/backref.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,12 @@ char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
241241
struct btrfs_data_container *init_data_container(u32 total_bytes);
242242
struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root,
243243
struct btrfs_path *path);
244-
void free_ipath(struct inode_fs_paths *ipath);
244+
245+
DEFINE_FREE(inode_fs_paths, struct inode_fs_paths *,
246+
if (_T) {
247+
kvfree(_T->fspath);
248+
kfree(_T);
249+
})
245250

246251
int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid,
247252
u64 start_off, struct btrfs_path *path,

0 commit comments

Comments
 (0)