All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Misc cleanups
@ 2020-10-29 12:01 David Sterba
  2020-10-29 12:01 ` [PATCH 1/8] btrfs: use the right number of levels for lockdep keysets David Sterba
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: David Sterba @ 2020-10-29 12:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Clean up:

- lockdep keyset definition
- accessors for various b-tree items
- message updates

David Sterba (8):
  btrfs: use the right number of levels for lockdep keysets
  btrfs: generate lockdep keyset names at compile time
  btrfs: send: use helpers to access root_item::ctransid
  btrfs: check-integrity: use proper helper to access btrfs_header
  btrfs: use root_item helpers for limit and flags in btrfs_create_tree
  btrfs: add set/get accessors for root_item::drop_level
  btrfs: remove unnecessary casts in printk
  btrfs: scrub: update message regarding read-only status

 fs/btrfs/check-integrity.c |  2 +-
 fs/btrfs/ctree.h           |  1 +
 fs/btrfs/disk-io.c         | 66 ++++++++++++++++++++------------------
 fs/btrfs/disk-io.h         |  3 --
 fs/btrfs/extent-tree.c     |  6 ++--
 fs/btrfs/inode.c           |  2 +-
 fs/btrfs/print-tree.c      |  3 +-
 fs/btrfs/ref-verify.c      |  3 +-
 fs/btrfs/relocation.c      | 10 +++---
 fs/btrfs/scrub.c           |  5 +--
 fs/btrfs/send.c            |  6 ++--
 fs/btrfs/super.c           |  2 --
 fs/btrfs/tree-checker.c    |  4 +--
 fs/btrfs/uuid-tree.c       |  3 +-
 14 files changed, 56 insertions(+), 60 deletions(-)

-- 
2.25.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/8] btrfs: use the right number of levels for lockdep keysets
  2020-10-29 12:01 [PATCH 0/8] Misc cleanups David Sterba
@ 2020-10-29 12:01 ` David Sterba
  2020-10-29 12:01 ` [PATCH 2/8] btrfs: generate lockdep keyset names at compile time David Sterba
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2020-10-29 12:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

BTRFS_MAX_LEVEL is 8 and the keyset table is supposed to have a key for
each level, but we'll never have more than 8 levels.  The values passed
to btrfs_set_buffer_lockdep_class are always derived from a valid extent
buffer.  Set the array sizes to the right value.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/disk-io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 601a7ab2adb4..c4052f171f04 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -153,8 +153,8 @@ struct async_submit_bio {
 static struct btrfs_lockdep_keyset {
 	u64			id;		/* root objectid */
 	const char		*name_stem;	/* lock name stem */
-	char			names[BTRFS_MAX_LEVEL + 1][20];
-	struct lock_class_key	keys[BTRFS_MAX_LEVEL + 1];
+	char			names[BTRFS_MAX_LEVEL][20];
+	struct lock_class_key	keys[BTRFS_MAX_LEVEL];
 } btrfs_lockdep_keysets[] = {
 	{ .id = BTRFS_ROOT_TREE_OBJECTID,	.name_stem = "root"	},
 	{ .id = BTRFS_EXTENT_TREE_OBJECTID,	.name_stem = "extent"	},
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/8] btrfs: generate lockdep keyset names at compile time
  2020-10-29 12:01 [PATCH 0/8] Misc cleanups David Sterba
  2020-10-29 12:01 ` [PATCH 1/8] btrfs: use the right number of levels for lockdep keysets David Sterba
