ocfs: no need to check return value of debugfs_create functions
PATCH 1/1 ocfs: no need to check return value of debugfs_create functions
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Also, because there is no need to save the file dentry, remove all of the variables that were being saved, and just recursively delete the whole directory when shutting down, saving a lot of logic and local variables.
--- fs/ocfs2/blockcheck.c | 54 +++++-------------- fs/ocfs2/blockcheck.h | 7 +-- fs/ocfs2/cluster/heartbeat.c | 98 +++++++++------------------------- fs/ocfs2/cluster/heartbeat.h | 2 +- fs/ocfs2/cluster/netdebug.c | 39 ++++---------- fs/ocfs2/cluster/nodemanager.c | 4 +- fs/ocfs2/cluster/tcp.c | 3 +- fs/ocfs2/cluster/tcp.h | 5 +- fs/ocfs2/dlm/dlmdebug.c | 44 ++------------- fs/ocfs2/dlm/dlmdebug.h | 10 ++-- fs/ocfs2/dlm/dlmdomain.c | 10 +--- fs/ocfs2/dlmglue.c | 18 +------ fs/ocfs2/super.c | 29 ++-------- 13 files changed, 73 insertions(+), 250 deletions(-)
fs/ocfs2/blockcheck.c +14 -40
@@ -242,57 +242,31 @@ static struct dentry *blockcheck_debugfs_create(const char *name,static void ocfs2_blockcheck_debug_remove (struct ocfs2_blockcheck_stats *stats) {if (stats) { -debugfs_remove (stats->b_debug_check); - stats->b_debug_check =NULL ; -debugfs_remove (stats->b_debug_failure); - stats->b_debug_failure =NULL ; -debugfs_remove (stats->b_debug_recover); - stats->b_debug_recover =NULL ; -debugfs_remove (stats->b_debug_dir); +debugfs_remove_recursive (stats->b_debug_dir); stats->b_debug_dir =NULL ; } } -static int ocfs2_blockcheck_debug_install (struct ocfs2_blockcheck_stats *stats, -struct dentry *parent) +static void ocfs2_blockcheck_debug_install (struct ocfs2_blockcheck_stats *stats, +struct dentry *parent) {int rc = -EINVAL ; -if (!stats) - goto out; - stats->b_debug_dir =debugfs_create_dir ("blockcheck" , parent); -if (!stats->b_debug_dir) - goto out; - stats->b_debug_check = -blockcheck_debugfs_create ("blocks_checked" , - stats->b_debug_dir, - &stats->b_check_count); +blockcheck_debugfs_create ("blocks_checked" , stats->b_debug_dir, + &stats->b_check_count); - stats->b_debug_failure = -blockcheck_debugfs_create ("checksums_failed" , - stats->b_debug_dir, - &stats->b_failure_count); +blockcheck_debugfs_create ("checksums_failed" , stats->b_debug_dir, + &stats->b_failure_count); - stats->b_debug_recover = -blockcheck_debugfs_create ("ecc_recoveries" , - stats->b_debug_dir, - &stats->b_recover_count); -if (stats->b_debug_check && stats->b_debug_failure && - stats->b_debug_recover) - rc =0 ; - -out: -if (rc) -ocfs2_blockcheck_debug_remove (stats); -return rc; +blockcheck_debugfs_create ("ecc_recoveries" , stats->b_debug_dir, + &stats->b_recover_count); }#else -static inline int ocfs2_blockcheck_debug_install (struct ocfs2_blockcheck_stats *stats, -struct dentry *parent) +static inline void ocfs2_blockcheck_debug_install (struct ocfs2_blockcheck_stats *stats, +struct dentry *parent) { -return 0 ; }static inline void ocfs2_blockcheck_debug_remove (struct ocfs2_blockcheck_stats *stats)
@@ -301,10 +275,10 @@ static inline void ocfs2_blockcheck_debug_remove(struct ocfs2_blockcheck_stats *#endif /* CONFIG_DEBUG_FS */ /* Always-called wrappers for starting and stopping the debugfs files */ -int ocfs2_blockcheck_stats_debugfs_install (struct ocfs2_blockcheck_stats *stats, -struct dentry *parent) +void ocfs2_blockcheck_stats_debugfs_install (struct ocfs2_blockcheck_stats *stats, +struct dentry *parent) { -return ocfs2_blockcheck_debug_install (stats, parent); +ocfs2_blockcheck_debug_install (stats, parent); }void ocfs2_blockcheck_stats_debugfs_remove (struct ocfs2_blockcheck_stats *stats)
fs/ocfs2/blockcheck.h +2 -5
@@ -25,9 +25,6 @@ struct ocfs2_blockcheck_stats {* ocfs2_blockcheck_stats_debugfs_install() */ struct dentry *b_debug_dir;/* Parent of the debugfs files */ -struct dentry *b_debug_check;/* Exposes b_check_count */ -struct dentry *b_debug_failure;/* Exposes b_failure_count */ -struct dentry *b_debug_recover;/* Exposes b_recover_count */ };
@@ -56,8 +53,8 @@ int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr, struct ocfs2_blockcheck_stats *stats);/* Debug Initialization */ -int ocfs2_blockcheck_stats_debugfs_install (struct ocfs2_blockcheck_stats *stats, -struct dentry *parent); +void ocfs2_blockcheck_stats_debugfs_install (struct ocfs2_blockcheck_stats *stats, +struct dentry *parent);void ocfs2_blockcheck_stats_debugfs_remove (struct ocfs2_blockcheck_stats *stats);/*
fs/ocfs2/cluster/heartbeat.c +25 -73
132 lines not on this page · raw message
fs/ocfs2/cluster/heartbeat.h +1 -1
@@ -63,7 +63,7 @@ void o2hb_unregister_callback(const char *region_uuid,void o2hb_fill_node_map (unsigned long *map,unsigned bytes);void o2hb_exit (void ); -int o2hb_init (void ); +void o2hb_init (void );int o2hb_check_node_heartbeating_no_sem (u8 node_num);int o2hb_check_node_heartbeating_from_callback (u8 node_num);void o2hb_stop_all_regions (void );
fs/ocfs2/cluster/netdebug.c +11 -28
@@ -38,10 +38,6 @@#define SHOW_SOCK_STATS 1static struct dentry *o2net_dentry; -static struct dentry *sc_dentry; -static struct dentry *nst_dentry; -static struct dentry *stats_dentry; -static struct dentry *nodes_dentry;static DEFINE_SPINLOCK (o2net_debug_lock);
@@ -490,36 +486,23 @@ static const struct file_operations nodes_fops = {void o2net_debugfs_exit (void ) { -debugfs_remove (nodes_dentry); -debugfs_remove (stats_dentry); -debugfs_remove (sc_dentry); -debugfs_remove (nst_dentry); -debugfs_remove (o2net_dentry); +debugfs_remove_recursive (o2net_dentry); } -int o2net_debugfs_init (void ) +void o2net_debugfs_init (void ) {umode_t mode =S_IFREG |S_IRUSR ; o2net_dentry =debugfs_create_dir (O2NET_DEBUG_DIR ,NULL ); -if (o2net_dentry) - nst_dentry =debugfs_create_file (NST_DEBUG_NAME , mode, - o2net_dentry,NULL , &nst_seq_fops); -if (nst_dentry) - sc_dentry =debugfs_create_file (SC_DEBUG_NAME , mode, - o2net_dentry,NULL , &sc_seq_fops); -if (sc_dentry) - stats_dentry =debugfs_create_file (STATS_DEBUG_NAME , mode, - o2net_dentry,NULL , &stats_seq_fops); -if (stats_dentry) - nodes_dentry =debugfs_create_file (NODES_DEBUG_NAME , mode, - o2net_dentry,NULL , &nodes_fops); -if (nodes_dentry) -return 0 ; - -o2net_debugfs_exit (); -mlog_errno (-ENOMEM ); -return -ENOMEM ; + +debugfs_create_file (NST_DEBUG_NAME , mode, o2net_dentry,NULL , + &nst_seq_fops); +debugfs_create_file (SC_DEBUG_NAME , mode, o2net_dentry,NULL , + &sc_seq_fops); +debugfs_create_file (STATS_DEBUG_NAME , mode, o2net_dentry,NULL , + &stats_seq_fops); +debugfs_create_file (NODES_DEBUG_NAME , mode, o2net_dentry,NULL , + &nodes_fops); }#endif /* CONFIG_DEBUG_FS */
fs/ocfs2/cluster/nodemanager.c +1 -3
@@ -828,9 +828,7 @@ static int __init init_o2nm(void) {int ret =-1 ; - ret =o2hb_init (); -if (ret) - goto out; +o2hb_init (); ret =o2net_init ();if (ret)
fs/ocfs2/cluster/tcp.c +1 -2
@@ -2129,8 +2129,7 @@ int o2net_init(void)o2quo_init (); -if (o2net_debugfs_init ()) - goto out; +o2net_debugfs_init (); o2net_hand =kzalloc (sizeof (struct o2net_handshake ),GFP_KERNEL ); o2net_keep_req =kzalloc (sizeof (struct o2net_msg ),GFP_KERNEL );
fs/ocfs2/cluster/tcp.h +2 -3
@@ -109,16 +109,15 @@ struct o2net_send_tracking;struct o2net_sock_container ;#ifdef CONFIG_DEBUG_FS -int o2net_debugfs_init (void ); +void o2net_debugfs_init (void );void o2net_debugfs_exit (void );void o2net_debug_add_nst (struct o2net_send_tracking *nst);void o2net_debug_del_nst (struct o2net_send_tracking *nst);void o2net_debug_add_sc (struct o2net_sock_container *sc);void o2net_debug_del_sc (struct o2net_sock_container *sc);#else -static inline int o2net_debugfs_init (void ) +static inline void o2net_debugfs_init (void ) { -return 0 ; }static inline void o2net_debugfs_exit (void ) {
fs/ocfs2/dlm/dlmdebug.c +5 -39
95 lines not on this page · raw message
fs/ocfs2/dlm/dlmdebug.h +4 -6
@@ -28,20 +28,19 @@ struct debug_lockres { struct dlm_lock_resource *dl_res; }; -int dlm_debug_init (struct dlm_ctxt *dlm); +void dlm_debug_init (struct dlm_ctxt *dlm);void dlm_debug_shutdown (struct dlm_ctxt *dlm);int dlm_create_debugfs_subroot (struct dlm_ctxt *dlm);void dlm_destroy_debugfs_subroot (struct dlm_ctxt *dlm); -int dlm_create_debugfs_root (void ); +void dlm_create_debugfs_root (void );void dlm_destroy_debugfs_root (void );#else -static inline int dlm_debug_init (struct dlm_ctxt *dlm) +static inline void dlm_debug_init (struct dlm_ctxt *dlm) { -return 0 ; }static inline void dlm_debug_shutdown (struct dlm_ctxt *dlm) {
@@ -53,9 +52,8 @@ static inline int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm)static inline void dlm_destroy_debugfs_subroot (struct dlm_ctxt *dlm) { } -static inline int dlm_create_debugfs_root (void ) +static inline void dlm_create_debugfs_root (void ) { -return 0 ; }static inline void dlm_destroy_debugfs_root (void ) {
fs/ocfs2/dlm/dlmdomain.c +2 -8
@@ -1881,11 +1881,7 @@ static int dlm_join_domain(struct dlm_ctxt *dlm) goto bail; } - status =dlm_debug_init (dlm); -if (status <0 ) { -mlog_errno (status); - goto bail; - } +dlm_debug_init (dlm);snprintf (wq_name,O2NM_MAX_NAME_LEN ,"dlm_wq-%s" , dlm->name); dlm->dlm_worker =alloc_workqueue (wq_name,WQ_MEM_RECLAIM ,0 );
@@ -2346,9 +2342,7 @@ static int __init dlm_init(void) goto error; } - status =dlm_create_debugfs_root (); -if (status) - goto error; +dlm_create_debugfs_root ();return 0 ; error:
fs/ocfs2/dlmglue.c +2 -16
@@ -3214,9 +3214,8 @@ static const struct file_operations ocfs2_dlm_debug_fops = { .llseek = seq_lseek, }; -static int ocfs2_dlm_init_debug (struct ocfs2_super *osb) +static void ocfs2_dlm_init_debug (struct ocfs2_super *osb) { -int ret =0 ;struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug; dlm_debug->d_locking_state = debugfs_create_file("locking_state",
@@ -3224,16 +3223,7 @@ static int ocfs2_dlm_init_debug(struct ocfs2_super *osb) osb->osb_debug_root, osb, &ocfs2_dlm_debug_fops); -if (!dlm_debug->d_locking_state) { - ret = -EINVAL ; -mlog (ML_ERROR , -"Unable to create locking state debugfs file.\n" ); - goto out; - } -ocfs2_get_dlm_debug (dlm_debug); -out: -return ret; }static void ocfs2_dlm_shutdown_debug (struct ocfs2_super *osb)
@@ -3256,11 +3246,7 @@ int ocfs2_dlm_init(struct ocfs2_super *osb) goto local; } - status =ocfs2_dlm_init_debug (osb); -if (status <0 ) { -mlog_errno (status); - goto bail; - } +ocfs2_dlm_init_debug (osb);/* launch downconvert thread */ osb->dc_task = kthread_run(ocfs2_downconvert_thread, osb, "ocfs2dc-%s",
fs/ocfs2/super.c +3 -26
@@ -1079,33 +1079,15 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) osb->osb_debug_root =debugfs_create_dir (osb->uuid_str, ocfs2_debugfs_root); -if (!osb->osb_debug_root) { - status = -EINVAL ; -mlog (ML_ERROR ,"Unable to create per-mount debugfs root.\n" ); - goto read_super_error; - } osb->osb_ctxt =debugfs_create_file ("fs_state" ,S_IFREG |S_IRUSR , osb->osb_debug_root, osb, &ocfs2_osb_debug_fops); -if (!osb->osb_ctxt) { - status = -EINVAL ; -mlog_errno (status); - goto read_super_error; - } -if (ocfs2_meta_ecc (osb)) { - status =ocfs2_blockcheck_stats_debugfs_install ( - &osb->osb_ecc_stats, - osb->osb_debug_root); -if (status) { -mlog (ML_ERROR , -"Unable to create blockcheck statistics " -"files\n" ); - goto read_super_error; - } - } +if (ocfs2_meta_ecc (osb)) +ocfs2_blockcheck_stats_debugfs_install ( &osb->osb_ecc_stats, + osb->osb_debug_root); status =ocfs2_mount_volume (sb);if (status <0 )
@@ -1592,11 +1574,6 @@ static int __init ocfs2_init(void) goto out2; ocfs2_debugfs_root =debugfs_create_dir ("ocfs2" ,NULL ); -if (!ocfs2_debugfs_root) { - status = -ENOMEM ; -mlog (ML_ERROR ,"Unable to create ocfs2 debugfs root.\n" ); - goto out3; - }ocfs2_set_locking_protocol ();
Signature · 1 line
2.22.0
PATCH 1/1 ocfs: no need to check return value of debugfs_create functions
In reply to a message not in the archiveQuoted 55 lines · Joseph Qi
Quoted 52 lines · Greg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Also, because there is no need to save the file dentry, remove all of the variables that were being saved, and just recursively delete the whole directory when shutting down, saving a lot of logic and local variables.
Cc Mark Fasheh <[email protected]>Cc Joel Becker <[email protected]>Cc Joseph Qi <[email protected]>Cc Andrew Morton <[email protected]>Cc Jia Guo <[email protected]>Cc ocfs2-devel at oss.oracle.comSigned-off-by Greg Kroah-Hartman <[email protected]>--- fs/ocfs2/blockcheck.c | 54 +++++-------------- fs/ocfs2/blockcheck.h | 7 +-- fs/ocfs2/cluster/heartbeat.c | 98 +++++++++------------------------- fs/ocfs2/cluster/heartbeat.h | 2 +- fs/ocfs2/cluster/netdebug.c | 39 ++++---------- fs/ocfs2/cluster/nodemanager.c | 4 +- fs/ocfs2/cluster/tcp.c | 3 +- fs/ocfs2/cluster/tcp.h | 5 +- fs/ocfs2/dlm/dlmdebug.c | 44 ++------------- fs/ocfs2/dlm/dlmdebug.h | 10 ++-- fs/ocfs2/dlm/dlmdomain.c | 10 +--- fs/ocfs2/dlmglue.c | 18 +------ fs/ocfs2/super.c | 29 ++-------- 13 files changed, 73 insertions(+), 250 deletions(-)fs/ocfs2/blockcheck.c +1
-7@@ -242,57 +242,31 @@ static struct dentry *blockcheck_debugfs_create(const char *name,static void ocfs2_blockcheck_debug_remove (struct ocfs2_blockcheck_stats *stats) {if (stats) { -debugfs_remove (stats->b_debug_check); - stats->b_debug_check =NULL ; -debugfs_remove (stats->b_debug_failure); - stats->b_debug_failure =NULL ; -debugfs_remove (stats->b_debug_recover); - stats->b_debug_recover =NULL ; -debugfs_remove (stats->b_debug_dir); +debugfs_remove_recursive (stats->b_debug_dir); stats->b_debug_dir =NULL ; } }
Quoted 8 lines
fs/ocfs2/blockcheck.c static struct dentry *blockcheck_debugfs_create(const char *name, · line 253
Quoted 6 lines
fs/ocfs2/blockcheck.c +2
-2-static int ocfs2_blockcheck_debug_install (struct ocfs2_blockcheck_stats *stats, -struct dentry *parent) +static void ocfs2_blockcheck_debug_install (struct ocfs2_blockcheck_stats *stats, +struct dentry *parent) {int rc = -EINVAL ;Here rc is no longer be used, should be removed as well.
Sorry about those, I wonder how 0-day was ignoring those warning messages. I'll go fix this and post a v2, thanks for the review!
greg k-h
PATCH v2 1/1 ocfs: no need to check return value of debugfs_create functions
In reply to a message not in the archiveWhen calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Also, because there is no need to save the file dentry, remove all of the variables that were being saved, and just recursively delete the whole directory when shutting down, saving a lot of logic and local variables.
---
v2: fix up some build warnings pointed out by Joseph.
fs/ocfs2/blockcheck.c | 56 +++++------------- fs/ocfs2/blockcheck.h | 7 +-- fs/ocfs2/cluster/heartbeat.c | 100 +++++++++------------------------ fs/ocfs2/cluster/heartbeat.h | 2 +- fs/ocfs2/cluster/netdebug.c | 39 ++++--------- fs/ocfs2/cluster/nodemanager.c | 4 +- fs/ocfs2/cluster/tcp.c | 3 +- fs/ocfs2/cluster/tcp.h | 5 +- fs/ocfs2/dlm/dlmdebug.c | 44 ++------------- fs/ocfs2/dlm/dlmdebug.h | 10 ++-- fs/ocfs2/dlm/dlmdomain.c | 10 +--- fs/ocfs2/dlmglue.c | 18 +----- fs/ocfs2/super.c | 29 +--------- 13 files changed, 73 insertions(+), 254 deletions(-)
fs/ocfs2/blockcheck.c +14 -42
@@ -242,57 +242,29 @@ static struct dentry *blockcheck_debugfs_create(const char *name,static void ocfs2_blockcheck_debug_remove (struct ocfs2_blockcheck_stats *stats) {if (stats) { -debugfs_remove (stats->b_debug_check); - stats->b_debug_check =NULL ; -debugfs_remove (stats->b_debug_failure); - stats->b_debug_failure =NULL ; -debugfs_remove (stats->b_debug_recover); - stats->b_debug_recover =NULL ; -debugfs_remove (stats->b_debug_dir); +debugfs_remove_recursive (stats->b_debug_dir); stats->b_debug_dir =NULL ; } } -static int ocfs2_blockcheck_debug_install (struct ocfs2_blockcheck_stats *stats, -struct dentry *parent) +static void ocfs2_blockcheck_debug_install (struct ocfs2_blockcheck_stats *stats, +struct dentry *parent) { -int rc = -EINVAL ; - -if (!stats) - goto out; - stats->b_debug_dir =debugfs_create_dir ("blockcheck" , parent); -if (!stats->b_debug_dir) - goto out; - stats->b_debug_check = -blockcheck_debugfs_create ("blocks_checked" , - stats->b_debug_dir, - &stats->b_check_count); +blockcheck_debugfs_create ("blocks_checked" , stats->b_debug_dir, + &stats->b_check_count); - stats->b_debug_failure = -blockcheck_debugfs_create ("checksums_failed" , - stats->b_debug_dir, - &stats->b_failure_count); +blockcheck_debugfs_create ("checksums_failed" , stats->b_debug_dir, + &stats->b_failure_count); - stats->b_debug_recover = -blockcheck_debugfs_create ("ecc_recoveries" , - stats->b_debug_dir, - &stats->b_recover_count); -if (stats->b_debug_check && stats->b_debug_failure && - stats->b_debug_recover) - rc =0 ; - -out: -if (rc) -ocfs2_blockcheck_debug_remove (stats); -return rc; +blockcheck_debugfs_create ("ecc_recoveries" , stats->b_debug_dir, + &stats->b_recover_count); }#else -static inline int ocfs2_blockcheck_debug_install (struct ocfs2_blockcheck_stats *stats, -struct dentry *parent) +static inline void ocfs2_blockcheck_debug_install (struct ocfs2_blockcheck_stats *stats, +struct dentry *parent) { -return 0 ; }static inline void ocfs2_blockcheck_debug_remove (struct ocfs2_blockcheck_stats *stats)
@@ -301,10 +273,10 @@ static inline void ocfs2_blockcheck_debug_remove(struct ocfs2_blockcheck_stats *#endif /* CONFIG_DEBUG_FS */ /* Always-called wrappers for starting and stopping the debugfs files */ -int ocfs2_blockcheck_stats_debugfs_install (struct ocfs2_blockcheck_stats *stats, -struct dentry *parent) +void ocfs2_blockcheck_stats_debugfs_install (struct ocfs2_blockcheck_stats *stats, +struct dentry *parent) { -return ocfs2_blockcheck_debug_install (stats, parent); +ocfs2_blockcheck_debug_install (stats, parent); }void ocfs2_blockcheck_stats_debugfs_remove (struct ocfs2_blockcheck_stats *stats)
fs/ocfs2/blockcheck.h +2 -5
@@ -25,9 +25,6 @@ struct ocfs2_blockcheck_stats {* ocfs2_blockcheck_stats_debugfs_install() */ struct dentry *b_debug_dir;/* Parent of the debugfs files */ -struct dentry *b_debug_check;/* Exposes b_check_count */ -struct dentry *b_debug_failure;/* Exposes b_failure_count */ -struct dentry *b_debug_recover;/* Exposes b_recover_count */ };
@@ -56,8 +53,8 @@ int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr, struct ocfs2_blockcheck_stats *stats);/* Debug Initialization */ -int ocfs2_blockcheck_stats_debugfs_install (struct ocfs2_blockcheck_stats *stats, -struct dentry *parent); +void ocfs2_blockcheck_stats_debugfs_install (struct ocfs2_blockcheck_stats *stats, +struct dentry *parent);void ocfs2_blockcheck_stats_debugfs_remove (struct ocfs2_blockcheck_stats *stats);/*
fs/ocfs2/cluster/heartbeat.c +25 -75
132 lines not on this page · raw message
fs/ocfs2/cluster/heartbeat.h +1 -1
@@ -63,7 +63,7 @@ void o2hb_unregister_callback(const char *region_uuid,void o2hb_fill_node_map (unsigned long *map,unsigned bytes);void o2hb_exit (void ); -int o2hb_init (void ); +void o2hb_init (void );int o2hb_check_node_heartbeating_no_sem (u8 node_num);int o2hb_check_node_heartbeating_from_callback (u8 node_num);void o2hb_stop_all_regions (void );
fs/ocfs2/cluster/netdebug.c +11 -28
@@ -38,10 +38,6 @@#define SHOW_SOCK_STATS 1static struct dentry *o2net_dentry; -static struct dentry *sc_dentry; -static struct dentry *nst_dentry; -static struct dentry *stats_dentry; -static struct dentry *nodes_dentry;static DEFINE_SPINLOCK (o2net_debug_lock);
@@ -490,36 +486,23 @@ static const struct file_operations nodes_fops = {void o2net_debugfs_exit (void ) { -debugfs_remove (nodes_dentry); -debugfs_remove (stats_dentry); -debugfs_remove (sc_dentry); -debugfs_remove (nst_dentry); -debugfs_remove (o2net_dentry); +debugfs_remove_recursive (o2net_dentry); } -int o2net_debugfs_init (void ) +void o2net_debugfs_init (void ) {umode_t mode =S_IFREG |S_IRUSR ; o2net_dentry =debugfs_create_dir (O2NET_DEBUG_DIR ,NULL ); -if (o2net_dentry) - nst_dentry =debugfs_create_file (NST_DEBUG_NAME , mode, - o2net_dentry,NULL , &nst_seq_fops); -if (nst_dentry) - sc_dentry =debugfs_create_file (SC_DEBUG_NAME , mode, - o2net_dentry,NULL , &sc_seq_fops); -if (sc_dentry) - stats_dentry =debugfs_create_file (STATS_DEBUG_NAME , mode, - o2net_dentry,NULL , &stats_seq_fops); -if (stats_dentry) - nodes_dentry =debugfs_create_file (NODES_DEBUG_NAME , mode, - o2net_dentry,NULL , &nodes_fops); -if (nodes_dentry) -return 0 ; - -o2net_debugfs_exit (); -mlog_errno (-ENOMEM ); -return -ENOMEM ; + +debugfs_create_file (NST_DEBUG_NAME , mode, o2net_dentry,NULL , + &nst_seq_fops); +debugfs_create_file (SC_DEBUG_NAME , mode, o2net_dentry,NULL , + &sc_seq_fops); +debugfs_create_file (STATS_DEBUG_NAME , mode, o2net_dentry,NULL , + &stats_seq_fops); +debugfs_create_file (NODES_DEBUG_NAME , mode, o2net_dentry,NULL , + &nodes_fops); }#endif /* CONFIG_DEBUG_FS */
fs/ocfs2/cluster/nodemanager.c +1 -3
@@ -828,9 +828,7 @@ static int __init init_o2nm(void) {int ret =-1 ; - ret =o2hb_init (); -if (ret) - goto out; +o2hb_init (); ret =o2net_init ();if (ret)
fs/ocfs2/cluster/tcp.c +1 -2
@@ -2129,8 +2129,7 @@ int o2net_init(void)o2quo_init (); -if (o2net_debugfs_init ()) - goto out; +o2net_debugfs_init (); o2net_hand =kzalloc (sizeof (struct o2net_handshake ),GFP_KERNEL ); o2net_keep_req =kzalloc (sizeof (struct o2net_msg ),GFP_KERNEL );
fs/ocfs2/cluster/tcp.h +2 -3
@@ -109,16 +109,15 @@ struct o2net_send_tracking;struct o2net_sock_container ;#ifdef CONFIG_DEBUG_FS -int o2net_debugfs_init (void ); +void o2net_debugfs_init (void );void o2net_debugfs_exit (void );void o2net_debug_add_nst (struct o2net_send_tracking *nst);void o2net_debug_del_nst (struct o2net_send_tracking *nst);void o2net_debug_add_sc (struct o2net_sock_container *sc);void o2net_debug_del_sc (struct o2net_sock_container *sc);#else -static inline int o2net_debugfs_init (void ) +static inline void o2net_debugfs_init (void ) { -return 0 ; }static inline void o2net_debugfs_exit (void ) {
fs/ocfs2/dlm/dlmdebug.c +5 -39
95 lines not on this page · raw message
fs/ocfs2/dlm/dlmdebug.h +4 -6
@@ -28,20 +28,19 @@ struct debug_lockres { struct dlm_lock_resource *dl_res; }; -int dlm_debug_init (struct dlm_ctxt *dlm); +void dlm_debug_init (struct dlm_ctxt *dlm);void dlm_debug_shutdown (struct dlm_ctxt *dlm);int dlm_create_debugfs_subroot (struct dlm_ctxt *dlm);void dlm_destroy_debugfs_subroot (struct dlm_ctxt *dlm); -int dlm_create_debugfs_root (void ); +void dlm_create_debugfs_root (void );void dlm_destroy_debugfs_root (void );#else -static inline int dlm_debug_init (struct dlm_ctxt *dlm) +static inline void dlm_debug_init (struct dlm_ctxt *dlm) { -return 0 ; }static inline void dlm_debug_shutdown (struct dlm_ctxt *dlm) {
@@ -53,9 +52,8 @@ static inline int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm)static inline void dlm_destroy_debugfs_subroot (struct dlm_ctxt *dlm) { } -static inline int dlm_create_debugfs_root (void ) +static inline void dlm_create_debugfs_root (void ) { -return 0 ; }static inline void dlm_destroy_debugfs_root (void ) {
fs/ocfs2/dlm/dlmdomain.c +2 -8
@@ -1881,11 +1881,7 @@ static int dlm_join_domain(struct dlm_ctxt *dlm) goto bail; } - status =dlm_debug_init (dlm); -if (status <0 ) { -mlog_errno (status); - goto bail; - } +dlm_debug_init (dlm);snprintf (wq_name,O2NM_MAX_NAME_LEN ,"dlm_wq-%s" , dlm->name); dlm->dlm_worker =alloc_workqueue (wq_name,WQ_MEM_RECLAIM ,0 );
@@ -2346,9 +2342,7 @@ static int __init dlm_init(void) goto error; } - status =dlm_create_debugfs_root (); -if (status) - goto error; +dlm_create_debugfs_root ();return 0 ; error:
fs/ocfs2/dlmglue.c +2 -16
@@ -3214,9 +3214,8 @@ static const struct file_operations ocfs2_dlm_debug_fops = { .llseek = seq_lseek, }; -static int ocfs2_dlm_init_debug (struct ocfs2_super *osb) +static void ocfs2_dlm_init_debug (struct ocfs2_super *osb) { -int ret =0 ;struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug; dlm_debug->d_locking_state = debugfs_create_file("locking_state",
@@ -3224,16 +3223,7 @@ static int ocfs2_dlm_init_debug(struct ocfs2_super *osb) osb->osb_debug_root, osb, &ocfs2_dlm_debug_fops); -if (!dlm_debug->d_locking_state) { - ret = -EINVAL ; -mlog (ML_ERROR , -"Unable to create locking state debugfs file.\n" ); - goto out; - } -ocfs2_get_dlm_debug (dlm_debug); -out: -return ret; }static void ocfs2_dlm_shutdown_debug (struct ocfs2_super *osb)
@@ -3256,11 +3246,7 @@ int ocfs2_dlm_init(struct ocfs2_super *osb) goto local; } - status =ocfs2_dlm_init_debug (osb); -if (status <0 ) { -mlog_errno (status); - goto bail; - } +ocfs2_dlm_init_debug (osb);/* launch downconvert thread */ osb->dc_task = kthread_run(ocfs2_downconvert_thread, osb, "ocfs2dc-%s",
fs/ocfs2/super.c +3 -26
@@ -1079,33 +1079,15 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) osb->osb_debug_root =debugfs_create_dir (osb->uuid_str, ocfs2_debugfs_root); -if (!osb->osb_debug_root) { - status = -EINVAL ; -mlog (ML_ERROR ,"Unable to create per-mount debugfs root.\n" ); - goto read_super_error; - } osb->osb_ctxt =debugfs_create_file ("fs_state" ,S_IFREG |S_IRUSR , osb->osb_debug_root, osb, &ocfs2_osb_debug_fops); -if (!osb->osb_ctxt) { - status = -EINVAL ; -mlog_errno (status); - goto read_super_error; - } -if (ocfs2_meta_ecc (osb)) { - status =ocfs2_blockcheck_stats_debugfs_install ( - &osb->osb_ecc_stats, - osb->osb_debug_root); -if (status) { -mlog (ML_ERROR , -"Unable to create blockcheck statistics " -"files\n" ); - goto read_super_error; - } - } +if (ocfs2_meta_ecc (osb)) +ocfs2_blockcheck_stats_debugfs_install ( &osb->osb_ecc_stats, + osb->osb_debug_root); status =ocfs2_mount_volume (sb);if (status <0 )
@@ -1592,11 +1574,6 @@ static int __init ocfs2_init(void) goto out2; ocfs2_debugfs_root =debugfs_create_dir ("ocfs2" ,NULL ); -if (!ocfs2_debugfs_root) { - status = -ENOMEM ; -mlog (ML_ERROR ,"Unable to create ocfs2 debugfs root.\n" ); - goto out3; - }ocfs2_set_locking_protocol ();
Signature · 1 line
2.22.0