diff mbox series

[13/18] btrfs-progs: add an atomic arg to btrfs_buffer_uptodate

Message ID 51dfbda01b5de4ee153c1b34e22d9753d9dc389e.1681939316.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: more prep work for syncing ctree.c | expand

Commit Message

Josef Bacik April 19, 2023, 9:24 p.m. UTC
We have this extra argument in the kernel to indicate if we are atomic
and thus can't lock the io_tree when checking the transid for an extent
buffer.  This isn't necessary in btrfs-progs, but to allow for easier
sync'ing of ctree.c add this argument to our copy of
btrfs_buffer_uptodate.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 check/main.c                | 2 +-
 check/mode-lowmem.c         | 2 +-
 kernel-shared/disk-io.c     | 9 +++++----
 kernel-shared/disk-io.h     | 3 ++-
 kernel-shared/extent-tree.c | 2 +-
 5 files changed, 10 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/check/main.c b/check/main.c
index 610c3091..f15272bf 100644
--- a/check/main.c
+++ b/check/main.c
@@ -1895,7 +1895,7 @@  static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
 		}
 
 		next = btrfs_find_tree_block(gfs_info, bytenr, gfs_info->nodesize);
-		if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) {
+		if (!next || !btrfs_buffer_uptodate(next, ptr_gen, 0)) {
 			free_extent_buffer(next);
 			reada_walk_down(root, cur, path->slots[*level]);
 			next = read_tree_block(gfs_info, bytenr,
diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 83b86e63..fb294c90 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -5043,7 +5043,7 @@  static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
 		}
 
 		next = btrfs_find_tree_block(gfs_info, bytenr, gfs_info->nodesize);
-		if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) {
+		if (!next || !btrfs_buffer_uptodate(next, ptr_gen, 0)) {
 			free_extent_buffer(next);
 			reada_walk_down(root, cur, path->slots[*level]);
 			next = read_tree_block(gfs_info, bytenr,
diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index 3b3188da..29fe9027 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -246,7 +246,7 @@  void readahead_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
 	struct btrfs_device *device;
 
 	eb = btrfs_find_tree_block(fs_info, bytenr, fs_info->nodesize);
-	if (!(eb && btrfs_buffer_uptodate(eb, parent_transid)) &&
+	if (!(eb && btrfs_buffer_uptodate(eb, parent_transid, 0)) &&
 	    !btrfs_map_block(fs_info, READ, bytenr, &length, &multi, 0,
 			     NULL)) {
 		device = multi->stripes[0].dev;
@@ -367,7 +367,7 @@  struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
 	if (!eb)
 		return ERR_PTR(-ENOMEM);
 
-	if (btrfs_buffer_uptodate(eb, parent_transid))
+	if (btrfs_buffer_uptodate(eb, parent_transid, 0))
 		return eb;
 
 	num_copies = btrfs_num_copies(fs_info, eb->start, eb->len);
@@ -478,7 +478,7 @@  int write_tree_block(struct btrfs_trans_handle *trans,
 		BUG();
 	}
 
-	if (trans && !btrfs_buffer_uptodate(eb, trans->transid))
+	if (trans && !btrfs_buffer_uptodate(eb, trans->transid, 0))
 		BUG();
 
 	btrfs_clear_header_flag(eb, BTRFS_HEADER_FLAG_CSUM_NEW);
@@ -2262,7 +2262,8 @@  void btrfs_mark_buffer_dirty(struct extent_buffer *eb)
 	set_extent_buffer_dirty(eb);
 }
 
-int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid)
+int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
+			  int atomic)
 {
 	int ret;
 
diff --git a/kernel-shared/disk-io.h b/kernel-shared/disk-io.h
index f349b3ef..ed7f9259 100644
--- a/kernel-shared/disk-io.h
+++ b/kernel-shared/disk-io.h
@@ -201,7 +201,8 @@  struct btrfs_root *btrfs_read_fs_root_no_cache(struct btrfs_fs_info *fs_info,
 					       struct btrfs_key *location);
 int btrfs_free_fs_root(struct btrfs_root *root);
 void btrfs_mark_buffer_dirty(struct extent_buffer *buf);
-int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid);
+int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
+			  int atomic);
 int btrfs_set_buffer_uptodate(struct extent_buffer *buf);
 int btrfs_csum_data(struct btrfs_fs_info *fs_info, u16 csum_type, const u8 *data,
 		    u8 *out, size_t len);
diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c
index 5c33fd53..062ff4a7 100644
--- a/kernel-shared/extent-tree.c
+++ b/kernel-shared/extent-tree.c
@@ -1893,7 +1893,7 @@  static int pin_down_bytes(struct btrfs_trans_handle *trans, u64 bytenr,
 	 * reuse anything from the tree log root because
 	 * it has tiny sub-transactions.
 	 */
-	if (btrfs_buffer_uptodate(buf, 0)) {
+	if (btrfs_buffer_uptodate(buf, 0, 0)) {
 		u64 header_owner = btrfs_header_owner(buf);
 		u64 header_transid = btrfs_header_generation(buf);
 		if (header_owner != BTRFS_TREE_LOG_OBJECTID &&