@ 2020-10-29 12:01 ` David Sterba
  2020-10-29 12:01 ` [PATCH 3/8] btrfs: send: use helpers to access root_item::ctransid David Sterba
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2020-10-29 12:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The names in btrfs_lockdep_keysets are generated from a simple pattern
using snprintf but we can generate them directly with some macro magic
and remove the helpers.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/disk-io.c | 56 ++++++++++++++++++++++++----------------------
 fs/btrfs/disk-io.h |  3 ---
 fs/btrfs/super.c   |  2 --
 3 files changed, 29 insertions(+), 32 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index c4052f171f04..42465b8728dd 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -150,40 +150,42 @@ struct async_submit_bio {
 #  error
 # endif
 
+#define DEFINE_LEVEL(stem, level)					\
+	.names[level] = "btrfs-" stem "-0" #level,
+
+#define DEFINE_NAME(stem)						\
+	DEFINE_LEVEL(stem, 0)						\
+	DEFINE_LEVEL(stem, 1)						\
+	DEFINE_LEVEL(stem, 2)						\
+	DEFINE_LEVEL(stem, 3)						\
+	DEFINE_LEVEL(stem, 4)						\
+	DEFINE_LEVEL(stem, 5)						\
+	DEFINE_LEVEL(stem, 6)						\
+	DEFINE_LEVEL(stem, 7)
+
 static struct btrfs_lockdep_keyset {
 	u64			id;		/* root objectid */
-	const char		*name_stem;	/* lock name stem */
+	/* Longest entry: btrfs-free-space-00 */
 	char			names[BTRFS_MAX_LEVEL][20];
 	struct lock_class_key	keys[BTRFS_MAX_LEVEL];
 } btrfs_lockdep_keysets[] = {
-	{ .id = BTRFS_ROOT_TREE_OBJECTID,	.name_stem = "root"	},
-	{ .id = BTRFS_EXTENT_TREE_OBJECTID,	.name_stem = "extent"	},
-	{ .id = BTRFS_CHUNK_TREE_OBJECTID,	.name_stem = "chunk"	},
-	{ .id = BTRFS_DEV_TREE_OBJECTID,	.name_stem = "dev"	},
-	{ .id = BTRFS_FS_TREE_OBJECTID,		.name_stem = "fs"	},
-	{ .id = BTRFS_CSUM_TREE_OBJECTID,	.name_stem = "csum"	},
-	{ .id = BTRFS_QUOTA_TREE_OBJECTID,	.name_stem = "quota"	},
-	{ .id = BTRFS_TREE_LOG_OBJECTID,	.name_stem = "log"	},
-	{ .id = BTRFS_TREE_RELOC_OBJECTID,	.name_stem = "treloc"	},
-	{ .id = BTRFS_DATA_RELOC_TREE_OBJECTID,	.name_stem = "dreloc"	},
-	{ .id = BTRFS_UUID_TREE_OBJECTID,	.name_stem = "uuid"	},
-	{ .id = BTRFS_FREE_SPACE_TREE_OBJECTID,	.name_stem = "free-space" },
-	{ .id = 0,				.name_stem = "tree"	},
+	{ .id = BTRFS_ROOT_TREE_OBJECTID,	DEFINE_NAME("root")	},
+	{ .id = BTRFS_EXTENT_TREE_OBJECTID,	DEFINE_NAME("extent")	},
+	{ .id = BTRFS_CHUNK_TREE_OBJECTID,	DEFINE_NAME("chunk")	},
+	{ .id = BTRFS_DEV_TREE_OBJECTID,	DEFINE_NAME("dev")	},
+	{ .id = BTRFS_FS_TREE_OBJECTID,		DEFINE_NAME("fs")	},
+	{ .id = BTRFS_CSUM_TREE_OBJECTID,	DEFINE_NAME("csum")	},
+	{ .id = BTRFS_QUOTA_TREE_OBJECTID,	DEFINE_NAME("quota")	},
+	{ .id = BTRFS_TREE_LOG_OBJECTID,	DEFINE_NAME("log")	},
+	{ .id = BTRFS_TREE_RELOC_OBJECTID,	DEFINE_NAME("treloc")	},
+	{ .id = BTRFS_DATA_RELOC_TREE_OBJECTID,	DEFINE_NAME("dreloc")	},
+	{ .id = BTRFS_UUID_TREE_OBJECTID,	DEFINE_NAME("uuid")	},
+	{ .id = BTRFS_FREE_SPACE_TREE_OBJECTID,	DEFINE_NAME("free-space") },
+	{ .id = 0,				DEFINE_NAME("tree")	},
 };
 
-void __init btrfs_init_lockdep(void)
-{
-	int i, j;
-
-	/* initialize lockdep class names */
-	for (i = 0; i < ARRAY_SIZE(btrfs_lockdep_keysets); i++) {
-		struct btrfs_lockdep_keyset *ks = &btrfs_lockdep_keysets[i];
-
-		for (j = 0; j < ARRAY_SIZE(ks->names); j++)
-			snprintf(ks->names[j], sizeof(ks->names[j]),
-				 "btrfs-%s-%02d", ks->name_stem, j);
-	}
-}
+#undef DEFINE_LEVEL
+#undef DEFINE_NAME
 
 void btrfs_set_buffer_lockdep_class(u64 objectid, struct extent_buffer *eb,
 				    int level)
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 182540bdcea0..d47894260cfa 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -135,12 +135,9 @@ int __init btrfs_end_io_wq_init(void);
 void __cold btrfs_end_io_wq_exit(void);
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
-void btrfs_init_lockdep(void);
 void btrfs_set_buffer_lockdep_class(u64 objectid,
 			            struct extent_buffer *eb, int level);
 #else
-static inline void btrfs_init_lockdep(void)
-{ }
 static inline void btrfs_set_buffer_lockdep_class(u64 objectid,
 					struct extent_buffer *eb, int level)
 {
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 1ffa50bae1dd..9f51b0a22b14 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2572,8 +2572,6 @@ static int __init init_btrfs_fs(void)
 	if (err)
 		goto free_end_io_wq;
 
-	btrfs_init_lockdep();
-
 	btrfs_print_mod_info();
 
 	err = btrfs_run_sanity_tests();
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/8] btrfs: send: use helpers to access root_item::ctransid
  2020-10-29 12:01 [PATCH 0/8] Misc cleanups David Sterba
  2020-10-29 12:01 ` [PATCH 1/8] btrfs: use the right number of levels for lockdep keysets David Sterba
  2020-10-29 12:01 ` [PATCH 2/8] btrfs: generate lockdep keyset names at compile time David Sterba
@ 2020-10-29 12:01 ` David Sterba
  2020-10-29 12:01 ` [PATCH 4/8] btrfs: check-integrity: use proper helper to access btrfs_header David Sterba
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2020-10-29 12:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

We have helpers to access the on-disk item members, use that for
root_item::ctransid instead of raw le64_to_cpu.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/send.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 340c76a12ce1..d719a2755a40 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -2410,7 +2410,7 @@ static int send_subvol_begin(struct send_ctx *sctx)
 			    sctx->send_root->root_item.uuid);
 
 	TLV_PUT_U64(sctx, BTRFS_SEND_A_CTRANSID,
-		    le64_to_cpu(sctx->send_root->root_item.ctransid));
+		    btrfs_root_ctransid(&sctx->send_root->root_item));
 	if (parent_root) {
 		if (!btrfs_is_empty_uuid(parent_root->root_item.received_uuid))
 			TLV_PUT_UUID(sctx, BTRFS_SEND_A_CLONE_UUID,
@@ -2419,7 +2419,7 @@ static int send_subvol_begin(struct send_ctx *sctx)
 			TLV_PUT_UUID(sctx, BTRFS_SEND_A_CLONE_UUID,
 				     parent_root->root_item.uuid);
 		TLV_PUT_U64(sctx, BTRFS_SEND_A_CLONE_CTRANSID,
-			    le64_to_cpu(sctx->parent_root->root_item.ctransid));
+			    btrfs_root_ctransid(&sctx->parent_root->root_item));
 	}
 
 	ret = send_cmd(sctx);
