* [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c
@ 2023-04-19 21:20 Josef Bacik
2023-04-19 21:20 ` [PATCH 01/10] btrfs-progs: const-ify the extent buffer helpers Josef Bacik
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
Hello,
These patches update a lot of the different ctree.c related helpers that have
diverged from the kernel in order to make ite easier syncing ctree.c directly.
This also syncs locking.[ch], but this is to just stub out the locking. This
will make it easier to sync ctree.c as well since there's locking in the kernel
that didn't exist when we had this in btrfs-progs.
This series depends on
btrfs-progs: prep work for syncing files into kernel-shared
btrfs-progs: sync basic code from the kernel
Thanks,
Josef
Josef Bacik (10):
btrfs-progs: const-ify the extent buffer helpers
btrfs-progs: bring root->state into btrfs-progs
btrfs-progs: rename btrfs_alloc_free_block to btrfs_alloc_tree_block
btrfs-progs: sync locking.h and stub out all the helpers
btrfs-progs: add btrfs_locking_nest to btrfs_alloc_tree_block
btrfs-progs: add some missing extent buffer helpers
btrfs-progs: rename btrfs_set_block_flags ->
btrfs_set_disk_extent_flags
btrfs-progs: cleanup args for btrfs_set_disk_extent_flags
btrfs-progs: rename clear_extent_buffer_dirty =>
btrfs_clear_buffer_dirty
btrfs-progs: make __btrfs_cow_block static
Makefile | 1 +
check/main.c | 7 +-
cmds/rescue-chunk-recover.c | 4 +-
cmds/rescue.c | 2 +-
include/kerncompat.h | 4 +
kernel-shared/ctree.c | 72 +++++-----
kernel-shared/ctree.h | 82 ++++++++++--
kernel-shared/disk-io.c | 33 +++--
kernel-shared/extent-tree.c | 28 ++--
kernel-shared/extent_io.c | 28 ++--
kernel-shared/extent_io.h | 15 ++-
kernel-shared/locking.c | 22 +++
kernel-shared/locking.h | 258 ++++++++++++++++++++++++++++++++++++
kernel-shared/transaction.c | 4 +-
14 files changed, 464 insertions(+), 96 deletions(-)
create mode 100644 kernel-shared/locking.c
create mode 100644 kernel-shared/locking.h
--
2.40.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 01/10] btrfs-progs: const-ify the extent buffer helpers
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
@ 2023-04-19 21:20 ` Josef Bacik
2023-04-19 21:20 ` [PATCH 02/10] btrfs-progs: bring root->state into btrfs-progs Josef Bacik
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
These helpers are all take const struct extent_buffer in the kernel, do
the same in btrfs-progs in order to enable us to more easily sync
ctree.c.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
kernel-shared/extent_io.c | 15 ++++++++-------
kernel-shared/extent_io.h | 10 ++++++----
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/kernel-shared/extent_io.c b/kernel-shared/extent_io.c
index 46c0fb3f..01dc5b1e 100644
--- a/kernel-shared/extent_io.c
+++ b/kernel-shared/extent_io.c
@@ -609,26 +609,27 @@ void write_extent_buffer(const struct extent_buffer *eb, const void *src,
memcpy((void *)eb->data + start, src, len);
}
-void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,
+void copy_extent_buffer(const struct extent_buffer *dst,
+ const struct extent_buffer *src,
unsigned long dst_offset, unsigned long src_offset,
unsigned long len)
{
- memcpy(dst->data + dst_offset, src->data + src_offset, len);
+ memcpy((void *)dst->data + dst_offset, src->data + src_offset, len);
}
-void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
+void memmove_extent_buffer(const struct extent_buffer *dst, unsigned long dst_offset,
unsigned long src_offset, unsigned long len)
{
- memmove(dst->data + dst_offset, dst->data + src_offset, len);
+ memmove((void *)dst->data + dst_offset, dst->data + src_offset, len);
}
-void memset_extent_buffer(struct extent_buffer *eb, char c,
+void memset_extent_buffer(const struct extent_buffer *eb, char c,
unsigned long start, unsigned long len)
{
- memset(eb->data + start, c, len);
+ memset((void *)eb->data + start, c, len);
}
-int extent_buffer_test_bit(struct extent_buffer *eb, unsigned long start,
+int extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
unsigned long nr)
{
return le_test_bit(nr, (u8 *)eb->data + start);
diff --git a/kernel-shared/extent_io.h b/kernel-shared/extent_io.h
index 8ba56eed..69133c3c 100644
--- a/kernel-shared/extent_io.h
+++ b/kernel-shared/extent_io.h
@@ -110,14 +110,16 @@ void read_extent_buffer(const struct extent_buffer *eb, void *dst,
unsigned long start, unsigned long len);
void write_extent_buffer(const struct extent_buffer *eb, const void *src,
unsigned long start, unsigned long len);
-void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,
+void copy_extent_buffer(const struct extent_buffer *dst,
+ const struct extent_buffer *src,
unsigned long dst_offset, unsigned long src_offset,
unsigned long len);
-void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
+void memmove_extent_buffer(const struct extent_buffer *dst,
+ const unsigned long dst_offset,
unsigned long src_offset, unsigned long len);
-void memset_extent_buffer(struct extent_buffer *eb, char c,
+void memset_extent_buffer(const struct extent_buffer *eb, char c,
unsigned long start, unsigned long len);
-int extent_buffer_test_bit(struct extent_buffer *eb, unsigned long start,
+int extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
unsigned long nr);
int set_extent_buffer_dirty(struct extent_buffer *eb);
int clear_extent_buffer_dirty(struct extent_buffer *eb);
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 02/10] btrfs-progs: bring root->state into btrfs-progs
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
2023-04-19 21:20 ` [PATCH 01/10] btrfs-progs: const-ify the extent buffer helpers Josef Bacik
@ 2023-04-19 21:20 ` Josef Bacik
2023-04-19 21:20 ` [PATCH 03/10] btrfs-progs: rename btrfs_alloc_free_block to btrfs_alloc_tree_block Josef Bacik
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
We changed from members in the root for all the different flags to a
bit based flag system. In order to make syncing the kernel code into
btrfs-progs easier go ahead and sync in the bits we use and update all
the users of the old ->track_dirty and ->ref_cows to use the state bits.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
check/main.c | 3 +-
kernel-shared/ctree.c | 22 ++++++++-----
kernel-shared/ctree.h | 66 +++++++++++++++++++++++++++++++++++--
kernel-shared/disk-io.c | 21 ++++++------
kernel-shared/extent-tree.c | 10 +++---
5 files changed, 94 insertions(+), 28 deletions(-)
diff --git a/check/main.c b/check/main.c
index 99ff3bc3..45e3442d 100644
--- a/check/main.c
+++ b/check/main.c
@@ -63,6 +63,7 @@
#include "check/qgroup-verify.h"
#include "check/clear-cache.h"
#include "kernel-shared/uapi/btrfs.h"
+#include "kernel-lib/bitops.h"
/* Global context variables */
struct btrfs_fs_info *gfs_info;
@@ -467,7 +468,7 @@ static void record_root_in_trans(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
if (root->last_trans != trans->transid) {
- root->track_dirty = 1;
+ set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state);
root->last_trans = trans->transid;
root->commit_root = root->node;
extent_buffer_get(root->node);
diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index 911ec51c..cfbcc689 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -20,6 +20,7 @@
#include "kernel-shared/disk-io.h"
#include "kernel-shared/transaction.h"
#include "kernel-shared/print-tree.h"
+#include "kernel-lib/bitops.h"
#include "crypto/crc32c.h"
#include "common/internal.h"
#include "common/messages.h"
@@ -119,7 +120,8 @@ void btrfs_release_path(struct btrfs_path *p)
void add_root_to_dirty_list(struct btrfs_root *root)
{
- if (root->track_dirty && list_empty(&root->dirty_list)) {
+ if (test_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state) &&
+ list_empty(&root->dirty_list)) {
list_add(&root->dirty_list,
&root->fs_info->dirty_cowonly_roots);
}
@@ -155,9 +157,10 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
memcpy(new_root, root, sizeof(*new_root));
new_root->root_key.objectid = new_root_objectid;
- WARN_ON(root->ref_cows && trans->transid !=
- root->fs_info->running_transaction->transid);
- WARN_ON(root->ref_cows && trans->transid != root->last_trans);
+ WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
+ trans->transid != root->fs_info->running_transaction->transid);
+ WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
+ trans->transid != root->last_trans);
level = btrfs_header_level(buf);
if (level == 0)
@@ -219,7 +222,7 @@ int btrfs_create_root(struct btrfs_trans_handle *trans,
btrfs_setup_root(new_root, fs_info, objectid);
if (!is_fstree(objectid))
- new_root->track_dirty = 1;
+ set_bit(BTRFS_ROOT_TRACK_DIRTY, &new_root->state);
add_root_to_dirty_list(new_root);
new_root->objectid = objectid;
@@ -332,7 +335,7 @@ static int btrfs_block_can_be_shared(struct btrfs_root *root,
* snapshot and the block was not allocated by tree relocation,
* we know the block is not shared.
*/
- if (root->ref_cows &&
+ if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
buf != root->node && buf != root->commit_root &&
(btrfs_header_generation(buf) <=
btrfs_root_last_snapshot(&root->root_item) ||
@@ -446,9 +449,10 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
struct btrfs_disk_key disk_key;
int level;
- WARN_ON(root->ref_cows && trans->transid !=
- root->fs_info->running_transaction->transid);
- WARN_ON(root->ref_cows && trans->transid != root->last_trans);
+ WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
+ trans->transid != root->fs_info->running_transaction->transid);
+ WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
+ trans->transid != root->last_trans);
level = btrfs_header_level(buf);
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index 8de1fba4..84acefef 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -388,6 +388,68 @@ static inline bool btrfs_is_zoned(const struct btrfs_fs_info *fs_info)
return fs_info->zoned != 0;
}
+/*
+ * The state of btrfs root
+ */
+enum {
+ /*
+ * btrfs_record_root_in_trans is a multi-step process, and it can race
+ * with the balancing code. But the race is very small, and only the
+ * first time the root is added to each transaction. So IN_TRANS_SETUP
+ * is used to tell us when more checks are required
+ */
+ BTRFS_ROOT_IN_TRANS_SETUP,
+
+ /*
+ * Set if tree blocks of this root can be shared by other roots.
+ * Only subvolume trees and their reloc trees have this bit set.
+ * Conflicts with TRACK_DIRTY bit.
+ *
+ * This affects two things:
+ *
+ * - How balance works
+ * For shareable roots, we need to use reloc tree and do path
+ * replacement for balance, and need various pre/post hooks for
+ * snapshot creation to handle them.
+ *
+ * While for non-shareable trees, we just simply do a tree search
+ * with COW.
+ *
+ * - How dirty roots are tracked
+ * For shareable roots, btrfs_record_root_in_trans() is needed to
+ * track them, while non-subvolume roots have TRACK_DIRTY bit, they
+ * don't need to set this manually.
+ */
+ BTRFS_ROOT_SHAREABLE,
+ BTRFS_ROOT_TRACK_DIRTY,
+ BTRFS_ROOT_IN_RADIX,
+ BTRFS_ROOT_ORPHAN_ITEM_INSERTED,
+ BTRFS_ROOT_DEFRAG_RUNNING,
+ BTRFS_ROOT_FORCE_COW,
+ BTRFS_ROOT_MULTI_LOG_TASKS,
+ BTRFS_ROOT_DIRTY,
+ BTRFS_ROOT_DELETING,
+
+ /*
+ * Reloc tree is orphan, only kept here for qgroup delayed subtree scan
+ *
+ * Set for the subvolume tree owning the reloc tree.
+ */
+ BTRFS_ROOT_DEAD_RELOC_TREE,
+ /* Mark dead root stored on device whose cleanup needs to be resumed */
+ BTRFS_ROOT_DEAD_TREE,
+ /* The root has a log tree. Used for subvolume roots and the tree root. */
+ BTRFS_ROOT_HAS_LOG_TREE,
+ /* Qgroup flushing is in progress */
+ BTRFS_ROOT_QGROUP_FLUSHING,
+ /* We started the orphan cleanup for this root. */
+ BTRFS_ROOT_ORPHAN_CLEANUP,
+ /* This root has a drop operation that was started previously. */
+ BTRFS_ROOT_UNFINISHED_DROP,
+ /* This reloc root needs to have its buffers lockdep class reset. */
+ BTRFS_ROOT_RESET_LOCKDEP_CLASS,
+};
+
/*
* in ram representation of the tree. extent_root is used for all allocations
* and for the extent tree extent_root root.
@@ -401,9 +463,7 @@ struct btrfs_root {
u64 objectid;
u64 last_trans;
- int ref_cows;
- int track_dirty;
-
+ unsigned long state;
u32 type;
u64 last_inode_alloc;
diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index 030bc780..44462d8f 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -32,6 +32,7 @@
#include "crypto/crc32c.h"
#include "common/utils.h"
#include "kernel-shared/print-tree.h"
+#include "kernel-lib/bitops.h"
#include "common/rbtree-utils.h"
#include "common/device-scan.h"
#include "common/device-utils.h"
@@ -491,8 +492,7 @@ void btrfs_setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
{
root->node = NULL;
root->commit_root = NULL;
- root->ref_cows = 0;
- root->track_dirty = 0;
+ root->state = 0;
root->fs_info = fs_info;
root->objectid = objectid;
@@ -654,9 +654,9 @@ out:
}
insert:
if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID)
- root->track_dirty = 1;
+ set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state);
if (is_fstree(root->root_key.objectid))
- root->ref_cows = 1;
+ set_bit(BTRFS_ROOT_SHAREABLE, &root->state);
return root;
}
@@ -1062,7 +1062,7 @@ static int load_global_roots_objectid(struct btrfs_fs_info *fs_info,
free(root);
break;
}
- root->track_dirty = 1;
+ set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state);
ret = btrfs_global_root_insert(fs_info, root);
if (ret) {
@@ -1099,7 +1099,7 @@ static int load_global_roots_objectid(struct btrfs_fs_info *fs_info,
root->root_key.objectid = objectid;
root->root_key.type = BTRFS_ROOT_ITEM_KEY;
root->root_key.offset = i;
- root->track_dirty = 1;
+ set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state);
root->node = btrfs_find_create_tree_block(fs_info, 0);
if (!root->node) {
free(root);
@@ -1232,7 +1232,8 @@ int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info, u64 root_tree_bytenr,
error("couldn't load block group tree");
return -EIO;
}
- fs_info->block_group_root->track_dirty = 1;
+ set_bit(BTRFS_ROOT_TRACK_DIRTY,
+ &fs_info->block_group_root->state);
}
ret = btrfs_find_and_setup_root(root, fs_info,
@@ -1242,7 +1243,7 @@ int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info, u64 root_tree_bytenr,
printk("Couldn't setup device tree\n");
return -EIO;
}
- fs_info->dev_root->track_dirty = 1;
+ set_bit(BTRFS_ROOT_TRACK_DIRTY, &fs_info->dev_root->state);
ret = btrfs_find_and_setup_root(root, fs_info,
BTRFS_UUID_TREE_OBJECTID,
@@ -1251,7 +1252,7 @@ int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info, u64 root_tree_bytenr,
free(fs_info->uuid_root);
fs_info->uuid_root = NULL;
} else {
- fs_info->uuid_root->track_dirty = 1;
+ set_bit(BTRFS_ROOT_TRACK_DIRTY, &fs_info->uuid_root->state);
}
ret = btrfs_find_and_setup_root(root, fs_info,
@@ -2355,7 +2356,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
extent_buffer_get(root->node);
root->commit_root = root->node;
- root->track_dirty = 1;
+ set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state);
root->root_item.flags = 0;
root->root_item.byte_limit = 0;
diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c
index 2a71b97a..8f3477bf 100644
--- a/kernel-shared/extent-tree.c
+++ b/kernel-shared/extent-tree.c
@@ -1471,7 +1471,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
nritems = btrfs_header_nritems(buf);
level = btrfs_header_level(buf);
- if (!root->ref_cows && level == 0)
+ if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state) && level == 0)
return 0;
if (inc)
@@ -2359,11 +2359,11 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans,
}
/*
- * Also preallocate metadata for csum tree and fs trees (root->ref_cows
- * already set), as they can consume a lot of metadata space.
- * Pre-allocate to avoid unexpected ENOSPC.
+ * Also preallocate metadata for csum tree and fs trees
+ * (BTRFS_ROOT_SHAREABLE already set) as they can consume a lot of
+ * metadata space. Pre-allocate to avoid unexpected ENOSPC.
*/
- if (root->ref_cows ||
+ if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) ||
root->root_key.objectid == BTRFS_CSUM_TREE_OBJECTID) {
if (!(profile & BTRFS_BLOCK_GROUP_METADATA)) {
ret = do_chunk_alloc(trans, info,
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 03/10] btrfs-progs: rename btrfs_alloc_free_block to btrfs_alloc_tree_block
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
2023-04-19 21:20 ` [PATCH 01/10] btrfs-progs: const-ify the extent buffer helpers Josef Bacik
2023-04-19 21:20 ` [PATCH 02/10] btrfs-progs: bring root->state into btrfs-progs Josef Bacik
@ 2023-04-19 21:20 ` Josef Bacik
2023-04-19 21:20 ` [PATCH 04/10] btrfs-progs: sync locking.h and stub out all the helpers Josef Bacik
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
This is in keeping with what the function actually does, and is named
this way in the kernel.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
check/main.c | 2 +-
cmds/rescue-chunk-recover.c | 2 +-
kernel-shared/ctree.c | 14 +++++++-------
kernel-shared/ctree.h | 2 +-
kernel-shared/disk-io.c | 2 +-
kernel-shared/extent-tree.c | 2 +-
6 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/check/main.c b/check/main.c
index 45e3442d..c5131b7a 100644
--- a/check/main.c
+++ b/check/main.c
@@ -9096,7 +9096,7 @@ static struct extent_buffer *btrfs_fsck_clear_root(
if (!path)
return ERR_PTR(-ENOMEM);
- c = btrfs_alloc_free_block(trans, gfs_info->tree_root,
+ c = btrfs_alloc_tree_block(trans, gfs_info->tree_root,
gfs_info->nodesize, key->objectid,
&disk_key, 0, 0, 0);
if (IS_ERR(c)) {
diff --git a/cmds/rescue-chunk-recover.c b/cmds/rescue-chunk-recover.c
index ce53da2e..b18d422e 100644
--- a/cmds/rescue-chunk-recover.c
+++ b/cmds/rescue-chunk-recover.c
@@ -1146,7 +1146,7 @@ static int __rebuild_chunk_root(struct btrfs_trans_handle *trans,
btrfs_set_disk_key_type(&disk_key, BTRFS_DEV_ITEM_KEY);
btrfs_set_disk_key_offset(&disk_key, min_devid);
- cow = btrfs_alloc_free_block(trans, root, root->fs_info->nodesize,
+ cow = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
BTRFS_CHUNK_TREE_OBJECTID,
&disk_key, 0, 0, 0);
btrfs_set_header_bytenr(cow, cow->start);
diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index cfbcc689..230dae1b 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -167,7 +167,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
btrfs_item_key(buf, &disk_key, 0);
else
btrfs_node_key(buf, &disk_key, 0);
- cow = btrfs_alloc_free_block(trans, new_root, buf->len,
+ cow = btrfs_alloc_tree_block(trans, new_root, buf->len,
new_root_objectid, &disk_key,
level, buf->start, 0);
if (IS_ERR(cow)) {
@@ -230,7 +230,7 @@ int btrfs_create_root(struct btrfs_trans_handle *trans,
new_root->root_key.type = BTRFS_ROOT_ITEM_KEY;
new_root->root_key.offset = 0;
- node = btrfs_alloc_free_block(trans, new_root, fs_info->nodesize,
+ node = btrfs_alloc_tree_block(trans, new_root, fs_info->nodesize,
objectid, &disk_key, 0, 0, 0);
if (IS_ERR(node)) {
ret = PTR_ERR(node);
@@ -285,7 +285,7 @@ int btrfs_create_root(struct btrfs_trans_handle *trans,
/*
* Essential trees can't be created by this function, yet.
* As we expect such skeleton exists, or a lot of functions like
- * btrfs_alloc_free_block() doesn't work at all
+ * btrfs_alloc_tree_block() doesn't work at all
*/
case BTRFS_ROOT_TREE_OBJECTID:
case BTRFS_EXTENT_TREE_OBJECTID:
@@ -461,7 +461,7 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
else
btrfs_node_key(buf, &disk_key, 0);
- cow = btrfs_alloc_free_block(trans, root, buf->len,
+ cow = btrfs_alloc_tree_block(trans, root, buf->len,
root->root_key.objectid, &disk_key,
level, search_start, empty_size);
if (IS_ERR(cow))
@@ -1732,7 +1732,7 @@ static int noinline insert_new_root(struct btrfs_trans_handle *trans,
else
btrfs_node_key(lower, &lower_key, 0);
- c = btrfs_alloc_free_block(trans, root, root->fs_info->nodesize,
+ c = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
root->root_key.objectid, &lower_key,
level, root->node->start, 0);
@@ -1858,7 +1858,7 @@ static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root
mid = (c_nritems + 1) / 2;
btrfs_node_key(c, &disk_key, mid);
- split = btrfs_alloc_free_block(trans, root, root->fs_info->nodesize,
+ split = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
root->root_key.objectid,
&disk_key, level, c->start, 0);
if (IS_ERR(split))
@@ -2425,7 +2425,7 @@ again:
else
btrfs_item_key(l, &disk_key, mid);
- right = btrfs_alloc_free_block(trans, root, root->fs_info->nodesize,
+ right = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
root->root_key.objectid,
&disk_key, 0, l->start, 0);
if (IS_ERR(right)) {
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index 84acefef..af60ba66 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -849,7 +849,7 @@ struct btrfs_block_group *btrfs_lookup_block_group(struct btrfs_fs_info *info,
struct btrfs_block_group *btrfs_lookup_first_block_group(struct
btrfs_fs_info *info,
u64 bytenr);
-struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
+struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u32 blocksize, u64 root_objectid,
struct btrfs_disk_key *key, int level,
diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index 44462d8f..6f9dc327 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -2333,7 +2333,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
btrfs_setup_root(root, fs_info, key->objectid);
memcpy(&root->root_key, key, sizeof(struct btrfs_key));
- leaf = btrfs_alloc_free_block(trans, root, fs_info->nodesize,
+ leaf = btrfs_alloc_tree_block(trans, root, fs_info->nodesize,
root->root_key.objectid, NULL, 0, 0, 0);
if (IS_ERR(leaf)) {
ret = PTR_ERR(leaf);
diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c
index 8f3477bf..d0b3aee3 100644
--- a/kernel-shared/extent-tree.c
+++ b/kernel-shared/extent-tree.c
@@ -2555,7 +2555,7 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans,
* helper function to allocate a block for a given tree
* returns the tree buffer or NULL.
*/
-struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
+struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u32 blocksize, u64 root_objectid,
struct btrfs_disk_key *key, int level,
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 04/10] btrfs-progs: sync locking.h and stub out all the helpers
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
` (2 preceding siblings ...)
2023-04-19 21:20 ` [PATCH 03/10] btrfs-progs: rename btrfs_alloc_free_block to btrfs_alloc_tree_block Josef Bacik
@ 2023-04-19 21:20 ` Josef Bacik
2023-04-19 21:20 ` [PATCH 05/10] btrfs-progs: add btrfs_locking_nest to btrfs_alloc_tree_block Josef Bacik
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
We want locking.h to have all the definitions that get used throughout
the codebase, however we don't want to actually use any of the actual
locking. This sync's the bulk of locking.h, and then stubs out all of
the definitions. We need a locking.c for the root lock helpers that
return the extent buffer, but everything else can simply be inlined out.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
Makefile | 1 +
include/kerncompat.h | 4 +
kernel-shared/locking.c | 22 ++++
kernel-shared/locking.h | 258 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 285 insertions(+)
create mode 100644 kernel-shared/locking.c
create mode 100644 kernel-shared/locking.h
diff --git a/Makefile b/Makefile
index 43dfd296..8001f46a 100644
--- a/Makefile
+++ b/Makefile
@@ -182,6 +182,7 @@ objects = \
kernel-shared/free-space-tree.o \
kernel-shared/inode-item.o \
kernel-shared/inode.o \
+ kernel-shared/locking.o \
kernel-shared/messages.o \
kernel-shared/print-tree.o \
kernel-shared/root-tree.o \
diff --git a/include/kerncompat.h b/include/kerncompat.h
index 68007915..28e9f443 100644
--- a/include/kerncompat.h
+++ b/include/kerncompat.h
@@ -615,6 +615,10 @@ do { \
#define smp_mb__before_atomic() do {} while (0)
#define smp_mb() do {} while (0)
+struct percpu_counter {
+ int count;
+};
+
typedef struct refcount_struct {
int refs;
} refcount_t;
diff --git a/kernel-shared/locking.c b/kernel-shared/locking.c
new file mode 100644
index 00000000..c4138e68
--- /dev/null
+++ b/kernel-shared/locking.c
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2008 Oracle. All rights reserved.
+ */
+
+#include "ctree.h"
+#include "locking.h"
+
+struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root)
+{
+ return root->node;
+}
+
+struct extent_buffer *btrfs_try_read_lock_root_node(struct btrfs_root *root)
+{
+ return root->node;
+}
+
+struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root)
+{
+ return root->node;
+}
diff --git a/kernel-shared/locking.h b/kernel-shared/locking.h
new file mode 100644
index 00000000..02c302e4
--- /dev/null
+++ b/kernel-shared/locking.h
@@ -0,0 +1,258 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2008 Oracle. All rights reserved.
+ */
+
+#ifndef BTRFS_LOCKING_H
+#define BTRFS_LOCKING_H
+
+#include "kerncompat.h"
+
+#define BTRFS_WRITE_LOCK 1
+#define BTRFS_READ_LOCK 2
+
+struct btrfs_root;
+
+/*
+ * We are limited in number of subclasses by MAX_LOCKDEP_SUBCLASSES, which at
+ * the time of this patch is 8, which is how many we use. Keep this in mind if
+ * you decide you want to add another subclass.
+ */
+enum btrfs_lock_nesting {
+ BTRFS_NESTING_NORMAL,
+
+ /*
+ * When we COW a block we are holding the lock on the original block,
+ * and since our lockdep maps are rootid+level, this confuses lockdep
+ * when we lock the newly allocated COW'd block. Handle this by having
+ * a subclass for COW'ed blocks so that lockdep doesn't complain.
+ */
+ BTRFS_NESTING_COW,
+
+ /*
+ * Oftentimes we need to lock adjacent nodes on the same level while
+ * still holding the lock on the original node we searched to, such as
+ * for searching forward or for split/balance.
+ *
+ * Because of this we need to indicate to lockdep that this is
+ * acceptable by having a different subclass for each of these
+ * operations.
+ */
+ BTRFS_NESTING_LEFT,
+ BTRFS_NESTING_RIGHT,
+
+ /*
+ * When splitting we will be holding a lock on the left/right node when
+ * we need to cow that node, thus we need a new set of subclasses for
+ * these two operations.
+ */
+ BTRFS_NESTING_LEFT_COW,
+ BTRFS_NESTING_RIGHT_COW,
+
+ /*
+ * When splitting we may push nodes to the left or right, but still use
+ * the subsequent nodes in our path, keeping our locks on those adjacent
+ * blocks. Thus when we go to allocate a new split block we've already
+ * used up all of our available subclasses, so this subclass exists to
+ * handle this case where we need to allocate a new split block.
+ */
+ BTRFS_NESTING_SPLIT,
+
+ /*
+ * When promoting a new block to a root we need to have a special
+ * subclass so we don't confuse lockdep, as it will appear that we are
+ * locking a higher level node before a lower level one. Copying also
+ * has this problem as it appears we're locking the same block again
+ * when we make a snapshot of an existing root.
+ */
+ BTRFS_NESTING_NEW_ROOT,
+
+ /*
+ * We are limited to MAX_LOCKDEP_SUBLCLASSES number of subclasses, so
+ * add this in here and add a static_assert to keep us from going over
+ * the limit. As of this writing we're limited to 8, and we're
+ * definitely using 8, hence this check to keep us from messing up in
+ * the future.
+ */
+ BTRFS_NESTING_MAX,
+};
+
+enum btrfs_lockdep_trans_states {
+ BTRFS_LOCKDEP_TRANS_COMMIT_START,
+ BTRFS_LOCKDEP_TRANS_UNBLOCKED,
+ BTRFS_LOCKDEP_TRANS_SUPER_COMMITTED,
+ BTRFS_LOCKDEP_TRANS_COMPLETED,
+};
+
+/*
+ * Lockdep annotation for wait events.
+ *
+ * @owner: The struct where the lockdep map is defined
+ * @lock: The lockdep map corresponding to a wait event
+ *
+ * This macro is used to annotate a wait event. In this case a thread acquires
+ * the lockdep map as writer (exclusive lock) because it has to block until all
+ * the threads that hold the lock as readers signal the condition for the wait
+ * event and release their locks.
+ */
+#define btrfs_might_wait_for_event(owner, lock) \
+ do { \
+ rwsem_acquire(&owner->lock##_map, 0, 0, _THIS_IP_); \
+ rwsem_release(&owner->lock##_map, _THIS_IP_); \
+ } while (0)
+
+/*
+ * Protection for the resource/condition of a wait event.
+ *
+ * @owner: The struct where the lockdep map is defined
+ * @lock: The lockdep map corresponding to a wait event
+ *
+ * Many threads can modify the condition for the wait event at the same time
+ * and signal the threads that block on the wait event. The threads that modify
+ * the condition and do the signaling acquire the lock as readers (shared
+ * lock).
+ */
+#define btrfs_lockdep_acquire(owner, lock) \
+ rwsem_acquire_read(&owner->lock##_map, 0, 0, _THIS_IP_)
+
+/*
+ * Used after signaling the condition for a wait event to release the lockdep
+ * map held by a reader thread.
+ */
+#define btrfs_lockdep_release(owner, lock) \
+ rwsem_release(&owner->lock##_map, _THIS_IP_)
+
+/*
+ * Macros for the transaction states wait events, similar to the generic wait
+ * event macros.
+ */
+#define btrfs_might_wait_for_state(owner, i) \
+ do { \
+ rwsem_acquire(&owner->btrfs_state_change_map[i], 0, 0, _THIS_IP_); \
+ rwsem_release(&owner->btrfs_state_change_map[i], _THIS_IP_); \
+ } while (0)
+
+#define btrfs_trans_state_lockdep_acquire(owner, i) \
+ rwsem_acquire_read(&owner->btrfs_state_change_map[i], 0, 0, _THIS_IP_)
+
+#define btrfs_trans_state_lockdep_release(owner, i) \
+ rwsem_release(&owner->btrfs_state_change_map[i], _THIS_IP_)
+
+/* Initialization of the lockdep map */
+#define btrfs_lockdep_init_map(owner, lock) \
+ do { \
+ static struct lock_class_key lock##_key; \
+ lockdep_init_map(&owner->lock##_map, #lock, &lock##_key, 0); \
+ } while (0)
+
+/* Initialization of the transaction states lockdep maps. */
+#define btrfs_state_lockdep_init_map(owner, lock, state) \
+ do { \
+ static struct lock_class_key lock##_key; \
+ lockdep_init_map(&owner->btrfs_state_change_map[state], #lock, \
+ &lock##_key, 0); \
+ } while (0)
+
+struct btrfs_path;
+
+static inline void __btrfs_tree_lock(struct extent_buffer *eb, enum btrfs_lock_nesting nest)
+{
+}
+
+static inline void btrfs_tree_lock(struct extent_buffer *eb)
+{
+}
+
+static inline void btrfs_tree_unlock(struct extent_buffer *eb)
+{
+}
+
+static inline void __btrfs_tree_read_lock(struct extent_buffer *eb, enum btrfs_lock_nesting nest)
+{
+}
+
+static inline void btrfs_tree_read_lock(struct extent_buffer *eb)
+{
+}
+
+static inline void btrfs_tree_read_unlock(struct extent_buffer *eb)
+{
+}
+
+static inline int btrfs_try_tree_read_lock(struct extent_buffer *eb)
+{
+ return 1;
+}
+
+static inline int btrfs_try_tree_write_lock(struct extent_buffer *eb)
+{
+ return 1;
+}
+
+static inline void btrfs_assert_tree_write_locked(struct extent_buffer *eb) { }
+
+static inline void btrfs_unlock_up_safe(struct btrfs_path *path, int level)
+{
+}
+
+struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root);
+struct extent_buffer *btrfs_try_read_lock_root_node(struct btrfs_root *root);
+struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root);
+
+static inline void btrfs_tree_unlock_rw(struct extent_buffer *eb, int rw)
+{
+ if (rw == BTRFS_WRITE_LOCK)
+ btrfs_tree_unlock(eb);
+ else if (rw == BTRFS_READ_LOCK)
+ btrfs_tree_read_unlock(eb);
+ else
+ BUG();
+}
+
+struct btrfs_drew_lock {
+ atomic_t readers;
+ struct percpu_counter writers;
+ wait_queue_head_t pending_writers;
+ wait_queue_head_t pending_readers;
+};
+
+static inline int btrfs_drew_lock_init(struct btrfs_drew_lock *lock)
+{
+ return 0;
+}
+
+static inline void btrfs_drew_lock_destroy(struct btrfs_drew_lock *lock)
+{
+}
+
+static inline void btrfs_drew_write_lock(struct btrfs_drew_lock *lock)
+{
+}
+
+static inline bool btrfs_drew_try_write_lock(struct btrfs_drew_lock *lock)
+{
+ return true;
+}
+
+static inline void btrfs_drew_write_unlock(struct btrfs_drew_lock *lock)
+{
+}
+
+static inline void btrfs_drew_read_lock(struct btrfs_drew_lock *lock)
+{
+}
+
+static inline void btrfs_drew_read_unlock(struct btrfs_drew_lock *lock)
+{
+}
+
+static inline void btrfs_set_buffer_lockdep_class(u64 objectid,
+ struct extent_buffer *eb, int level)
+{
+}
+static inline void btrfs_maybe_reset_lockdep_class(struct btrfs_root *root,
+ struct extent_buffer *eb)
+{
+}
+
+#endif
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 05/10] btrfs-progs: add btrfs_locking_nest to btrfs_alloc_tree_block
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
` (3 preceding siblings ...)
2023-04-19 21:20 ` [PATCH 04/10] btrfs-progs: sync locking.h and stub out all the helpers Josef Bacik
@ 2023-04-19 21:20 ` Josef Bacik
2023-04-19 21:20 ` [PATCH 06/10] btrfs-progs: add some missing extent buffer helpers Josef Bacik
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
This is how btrfs_alloc_tree_block is defined in the kernel, so when we
go to sync this code in it'll be easier if we're already setup to accept
this argument. Since we're in progs we don't care about nesting so just
use BTRFS_NORMAL_NESTING everywhere, as we sync in the kernel code it'll
get updated to whatever is appropriate.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
check/main.c | 2 +-
cmds/rescue-chunk-recover.c | 2 +-
kernel-shared/ctree.c | 18 ++++++++++++------
kernel-shared/ctree.h | 4 +++-
kernel-shared/disk-io.c | 3 ++-
kernel-shared/extent-tree.c | 3 ++-
6 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/check/main.c b/check/main.c
index c5131b7a..09805511 100644
--- a/check/main.c
+++ b/check/main.c
@@ -9098,7 +9098,7 @@ static struct extent_buffer *btrfs_fsck_clear_root(
c = btrfs_alloc_tree_block(trans, gfs_info->tree_root,
gfs_info->nodesize, key->objectid,
- &disk_key, 0, 0, 0);
+ &disk_key, 0, 0, 0, BTRFS_NESTING_NORMAL);
if (IS_ERR(c)) {
btrfs_free_path(path);
return c;
diff --git a/cmds/rescue-chunk-recover.c b/cmds/rescue-chunk-recover.c
index b18d422e..52119d98 100644
--- a/cmds/rescue-chunk-recover.c
+++ b/cmds/rescue-chunk-recover.c
@@ -1148,7 +1148,7 @@ static int __rebuild_chunk_root(struct btrfs_trans_handle *trans,
cow = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
BTRFS_CHUNK_TREE_OBJECTID,
- &disk_key, 0, 0, 0);
+ &disk_key, 0, 0, 0, BTRFS_NESTING_NORMAL);
btrfs_set_header_bytenr(cow, cow->start);
btrfs_set_header_generation(cow, trans->transid);
btrfs_set_header_nritems(cow, 0);
diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index 230dae1b..cad15093 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -169,7 +169,8 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
btrfs_node_key(buf, &disk_key, 0);
cow = btrfs_alloc_tree_block(trans, new_root, buf->len,
new_root_objectid, &disk_key,
- level, buf->start, 0);
+ level, buf->start, 0,
+ BTRFS_NESTING_NORMAL);
if (IS_ERR(cow)) {
kfree(new_root);
return PTR_ERR(cow);
@@ -231,7 +232,8 @@ int btrfs_create_root(struct btrfs_trans_handle *trans,
new_root->root_key.offset = 0;
node = btrfs_alloc_tree_block(trans, new_root, fs_info->nodesize,
- objectid, &disk_key, 0, 0, 0);
+ objectid, &disk_key, 0, 0, 0,
+ BTRFS_NESTING_NORMAL);
if (IS_ERR(node)) {
ret = PTR_ERR(node);
error("failed to create root node for tree %llu: %d (%m)",
@@ -463,7 +465,8 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
cow = btrfs_alloc_tree_block(trans, root, buf->len,
root->root_key.objectid, &disk_key,
- level, search_start, empty_size);
+ level, search_start, empty_size,
+ BTRFS_NESTING_NORMAL);
if (IS_ERR(cow))
return PTR_ERR(cow);
@@ -1734,7 +1737,8 @@ static int noinline insert_new_root(struct btrfs_trans_handle *trans,
c = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
root->root_key.objectid, &lower_key,
- level, root->node->start, 0);
+ level, root->node->start, 0,
+ BTRFS_NESTING_NORMAL);
if (IS_ERR(c))
return PTR_ERR(c);
@@ -1860,7 +1864,8 @@ static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root
split = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
root->root_key.objectid,
- &disk_key, level, c->start, 0);
+ &disk_key, level, c->start, 0,
+ BTRFS_NESTING_NORMAL);
if (IS_ERR(split))
return PTR_ERR(split);
@@ -2427,7 +2432,8 @@ again:
right = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
root->root_key.objectid,
- &disk_key, 0, l->start, 0);
+ &disk_key, 0, l->start, 0,
+ BTRFS_NESTING_NORMAL);
if (IS_ERR(right)) {
BUG_ON(1);
return PTR_ERR(right);
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index af60ba66..f416fc36 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -29,6 +29,7 @@
#include "kernel-shared/uapi/btrfs_tree.h"
#include "accessors.h"
#include "extent-io-tree.h"
+#include "locking.h"
struct btrfs_root;
struct btrfs_trans_handle;
@@ -853,7 +854,8 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u32 blocksize, u64 root_objectid,
struct btrfs_disk_key *key, int level,
- u64 hint, u64 empty_size);
+ u64 hint, u64 empty_size,
+ enum btrfs_lock_nesting nest);
int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info, u64 bytenr,
u64 offset, int metadata, u64 *refs, u64 *flags);
diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index 6f9dc327..7ee45ad1 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -2334,7 +2334,8 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
memcpy(&root->root_key, key, sizeof(struct btrfs_key));
leaf = btrfs_alloc_tree_block(trans, root, fs_info->nodesize,
- root->root_key.objectid, NULL, 0, 0, 0);
+ root->root_key.objectid, NULL, 0, 0, 0,
+ BTRFS_NESTING_NORMAL);
if (IS_ERR(leaf)) {
ret = PTR_ERR(leaf);
leaf = NULL;
diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c
index d0b3aee3..916eb840 100644
--- a/kernel-shared/extent-tree.c
+++ b/kernel-shared/extent-tree.c
@@ -2559,7 +2559,8 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u32 blocksize, u64 root_objectid,
struct btrfs_disk_key *key, int level,
- u64 hint, u64 empty_size)
+ u64 hint, u64 empty_size,
+ enum btrfs_lock_nesting nest)
{
struct btrfs_key ins;
int ret;
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 06/10] btrfs-progs: add some missing extent buffer helpers
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
` (4 preceding siblings ...)
2023-04-19 21:20 ` [PATCH 05/10] btrfs-progs: add btrfs_locking_nest to btrfs_alloc_tree_block Josef Bacik
@ 2023-04-19 21:20 ` Josef Bacik
2023-04-19 21:20 ` [PATCH 07/10] btrfs-progs: rename btrfs_set_block_flags -> btrfs_set_disk_extent_flags Josef Bacik
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
The following are some extent buffer helpers we have in the kernel but
not in btrfs-progs. Sync these in to make syncing ctree.c easier.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
kernel-shared/extent_io.c | 11 +++++++++++
kernel-shared/extent_io.h | 3 +++
2 files changed, 14 insertions(+)
diff --git a/kernel-shared/extent_io.c b/kernel-shared/extent_io.c
index 01dc5b1e..f740b3a6 100644
--- a/kernel-shared/extent_io.c
+++ b/kernel-shared/extent_io.c
@@ -617,6 +617,12 @@ void copy_extent_buffer(const struct extent_buffer *dst,
memcpy((void *)dst->data + dst_offset, src->data + src_offset, len);
}
+void copy_extent_buffer_full(const struct extent_buffer *dst,
+ const struct extent_buffer *src)
+{
+ copy_extent_buffer(dst, src, 0, 0, src->len);
+}
+
void memmove_extent_buffer(const struct extent_buffer *dst, unsigned long dst_offset,
unsigned long src_offset, unsigned long len)
{
@@ -634,3 +640,8 @@ int extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
{
return le_test_bit(nr, (u8 *)eb->data + start);
}
+
+void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *srcv)
+{
+ write_extent_buffer(eb, srcv, btrfs_header_fsid(), BTRFS_FSID_SIZE);
+}
diff --git a/kernel-shared/extent_io.h b/kernel-shared/extent_io.h
index 69133c3c..103f93cb 100644
--- a/kernel-shared/extent_io.h
+++ b/kernel-shared/extent_io.h
@@ -114,6 +114,8 @@ void copy_extent_buffer(const struct extent_buffer *dst,
const struct extent_buffer *src,
unsigned long dst_offset, unsigned long src_offset,
unsigned long len);
+void copy_extent_buffer_full(const struct extent_buffer *dst,
+ const struct extent_buffer *src);
void memmove_extent_buffer(const struct extent_buffer *dst,
const unsigned long dst_offset,
unsigned long src_offset, unsigned long len);
@@ -133,5 +135,6 @@ void extent_buffer_bitmap_set(struct extent_buffer *eb, unsigned long start,
unsigned long pos, unsigned long len);
void extent_buffer_init_cache(struct btrfs_fs_info *fs_info);
void extent_buffer_free_cache(struct btrfs_fs_info *fs_info);
+void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *srcv);
#endif
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 07/10] btrfs-progs: rename btrfs_set_block_flags -> btrfs_set_disk_extent_flags
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
` (5 preceding siblings ...)
2023-04-19 21:20 ` [PATCH 06/10] btrfs-progs: add some missing extent buffer helpers Josef Bacik
@ 2023-04-19 21:20 ` Josef Bacik
2023-04-19 21:20 ` [PATCH 08/10] btrfs-progs: cleanup args for btrfs_set_disk_extent_flags Josef Bacik
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
This helper in the kernel is named btrfs_set_disk_extent_flags, which is
a more accurate description than btrfs_set_block_flags. Rename to the
in kernel name to make sync'ing ctree.c easier.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
kernel-shared/ctree.c | 6 +++---
kernel-shared/ctree.h | 4 ++--
kernel-shared/extent-tree.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index cad15093..e95dcc79 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -419,9 +419,9 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
BUG_ON(ret);
}
if (new_flags != 0) {
- ret = btrfs_set_block_flags(trans, buf->start,
- btrfs_header_level(buf),
- new_flags);
+ ret = btrfs_set_disk_extent_flags(trans, buf->start,
+ btrfs_header_level(buf),
+ new_flags);
BUG_ON(ret);
}
} else {
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index f416fc36..aaace45e 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -859,8 +859,8 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info, u64 bytenr,
u64 offset, int metadata, u64 *refs, u64 *flags);
-int btrfs_set_block_flags(struct btrfs_trans_handle *trans, u64 bytenr,
- int level, u64 flags);
+int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, u64 bytenr,
+ int level, u64 flags);
int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct extent_buffer *buf, int record_parent);
int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c
index 916eb840..8a6ab996 100644
--- a/kernel-shared/extent-tree.c
+++ b/kernel-shared/extent-tree.c
@@ -1375,8 +1375,8 @@ out:
return ret;
}
-int btrfs_set_block_flags(struct btrfs_trans_handle *trans, u64 bytenr,
- int level, u64 flags)
+int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, u64 bytenr,
+ int level, u64 flags)
{
struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_root *extent_root = btrfs_extent_root(fs_info, bytenr);
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 08/10] btrfs-progs: cleanup args for btrfs_set_disk_extent_flags
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
` (6 preceding siblings ...)
2023-04-19 21:20 ` [PATCH 07/10] btrfs-progs: rename btrfs_set_block_flags -> btrfs_set_disk_extent_flags Josef Bacik
@ 2023-04-19 21:20 ` Josef Bacik
2023-04-19 21:20 ` [PATCH 09/10] btrfs-progs: rename clear_extent_buffer_dirty => btrfs_clear_buffer_dirty Josef Bacik
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
In the kernel we just pass in the extent_buffer and get the fields we
need from that to update the extent ref flags. Update this helper to
match the kernel to make syncing ctree.c easier.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
kernel-shared/ctree.c | 4 +---
kernel-shared/ctree.h | 4 ++--
kernel-shared/extent-tree.c | 11 +++++++----
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index e95dcc79..ea2a7af3 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -419,9 +419,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
BUG_ON(ret);
}
if (new_flags != 0) {
- ret = btrfs_set_disk_extent_flags(trans, buf->start,
- btrfs_header_level(buf),
- new_flags);
+ ret = btrfs_set_disk_extent_flags(trans, buf, new_flags);
BUG_ON(ret);
}
} else {
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index aaace45e..069e000d 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -859,8 +859,8 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info, u64 bytenr,
u64 offset, int metadata, u64 *refs, u64 *flags);
-int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, u64 bytenr,
- int level, u64 flags);
+int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans,
+ struct extent_buffer *eb, u64 flags);
int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct extent_buffer *buf, int record_parent);
int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c
index 8a6ab996..cfce4426 100644
--- a/kernel-shared/extent-tree.c
+++ b/kernel-shared/extent-tree.c
@@ -1375,26 +1375,29 @@ out:
return ret;
}
-int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, u64 bytenr,
- int level, u64 flags)
+int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans,
+ struct extent_buffer *eb, u64 flags)
{
struct btrfs_fs_info *fs_info = trans->fs_info;
- struct btrfs_root *extent_root = btrfs_extent_root(fs_info, bytenr);
+ struct btrfs_root *extent_root;
struct btrfs_path *path;
int ret;
struct btrfs_key key;
struct extent_buffer *l;
struct btrfs_extent_item *item;
u32 item_size;
+ u64 bytenr = eb->start;
int skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA);
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
+ extent_root = btrfs_extent_root(fs_info, bytenr);
+
key.objectid = bytenr;
if (skinny_metadata) {
- key.offset = level;
+ key.offset = btrfs_header_level(eb);
key.type = BTRFS_METADATA_ITEM_KEY;
} else {
key.offset = fs_info->nodesize;
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 09/10] btrfs-progs: rename clear_extent_buffer_dirty => btrfs_clear_buffer_dirty
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
` (7 preceding siblings ...)
2023-04-19 21:20 ` [PATCH 08/10] btrfs-progs: cleanup args for btrfs_set_disk_extent_flags Josef Bacik
@ 2023-04-19 21:20 ` Josef Bacik
2023-04-19 21:20 ` [PATCH 10/10] btrfs-progs: make __btrfs_cow_block static Josef Bacik
2023-05-03 9:54 ` [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c David Sterba
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
This is a mirror of the change I've done in the kernel, but in progs
it's even more simply because clean_tree_block was just a wrapper around
clear_extent_buffer_dirty. Change this to btrfs_clear_buffer_dirty, and
then update all the callers to use this helper instead of
clean_tree_block and clear_extent_buffer_dirty.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
cmds/rescue.c | 2 +-
kernel-shared/ctree.c | 12 ++++++------
kernel-shared/disk-io.c | 7 +------
kernel-shared/extent-tree.c | 2 +-
kernel-shared/extent_io.c | 2 +-
kernel-shared/extent_io.h | 2 +-
kernel-shared/transaction.c | 4 ++--
7 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/cmds/rescue.c b/cmds/rescue.c
index cbeaa6f2..b84166ea 100644
--- a/cmds/rescue.c
+++ b/cmds/rescue.c
@@ -340,7 +340,7 @@ static int clear_uuid_tree(struct btrfs_fs_info *fs_info)
if (ret < 0)
goto out;
list_del(&uuid_root->dirty_list);
- ret = clean_tree_block(uuid_root->node);
+ ret = btrfs_clear_buffer_dirty(uuid_root->node);
if (ret < 0)
goto out;
ret = btrfs_free_tree_block(trans, uuid_root, uuid_root->node, 0, 1);
diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index ea2a7af3..4d33994d 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -433,7 +433,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
ret = btrfs_dec_ref(trans, root, buf, 1);
BUG_ON(ret);
}
- clean_tree_block(buf);
+ btrfs_clear_buffer_dirty(buf);
}
return 0;
}
@@ -936,7 +936,7 @@ static int balance_level(struct btrfs_trans_handle *trans,
root->node = child;
add_root_to_dirty_list(root);
path->nodes[level] = NULL;
- clean_tree_block(mid);
+ btrfs_clear_buffer_dirty(mid);
/* once for the path */
free_extent_buffer(mid);
@@ -991,7 +991,7 @@ static int balance_level(struct btrfs_trans_handle *trans,
u64 bytenr = right->start;
u32 blocksize = right->len;
- clean_tree_block(right);
+ btrfs_clear_buffer_dirty(right);
free_extent_buffer(right);
right = NULL;
wret = btrfs_del_ptr(root, path, level + 1, pslot + 1);
@@ -1039,7 +1039,7 @@ static int balance_level(struct btrfs_trans_handle *trans,
/* we've managed to empty the middle node, drop it */
u64 bytenr = mid->start;
u32 blocksize = mid->len;
- clean_tree_block(mid);
+ btrfs_clear_buffer_dirty(mid);
free_extent_buffer(mid);
mid = NULL;
wret = btrfs_del_ptr(root, path, level + 1, pslot);
@@ -3012,7 +3012,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
if (leaf == root->node) {
btrfs_set_header_level(leaf, 0);
} else {
- clean_tree_block(leaf);
+ btrfs_clear_buffer_dirty(leaf);
wret = btrfs_del_leaf(trans, root, path, leaf);
BUG_ON(ret);
if (wret)
@@ -3048,7 +3048,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
}
if (btrfs_header_nritems(leaf) == 0) {
- clean_tree_block(leaf);
+ btrfs_clear_buffer_dirty(leaf);
path->slots[1] = slot;
ret = btrfs_del_leaf(trans, root, path, leaf);
BUG_ON(ret);
diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index 7ee45ad1..7bbcc381 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -2255,11 +2255,6 @@ skip_commit:
return err;
}
-int clean_tree_block(struct extent_buffer *eb)
-{
- return clear_extent_buffer_dirty(eb);
-}
-
void btrfs_mark_buffer_dirty(struct extent_buffer *eb)
{
set_extent_buffer_dirty(eb);
@@ -2303,7 +2298,7 @@ int btrfs_delete_and_free_root(struct btrfs_trans_handle *trans,
return ret;
list_del(&root->dirty_list);
- ret = clean_tree_block(root->node);
+ ret = btrfs_clear_buffer_dirty(root->node);
if (ret)
return ret;
ret = btrfs_free_tree_block(trans, root, root->node, 0, 1);
diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c
index cfce4426..4dfb35d4 100644
--- a/kernel-shared/extent-tree.c
+++ b/kernel-shared/extent-tree.c
@@ -1902,7 +1902,7 @@ static int pin_down_bytes(struct btrfs_trans_handle *trans, u64 bytenr,
if (header_owner != BTRFS_TREE_LOG_OBJECTID &&
header_transid == trans->transid &&
!btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) {
- clean_tree_block(buf);
+ btrfs_clear_buffer_dirty(buf);
free_extent_buffer(buf);
return 1;
}
diff --git a/kernel-shared/extent_io.c b/kernel-shared/extent_io.c
index f740b3a6..4dff81bd 100644
--- a/kernel-shared/extent_io.c
+++ b/kernel-shared/extent_io.c
@@ -579,7 +579,7 @@ int set_extent_buffer_dirty(struct extent_buffer *eb)
return 0;
}
-int clear_extent_buffer_dirty(struct extent_buffer *eb)
+int btrfs_clear_buffer_dirty(struct extent_buffer *eb)
{
struct extent_io_tree *tree = &eb->fs_info->dirty_buffers;
if (eb->flags & EXTENT_BUFFER_DIRTY) {
diff --git a/kernel-shared/extent_io.h b/kernel-shared/extent_io.h
index 103f93cb..09f3c82a 100644
--- a/kernel-shared/extent_io.h
+++ b/kernel-shared/extent_io.h
@@ -124,7 +124,7 @@ void memset_extent_buffer(const struct extent_buffer *eb, char c,
int extent_buffer_test_bit(const struct extent_buffer *eb, unsigned long start,
unsigned long nr);
int set_extent_buffer_dirty(struct extent_buffer *eb);
-int clear_extent_buffer_dirty(struct extent_buffer *eb);
+int btrfs_clear_buffer_dirty(struct extent_buffer *eb);
int read_data_from_disk(struct btrfs_fs_info *info, void *buf, u64 logical,
u64 *len, int mirror);
int write_data_to_disk(struct btrfs_fs_info *info, void *buf, u64 offset,
diff --git a/kernel-shared/transaction.c b/kernel-shared/transaction.c
index b16c07c3..f99bc684 100644
--- a/kernel-shared/transaction.c
+++ b/kernel-shared/transaction.c
@@ -161,7 +161,7 @@ again:
goto cleanup;
}
start += eb->len;
- clear_extent_buffer_dirty(eb);
+ btrfs_clear_buffer_dirty(eb);
free_extent_buffer(eb);
}
}
@@ -184,7 +184,7 @@ cleanup:
eb = find_first_extent_buffer(fs_info, start);
BUG_ON(!eb || eb->start != start);
start += eb->len;
- clear_extent_buffer_dirty(eb);
+ btrfs_clear_buffer_dirty(eb);
free_extent_buffer(eb);
}
}
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 10/10] btrfs-progs: make __btrfs_cow_block static
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
` (8 preceding siblings ...)
2023-04-19 21:20 ` [PATCH 09/10] btrfs-progs: rename clear_extent_buffer_dirty => btrfs_clear_buffer_dirty Josef Bacik
@ 2023-04-19 21:20 ` Josef Bacik
2023-05-03 9:54 ` [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c David Sterba
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2023-04-19 21:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
This isn't used anywhere other than ctree.c, make it static.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
kernel-shared/ctree.c | 2 +-
kernel-shared/ctree.h | 6 ------
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index 4d33994d..da9282b9 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -438,7 +438,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
return 0;
}
-int __btrfs_cow_block(struct btrfs_trans_handle *trans,
+static int __btrfs_cow_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct extent_buffer *buf,
struct extent_buffer *parent, int parent_slot,
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index 069e000d..655b714f 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -936,12 +936,6 @@ int btrfs_cow_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct extent_buffer *buf,
struct extent_buffer *parent, int parent_slot,
struct extent_buffer **cow_ret);
-int __btrfs_cow_block(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
- struct extent_buffer *buf,
- struct extent_buffer *parent, int parent_slot,
- struct extent_buffer **cow_ret,
- u64 search_start, u64 empty_size);
int btrfs_copy_root(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct extent_buffer *buf,
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
` (9 preceding siblings ...)
2023-04-19 21:20 ` [PATCH 10/10] btrfs-progs: make __btrfs_cow_block static Josef Bacik
@ 2023-05-03 9:54 ` David Sterba
10 siblings, 0 replies; 12+ messages in thread
From: David Sterba @ 2023-05-03 9:54 UTC (permalink / raw)
To: Josef Bacik; +Cc: linux-btrfs, kernel-team
On Wed, Apr 19, 2023 at 05:20:40PM -0400, Josef Bacik wrote:
> Hello,
>
> These patches update a lot of the different ctree.c related helpers that have
> diverged from the kernel in order to make ite easier syncing ctree.c directly.
> This also syncs locking.[ch], but this is to just stub out the locking. This
> will make it easier to sync ctree.c as well since there's locking in the kernel
> that didn't exist when we had this in btrfs-progs.
>
> This series depends on
>
> btrfs-progs: prep work for syncing files into kernel-shared
> btrfs-progs: sync basic code from the kernel
>
> Thanks,
>
> Josef
>
> Josef Bacik (10):
> btrfs-progs: const-ify the extent buffer helpers
> btrfs-progs: bring root->state into btrfs-progs
> btrfs-progs: rename btrfs_alloc_free_block to btrfs_alloc_tree_block
> btrfs-progs: sync locking.h and stub out all the helpers
> btrfs-progs: add btrfs_locking_nest to btrfs_alloc_tree_block
> btrfs-progs: add some missing extent buffer helpers
> btrfs-progs: rename btrfs_set_block_flags ->
> btrfs_set_disk_extent_flags
> btrfs-progs: cleanup args for btrfs_set_disk_extent_flags
> btrfs-progs: rename clear_extent_buffer_dirty =>
> btrfs_clear_buffer_dirty
> btrfs-progs: make __btrfs_cow_block static
Added to devel. However, this fails build on Centos7 image with warnings
like
[CC] kernel-shared/backref.o
In file included from ./kernel-shared/ctree.h:30:0,
from kernel-shared/volumes.h:23,
from btrfs.c:24:
./kernel-shared/accessors.h: In function 'btrfs_device_total_bytes':
./kernel-shared/accessors.h:118:58: error: expected ',' before ')' token
sizeof(((struct btrfs_dev_item *)0))->total_bytes);
^
./kernel-shared/accessors.h: In function 'btrfs_set_device_total_bytes':
./kernel-shared/accessors.h:132:58: error: expected ',' before ')' token
sizeof(((struct btrfs_dev_item *)0))->total_bytes);
^
The code is same as in kernel e.g.
114 static inline u64 btrfs_device_total_bytes(const struct extent_buffer *eb,
115 struct btrfs_dev_item *s)
116 {
117 static_assert(sizeof(u64) ==
118 sizeof(((struct btrfs_dev_item *)0))->total_bytes);
119 return btrfs_get_64(eb, s, offsetof(struct btrfs_dev_item,
120 total_bytes));
121 }
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-05-03 10:00 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-19 21:20 [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c Josef Bacik
2023-04-19 21:20 ` [PATCH 01/10] btrfs-progs: const-ify the extent buffer helpers Josef Bacik
2023-04-19 21:20 ` [PATCH 02/10] btrfs-progs: bring root->state into btrfs-progs Josef Bacik
2023-04-19 21:20 ` [PATCH 03/10] btrfs-progs: rename btrfs_alloc_free_block to btrfs_alloc_tree_block Josef Bacik
2023-04-19 21:20 ` [PATCH 04/10] btrfs-progs: sync locking.h and stub out all the helpers Josef Bacik
2023-04-19 21:20 ` [PATCH 05/10] btrfs-progs: add btrfs_locking_nest to btrfs_alloc_tree_block Josef Bacik
2023-04-19 21:20 ` [PATCH 06/10] btrfs-progs: add some missing extent buffer helpers Josef Bacik
2023-04-19 21:20 ` [PATCH 07/10] btrfs-progs: rename btrfs_set_block_flags -> btrfs_set_disk_extent_flags Josef Bacik
2023-04-19 21:20 ` [PATCH 08/10] btrfs-progs: cleanup args for btrfs_set_disk_extent_flags Josef Bacik
2023-04-19 21:20 ` [PATCH 09/10] btrfs-progs: rename clear_extent_buffer_dirty => btrfs_clear_buffer_dirty Josef Bacik
2023-04-19 21:20 ` [PATCH 10/10] btrfs-progs: make __btrfs_cow_block static Josef Bacik
2023-05-03 9:54 ` [PATCH 00/10] btrfs-progs: prep work for syncing ctree.c David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).