Clean up of RCU in message helpers
David Sterba
maintainercover Clean up of RCU in message helpers
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(-)
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 2/11 btrfs: remove unused rcu-string printk helpers
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.
--- fs/btrfs/messages.h | 4 ++-- fs/btrfs/rcu-string.h | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-)
fs/btrfs/messages.h +2 -2
@@ -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)
fs/btrfs/rcu-string.h +0 -12
@@ -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; \
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 1/11 btrfs: open code rcu_string_free() and remove it
In reply to David SterbaThe 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().
--- fs/btrfs/rcu-string.h | 6 ------ fs/btrfs/volumes.c | 5 +++-- 2 files changed, 3 insertions(+), 8 deletions(-)
fs/btrfs/rcu-string.h +0 -6
@@ -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__); \
fs/btrfs/volumes.c +3 -2
@@ -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--;
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 4/11 btrfs: switch all message helpers to be RCU safe
In reply to David SterbaWe 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.
--- fs/btrfs/messages.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
fs/btrfs/messages.h +17 -14
@@ -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...) \
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 3/11 btrfs: remove unused levels of message helpers
In reply to David SterbaWe'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.
--- fs/btrfs/messages.h | 24 ------------------------ 1 file changed, 24 deletions(-)
fs/btrfs/messages.h +0 -24
@@ -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)
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 6/11 btrfs: switch RCU helper versions to btrfs_warn()
In reply to David SterbaThe RCU protection is now done in the plain helpers, we can remove the "_in_rcu" and "_rl_in_rcu".
--- 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(-)
fs/btrfs/dev-replace.c +1 -1
@@ -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 ;
fs/btrfs/disk-io.c +1 -1
@@ -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));
fs/btrfs/extent-tree.c +1 -1
@@ -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),
fs/btrfs/messages.h +0 -4
@@ -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)
fs/btrfs/scrub.c +4 -4
@@ -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"),
fs/btrfs/volumes.c +5 -5
@@ -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;
fs/btrfs/zoned.c +1 -1
@@ -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);
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 5/11 btrfs: switch RCU helper versions to btrfs_err()
In reply to David SterbaThe RCU protection is now done in the plain helpers, we can remove the "_in_rcu" and "_rl_in_rcu".
--- 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(-)
fs/btrfs/dev-replace.c +1 -1
@@ -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,
fs/btrfs/messages.h +0 -4
@@ -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...) \
fs/btrfs/scrub.c +5 -5
@@ -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 ;
fs/btrfs/volumes.c +1 -1
@@ -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),
fs/btrfs/zoned.c +11 -11
@@ -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);
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 7/11 btrfs: switch RCU helper versions to btrfs_info()
In reply to David SterbaThe RCU protection is now done in the plain helpers, we can remove the "_in_rcu" and "_rl_in_rcu".
--- 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(-)
fs/btrfs/bio.c +1 -1
@@ -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 );
fs/btrfs/dev-replace.c +5 -5
@@ -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,
fs/btrfs/ioctl.c +1 -1
@@ -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);
fs/btrfs/messages.h +0 -4
@@ -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
fs/btrfs/volumes.c +2 -2
@@ -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),
fs/btrfs/zoned.c +1 -1
@@ -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);
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 9/11 btrfs: remove remaining unused message helpers
In reply to David SterbaRemove the critical level message helpers as they're not used, the RCU protection is provided by the plain helpers.
--- fs/btrfs/messages.h | 12 ------------ 1 file changed, 12 deletions(-)
fs/btrfs/messages.h +0 -12
@@ -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 */
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 8/11 btrfs: switch RCU helper versions to btrfs_debug()
In reply to David SterbaThe RCU protection is now done in the plain helpers, we can remove the "_in_rcu" and "_rl_in_rcu".
--- fs/btrfs/bio.c | 2 +- fs/btrfs/messages.h | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-)
fs/btrfs/bio.c +1 -1
@@ -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),
fs/btrfs/messages.h +0 -14
@@ -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
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 11/11 btrfs: merge btrfs_printk_ratelimited() and it's only caller
In reply to David SterbaThere's only one caller of btrfs_printk_ratelimited(), merge it there.
--- fs/btrfs/messages.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/btrfs/messages.h +3 -7
@@ -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 )
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 10/11 btrfs: simplify debug print helpers without enabled printk
In reply to David SterbaThe 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().
--- fs/btrfs/messages.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
fs/btrfs/messages.h +3 -11
@@ -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, \
Signature · 1 line
2.49.0
Quoted 4 lines · David Sterba
Add the RCU protection to the plain message helpers, remove the specialized versions, plus some related cleanups.
Quoted 12 lines
David Sterba (11):
btrfs: open codercu_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 tobtrfs_err()
btrfs: switch RCU helper versions tobtrfs_warn()
btrfs: switch RCU helper versions tobtrfs_info()
btrfs: switch RCU helper versions tobtrfs_debug()
btrfs: remove remaining unused message helpers
btrfs: simplify debug print helpers without enabled printk
btrf: mergebtrfs_printk_ratelimited()and it's only caller
The series looks good to me.
Quoted 16 lines
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