@@ -5101,7 +5101,7 @@ static int send_clone(struct send_ctx *sctx,
 		TLV_PUT_UUID(sctx, BTRFS_SEND_A_CLONE_UUID,
 			     clone_root->root->root_item.uuid);
 	TLV_PUT_U64(sctx, BTRFS_SEND_A_CLONE_CTRANSID,
-		    le64_to_cpu(clone_root->root->root_item.ctransid));
+		    btrfs_root_ctransid(&clone_root->root->root_item));
 	TLV_PUT_PATH(sctx, BTRFS_SEND_A_CLONE_PATH, p);
 	TLV_PUT_U64(sctx, BTRFS_SEND_A_CLONE_OFFSET,
 			clone_root->offset);
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/8] btrfs: check-integrity: use proper helper to access btrfs_header
  2020-10-29 12:01 [PATCH 0/8] Misc cleanups David Sterba
                   ` (2 preceding siblings ...)
  2020-10-29 12:01 ` [PATCH 3/8] btrfs: send: use helpers to access root_item::ctransid David Sterba
@ 2020-10-29 12:01 ` David Sterba
  2020-10-29 12:01 ` [PATCH 5/8] btrfs: use root_item helpers for limit and flags in btrfs_create_tree David Sterba
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2020-10-29 12:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

There's one raw use of le->cpu conversion but we have a helper to do
that for us, so use it.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/check-integrity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 81a8c87a5afb..106874c959a0 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -954,7 +954,7 @@ static noinline_for_stack int btrfsic_process_metablock(
 	sf->prev = NULL;
 
 continue_with_new_stack_frame:
-	sf->block->generation = le64_to_cpu(sf->hdr->generation);
+	sf->block->generation = btrfs_stack_header_generation(sf->hdr);
 	if (0 == sf->hdr->level) {
 		struct btrfs_leaf *const leafhdr =
 		    (struct btrfs_leaf *)sf->hdr;
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/8] btrfs: use root_item helpers for limit and flags in btrfs_create_tree
  2020-10-29 12:01 [PATCH 0/8] Misc cleanups David Sterba
                   ` (3 preceding siblings ...)
  2020-10-29 12:01 ` [PATCH 4/8] btrfs: check-integrity: use proper helper to access btrfs_header David Sterba
@ 2020-10-29 12:01 ` David Sterba
  2020-10-29 12:01 ` [PATCH 6/8] btrfs: add set/get accessors for root_item::drop_level David Sterba
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2020-10-29 12:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

For consistency use the available helpers to set flags and limit.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/disk-io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 42465b8728dd..21f7034945a0 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1166,8 +1166,8 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
 	root->commit_root = btrfs_root_node(root);
 	set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state);
 
-	root->root_item.flags = 0;
-	root->root_item.byte_limit = 0;
+	btrfs_set_root_flags(&root->root_item, 0);
+	btrfs_set_root_limit(&root->root_item, 0);
 	btrfs_set_root_bytenr(&root->root_item, leaf->start);
 	btrfs_set_root_generation(&root->root_item, trans->transid);
 	btrfs_set_root_level(&root->root_item, 0);
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/8] btrfs: add set/get accessors for root_item::drop_level
  2020-10-29 12:01 [PATCH 0/8] Misc cleanups David Sterba
                   ` (4 preceding siblings ...)
  2020-10-29 12:01 ` [PATCH 5/8] btrfs: use root_item helpers for limit and flags in btrfs_create_tree David Sterba
@ 2020-10-29 12:01 ` David Sterba
  2020-10-29 12:01 ` [PATCH 7/8] btrfs: remove unnecessary casts in printk David Sterba
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2020-10-29 12:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The drop_level member is used directly unlike all the other int types in
root_item. Add the definition and use it everywhere. The type is u8 so
there's no conversion necessary and the helpers are properly inlined,
this is for consistency.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ctree.h        |  1 +
 fs/btrfs/disk-io.c      |  2 +-
 fs/btrfs/extent-tree.c  |  6 +++---
 fs/btrfs/inode.c        |  2 +-
 fs/btrfs/relocation.c   | 10 +++++-----
 fs/btrfs/tree-checker.c |  4 ++--
 6 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 8a83bce3225c..09013ab8d4dc 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2085,6 +2085,7 @@ BTRFS_SETGET_FUNCS(disk_root_level, struct btrfs_root_item, level, 8);
 BTRFS_SETGET_STACK_FUNCS(root_generation, struct btrfs_root_item,
 			 generation, 64);
 BTRFS_SETGET_STACK_FUNCS(root_bytenr, struct btrfs_root_item, bytenr, 64);
+BTRFS_SETGET_STACK_FUNCS(root_drop_level, struct btrfs_root_item, drop_level, 8);
 BTRFS_SETGET_STACK_FUNCS(root_level, struct btrfs_root_item, level, 8);
 BTRFS_SETGET_STACK_FUNCS(root_dirid, struct btrfs_root_item, root_dirid, 64);
 BTRFS_SETGET_STACK_FUNCS(root_refs, struct btrfs_root_item, refs, 32);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 21f7034945a0..fd92326980bd 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1179,7 +1179,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
 		generate_random_guid(root->root_item.uuid);
 	else
 		export_guid(root->root_item.uuid, &guid_null);
-	root->root_item.drop_level = 0;
+	btrfs_set_root_drop_level(&root->root_item, 0);
 
 	key.objectid = objectid;
 	key.type = BTRFS_ROOT_ITEM_KEY;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 5fd60b13f4f8..bac1eb17e498 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5496,7 +5496,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
 		memcpy(&wc->update_progress, &key,
 		       sizeof(wc->update_progress));
 
-		level = root_item->drop_level;
+		level = btrfs_root_drop_level(root_item);
 		BUG_ON(level == 0);
 		path->lowest_level = level;
 		ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
@@ -5529,7 +5529,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
 			}
 			BUG_ON(wc->refs[level] == 0);
 
-			if (level == root_item->drop_level)
+			if (level == btrfs_root_drop_level(root_item))
 				break;
 
 			btrfs_tree_unlock(path->nodes[level]);
@@ -5574,7 +5574,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
 		}
 		btrfs_cpu_key_to_disk(&root_item->drop_progress,
 				      &wc->drop_progress);
