public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Ding Tianhong <dingtianhong@huawei•com>
To: Jay Vosburgh <fubar@us•ibm.com>
Cc: <vfalico@redhat•com>, <andy@greyhouse•net>,
	<cwang@twopensource•com>, <jiri@resnulli•us>,
	<thomas@glanzmann•de>, <eric.dumazet@gmail•com>,
	<sfeldma@cumulusnetworks•com>, <davem@davemloft•net>,
	<netdev@vger•kernel.org>
Subject: Re: [PATCH net-next 2/3] bonding: add new slave param and bond_slave_state_notify()
Date: Tue, 18 Feb 2014 11:49:44 +0800	[thread overview]
Message-ID: <5302D858.5020802@huawei.com> (raw)
In-Reply-To: <5310.1392689226@death.nxdomain>

On 2014/2/18 10:07, Jay Vosburgh wrote:
> Ding Tianhong <dingtianhong@huawei•com> wrote:
> 
>> Add a new slave parameter which called should_notify, if the slave's state
>> changed and don't notify yet, the parameter will be set to 1, and then if
>> the slave's state changed again, the param will be set to 0, it indicate that
>> the slave's state has been restored, no need to notify any one.
>>
>> The bond_slave_state_notify() will check whether the status changed and then
>> decide to notify or not.
>>
>> Cc: Jay Vosburgh <fubar@us•ibm.com>
>> Cc: Veaceslav Falico <vfalico@redhat•com>
>> Cc: Andy Gospodarek <andy@greyhouse•net>
>> Signed-off-by: Ding Tianhong <dingtianhong@huawei•com>
>> ---
>> drivers/net/bonding/bonding.h | 44 +++++++++++++++++++++++++++++++++++++++++--
>> 1 file changed, 42 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
>> index d210124..4d0cd41 100644
>> --- a/drivers/net/bonding/bonding.h
>> +++ b/drivers/net/bonding/bonding.h
>> @@ -195,7 +195,8 @@ struct slave {
>> 	s8     new_link;
>> 	u8     backup:1,   /* indicates backup slave. Value corresponds with
>> 			      BOND_STATE_ACTIVE and BOND_STATE_BACKUP */
>> -	       inactive:1; /* indicates inactive slave */
>> +	       inactive:1, /* indicates inactive slave */
>> +	       should_notify:1; /* indicateds whether the state changed */
>> 	u8     duplex;
>> 	u32    original_mtu;
>> 	u32    link_failure_count;
>> @@ -311,8 +312,47 @@ static inline void bond_set_slave_state(struct slave *slave,
>> 	else
>> 		return;
>>
>> -	if (notify)
>> +	if (notify) {
>> 		rtmsg_ifinfo(RTM_NEWLINK, slave->dev, 0, GFP_KERNEL);
>> +		slave->should_notify = 0;
>> +	} else {
>> +		if (slave->should_notify)
>> +			slave->should_notify = 0;
>> +		else
>> +			slave->should_notify = 1;
>> +	}
>> +}
>> +
>> +static inline void bond_slave_state_notify(struct bonding *bond,
>> +					   bool rtnl_locked)
>> +{
>> +	struct list_head *iter;
>> +	struct slave *tmp;
>> +
>> +	rcu_read_lock();
>> +	bond_for_each_slave_rcu(bond, tmp, iter) {
>> +		if (tmp->should_notify) {
>> +			rcu_read_unlock();
>> +			goto should_notify;
>> +		}
>> +	}
>> +	rcu_read_unlock();
>> +	return;
>> +
>> +should_notify:
>> +
>> +	if (!rtnl_locked && !rtnl_trylock())
>> +		return;
>> +
>> +	bond_for_each_slave(bond, tmp, iter) {
>> +		if (tmp->should_notify) {
>> +			rtmsg_ifinfo(RTM_NEWLINK, tmp->dev, 0, GFP_KERNEL);
>> +			tmp->should_notify = 0;
>> +		}
>> +	}
>> +
>> +	if (!rtnl_locked)
>> +		rtnl_unlock();
>> }
> 
> 	This function (bond_slave_state_notify) seems overly complicated
> given that there appears to be only one caller.  In particular, why
> bother with the "rtnl_locked" flag at all, when it is never called with
> it set to true?  Really, with only one caller (in patch 3 of the
> series), I'm not convinced this even needs to be a separate function.
> 
> 	-J
> 
In my original opinion, I think it may be used in RTNL for other monitor,
so add this one, I will remove it, thanks.

Regards
Ding

>>
>> static inline void bond_slave_state_change(struct bonding *bond)
>> -- 
>> 1.8.0
> 
> ---
> 	-Jay Vosburgh, IBM Linux Technology Center, fubar@us•ibm.com
> 
> 
> .
> 

  reply	other threads:[~2014-02-18  3:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17  8:35 [PATCH net-next 0/3] bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c Ding Tianhong
2014-02-17  8:35 ` [PATCH net-next 1/3] bonding: add bond_set_slave_state/flags() Ding Tianhong
2014-02-18  2:08   ` Jay Vosburgh
2014-02-18  3:50     ` Ding Tianhong
2014-02-17  8:35 ` [PATCH net-next 2/3] bonding: add new slave param and bond_slave_state_notify() Ding Tianhong
2014-02-18  2:07   ` Jay Vosburgh
2014-02-18  3:49     ` Ding Tianhong [this message]
2014-02-17  8:35 ` [PATCH net-next 3/3] bonding: Fix the RTNL assertion failed for 802.3ad state machine Ding Tianhong
2014-02-18  2:06   ` Jay Vosburgh
2014-02-18  3:47     ` Ding Tianhong
2014-02-17 14:06 ` [PATCH net-next 0/3] bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c Thomas Glanzmann
2014-02-17 21:36 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5302D858.5020802@huawei.com \
    --to=dingtianhong@huawei$(echo .)com \
    --cc=andy@greyhouse$(echo .)net \
    --cc=cwang@twopensource$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=fubar@us$(echo .)ibm.com \
    --cc=jiri@resnulli$(echo .)us \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=sfeldma@cumulusnetworks$(echo .)com \
    --cc=thomas@glanzmann$(echo .)de \
    --cc=vfalico@redhat$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox