From patchwork Fri Oct 30 00:18:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 37234 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.176.167]) by ozlabs.org (Postfix) with ESMTP id D1BC71007D2 for ; Fri, 30 Oct 2009 11:18:54 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755849AbZJ3ASo (ORCPT ); Thu, 29 Oct 2009 20:18:44 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755735AbZJ3ASm (ORCPT ); Thu, 29 Oct 2009 20:18:42 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:35830 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755430AbZJ3ASl (ORCPT ); Thu, 29 Oct 2009 20:18:41 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1N3fCY-00068r-4t; Thu, 29 Oct 2009 18:18:46 -0600 Received: from c-76-21-114-89.hsd1.ca.comcast.net ([76.21.114.89] helo=fess.ebiederm.org) by in01.mta.xmission.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1N3fC2-0003rY-MR; Thu, 29 Oct 2009 18:18:14 -0600 Received: from fess.ebiederm.org (localhost [127.0.0.1]) by fess.ebiederm.org (8.14.3/8.14.3/Debian-4) with ESMTP id n9U0Igbn005095; Thu, 29 Oct 2009 17:18:42 -0700 Received: (from eric@localhost) by fess.ebiederm.org (8.14.3/8.14.3/Submit) id n9U0IgMe005094; Thu, 29 Oct 2009 17:18:42 -0700 From: "Eric W. Biederman" To: David Miller Cc: , Jay Vosburgh , "Eric W. Biederman" Subject: [PATCH 2/6] bond: Simply bond sysfs group creation Date: Thu, 29 Oct 2009 17:18:22 -0700 Message-Id: <1256861906-5059-2-git-send-email-ebiederm@xmission.com> X-Mailer: git-send-email 1.6.3.1.54.g99dd.dirty In-Reply-To: References: X-XM-SPF: eid=; ; ; mid=; ; ; hst=in01.mta.xmission.com; ; ; ip=76.21.114.89; ; ; frm=ebiederm@xmission.com; ; ; spf=neutral X-SA-Exim-Connect-IP: 76.21.114.89 X-SA-Exim-Mail-From: ebiederm@xmission.com X-SA-Exim-Scanned: No (on in01.mta.xmission.com); Exit with error (see exim mainlog) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric W. Biederman This patch delegates the work of creating the sysfs groups to the netdev layer and ultimately to the device layer. This closes races between uevents. Signed-off-by: Eric W. Biederman --- drivers/net/bonding/bond_main.c | 11 +---------- drivers/net/bonding/bond_sysfs.c | 20 ++------------------ drivers/net/bonding/bonding.h | 3 +-- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 8c5ebfb..f73d2de 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -2011,7 +2011,6 @@ static void bond_uninit(struct net_device *bond_dev) struct bonding *bond = netdev_priv(bond_dev); bond_deinit(bond_dev); - bond_destroy_sysfs_entry(bond); if (bond->wq) destroy_workqueue(bond->wq); @@ -3457,9 +3456,6 @@ static int bond_event_changename(struct bonding *bond) bond_remove_proc_entry(bond); bond_create_proc_entry(bond); - bond_destroy_sysfs_entry(bond); - bond_create_sysfs_entry(bond); - return NOTIFY_DONE; } @@ -5078,6 +5074,7 @@ static int bond_init(struct net_device *bond_dev) bond_create_proc_entry(bond); list_add_tail(&bond->bond_list, &bond_dev_list); + bond_prepare_sysfs_group(bond); return 0; } @@ -5120,15 +5117,9 @@ int bond_create(const char *name) if (res < 0) goto out_bond; - res = bond_create_sysfs_entry(netdev_priv(bond_dev)); - if (res < 0) - goto out_unreg; - rtnl_unlock(); return 0; -out_unreg: - unregister_netdevice(bond_dev); out_bond: bond_deinit(bond_dev); out_netdev: diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index dca7d82..f924a0b 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -1616,24 +1616,8 @@ void bond_destroy_sysfs(void) * Initialize sysfs for each bond. This sets up and registers * the 'bondctl' directory for each individual bond under /sys/class/net. */ -int bond_create_sysfs_entry(struct bonding *bond) +void bond_prepare_sysfs_group(struct bonding *bond) { - struct net_device *dev = bond->dev; - int err; - - err = sysfs_create_group(&(dev->dev.kobj), &bonding_group); - if (err) - pr_emerg("eek! didn't create group!\n"); - - return err; -} -/* - * Remove sysfs entries for each bond. - */ -void bond_destroy_sysfs_entry(struct bonding *bond) -{ - struct net_device *dev = bond->dev; - - sysfs_remove_group(&(dev->dev.kobj), &bonding_group); + bond->dev->sysfs_groups[0] = &bonding_group; } diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 9b520b0..013be29 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -331,8 +331,7 @@ int bond_create(const char *name); int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev); int bond_create_sysfs(void); void bond_destroy_sysfs(void); -void bond_destroy_sysfs_entry(struct bonding *bond); -int bond_create_sysfs_entry(struct bonding *bond); +void bond_prepare_sysfs_group(struct bonding *bond); int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave); void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave); int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);