bonding: style, comment and assertion changes
Subsystems (3)
cover bonding: style, comment and assertion changes
Hi all,
This is a small and simple patch-set that doesn't introduce (hopefully) any functional changes, but only stylistic and semantic ones.
Patch 01 simply uses the already provided __rlb_next_rx_slave function inside rlb_next_rx_slave(), thus removing the duplication of code.
Patch 02 changes all comments that I could find to netdev style, removes some outdated ones and fixes a few more small cosmetic issues (new line after declaration, braces around if; else and such)
Patch 03 removes one extra ASSERT_RTNL() because we already have it in the parent function and consolidates two other ASSERT_RTNL()s to the function that is exported and supposed to be called with RTNL anyway.
Best regards,
Nikolay Aleksandrov
Nikolay Aleksandrov (3):
bonding: consolidate the two rlb_next_rx_slave functions into one
bonding: trivial: style and comment fixes
bonding: consolidate ASSERT_RTNL()s and remove the unnecessary
drivers/net/bonding/bond_3ad.c | 5 +- drivers/net/bonding/bond_alb.c | 86 ++++++---------- drivers/net/bonding/bond_debugfs.c | 4 +- drivers/net/bonding/bond_main.c | 205 +++++++++++++------------------------ drivers/net/bonding/bond_sysfs.c | 1 - drivers/net/bonding/bonding.h | 3 +- 6 files changed, 105 insertions(+), 199 deletions(-)
Signature · 1 line
1.9.3
PATCH 1/3 bonding: consolidate the two rlb_next_rx_slave functions into one
__rlb_next_rx_slave() is a copy of rlb_next_rx_slave() with the difference that it uses rcu primitives to walk the slave list. We don't need the two functions and can make rlb_next_rx_slave() a wrapper for callers which hold RTNL.
So add a comment and ASSERT_RTNL() to make sure what is intended.
--- drivers/net/bonding/bond_alb.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-)
drivers/net/bonding/bond_alb.c +10 -28
@@ -334,14 +334,15 @@ out:return RX_HANDLER_ANOTHER ; } -static struct slave *rlb_next_rx_slave (struct bonding *bond) +/* Caller must hold rcu_read_lock() */ +static struct slave *__rlb_next_rx_slave (struct bonding *bond) {struct alb_bond_info *bond_info = &(BOND_ALB_INFO (bond));struct slave *before =NULL , *rx_slave =NULL , *slave;struct list_head *iter;bool found = false; -bond_for_each_slave (bond, slave, iter) { +bond_for_each_slave_rcu (bond, slave, iter) {if (!bond_slave_can_tx (slave))continue ;if (!found) {
@@ -366,35 +367,16 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond)return rx_slave; } -/* Caller must hold rcu_read_lock() */ -static struct slave *__rlb_next_rx_slave (struct bonding *bond) +/* Caller must hold RTNL, rcu_read_lock is obtained only to silence checkers */ +static struct slave *rlb_next_rx_slave (struct bonding *bond) { -struct alb_bond_info *bond_info = &(BOND_ALB_INFO (bond)); -struct slave *before =NULL , *rx_slave =NULL , *slave; -struct list_head *iter; -bool found = false; +struct slave *rx_slave; -bond_for_each_slave_rcu (bond, slave, iter) { -if (!bond_slave_can_tx (slave)) -continue ; -if (!found) { -if (!before || before->speed < slave->speed) - before = slave; - }else { -if (!rx_slave || rx_slave->speed < slave->speed) - rx_slave = slave; - } -if (slave == bond_info->rx_slave) - found = true; - } -/* we didn't find anything after the current or we have something -* better before and up to the current slave -*/ -if (!rx_slave || (before && rx_slave->speed < before->speed)) - rx_slave = before; +ASSERT_RTNL (); -if (rx_slave) - bond_info->rx_slave = rx_slave; +rcu_read_lock (); + rx_slave =__rlb_next_rx_slave (bond); +rcu_read_unlock ();return rx_slave; }
Signature · 1 line
1.9.3
PATCH 2/3 bonding: trivial: style and comment fixes
In reply to Nikolay AleksandrovFirst adjust a couple of locking comments that were left inaccurate, then adjust comments to use the netdev styling and remove extra new lines where necessary and add a couple of new lines between declarations and code. These are all trivial styling changes, no functional change. Also removed a couple of outdated or obvious comments.
This patch is by no means a complete fix of all netdev style violations but it gets the bonding closer.
--- drivers/net/bonding/bond_3ad.c | 5 +- drivers/net/bonding/bond_alb.c | 48 ++++----- drivers/net/bonding/bond_debugfs.c | 4 +- drivers/net/bonding/bond_main.c | 199 +++++++++++++------------------------ drivers/net/bonding/bond_sysfs.c | 1 - drivers/net/bonding/bonding.h | 3 +- 6 files changed, 93 insertions(+), 167 deletions(-)
drivers/net/bonding/bond_3ad.c +2 -3
@@ -297,15 +297,14 @@ static u16 __get_link_speed(struct port *port)static u8 __get_duplex (struct port *port) {struct slave *slave = port->slave; -u8 retval;/* handling a special case: when the configuration starts with * link down, it sets the duplex to 0. */ -if (slave->link !=BOND_LINK_UP ) +if (slave->link !=BOND_LINK_UP ) { retval =0x0 ; -else { + }else {switch (slave->duplex) {case DUPLEX_FULL : retval =0x1 ;
drivers/net/bonding/bond_alb.c +20 -28
151 lines not on this page · raw message
drivers/net/bonding/bond_debugfs.c +1 -3
@@ -13,9 +13,7 @@static struct dentry *bonding_debug_root; -/* -* Show RLB hash table -*/ +/* Show RLB hash table */ static int bond_debug_rlb_hash_show (struct seq_file *m,void *v) {struct bonding *bond = m->private;
drivers/net/bonding/bond_main.c +68 -131
546 lines not on this page · raw message
drivers/net/bonding/bond_sysfs.c +0 -1
@@ -91,7 +91,6 @@ static struct net_device *bond_get_by_name(struct bond_net *bn, const char *ifna* creates and deletes entire bonds. * * The class parameter is ignored. -* */ static ssize_t bonding_store_bonds(struct class *cls, struct class_attribute *attr,
drivers/net/bonding/bonding.h +2 -1
@@ -197,7 +197,8 @@ struct bonding { struct slave *);/* mode_lock is used for mode-specific locking needs, currently used by: * 3ad mode (4) - protect against running bond_3ad_unbind_slave() and -* bond_3ad_state_machine_handler() concurrently. +* bond_3ad_state_machine_handler() concurrently and also +* the access to the state machine shared variables. * TLB mode (5) - to sync the use and modifications of its hash table * ALB mode (6) - to sync the use and modifications of its hash table */
Signature · 1 line
1.9.3
PATCH 3/3 bonding: consolidate ASSERT_RTNL()s and remove the unnecessary
In reply to Nikolay AleksandrovConsolidate the calls to ASSERT_RTNL() before bond_select_active_slave() inside bond_select_active_slave() itself and remove the ASSERT_RTNL() from bond_hw_addr_swap() as it's not exported and its only caller - bond_change_active_slave() already has an ASSERT_RTNL().
--- drivers/net/bonding/bond_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/bonding/bond_main.c +2 -4
@@ -577,8 +577,6 @@ static void bond_hw_addr_flush(struct net_device *bond_dev,static void bond_hw_addr_swap (struct bonding *bond,struct slave *new_active,struct slave *old_active) { -ASSERT_RTNL (); -if (old_active) {if (bond->dev->flags &IFF_PROMISC )dev_set_promiscuity (old_active->dev,-1 );
@@ -876,6 +874,8 @@ void bond_select_active_slave(struct bonding *bond)struct slave *best_slave;int rv; +ASSERT_RTNL (); + best_slave =bond_find_best_slave (bond);if (best_slave !=rtnl_dereference (bond->curr_active_slave)) {bond_change_active_slave (bond, best_slave);
@@ -2004,7 +2004,6 @@ static void bond_miimon_commit(struct bonding *bond) } do_failover: -ASSERT_RTNL ();block_netpoll_tx ();bond_select_active_slave (bond);unblock_netpoll_tx ();
@@ -2598,7 +2597,6 @@ static void bond_ab_arp_commit(struct bonding *bond) } do_failover: -ASSERT_RTNL ();block_netpoll_tx ();bond_select_active_slave (bond);unblock_netpoll_tx ();
Signature · 1 line
1.9.3
David Miller
maintainerFrom: Nikolay Aleksandrov <[email protected]>
Date: Mon, 15 Sep 2014 17:19:32 +0200
Quoted 10 lines
This is a small and simple patch-set that doesn't introduce (hopefully) any functional changes, but only stylistic and semantic ones.
Patch 01 simply uses the already provided__rlb_next_rx_slavefunction insiderlb_next_rx_slave(), thus removing the duplication of code.
Patch 02 changes all comments that I could find to netdev style, removes some outdated ones and fixes a few more small cosmetic issues (new line after declaration, braces around if; else and such)
Patch 03 removes one extraASSERT_RTNL()because we already have it in the parent function and consolidates two other ASSERT_RTNL()s to the function that is exported and supposed to be called with RTNL anyway.
Series applied, thanks.