From: Tejun Heo <tj@kernel.org>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, kay@vrfy.org,
ebiederm@xmission.com, netdev@vger.kernel.org,
lizefan@huawei.com
Subject: [PATCHSET] sysfs: disentangle kobject namespace handling from sysfs
Date: Wed, 11 Sep 2013 22:29:02 -0400 [thread overview]
Message-ID: <1378952949-7900-1-git-send-email-tj@kernel.org> (raw)
Hello,
I'll send out multiple patchsets to separate out sysfs from driver
core and kobject. The eventual goal is making sysfs modular enough so
that cgroup can replace its nightmarish cgroupfs implementation which
repeated and worsened all the past mistakes of sysfs. This patchset
is first of the effort and separates out kobject namespace handling
from sysfs.
I never really understood why namespace support was added the way it
was added. Namespace information is communicated to sysfs via
callbacks and back-queries to upper layer, which is a very unusual and
weird thing to do when all the involved operations are synchronous.
For example, a tagged attribute creation looks like the following.
driver code driver callback
v ^
netdev_class_create_file() |
v class_attr->namespace()
class_create_file() class_attr_namespace()
v |
sysfs_create_file() |
v |
sysfs_attr_ns() -------------> sysfs_ops->namespace()
This is an absurd thing to do. It significantly obfuscates what's
going on and adds unnecessary uncertainties - for example, can
namespace() return value disagree with the recorded s_ns value without
being renamed? If so, how should that be handled? If not, what
guarantees that? Even the basic placements of callbacks don't make
much, if any, sense. Why is per-directory namespace() callback in
kobj_type while per-attr namespace() callback is in sysfs_ops? What
does this even mean?
Maybe there's some grand design scheme governing all this but it isn't
obvious at all and the whole thing looks like a hodgepodge of
short-sighted hacks.
There is absolutely *nothing* which requires this convolution. NS tag
can simply be passed down the stack just like any other type of
information and adding an extra argument or variant of interface to
pass down the extra information is way more straight-forward and
apparently even takes less amount of code, so let's please stop the
insanity.
This patchset contains the following seven patches.
0001-sysfs-drop-semicolon-from-to_sysfs_dirent-definition.patch
0002-sysfs-make-attr-namespace-interface-less-convoluted.patch
0003-sysfs-remove-ktype-namespace-invocations-in-director.patch
0004-sysfs-remove-ktype-namespace-invocations-in-symlink-.patch
0005-sysfs-drop-kobj_ns_type-handling.patch
0006-sysfs-clean-up-sysfs_get_dirent.patch
0007-sysfs-name-comes-before-ns.patch
0001 is a minor prep patch.
0002 removes the attr namespace callback.
0003-0004 push the dir namespace callback invocations from sysfs to
kobjct layer. Eventually, this callback should go too.
0005 simplifies sysfs ns support such that sysfs doesn't have any
specific knowledge of kobj namespaces. It now purely deals with
pointer tags. Combined with the previous changes, this makes sysfs ns
support mostly modular.
0006-0007 are cleanup patches to make param orders conventional and
consistent - optional param after mandatory one; otherwise, things get
extremely confusing with different variants of interfaces which take
or don't take optional params. No idea how/why this was done the
wrong way.
This patchset is based on top of the current master
c2d95729e3094ecdd8c54e856bbe971adbbd7f48 ("Merge branch 'akpm'
(patches from Andrew Morton)") and available in the following git
branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git review-sysfs-separate-out-ns
The series was lightly tested with normal and basic namespace
operations. diffstat follows.
drivers/base/class.c | 29 ++----
drivers/base/core.c | 8 +
drivers/gpio/gpiolib.c | 2
drivers/md/bitmap.c | 4
drivers/md/md.c | 2
drivers/md/md.h | 2
drivers/net/bonding/bond_sysfs.c | 14 ---
fs/sysfs/bin.c | 2
fs/sysfs/dir.c | 163 ++++++++++++++-------------------------
fs/sysfs/file.c | 105 ++++++-------------------
fs/sysfs/group.c | 29 +++---
fs/sysfs/inode.c | 6 -
fs/sysfs/mount.c | 24 +----
fs/sysfs/symlink.c | 49 +++--------
fs/sysfs/sysfs.h | 43 +++-------
include/linux/device.h | 24 ++++-
include/linux/kobject.h | 1
include/linux/netdevice.h | 16 +++
include/linux/sysfs.h | 88 ++++++++++++++-------
lib/kobject.c | 31 ++++++-
net/core/net-sysfs.c | 14 +--
21 files changed, 294 insertions(+), 362 deletions(-)
Thanks.
--
tejun
next reply other threads:[~2013-09-12 2:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-12 2:29 Tejun Heo [this message]
2013-09-12 2:29 ` [PATCH 1/7] sysfs: drop semicolon from to_sysfs_dirent() definition Tejun Heo
2013-09-12 2:29 ` [PATCH 2/7] sysfs: make attr namespace interface less convoluted Tejun Heo
2013-09-12 19:46 ` David Miller
2013-09-12 2:29 ` [PATCH 3/7] sysfs: remove ktype->namespace() invocations in directory code Tejun Heo
2013-09-12 2:29 ` [PATCH 4/7] sysfs: remove ktype->namespace() invocations in symlink code Tejun Heo
2013-09-12 2:29 ` [PATCH 5/7] sysfs: drop kobj_ns_type handling Tejun Heo
2013-09-12 2:29 ` [PATCH 6/7] sysfs: clean up sysfs_get_dirent() Tejun Heo
2013-09-12 3:22 ` [PATCH v2 " Tejun Heo
2013-09-12 2:29 ` [PATCH 7/7] sysfs: @name comes before @ns Tejun Heo
2013-09-12 3:39 ` Eric W. Biederman
2013-09-12 3:49 ` Tejun Heo
2013-09-26 22:32 ` Greg KH
2013-09-12 3:19 ` [PATCHSET] sysfs: disentangle kobject namespace handling from sysfs Greg KH
2013-09-12 3:23 ` Tejun Heo
2013-09-12 3:33 ` Greg KH
2013-09-12 3:34 ` Tejun Heo
2013-09-12 3:38 ` Eric W. Biederman
2013-09-12 4:17 ` Greg KH
2013-09-12 3:37 ` Eric W. Biederman
2013-09-12 3:47 ` Tejun Heo
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=1378952949-7900-1-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=ebiederm@xmission.com \
--cc=gregkh@linuxfoundation.org \
--cc=kay@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).