-		root_item->drop_level = wc->drop_level;
+		btrfs_set_root_drop_level(root_item, wc->drop_level);
 
 		BUG_ON(wc->level == 0);
 		if (btrfs_should_end_transaction(trans) ||
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 1dcccd212809..1e444703afaa 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4003,7 +4003,7 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
 
 	memset(&dest->root_item.drop_progress, 0,
 		sizeof(dest->root_item.drop_progress));
-	dest->root_item.drop_level = 0;
+	btrfs_set_root_drop_level(&dest->root_item, 0);
 	btrfs_set_root_refs(&dest->root_item, 0);
 
 	if (!test_and_set_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &dest->state)) {
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 3602806d71bd..d4d31525cfa9 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -783,7 +783,7 @@ static struct btrfs_root *create_reloc_root(struct btrfs_trans_handle *trans,
 		btrfs_set_root_refs(root_item, 0);
 		memset(&root_item->drop_progress, 0,
 		       sizeof(struct btrfs_disk_key));
-		root_item->drop_level = 0;
+		btrfs_set_root_drop_level(root_item, 0);
 	}
 
 	btrfs_tree_unlock(eb);
@@ -1575,7 +1575,7 @@ static void insert_dirty_subvol(struct btrfs_trans_handle *trans,
 	reloc_root_item = &reloc_root->root_item;
 	memset(&reloc_root_item->drop_progress, 0,
 		sizeof(reloc_root_item->drop_progress));
-	reloc_root_item->drop_level = 0;
+	btrfs_set_root_drop_level(reloc_root_item, 0);
 	btrfs_set_root_refs(reloc_root_item, 0);
 	btrfs_update_reloc_root(trans, root);
 
@@ -1671,7 +1671,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
 	} else {
 		btrfs_disk_key_to_cpu(&key, &root_item->drop_progress);
 
-		level = root_item->drop_level;
+		level = btrfs_root_drop_level(root_item);
 		BUG_ON(level == 0);
 		path->lowest_level = level;
 		ret = btrfs_search_slot(NULL, reloc_root, &key, path, 0, 0);
@@ -1767,7 +1767,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
 		 */
 		btrfs_node_key(path->nodes[level], &root_item->drop_progress,
 			       path->slots[level]);
-		root_item->drop_level = level;
+		btrfs_set_root_drop_level(root_item, level);
 
 		btrfs_end_transaction_throttle(trans);
 		trans = NULL;
@@ -3692,7 +3692,7 @@ static noinline_for_stack int mark_garbage_root(struct btrfs_root *root)
 
 	memset(&root->root_item.drop_progress, 0,
 		sizeof(root->root_item.drop_progress));
-	root->root_item.drop_level = 0;
+	btrfs_set_root_drop_level(&root->root_item, 0);
 	btrfs_set_root_refs(&root->root_item, 0);
 	ret = btrfs_update_root(trans, fs_info->tree_root,
 				&root->root_key, &root->root_item);
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 8784b74f5232..47f9502caf9f 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -1117,10 +1117,10 @@ static int check_root_item(struct extent_buffer *leaf, struct btrfs_key *key,
 			    btrfs_root_level(&ri), BTRFS_MAX_LEVEL - 1);
 		return -EUCLEAN;
 	}
-	if (ri.drop_level >= BTRFS_MAX_LEVEL) {
+	if (btrfs_root_drop_level(&ri) >= BTRFS_MAX_LEVEL) {
 		generic_err(leaf, slot,
 			    "invalid root level, have %u expect [0, %u]",
-			    ri.drop_level, BTRFS_MAX_LEVEL - 1);
+			    btrfs_root_drop_level(&ri), BTRFS_MAX_LEVEL - 1);
 		return -EUCLEAN;
 	}
 
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/8] btrfs: remove unnecessary casts in printk
  2020-10-29 12:01 [PATCH 0/8] Misc cleanups David Sterba
                   ` (5 preceding siblings ...)
  2020-10-29 12:01 ` [PATCH 6/8] btrfs: add set/get accessors for root_item::drop_level David Sterba
