From patchwork Sun Jul 25 05:43:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 59872 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 B4B59B6F11 for ; Sun, 25 Jul 2010 15:44:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751702Ab0GYFoH (ORCPT ); Sun, 25 Jul 2010 01:44:07 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:45942 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751551Ab0GYFoF (ORCPT ); Sun, 25 Jul 2010 01:44:05 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Ocu04-0007er-2X; Sat, 24 Jul 2010 23:43:48 -0600 Received: from c-67-188-4-80.hsd1.ca.comcast.net ([67.188.4.80] helo=fess.ebiederm.org) by in01.mta.xmission.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Ocu03-0002fC-Ox; Sat, 24 Jul 2010 23:43:47 -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 o6P5hi8Z031967; Sat, 24 Jul 2010 22:43:44 -0700 Received: (from eric@localhost) by fess.ebiederm.org (8.14.3/8.14.3/Submit) id o6P5hZEV031962; Sat, 24 Jul 2010 22:43:35 -0700 To: Linus Torvalds Cc: Johannes Berg , Kay Sievers , Andrew Morton , Greg KH , "Rafael J. Wysocki" , "Maciej W. Rozycki" , netdev , " Marcel Holtmann" , linux-bluetooth@vger.kernel.org, Greg KH Subject: [PATCH] Driver-core: Always create class directories for classses that support namespaces. References: <20100719133451.0862ca62.akpm@linux-foundation.org> <20100720201334.GA11991@suse.de> <1279822828.12439.24.camel@jlt3.sipsolutions.net> <20100722182827.GA12821@suse.de> <1279823801.12439.31.camel@jlt3.sipsolutions.net> <20100722185449.GB528@suse.de> From: ebiederm@xmission.com (Eric W. Biederman) Date: Sat, 24 Jul 2010 22:43:35 -0700 In-Reply-To: <20100722185449.GB528@suse.de> (Greg KH's message of "Thu\, 22 Jul 2010 11\:54\:49 -0700") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 X-XM-SPF: eid=; ; ; mid=; ; ; hst=in01.mta.xmission.com; ; ; ip=67.188.4.80; ; ; frm=ebiederm@xmission.com; ; ; spf=neutral X-SA-Exim-Connect-IP: 67.188.4.80 X-SA-Exim-Mail-From: ebiederm@xmission.com X-SA-Exim-Scanned: No (on in01.mta.xmission.com); SAEximRunCond expanded to false Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This fixes the regression in 2.6.35-rcX where bluetooth network devices would fail to be deleted from sysfs, causing their destruction and recreation to fail. In addition this fixes the mac80211_hwsim driver where it would leave around sysfs files when the driver was removed. This problem is discussed at https://bugzilla.kernel.org/show_bug.cgi?id=16257 The reason for the regression is that the network namespace support added to sysfs expects and requires that network devices be put in directories that can contain only network devices. Today get_device_parent almost provides that guarantee for all class devices, except for a specific exception when the parent of a class devices is a class device. It would be nice to simply remove that arguably incorrect special case, but apparently the input devices depend on it being there. So I have only removed it for class devices with network namespace support. Which today are the network devices. It has been suggested that a better fix would be to change the parent device from a class device to a bus device, which in the case of the bluetooth driver would change /sys/class/bluetooth to /sys/bus/bluetoth, I can not see how we would avoid significant userspace breakage if we were to make that change. Adding an extra directory in the path to the device will also be userspace visible but it is much less likely to break things. Everything is still accessible from /sys/class (for example), and it fixes two bugs. Adding an extra directory fixes a 3 year old regression introduced with the new sysfs layout that makes if impossible to rename bnep0 network devices to names that conflict with hci device attributes like hci_revsion. Adding an additional directory remove the new failure modes introduced by the network namespace code. If it weren't for the regession in the renaming of network devices I would figure out how to just make the sysfs code deal with this configuration of devices. In summary this patch fixes regressions by changing: "/sys/class/bluetooth/hci0/bnep0" to "/sys/class/bluetooth/hci0/net/bnep0". Reported-by: Johannes Berg Reported-by: Janusz Krzysztofik Signed-off-by: Eric W. Biederman --- p.s. Linus my apologies for sending this directly but I have gotten an incredible amount of flak trying to fix this problem, and I would like not to leave an accidental regression whose cause is well known in 2.6.35 if I can help it. drivers/base/core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 9630fbd..9b9d3bd 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -673,7 +673,7 @@ static struct kobject *get_device_parent(struct device *dev, */ if (parent == NULL) parent_kobj = virtual_device_parent(dev); - else if (parent->class) + else if (parent->class && !dev->class->ns_type) return &parent->kobj; else parent_kobj = &parent->kobj;