From patchwork Mon Oct 21 08:59:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Tianhong X-Patchwork-Id: 285137 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0EDA72C016A for ; Mon, 21 Oct 2013 20:06:53 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754799Ab3JUJGd (ORCPT ); Mon, 21 Oct 2013 05:06:33 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:41603 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754661Ab3JUJG3 (ORCPT ); Mon, 21 Oct 2013 05:06:29 -0400 Received: from 172.24.2.119 (EHLO szxeml207-edg.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AFR03538; Mon, 21 Oct 2013 16:59:55 +0800 (CST) Received: from SZXEML413-HUB.china.huawei.com (10.82.67.152) by szxeml207-edg.china.huawei.com (172.24.2.56) with Microsoft SMTP Server (TLS) id 14.3.146.0; Mon, 21 Oct 2013 16:59:16 +0800 Received: from [127.0.0.1] (10.135.72.199) by szxeml413-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.146.0; Mon, 21 Oct 2013 16:59:12 +0800 Message-ID: <5264ECDD.1030600@huawei.com> Date: Mon, 21 Oct 2013 16:59:09 +0800 From: Ding Tianhong User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Jay Vosburgh , Andy Gospodarek , "David S. Miller" , Nikolay Aleksandrov , Veaceslav Falico , Netdev Subject: [PATCH net-next 4/5] bonding: remove bond read lock for bond_activebackup_arp_mon() X-Originating-IP: [10.135.72.199] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The bond now only attach and detach slave in rtnl lock, so read_lock for bond could not protect slave list, replace bond read lock with rtnl lock for bond_activebackup_arp_mon(). Signed-off-by: Ding Tianhong --- drivers/net/bonding/bond_main.c | 46 ++++++++++++----------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 149f4b9..f3df532 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -2763,51 +2763,31 @@ void bond_activebackup_arp_mon(struct work_struct *work) struct bonding *bond = container_of(work, struct bonding, arp_work.work); bool should_notify_peers = false; - int delta_in_ticks; - read_lock(&bond->lock); - - delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); + if (!rtnl_trylock()) + goto re_arm; - if (!bond_has_slaves(bond)) + if (!bond_has_slaves(bond)) { + rtnl_unlock(); goto re_arm; + } should_notify_peers = bond_should_notify_peers(bond); - if (bond_ab_arp_inspect(bond)) { - read_unlock(&bond->lock); - - /* Race avoidance with bond_close flush of workqueue */ - if (!rtnl_trylock()) { - read_lock(&bond->lock); - delta_in_ticks = 1; - should_notify_peers = false; - goto re_arm; - } - - read_lock(&bond->lock); - + if (bond_ab_arp_inspect(bond)) bond_ab_arp_commit(bond); - read_unlock(&bond->lock); - rtnl_unlock(); - read_lock(&bond->lock); - } - bond_ab_arp_probe(bond); -re_arm: - if (bond->params.arp_interval) - queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks); + if (should_notify_peers) + call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); - read_unlock(&bond->lock); + rtnl_unlock(); - if (should_notify_peers) { - if (!rtnl_trylock()) - return; - call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); - rtnl_unlock(); - } +re_arm: + if (bond->params.arp_interval) + queue_delayed_work(bond->wq, &bond->arp_work, + msecs_to_jiffies(bond->params.arp_interval)); } /*-------------------------- netdev event handling --------------------------*/