@ 2020-10-29 12:01 ` David Sterba
  2020-10-29 12:01 ` [PATCH 8/8] btrfs: scrub: update message regarding read-only status David Sterba
  2020-10-29 18:47 ` [PATCH 0/8] Misc cleanups Josef Bacik
  8 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2020-10-29 12:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Long time ago the explicit casts were necessary for u64 but we don't
need it.  Remove casts where the type matches, leaving only cases that
cast sector_t or loff_t.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/print-tree.c | 3 +--
 fs/btrfs/ref-verify.c | 3 +--
 fs/btrfs/uuid-tree.c  | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index 7695c4783d33..e7ada5ceaa90 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -177,8 +177,7 @@ static void print_uuid_item(struct extent_buffer *l, unsigned long offset,
 		__le64 subvol_id;
 
 		read_extent_buffer(l, &subvol_id, offset, sizeof(subvol_id));
-		pr_info("\t\tsubvol_id %llu\n",
-		       (unsigned long long)le64_to_cpu(subvol_id));
+		pr_info("\t\tsubvol_id %llu\n", le64_to_cpu(subvol_id));
 		item_size -= sizeof(u64);
 		offset += sizeof(u64);
 	}
diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c
index 7f03dbe5b609..31caf4ec1c54 100644
--- a/fs/btrfs/ref-verify.c
+++ b/fs/btrfs/ref-verify.c
@@ -799,8 +799,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
 		if (!be) {
 			btrfs_err(fs_info,
 "trying to do action %d to bytenr %llu num_bytes %llu but there is no existing entry!",
-				  action, (unsigned long long)bytenr,
-				  (unsigned long long)num_bytes);
+				  action, bytenr, num_bytes);
 			dump_ref_action(fs_info, ra);
 			kfree(ref);
 			kfree(ra);
diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
index 28525ad7ff8c..74023c8a783f 100644
--- a/fs/btrfs/uuid-tree.c
+++ b/fs/btrfs/uuid-tree.c
@@ -129,8 +129,7 @@ int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
 	} else {
 		btrfs_warn(fs_info,
 			   "insert uuid item failed %d (0x%016llx, 0x%016llx) type %u!",
-			   ret, (unsigned long long)key.objectid,
-			   (unsigned long long)key.offset, type);
+			   ret, key.objectid, key.offset, type);
 		goto out;
 	}
 
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 8/8] btrfs: scrub: update message regarding read-only status
  2020-10-29 12:01 [PATCH 0/8] Misc cleanups David Sterba
                   ` (6 preceding siblings ...)
  2020-10-29 12:01 ` [PATCH 7/8] btrfs: remove unnecessary casts in printk David Sterba
@ 2020-10-29 12:01 ` David Sterba
  2020-10-29 18:47 ` [PATCH 0/8] Misc cleanups Josef Bacik
  8 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2020-10-29 12:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Based on user feedback update the message printed when scrub fails to
start due to write requirements. To make a distinction add a device id
to the messages.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/scrub.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 54a4f34d4c1c..04351b55dd14 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -3870,8 +3870,9 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
 	if (!is_dev_replace && !readonly &&
 	    !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state)) {
 		mutex_unlock(&fs_info->fs_devices->device_list_mutex);
-		btrfs_err_in_rcu(fs_info, "scrub: device %s is not writable",
-				rcu_str_deref(dev->name));
+		btrfs_err_in_rcu(fs_info,
+			"scrub on devid %llu: filesystem on %s is not writable",
+				 devid, rcu_str_deref(dev->name));
 		ret = -EROFS;
 		goto out;
 	}
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/8] Misc cleanups
  2020-10-29 12:01 [PATCH 0/8] Misc cleanups David Sterba
                   ` (7 preceding siblings ...)
  2020-10-29 12:01 ` [PATCH 8/8] btrfs: scrub: update message regarding read-only status David Sterba
@ 2020-10-29 18:47 ` Josef Bacik
  8 siblings, 0 replies; 10+ messages in thread
From: Josef Bacik @ 2020-10-29 18:47 UTC (permalink / raw)
  To: David Sterba, linux-btrfs

On 10/29/20 8:01 AM, David Sterba wrote:
> Clean up:
> 
> - lockdep keyset definition
> - accessors for various b-tree items
> - message updates
> 

You can add

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

to the series, thanks,

Josef

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-10-29 18:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 12:01 [PATCH 0/8] Misc cleanups David Sterba
2020-10-29 12:01 ` [PATCH 1/8] btrfs: use the right number of levels for lockdep keysets David Sterba
2020-10-29 12:01 ` [PATCH 2/8] btrfs: generate lockdep keyset names at compile time David Sterba
2020-10-29 12:01 ` [PATCH 3/8] btrfs: send: use helpers to access root_item::ctransid David Sterba
2020-10-29 12:01 ` [PATCH 4/8] btrfs: check-integrity: use proper helper to access btrfs_header David Sterba
2020-10-29 12:01 ` [PATCH 5/8] btrfs: use root_item helpers for limit and flags in btrfs_create_tree David Sterba
2020-10-29 12:01 ` [PATCH 6/8] btrfs: add set/get accessors for root_item::drop_level David Sterba
2020-10-29 12:01 ` [PATCH 7/8] btrfs: remove unnecessary casts in printk David Sterba
2020-10-29 12:01 ` [PATCH 8/8] btrfs: scrub: update message regarding read-only status David Sterba
2020-10-29 18:47 ` [PATCH 0/8] Misc cleanups Josef Bacik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.