Commit 4b006b43 authored by David S. Miller's avatar David S. Miller

Merge branch 'bond-cleanups'

Zhengchao Shao says:

====================
bonding: do some cleanups in bond driver

Do some cleanups in bond driver.

---
v2: use IS_ERR instead of NULL check in patch 2/5, update commit
    information in patch 3/5, remove inline modifier in patch 4/5
====================
Reviewed-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e5cd429e f5370ba3
...@@ -49,9 +49,6 @@ DEFINE_SHOW_ATTRIBUTE(bond_debug_rlb_hash); ...@@ -49,9 +49,6 @@ DEFINE_SHOW_ATTRIBUTE(bond_debug_rlb_hash);
void bond_debug_register(struct bonding *bond) void bond_debug_register(struct bonding *bond)
{ {
if (!bonding_debug_root)
return;
bond->debug_dir = bond->debug_dir =
debugfs_create_dir(bond->dev->name, bonding_debug_root); debugfs_create_dir(bond->dev->name, bonding_debug_root);
...@@ -61,9 +58,6 @@ void bond_debug_register(struct bonding *bond) ...@@ -61,9 +58,6 @@ void bond_debug_register(struct bonding *bond)
void bond_debug_unregister(struct bonding *bond) void bond_debug_unregister(struct bonding *bond)
{ {
if (!bonding_debug_root)
return;
debugfs_remove_recursive(bond->debug_dir); debugfs_remove_recursive(bond->debug_dir);
} }
...@@ -71,9 +65,6 @@ void bond_debug_reregister(struct bonding *bond) ...@@ -71,9 +65,6 @@ void bond_debug_reregister(struct bonding *bond)
{ {
struct dentry *d; struct dentry *d;
if (!bonding_debug_root)
return;
d = debugfs_rename(bonding_debug_root, bond->debug_dir, d = debugfs_rename(bonding_debug_root, bond->debug_dir,
bonding_debug_root, bond->dev->name); bonding_debug_root, bond->dev->name);
if (!IS_ERR(d)) { if (!IS_ERR(d)) {
...@@ -84,11 +75,11 @@ void bond_debug_reregister(struct bonding *bond) ...@@ -84,11 +75,11 @@ void bond_debug_reregister(struct bonding *bond)
} }
} }
void bond_create_debugfs(void) void __init bond_create_debugfs(void)
{ {
bonding_debug_root = debugfs_create_dir("bonding", NULL); bonding_debug_root = debugfs_create_dir("bonding", NULL);
if (!bonding_debug_root) if (IS_ERR(bonding_debug_root))
pr_warn("Warning: Cannot create bonding directory in debugfs\n"); pr_warn("Warning: Cannot create bonding directory in debugfs\n");
} }
...@@ -113,7 +104,7 @@ void bond_debug_reregister(struct bonding *bond) ...@@ -113,7 +104,7 @@ void bond_debug_reregister(struct bonding *bond)
{ {
} }
void bond_create_debugfs(void) void __init bond_create_debugfs(void)
{ {
} }
......
...@@ -5046,19 +5046,7 @@ static void bond_set_slave_arr(struct bonding *bond, ...@@ -5046,19 +5046,7 @@ static void bond_set_slave_arr(struct bonding *bond,
static void bond_reset_slave_arr(struct bonding *bond) static void bond_reset_slave_arr(struct bonding *bond)
{ {
struct bond_up_slave *usable, *all; bond_set_slave_arr(bond, NULL, NULL);
usable = rtnl_dereference(bond->usable_slaves);
if (usable) {
RCU_INIT_POINTER(bond->usable_slaves, NULL);
kfree_rcu(usable, rcu);
}
all = rtnl_dereference(bond->all_slaves);
if (all) {
RCU_INIT_POINTER(bond->all_slaves, NULL);
kfree_rcu(all, rcu);
}
} }
/* Build the usable slaves array in control path for modes that use xmit-hash /* Build the usable slaves array in control path for modes that use xmit-hash
...@@ -5875,7 +5863,6 @@ static void bond_destructor(struct net_device *bond_dev) ...@@ -5875,7 +5863,6 @@ static void bond_destructor(struct net_device *bond_dev)
if (bond->wq) if (bond->wq)
destroy_workqueue(bond->wq); destroy_workqueue(bond->wq);
if (bond->rr_tx_counter)
free_percpu(bond->rr_tx_counter); free_percpu(bond->rr_tx_counter);
} }
...@@ -5951,7 +5938,6 @@ void bond_setup(struct net_device *bond_dev) ...@@ -5951,7 +5938,6 @@ void bond_setup(struct net_device *bond_dev)
static void bond_uninit(struct net_device *bond_dev) static void bond_uninit(struct net_device *bond_dev)
{ {
struct bonding *bond = netdev_priv(bond_dev); struct bonding *bond = netdev_priv(bond_dev);
struct bond_up_slave *usable, *all;
struct list_head *iter; struct list_head *iter;
struct slave *slave; struct slave *slave;
...@@ -5962,17 +5948,7 @@ static void bond_uninit(struct net_device *bond_dev) ...@@ -5962,17 +5948,7 @@ static void bond_uninit(struct net_device *bond_dev)
__bond_release_one(bond_dev, slave->dev, true, true); __bond_release_one(bond_dev, slave->dev, true, true);
netdev_info(bond_dev, "Released all slaves\n"); netdev_info(bond_dev, "Released all slaves\n");
usable = rtnl_dereference(bond->usable_slaves); bond_set_slave_arr(bond, NULL, NULL);
if (usable) {
RCU_INIT_POINTER(bond->usable_slaves, NULL);
kfree_rcu(usable, rcu);
}
all = rtnl_dereference(bond->all_slaves);
if (all) {
RCU_INIT_POINTER(bond->all_slaves, NULL);
kfree_rcu(all, rcu);
}
list_del(&bond->bond_list); list_del(&bond->bond_list);
...@@ -5981,7 +5957,7 @@ static void bond_uninit(struct net_device *bond_dev) ...@@ -5981,7 +5957,7 @@ static void bond_uninit(struct net_device *bond_dev)
/*------------------------- Module initialization ---------------------------*/ /*------------------------- Module initialization ---------------------------*/
static int bond_check_params(struct bond_params *params) static int __init bond_check_params(struct bond_params *params)
{ {
int arp_validate_value, fail_over_mac_value, primary_reselect_value, i; int arp_validate_value, fail_over_mac_value, primary_reselect_value, i;
struct bond_opt_value newval; struct bond_opt_value newval;
......
...@@ -803,7 +803,7 @@ static const struct attribute_group bonding_group = { ...@@ -803,7 +803,7 @@ static const struct attribute_group bonding_group = {
/* Initialize sysfs. This sets up the bonding_masters file in /* Initialize sysfs. This sets up the bonding_masters file in
* /sys/class/net. * /sys/class/net.
*/ */
int bond_create_sysfs(struct bond_net *bn) int __net_init bond_create_sysfs(struct bond_net *bn)
{ {
int ret; int ret;
...@@ -836,7 +836,7 @@ int bond_create_sysfs(struct bond_net *bn) ...@@ -836,7 +836,7 @@ int bond_create_sysfs(struct bond_net *bn)
} }
/* Remove /sys/class/net/bonding_masters. */ /* Remove /sys/class/net/bonding_masters. */
void bond_destroy_sysfs(struct bond_net *bn) void __net_exit bond_destroy_sysfs(struct bond_net *bn)
{ {
netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, bn->net); netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, bn->net);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment