* [PATCH 00/11] Clean up of RCU in message helpers
@ 2025-06-09 17:09 David Sterba
2025-06-09 17:09 ` [PATCH 01/11] btrfs: open code rcu_string_free() and remove it David Sterba
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Add the RCU protection to the plain message helpers, remove the
specialized versions, plus some related cleanups.
David Sterba (11):
btrfs: open code rcu_string_free() and remove it
btrfs: remove unused rcu-string printk helpers
btrfs: remove unused levels of message helpers
btrfs: switch all message helpers to be RCU safe
btrfs: switch RCU helper versions to btrfs_err()
btrfs: switch RCU helper versions to btrfs_warn()
btrfs: switch RCU helper versions to btrfs_info()
btrfs: switch RCU helper versions to btrfs_debug()
btrfs: remove remaining unused message helpers
btrfs: simplify debug print helpers without enabled printk
btrf: merge btrfs_printk_ratelimited() and it's only caller
fs/btrfs/bio.c | 4 +-
fs/btrfs/dev-replace.c | 14 +++---
fs/btrfs/disk-io.c | 2 +-
fs/btrfs/extent-tree.c | 2 +-
fs/btrfs/ioctl.c | 2 +-
fs/btrfs/messages.h | 107 +++++++----------------------------------
fs/btrfs/rcu-string.h | 18 -------
fs/btrfs/scrub.c | 18 +++----
fs/btrfs/volumes.c | 21 ++++----
fs/btrfs/zoned.c | 26 +++++-----
10 files changed, 63 insertions(+), 151 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 01/11] btrfs: open code rcu_string_free() and remove it
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-09 17:09 ` [PATCH 02/11] btrfs: remove unused rcu-string printk helpers David Sterba
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The helper is trivial and we can simply use kfree_rcu() if needed. In
our case it's just one place where we rename a device in
device_list_add() and the old name can still be used until the end of
the RCU grace period. The other case is freeing a device and there
nothing should reach the device, so we can use plain kfree().
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/rcu-string.h | 6 ------
fs/btrfs/volumes.c | 5 +++--
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/rcu-string.h b/fs/btrfs/rcu-string.h
index 1c2d7cb1fe6f63..7f35cf75b50ff3 100644
--- a/fs/btrfs/rcu-string.h
+++ b/fs/btrfs/rcu-string.h
@@ -32,12 +32,6 @@ static inline struct rcu_string *rcu_string_strdup(const char *src, gfp_t mask)
return ret;
}
-static inline void rcu_string_free(struct rcu_string *str)
-{
- if (str)
- kfree_rcu(str, rcu);
-}
-
#define printk_in_rcu(fmt, ...) do { \
rcu_read_lock(); \
printk(fmt, __VA_ARGS__); \
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ff80ac2ab53377..70821a46bfb358 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -403,7 +403,8 @@ static struct btrfs_fs_devices *alloc_fs_devices(const u8 *fsid)
static void btrfs_free_device(struct btrfs_device *device)
{
WARN_ON(!list_empty(&device->post_commit_list));
- rcu_string_free(device->name);
+ /* No need to call kfree_rcu(), nothing is reading the device name. */
+ kfree(device->name);
btrfs_extent_io_tree_release(&device->alloc_state);
btrfs_destroy_dev_zone_info(device);
kfree(device);
@@ -962,7 +963,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,
mutex_unlock(&fs_devices->device_list_mutex);
return ERR_PTR(-ENOMEM);
}
- rcu_string_free(device->name);
+ kfree_rcu(device->name, rcu);
rcu_assign_pointer(device->name, name);
if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state)) {
fs_devices->missing_devices--;
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 02/11] btrfs: remove unused rcu-string printk helpers
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
2025-06-09 17:09 ` [PATCH 01/11] btrfs: open code rcu_string_free() and remove it David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-09 17:09 ` [PATCH 03/11] btrfs: remove unused levels of message helpers David Sterba
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The RCU-string API has never taken off and we don't use the printk
helpers provided as we do the protection in our helpers. Remove the "in
RCU" wrappers.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/messages.h | 4 ++--
fs/btrfs/rcu-string.h | 12 ------------
2 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index 6abf81bb00c2fe..12d798802a010f 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -53,7 +53,7 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
btrfs_printk(fs_info, KERN_INFO fmt, ##args)
/*
- * Wrappers that use printk_in_rcu
+ * Wrappers that use printk in RCU
*/
#define btrfs_emerg_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_EMERG fmt, ##args)
@@ -71,7 +71,7 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args)
/*
- * Wrappers that use a ratelimited printk_in_rcu
+ * Wrappers that use a ratelimited printk in RCU
*/
#define btrfs_emerg_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_EMERG fmt, ##args)
diff --git a/fs/btrfs/rcu-string.h b/fs/btrfs/rcu-string.h
index 7f35cf75b50ff3..70b1e19b50e666 100644
--- a/fs/btrfs/rcu-string.h
+++ b/fs/btrfs/rcu-string.h
@@ -32,18 +32,6 @@ static inline struct rcu_string *rcu_string_strdup(const char *src, gfp_t mask)
return ret;
}
-#define printk_in_rcu(fmt, ...) do { \
- rcu_read_lock(); \
- printk(fmt, __VA_ARGS__); \
- rcu_read_unlock(); \
-} while (0)
-
-#define printk_ratelimited_in_rcu(fmt, ...) do { \
- rcu_read_lock(); \
- printk_ratelimited(fmt, __VA_ARGS__); \
- rcu_read_unlock(); \
-} while (0)
-
#define rcu_str_deref(rcu_str) ({ \
struct rcu_string *__str = rcu_dereference(rcu_str); \
__str->str; \
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 03/11] btrfs: remove unused levels of message helpers
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
2025-06-09 17:09 ` [PATCH 01/11] btrfs: open code rcu_string_free() and remove it David Sterba
2025-06-09 17:09 ` [PATCH 02/11] btrfs: remove unused rcu-string printk helpers David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-09 17:09 ` [PATCH 04/11] btrfs: switch all message helpers to be RCU safe David Sterba
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
We're using the following levels: crit, err, warn, info, debug. This
covers our needs and further specializations is not needed, so let's
remove emerg, alert and notice.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/messages.h | 24 ------------------------
1 file changed, 24 deletions(-)
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index 12d798802a010f..f6b3989939b56f 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -37,72 +37,48 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
btrfs_no_printk(fs_info, fmt, ##args)
#endif
-#define btrfs_emerg(fs_info, fmt, args...) \
- btrfs_printk(fs_info, KERN_EMERG fmt, ##args)
-#define btrfs_alert(fs_info, fmt, args...) \
- btrfs_printk(fs_info, KERN_ALERT fmt, ##args)
#define btrfs_crit(fs_info, fmt, args...) \
btrfs_printk(fs_info, KERN_CRIT fmt, ##args)
#define btrfs_err(fs_info, fmt, args...) \
btrfs_printk(fs_info, KERN_ERR fmt, ##args)
#define btrfs_warn(fs_info, fmt, args...) \
btrfs_printk(fs_info, KERN_WARNING fmt, ##args)
-#define btrfs_notice(fs_info, fmt, args...) \
- btrfs_printk(fs_info, KERN_NOTICE fmt, ##args)
#define btrfs_info(fs_info, fmt, args...) \
btrfs_printk(fs_info, KERN_INFO fmt, ##args)
/*
* Wrappers that use printk in RCU
*/
-#define btrfs_emerg_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_in_rcu(fs_info, KERN_EMERG fmt, ##args)
-#define btrfs_alert_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_in_rcu(fs_info, KERN_ALERT fmt, ##args)
#define btrfs_crit_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_CRIT fmt, ##args)
#define btrfs_err_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_ERR fmt, ##args)
#define btrfs_warn_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_WARNING fmt, ##args)
-#define btrfs_notice_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_in_rcu(fs_info, KERN_NOTICE fmt, ##args)
#define btrfs_info_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args)
/*
* Wrappers that use a ratelimited printk in RCU
*/
-#define btrfs_emerg_rl_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_rl_in_rcu(fs_info, KERN_EMERG fmt, ##args)
-#define btrfs_alert_rl_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_rl_in_rcu(fs_info, KERN_ALERT fmt, ##args)
#define btrfs_crit_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_CRIT fmt, ##args)
#define btrfs_err_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_ERR fmt, ##args)
#define btrfs_warn_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_WARNING fmt, ##args)
-#define btrfs_notice_rl_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_rl_in_rcu(fs_info, KERN_NOTICE fmt, ##args)
#define btrfs_info_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_INFO fmt, ##args)
/*
* Wrappers that use a ratelimited printk
*/
-#define btrfs_emerg_rl(fs_info, fmt, args...) \
- btrfs_printk_ratelimited(fs_info, KERN_EMERG fmt, ##args)
-#define btrfs_alert_rl(fs_info, fmt, args...) \
- btrfs_printk_ratelimited(fs_info, KERN_ALERT fmt, ##args)
#define btrfs_crit_rl(fs_info, fmt, args...) \
btrfs_printk_ratelimited(fs_info, KERN_CRIT fmt, ##args)
#define btrfs_err_rl(fs_info, fmt, args...) \
btrfs_printk_ratelimited(fs_info, KERN_ERR fmt, ##args)
#define btrfs_warn_rl(fs_info, fmt, args...) \
btrfs_printk_ratelimited(fs_info, KERN_WARNING fmt, ##args)
-#define btrfs_notice_rl(fs_info, fmt, args...) \
- btrfs_printk_ratelimited(fs_info, KERN_NOTICE fmt, ##args)
#define btrfs_info_rl(fs_info, fmt, args...) \
btrfs_printk_ratelimited(fs_info, KERN_INFO fmt, ##args)
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 04/11] btrfs: switch all message helpers to be RCU safe
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
` (2 preceding siblings ...)
2025-06-09 17:09 ` [PATCH 03/11] btrfs: remove unused levels of message helpers David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-09 17:09 ` [PATCH 05/11] btrfs: switch RCU helper versions to btrfs_err() David Sterba
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
We have two versions of message helpers, one that provides RCU
protection around the call in case we need to dereference device name.
As messages are not performance critical we can set up the RCU
protection for all of them and drop the distinction for those where
device name is needed. This will lead to further simplifications.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/messages.h | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index f6b3989939b56f..fe9a92da6b1439 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -37,14 +37,17 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
btrfs_no_printk(fs_info, fmt, ##args)
#endif
+/*
+ * Print a message with filesystem info, enclosed in RCU protection.
+ */
#define btrfs_crit(fs_info, fmt, args...) \
- btrfs_printk(fs_info, KERN_CRIT fmt, ##args)
+ btrfs_printk_in_rcu(fs_info, KERN_CRIT fmt, ##args)
#define btrfs_err(fs_info, fmt, args...) \
- btrfs_printk(fs_info, KERN_ERR fmt, ##args)
+ btrfs_printk_in_rcu(fs_info, KERN_ERR fmt, ##args)
#define btrfs_warn(fs_info, fmt, args...) \
- btrfs_printk(fs_info, KERN_WARNING fmt, ##args)
+ btrfs_printk_in_rcu(fs_info, KERN_WARNING fmt, ##args)
#define btrfs_info(fs_info, fmt, args...) \
- btrfs_printk(fs_info, KERN_INFO fmt, ##args)
+ btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args)
/*
* Wrappers that use printk in RCU
@@ -74,17 +77,17 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
* Wrappers that use a ratelimited printk
*/
#define btrfs_crit_rl(fs_info, fmt, args...) \
- btrfs_printk_ratelimited(fs_info, KERN_CRIT fmt, ##args)
+ btrfs_printk_rl_in_rcu(fs_info, KERN_CRIT fmt, ##args)
#define btrfs_err_rl(fs_info, fmt, args...) \
- btrfs_printk_ratelimited(fs_info, KERN_ERR fmt, ##args)
+ btrfs_printk_rl_in_rcu(fs_info, KERN_ERR fmt, ##args)
#define btrfs_warn_rl(fs_info, fmt, args...) \
- btrfs_printk_ratelimited(fs_info, KERN_WARNING fmt, ##args)
+ btrfs_printk_rl_in_rcu(fs_info, KERN_WARNING fmt, ##args)
#define btrfs_info_rl(fs_info, fmt, args...) \
- btrfs_printk_ratelimited(fs_info, KERN_INFO fmt, ##args)
+ btrfs_printk_rl_in_rcu(fs_info, KERN_INFO fmt, ##args)
#if defined(CONFIG_DYNAMIC_DEBUG)
#define btrfs_debug(fs_info, fmt, args...) \
- _dynamic_func_call_no_desc(fmt, btrfs_printk, \
+ _dynamic_func_call_no_desc(fmt, btrfs_printk_in_rcu, \
fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
_dynamic_func_call_no_desc(fmt, btrfs_printk_in_rcu, \
@@ -93,26 +96,26 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
_dynamic_func_call_no_desc(fmt, btrfs_printk_rl_in_rcu, \
fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_rl(fs_info, fmt, args...) \
- _dynamic_func_call_no_desc(fmt, btrfs_printk_ratelimited, \
+ _dynamic_func_call_no_desc(fmt, btrfs_printk_rl_in_rcu, \
fs_info, KERN_DEBUG fmt, ##args)
#elif defined(DEBUG)
#define btrfs_debug(fs_info, fmt, args...) \
- btrfs_printk(fs_info, KERN_DEBUG fmt, ##args)
+ btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_rl(fs_info, fmt, args...) \
- btrfs_printk_ratelimited(fs_info, KERN_DEBUG fmt, ##args)
+ btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#else
#define btrfs_debug(fs_info, fmt, args...) \
- btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
+ btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_rl(fs_info, fmt, args...) \
- btrfs_no_printk(fs_info, KERN_DEBUG fmt, ##args)
+ btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#endif
#define btrfs_printk_in_rcu(fs_info, fmt, args...) \
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 05/11] btrfs: switch RCU helper versions to btrfs_err()
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
` (3 preceding siblings ...)
2025-06-09 17:09 ` [PATCH 04/11] btrfs: switch all message helpers to be RCU safe David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-09 17:09 ` [PATCH 06/11] btrfs: switch RCU helper versions to btrfs_warn() David Sterba
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The RCU protection is now done in the plain helpers, we can remove the
"_in_rcu" and "_rl_in_rcu".
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/dev-replace.c | 2 +-
fs/btrfs/messages.h | 4 ----
fs/btrfs/scrub.c | 10 +++++-----
fs/btrfs/volumes.c | 2 +-
fs/btrfs/zoned.c | 22 +++++++++++-----------
5 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 2decb9fff44519..0e9acedd7bb467 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -943,7 +943,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
tgt_device);
} else {
if (scrub_ret != -ECANCELED)
- btrfs_err_in_rcu(fs_info,
+ btrfs_err(fs_info,
"btrfs_scrub_dev(%s, %llu, %s) failed %d",
btrfs_dev_name(src_device),
src_device->devid,
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index fe9a92da6b1439..f9f68a2a769792 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -54,8 +54,6 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
*/
#define btrfs_crit_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_CRIT fmt, ##args)
-#define btrfs_err_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_in_rcu(fs_info, KERN_ERR fmt, ##args)
#define btrfs_warn_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_WARNING fmt, ##args)
#define btrfs_info_in_rcu(fs_info, fmt, args...) \
@@ -66,8 +64,6 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
*/
#define btrfs_crit_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_CRIT fmt, ##args)
-#define btrfs_err_rl_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_rl_in_rcu(fs_info, KERN_ERR fmt, ##args)
#define btrfs_warn_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_WARNING fmt, ##args)
#define btrfs_info_rl_in_rcu(fs_info, fmt, args...) \
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index e8fa2775456376..04c43f05afc9fa 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1045,12 +1045,12 @@ static void scrub_stripe_report_errors(struct scrub_ctx *sctx,
*/
if (repaired) {
if (dev) {
- btrfs_err_rl_in_rcu(fs_info,
+ btrfs_err_rl(fs_info,
"scrub: fixed up error at logical %llu on dev %s physical %llu",
stripe->logical, btrfs_dev_name(dev),
physical);
} else {
- btrfs_err_rl_in_rcu(fs_info,
+ btrfs_err_rl(fs_info,
"scrub: fixed up error at logical %llu on mirror %u",
stripe->logical, stripe->mirror_num);
}
@@ -1059,12 +1059,12 @@ static void scrub_stripe_report_errors(struct scrub_ctx *sctx,
/* The remaining are all for unrepaired. */
if (dev) {
- btrfs_err_rl_in_rcu(fs_info,
+ btrfs_err_rl(fs_info,
"scrub: unable to fixup (regular) error at logical %llu on dev %s physical %llu",
stripe->logical, btrfs_dev_name(dev),
physical);
} else {
- btrfs_err_rl_in_rcu(fs_info,
+ btrfs_err_rl(fs_info,
"scrub: unable to fixup (regular) error at logical %llu on mirror %u",
stripe->logical, stripe->mirror_num);
}
@@ -3057,7 +3057,7 @@ 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,
+ btrfs_err(fs_info,
"scrub: devid %llu: filesystem on %s is not writable",
devid, btrfs_dev_name(dev));
ret = -EROFS;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 70821a46bfb358..9c5625a06e0b12 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7796,7 +7796,7 @@ void btrfs_dev_stat_inc_and_print(struct btrfs_device *dev, int index)
if (!dev->dev_stats_valid)
return;
- btrfs_err_rl_in_rcu(dev->fs_info,
+ btrfs_err_rl(dev->fs_info,
"bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u",
btrfs_dev_name(dev),
btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS),
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index d416df1e0d2c92..18848a9756d142 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -263,7 +263,7 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos,
ret = blkdev_report_zones(device->bdev, pos >> SECTOR_SHIFT, *nr_zones,
copy_zone_info_cb, zones);
if (ret < 0) {
- btrfs_err_in_rcu(device->fs_info,
+ btrfs_err(device->fs_info,
"zoned: failed to read zone %llu on %s (devid %llu)",
pos, rcu_str_deref(device->name),
device->devid);
@@ -395,14 +395,14 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
/* We reject devices with a zone size larger than 8GB */
if (zone_info->zone_size > BTRFS_MAX_ZONE_SIZE) {
- btrfs_err_in_rcu(fs_info,
+ btrfs_err(fs_info,
"zoned: %s: zone size %llu larger than supported maximum %llu",
rcu_str_deref(device->name),
zone_info->zone_size, BTRFS_MAX_ZONE_SIZE);
ret = -EINVAL;
goto out;
} else if (zone_info->zone_size < BTRFS_MIN_ZONE_SIZE) {
- btrfs_err_in_rcu(fs_info,
+ btrfs_err(fs_info,
"zoned: %s: zone size %llu smaller than supported minimum %u",
rcu_str_deref(device->name),
zone_info->zone_size, BTRFS_MIN_ZONE_SIZE);
@@ -418,7 +418,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
max_active_zones = bdev_max_active_zones(bdev);
if (max_active_zones && max_active_zones < BTRFS_MIN_ACTIVE_ZONES) {
- btrfs_err_in_rcu(fs_info,
+ btrfs_err(fs_info,
"zoned: %s: max active zones %u is too small, need at least %u active zones",
rcu_str_deref(device->name), max_active_zones,
BTRFS_MIN_ACTIVE_ZONES);
@@ -460,7 +460,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
zone_info->zone_cache = vcalloc(zone_info->nr_zones,
sizeof(struct blk_zone));
if (!zone_info->zone_cache) {
- btrfs_err_in_rcu(device->fs_info,
+ btrfs_err(device->fs_info,
"zoned: failed to allocate zone cache for %s",
rcu_str_deref(device->name));
ret = -ENOMEM;
@@ -497,7 +497,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
}
if (nreported != zone_info->nr_zones) {
- btrfs_err_in_rcu(device->fs_info,
+ btrfs_err(device->fs_info,
"inconsistent number of zones on %s (%u/%u)",
rcu_str_deref(device->name), nreported,
zone_info->nr_zones);
@@ -507,7 +507,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
if (max_active_zones) {
if (nactive > max_active_zones) {
- btrfs_err_in_rcu(device->fs_info,
+ btrfs_err(device->fs_info,
"zoned: %u active zones on %s exceeds max_active_zones %u",
nactive, rcu_str_deref(device->name),
max_active_zones);
@@ -538,7 +538,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
goto out;
if (nr_zones != BTRFS_NR_SB_LOG_ZONES) {
- btrfs_err_in_rcu(device->fs_info,
+ btrfs_err(device->fs_info,
"zoned: failed to read super block log zone info at devid %llu zone %u",
device->devid, sb_zone);
ret = -EUCLEAN;
@@ -556,7 +556,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
ret = sb_write_pointer(device->bdev,
&zone_info->sb_zones[sb_pos], &sb_wp);
if (ret != -ENOENT && ret) {
- btrfs_err_in_rcu(device->fs_info,
+ btrfs_err(device->fs_info,
"zoned: super block log zone corrupted devid %llu zone %u",
device->devid, sb_zone);
ret = -EUCLEAN;
@@ -1345,7 +1345,7 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx,
}
if (zone.type == BLK_ZONE_TYPE_CONVENTIONAL) {
- btrfs_err_in_rcu(fs_info,
+ btrfs_err(fs_info,
"zoned: unexpected conventional zone %llu on device %s (devid %llu)",
zone.start << SECTOR_SHIFT, rcu_str_deref(device->name),
device->devid);
@@ -1358,7 +1358,7 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx,
switch (zone.cond) {
case BLK_ZONE_COND_OFFLINE:
case BLK_ZONE_COND_READONLY:
- btrfs_err_in_rcu(fs_info,
+ btrfs_err(fs_info,
"zoned: offline/readonly zone %llu on device %s (devid %llu)",
(info->physical >> device->zone_info->zone_size_shift),
rcu_str_deref(device->name), device->devid);
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 06/11] btrfs: switch RCU helper versions to btrfs_warn()
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
` (4 preceding siblings ...)
2025-06-09 17:09 ` [PATCH 05/11] btrfs: switch RCU helper versions to btrfs_err() David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-09 17:09 ` [PATCH 07/11] btrfs: switch RCU helper versions to btrfs_info() David Sterba
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The RCU protection is now done in the plain helpers, we can remove the
"_in_rcu" and "_rl_in_rcu".
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/dev-replace.c | 2 +-
fs/btrfs/disk-io.c | 2 +-
fs/btrfs/extent-tree.c | 2 +-
fs/btrfs/messages.h | 4 ----
fs/btrfs/scrub.c | 8 ++++----
fs/btrfs/volumes.c | 10 +++++-----
fs/btrfs/zoned.c | 2 +-
7 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 0e9acedd7bb467..f7f024a956cdda 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -600,7 +600,7 @@ static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
return PTR_ERR(src_device);
if (btrfs_pinned_by_swapfile(fs_info, src_device)) {
- btrfs_warn_in_rcu(fs_info,
+ btrfs_warn(fs_info,
"cannot replace device %s (devid %llu) due to active swapfile",
btrfs_dev_name(src_device), src_device->devid);
return -ETXTBSY;
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index f48f9d924a6216..2b5ec6d349356c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3695,7 +3695,7 @@ static void btrfs_end_super_write(struct bio *bio)
bio_for_each_folio_all(fi, bio) {
if (bio->bi_status) {
- btrfs_warn_rl_in_rcu(device->fs_info,
+ btrfs_warn_rl(device->fs_info,
"lost super block write due to IO error on %s (%d)",
btrfs_dev_name(device),
blk_status_to_errno(bio->bi_status));
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1c3bfb9ff025ef..013a095290bd65 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6479,7 +6479,7 @@ static int btrfs_trim_free_extents(struct btrfs_device *device, u64 *trimmed,
/* Check if there are any CHUNK_* bits left */
if (start > device->total_bytes) {
DEBUG_WARN();
- btrfs_warn_in_rcu(fs_info,
+ btrfs_warn(fs_info,
"ignoring attempt to trim beyond device size: offset %llu length %llu device %s device size %llu",
start, end - start + 1,
btrfs_dev_name(device),
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index f9f68a2a769792..0520081a66f0f6 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -54,8 +54,6 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
*/
#define btrfs_crit_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_CRIT fmt, ##args)
-#define btrfs_warn_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_in_rcu(fs_info, KERN_WARNING fmt, ##args)
#define btrfs_info_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args)
@@ -64,8 +62,6 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
*/
#define btrfs_crit_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_CRIT fmt, ##args)
-#define btrfs_warn_rl_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_rl_in_rcu(fs_info, KERN_WARNING fmt, ##args)
#define btrfs_info_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_INFO fmt, ##args)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 04c43f05afc9fa..6776e6ab8d1080 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -556,7 +556,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
* hold all of the paths here
*/
for (i = 0; i < ipath->fspath->elem_cnt; ++i)
- btrfs_warn_in_rcu(fs_info,
+ btrfs_warn(fs_info,
"scrub: %s at logical %llu on dev %s, physical %llu root %llu inode %llu offset %llu length %u links %u (path: %s)",
swarn->errstr, swarn->logical,
btrfs_dev_name(swarn->dev),
@@ -570,7 +570,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
return 0;
err:
- btrfs_warn_in_rcu(fs_info,
+ btrfs_warn(fs_info,
"scrub: %s at logical %llu on dev %s, physical %llu root %llu inode %llu offset %llu: path resolving failed with ret=%d",
swarn->errstr, swarn->logical,
btrfs_dev_name(swarn->dev),
@@ -596,7 +596,7 @@ static void scrub_print_common_warning(const char *errstr, struct btrfs_device *
/* Super block error, no need to search extent tree. */
if (is_super) {
- btrfs_warn_in_rcu(fs_info, "scrub: %s on device %s, physical %llu",
+ btrfs_warn(fs_info, "scrub: %s on device %s, physical %llu",
errstr, btrfs_dev_name(dev), physical);
return;
}
@@ -637,7 +637,7 @@ static void scrub_print_common_warning(const char *errstr, struct btrfs_device *
}
if (ret > 0)
break;
- btrfs_warn_in_rcu(fs_info,
+ btrfs_warn(fs_info,
"scrub: %s at logical %llu on dev %s, physical %llu: metadata %s (level %d) in tree %llu",
errstr, swarn.logical, btrfs_dev_name(dev),
swarn.physical, (ref_level ? "node" : "leaf"),
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 9c5625a06e0b12..002f4505ef2e7e 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -944,7 +944,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,
if (device->bdev) {
if (device->devt != path_devt) {
mutex_unlock(&fs_devices->device_list_mutex);
- btrfs_warn_in_rcu(NULL,
+ btrfs_warn(NULL,
"duplicate device %s devid %llu generation %llu scanned by %s (%d)",
path, devid, found_transid,
current->comm,
@@ -2205,7 +2205,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
}
if (btrfs_pinned_by_swapfile(fs_info, device)) {
- btrfs_warn_in_rcu(fs_info,
+ btrfs_warn(fs_info,
"cannot remove device %s (devid %llu) due to active swapfile",
btrfs_dev_name(device), device->devid);
return -ETXTBSY;
@@ -7708,7 +7708,7 @@ static int update_dev_stat_item(struct btrfs_trans_handle *trans,
return -ENOMEM;
ret = btrfs_search_slot(trans, dev_root, &key, path, -1, 1);
if (ret < 0) {
- btrfs_warn_in_rcu(fs_info,
+ btrfs_warn(fs_info,
"error %d while searching for dev_stats item for device %s",
ret, btrfs_dev_name(device));
goto out;
@@ -7719,7 +7719,7 @@ static int update_dev_stat_item(struct btrfs_trans_handle *trans,
/* need to delete old one and insert a new one */
ret = btrfs_del_item(trans, dev_root, path);
if (ret != 0) {
- btrfs_warn_in_rcu(fs_info,
+ btrfs_warn(fs_info,
"delete too small dev_stats item for device %s failed %d",
btrfs_dev_name(device), ret);
goto out;
@@ -7733,7 +7733,7 @@ static int update_dev_stat_item(struct btrfs_trans_handle *trans,
ret = btrfs_insert_empty_item(trans, dev_root, path,
&key, sizeof(*ptr));
if (ret < 0) {
- btrfs_warn_in_rcu(fs_info,
+ btrfs_warn(fs_info,
"insert dev_stats item for device %s failed %d",
btrfs_dev_name(device), ret);
goto out;
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 18848a9756d142..9bacc8c32b40de 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1182,7 +1182,7 @@ int btrfs_ensure_empty_zones(struct btrfs_device *device, u64 start, u64 size)
continue;
/* Free regions should be empty */
- btrfs_warn_in_rcu(
+ btrfs_warn(
device->fs_info,
"zoned: resetting device %s (devid %llu) zone %llu for allocation",
rcu_str_deref(device->name), device->devid, pos >> shift);
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 07/11] btrfs: switch RCU helper versions to btrfs_info()
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
` (5 preceding siblings ...)
2025-06-09 17:09 ` [PATCH 06/11] btrfs: switch RCU helper versions to btrfs_warn() David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-09 17:09 ` [PATCH 08/11] btrfs: switch RCU helper versions to btrfs_debug() David Sterba
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The RCU protection is now done in the plain helpers, we can remove the
"_in_rcu" and "_rl_in_rcu".
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/bio.c | 2 +-
fs/btrfs/dev-replace.c | 10 +++++-----
fs/btrfs/ioctl.c | 2 +-
fs/btrfs/messages.h | 4 ----
fs/btrfs/volumes.c | 4 ++--
fs/btrfs/zoned.c | 2 +-
6 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 00d274ed2b1fa2..aa970fd41c4b78 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -839,7 +839,7 @@ int btrfs_repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
goto out_bio_uninit;
}
- btrfs_info_rl_in_rcu(fs_info,
+ btrfs_info_rl(fs_info,
"read error corrected: ino %llu off %llu (dev %s sector %llu)",
ino, start, btrfs_dev_name(smap.dev),
smap.physical >> SECTOR_SHIFT);
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index f7f024a956cdda..bd276179918172 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -647,7 +647,7 @@ static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
dev_replace->srcdev = src_device;
dev_replace->tgtdev = tgt_device;
- btrfs_info_in_rcu(fs_info,
+ btrfs_info(fs_info,
"dev_replace from %s (devid %llu) to %s started",
btrfs_dev_name(src_device),
src_device->devid,
@@ -961,7 +961,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
return scrub_ret;
}
- btrfs_info_in_rcu(fs_info,
+ btrfs_info(fs_info,
"dev_replace from %s (devid %llu) to %s finished",
btrfs_dev_name(src_device),
src_device->devid,
@@ -1109,7 +1109,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
* btrfs_dev_replace_finishing() will handle the
* cleanup part
*/
- btrfs_info_in_rcu(fs_info,
+ btrfs_info(fs_info,
"dev_replace from %s (devid %llu) to %s canceled",
btrfs_dev_name(src_device), src_device->devid,
btrfs_dev_name(tgt_device));
@@ -1143,7 +1143,7 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
ret = btrfs_commit_transaction(trans);
WARN_ON(ret);
- btrfs_info_in_rcu(fs_info,
+ btrfs_info(fs_info,
"suspended dev_replace from %s (devid %llu) to %s canceled",
btrfs_dev_name(src_device), src_device->devid,
btrfs_dev_name(tgt_device));
@@ -1247,7 +1247,7 @@ static int btrfs_dev_replace_kthread(void *data)
progress = btrfs_dev_replace_progress(fs_info);
progress = div_u64(progress, 10);
- btrfs_info_in_rcu(fs_info,
+ btrfs_info(fs_info,
"continuing dev_replace from %s (devid %llu) to target %s @%u%%",
btrfs_dev_name(dev_replace->srcdev),
dev_replace->srcdev->devid,
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 7cc89f6f37ae2d..00047367655968 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1169,7 +1169,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
} /* equal, nothing need to do */
if (ret == 0 && new_size != old_size)
- btrfs_info_in_rcu(fs_info,
+ btrfs_info(fs_info,
"resize device %s (devid %llu) from %llu to %llu",
btrfs_dev_name(device), device->devid,
old_size, new_size);
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index 0520081a66f0f6..9d5330ba02534f 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -54,16 +54,12 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
*/
#define btrfs_crit_in_rcu(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_CRIT fmt, ##args)
-#define btrfs_info_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args)
/*
* Wrappers that use a ratelimited printk in RCU
*/
#define btrfs_crit_rl_in_rcu(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_CRIT fmt, ##args)
-#define btrfs_info_rl_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_rl_in_rcu(fs_info, KERN_INFO fmt, ##args)
/*
* Wrappers that use a ratelimited printk
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 002f4505ef2e7e..134b7754347ef3 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -951,7 +951,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,
task_pid_nr(current));
return ERR_PTR(-EEXIST);
}
- btrfs_info_in_rcu(NULL,
+ btrfs_info(NULL,
"devid %llu device path %s changed to %s scanned by %s (%d)",
devid, btrfs_dev_name(device),
path, current->comm,
@@ -7816,7 +7816,7 @@ static void btrfs_dev_stat_print_on_load(struct btrfs_device *dev)
if (i == BTRFS_DEV_STAT_VALUES_MAX)
return; /* all values == 0, suppress message */
- btrfs_info_in_rcu(dev->fs_info,
+ btrfs_info(dev->fs_info,
"bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u",
btrfs_dev_name(dev),
btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS),
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 9bacc8c32b40de..82ccd78745a3db 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -575,7 +575,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
emulated = "emulated ";
}
- btrfs_info_in_rcu(fs_info,
+ btrfs_info(fs_info,
"%s block device %s, %u %szones of %llu bytes",
model, rcu_str_deref(device->name), zone_info->nr_zones,
emulated, zone_info->zone_size);
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 08/11] btrfs: switch RCU helper versions to btrfs_debug()
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
` (6 preceding siblings ...)
2025-06-09 17:09 ` [PATCH 07/11] btrfs: switch RCU helper versions to btrfs_info() David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-09 17:09 ` [PATCH 09/11] btrfs: remove remaining unused message helpers David Sterba
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The RCU protection is now done in the plain helpers, we can remove the
"_in_rcu" and "_rl_in_rcu".
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/bio.c | 2 +-
fs/btrfs/messages.h | 14 --------------
2 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index aa970fd41c4b78..50b5fc1c06d7cc 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -433,7 +433,7 @@ static void btrfs_submit_dev_bio(struct btrfs_device *dev, struct bio *bio)
ASSERT(btrfs_dev_is_sequential(dev, physical));
bio->bi_iter.bi_sector = zone_start >> SECTOR_SHIFT;
}
- btrfs_debug_in_rcu(dev->fs_info,
+ btrfs_debug(dev->fs_info,
"%s: rw %d 0x%x, sector=%llu, dev=%lu (%s id %llu), size=%u",
__func__, bio_op(bio), bio->bi_opf, bio->bi_iter.bi_sector,
(unsigned long)dev->bdev->bd_dev, btrfs_dev_name(dev),
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index 9d5330ba02534f..659889faec8518 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -77,31 +77,17 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
#define btrfs_debug(fs_info, fmt, args...) \
_dynamic_func_call_no_desc(fmt, btrfs_printk_in_rcu, \
fs_info, KERN_DEBUG fmt, ##args)
-#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
- _dynamic_func_call_no_desc(fmt, btrfs_printk_in_rcu, \
- fs_info, KERN_DEBUG fmt, ##args)
-#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
- _dynamic_func_call_no_desc(fmt, btrfs_printk_rl_in_rcu, \
- fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_rl(fs_info, fmt, args...) \
_dynamic_func_call_no_desc(fmt, btrfs_printk_rl_in_rcu, \
fs_info, KERN_DEBUG fmt, ##args)
#elif defined(DEBUG)
#define btrfs_debug(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
-#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
-#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_rl(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#else
#define btrfs_debug(fs_info, fmt, args...) \
btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
-#define btrfs_debug_in_rcu(fs_info, fmt, args...) \
- btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
-#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \
- btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#define btrfs_debug_rl(fs_info, fmt, args...) \
btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#endif
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 09/11] btrfs: remove remaining unused message helpers
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
` (7 preceding siblings ...)
2025-06-09 17:09 ` [PATCH 08/11] btrfs: switch RCU helper versions to btrfs_debug() David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-09 17:09 ` [PATCH 10/11] btrfs: simplify debug print helpers without enabled printk David Sterba
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Remove the critical level message helpers as they're not used, the RCU
protection is provided by the plain helpers.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/messages.h | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index 659889faec8518..9b78600efe0eb1 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -49,18 +49,6 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
#define btrfs_info(fs_info, fmt, args...) \
btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args)
-/*
- * Wrappers that use printk in RCU
- */
-#define btrfs_crit_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_in_rcu(fs_info, KERN_CRIT fmt, ##args)
-
-/*
- * Wrappers that use a ratelimited printk in RCU
- */
-#define btrfs_crit_rl_in_rcu(fs_info, fmt, args...) \
- btrfs_printk_rl_in_rcu(fs_info, KERN_CRIT fmt, ##args)
-
/*
* Wrappers that use a ratelimited printk
*/
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 10/11] btrfs: simplify debug print helpers without enabled printk
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
` (8 preceding siblings ...)
2025-06-09 17:09 ` [PATCH 09/11] btrfs: remove remaining unused message helpers David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-09 17:09 ` [PATCH 11/11] btrfs: merge btrfs_printk_ratelimited() and it's only caller David Sterba
2025-06-12 13:02 ` [PATCH 00/11] Clean up of RCU in message helpers Daniel Vacek
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The btrfs_debug() helpers depend on various config options. In case of
"no_printk" we don't need to define a special helper that in the end
does nothing but validates the parameters. As the default build config
is to validate the parameters we can simplify it to let the debug
helpers expand to nothing and remove btrfs_no_printk_in_rcu().
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/messages.h | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index 9b78600efe0eb1..cef7526236d989 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -74,10 +74,9 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
#define btrfs_debug_rl(fs_info, fmt, args...) \
btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
#else
-#define btrfs_debug(fs_info, fmt, args...) \
- btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
-#define btrfs_debug_rl(fs_info, fmt, args...) \
- btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
+/* When printk() is no_printk(), expand to nothing. */
+#define btrfs_debug(fs_info, fmt, args...)
+#define btrfs_debug_rl(fs_info, fmt, args...)
#endif
#define btrfs_printk_in_rcu(fs_info, fmt, args...) \
@@ -87,13 +86,6 @@ do { \
rcu_read_unlock(); \
} while (0)
-#define btrfs_no_printk_in_rcu(fs_info, fmt, args...) \
-do { \
- rcu_read_lock(); \
- btrfs_no_printk(fs_info, fmt, ##args); \
- rcu_read_unlock(); \
-} while (0)
-
#define btrfs_printk_ratelimited(fs_info, fmt, args...) \
do { \
static DEFINE_RATELIMIT_STATE(_rs, \
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 11/11] btrfs: merge btrfs_printk_ratelimited() and it's only caller
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
` (9 preceding siblings ...)
2025-06-09 17:09 ` [PATCH 10/11] btrfs: simplify debug print helpers without enabled printk David Sterba
@ 2025-06-09 17:09 ` David Sterba
2025-06-12 13:02 ` [PATCH 00/11] Clean up of RCU in message helpers Daniel Vacek
11 siblings, 0 replies; 13+ messages in thread
From: David Sterba @ 2025-06-09 17:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
There's only one caller of btrfs_printk_ratelimited(), merge it there.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/messages.h | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index cef7526236d989..c89b315fca8f4a 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -86,19 +86,15 @@ do { \
rcu_read_unlock(); \
} while (0)
-#define btrfs_printk_ratelimited(fs_info, fmt, args...) \
+#define btrfs_printk_rl_in_rcu(fs_info, fmt, args...) \
do { \
static DEFINE_RATELIMIT_STATE(_rs, \
DEFAULT_RATELIMIT_INTERVAL, \
DEFAULT_RATELIMIT_BURST); \
+ \
+ rcu_read_lock(); \
if (__ratelimit(&_rs)) \
btrfs_printk(fs_info, fmt, ##args); \
-} while (0)
-
-#define btrfs_printk_rl_in_rcu(fs_info, fmt, args...) \
-do { \
- rcu_read_lock(); \
- btrfs_printk_ratelimited(fs_info, fmt, ##args); \
rcu_read_unlock(); \
} while (0)
--
2.49.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 00/11] Clean up of RCU in message helpers
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
` (10 preceding siblings ...)
2025-06-09 17:09 ` [PATCH 11/11] btrfs: merge btrfs_printk_ratelimited() and it's only caller David Sterba
@ 2025-06-12 13:02 ` Daniel Vacek
11 siblings, 0 replies; 13+ messages in thread
From: Daniel Vacek @ 2025-06-12 13:02 UTC (permalink / raw)
To: David Sterba; +Cc: linux-btrfs
On Mon, 9 Jun 2025 at 19:09, David Sterba <dsterba@suse.com> wrote:
>
> Add the RCU protection to the plain message helpers, remove the
> specialized versions, plus some related cleanups.
>
> David Sterba (11):
> btrfs: open code rcu_string_free() and remove it
> btrfs: remove unused rcu-string printk helpers
> btrfs: remove unused levels of message helpers
> btrfs: switch all message helpers to be RCU safe
> btrfs: switch RCU helper versions to btrfs_err()
> btrfs: switch RCU helper versions to btrfs_warn()
> btrfs: switch RCU helper versions to btrfs_info()
> btrfs: switch RCU helper versions to btrfs_debug()
> btrfs: remove remaining unused message helpers
> btrfs: simplify debug print helpers without enabled printk
> btrf: merge btrfs_printk_ratelimited() and it's only caller
The series looks good to me.
Reviewed-by: Daniel Vacek <neelx@suse.com>
> fs/btrfs/bio.c | 4 +-
> fs/btrfs/dev-replace.c | 14 +++---
> fs/btrfs/disk-io.c | 2 +-
> fs/btrfs/extent-tree.c | 2 +-
> fs/btrfs/ioctl.c | 2 +-
> fs/btrfs/messages.h | 107 +++++++----------------------------------
> fs/btrfs/rcu-string.h | 18 -------
> fs/btrfs/scrub.c | 18 +++----
> fs/btrfs/volumes.c | 21 ++++----
> fs/btrfs/zoned.c | 26 +++++-----
> 10 files changed, 63 insertions(+), 151 deletions(-)
>
> --
> 2.49.0
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-06-12 13:02 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-09 17:09 [PATCH 00/11] Clean up of RCU in message helpers David Sterba
2025-06-09 17:09 ` [PATCH 01/11] btrfs: open code rcu_string_free() and remove it David Sterba
2025-06-09 17:09 ` [PATCH 02/11] btrfs: remove unused rcu-string printk helpers David Sterba
2025-06-09 17:09 ` [PATCH 03/11] btrfs: remove unused levels of message helpers David Sterba
2025-06-09 17:09 ` [PATCH 04/11] btrfs: switch all message helpers to be RCU safe David Sterba
2025-06-09 17:09 ` [PATCH 05/11] btrfs: switch RCU helper versions to btrfs_err() David Sterba
2025-06-09 17:09 ` [PATCH 06/11] btrfs: switch RCU helper versions to btrfs_warn() David Sterba
2025-06-09 17:09 ` [PATCH 07/11] btrfs: switch RCU helper versions to btrfs_info() David Sterba
2025-06-09 17:09 ` [PATCH 08/11] btrfs: switch RCU helper versions to btrfs_debug() David Sterba
2025-06-09 17:09 ` [PATCH 09/11] btrfs: remove remaining unused message helpers David Sterba
2025-06-09 17:09 ` [PATCH 10/11] btrfs: simplify debug print helpers without enabled printk David Sterba
2025-06-09 17:09 ` [PATCH 11/11] btrfs: merge btrfs_printk_ratelimited() and it's only caller David Sterba
2025-06-12 13:02 ` [PATCH 00/11] Clean up of RCU in message helpers Daniel Vacek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox