Re: [PATCH 06/11] sysfs: Implement sysfs tagged directory support.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Tejun Heo <htejun@...>
Cc: Benjamin Thery <benjamin.thery@...>, Greg Kroah-Hartman <gregkh@...>, Andrew Morton <akpm@...>, Daniel Lezcano <dlezcano@...>, Serge Hallyn <serue@...>, <linux-kernel@...>, Al Viro <viro@...>, Linux Containers <containers@...>
Date: Thursday, June 26, 2008 - 4:21 pm

Tejun thank you for the review, and my apologies for the delayed
reply.

Tejun Heo <htejun@gmail.com> writes:


It isn't so much computing tags dynamically but rather it is reading them
from where they are stored.



Youch that seems limiting.  The expectation is that we could have
as many as 100 different containers in use on a single system at one
time.  So 100 apparent copies of the network stack.

There is also a second dimension here we multiplex different
directories based on different sets of tags.   One directory based
on user namespaces another on the network namespaces.

The tags in practice are just pointers to the namespace pointers.

So while we could use the ida technique to specify which set of tags
we are talking about for a directory it isn't sufficient.

The question sysfs_tag_enabled(sb, tag) makes no sense to me.
Especially in the context of needed a sysfs_sb_show_tag(sb, tag);

The current structure is because of all of the darn fool races and
magic that sysfs does.  We have to say for a given directory:  Your
contents will always be tagged, and only those that one tag that
matches what was captured by the superblock when sysfs is mounted
will be shown.


We have a  fundamental issue that we have to handle, and it sounds like
you are proposing something that will not handle it.

- network devices can move between namespaces.
- network devices have driver specific sysfs attributes hanging off of them.

So we have to move the network devices and their sysfs attributes
between namespaces, and I implemented that in kobject_rename,
sysfs_rename path.

The tags on a kobject can only change during a rename operation.
So when the change happens is well defined.  Further there is a
set of functions:  sysfs_creation_tag, sysfs_removal_tag,
sysfs_lookup_tag, sysfs_dirent_tag which makes it clear what we
are doing.

If you really don't like how the tags are managed we need to talk
about how we store the tags on kobjects and on the super block.

Registering a set of tags could easily make the sb_tag function
obsolete, and that is one small piece of code so it is no big deal.

struct sysfs_tag_type_operations {
	const void *(*mount_tag)(void);
        const void *(*kobject_tag)(struct kobject *kobj);
};

Then we could do:
struct sysfs_sbtag_operations *tag_type_ops[MAX_TAG_TYPES];

And sysfs_tag_info could become.
struct sysfs_tag_info {
       void *tag[MAX_TAG_TYPES];
};

During subsystem initialization we could call
tag_type = sysfs_allocate_tag_type();

Just after the subsystem creates a directory.
sysfs_enable_tagging(kobj/sd, tag_type);

Then anytime we currently call sb_tag during lookup we can instead
just look at sysfs_info(sb)->tag[tag_type] and compare that with
sd->s_tag.tag.

The actual tag values themselves are current stored in the object in
which the kobject is embedded.

So we still need to call kobject_tag when we create or rename
something in a tagged directory.  So we know what the tag is.

When we go to remove a kobj using the existing tag on the object
is the right choice.

Rename is the fun case where we need to grab the old tag from the
sd and place on it the new tag from kobject_tag. 

One of the big problems at least with the class directories is that
the lifetimes are completely decoupled the between the tags and
the subsystem objects and subsystem directories that need to be
tagged.  This isn't a set things up at the start of your subsystem
and everything is happy situation.  To handle the races there must
be support at least at the kobject level for handling this in the
network namespace case.

Eric
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 06/11] sysfs: Implement sysfs tagged directory su..., Eric W. Biederman, (Thu Jun 26, 4:21 pm)
Re: [PATCH 06/11] sysfs: Implement sysfs tagged directory su..., Eric W. Biederman, (Mon Jun 30, 2:56 pm)
Re: [PATCH 06/11] sysfs: Implement sysfs tagged directory su..., Eric W. Biederman, (Tue Jul 1, 11:53 pm)
Re: [PATCH 06/11] sysfs: Implement sysfs tagged directory su..., Eric W. Biederman, (Wed Jul 2, 12:49 pm)
[PATCH 00/15] sysfs support for namespaces, Eric W. Biederman, (Thu Jul 3, 8:48 pm)
Re: [PATCH 00/15] sysfs support for namespaces, Eric W. Biederman, (Sun Jul 6, 12:42 am)
Re: [PATCH 00/15] sysfs support for namespaces, Cornelia Huck, (Mon Jul 7, 7:41 am)
Re: [PATCH 00/15] sysfs support for namespaces, Eric W. Biederman, (Mon Jul 7, 8:22 am)
Re: [PATCH 00/15] sysfs support for namespaces, Eric W. Biederman, (Thu Jul 3, 9:27 pm)
[PATCH 02/15] sysfs: Support for preventing unmounts., Eric W. Biederman, (Thu Jul 3, 9:07 pm)
[PATCH 03/15] sysfs: sysfs_get_dentry add a sb parameter, Eric W. Biederman, (Thu Jul 3, 9:08 pm)
[PATCH 04/15] sysfs: Implement __sysfs_get_dentry, Eric W. Biederman, (Thu Jul 3, 9:09 pm)
[PATCH 05/15] sysfs: Rename Support multiple superblocks, Eric W. Biederman, (Thu Jul 3, 9:10 pm)
[PATCH 06/15] Introduce sysfs_sd_setattr and fix sysfs_chmod, Eric W. Biederman, (Thu Jul 3, 9:11 pm)
[PATCH 08/15] sysfs: Make sysfs_mount static once again., Eric W. Biederman, (Thu Jul 3, 9:14 pm)
[PATCH 0/8] sysfs namespace support, Eric W. Biederman, (Thu Aug 21, 2:31 am)
[PATCH 1/8] sysfs: Implement sysfs tagged directory support., Eric W. Biederman, (Thu Aug 21, 2:33 am)
Re: [PATCH 1/8] sysfs: Implement sysfs tagged directory supp..., Eric W. Biederman, (Mon Oct 13, 11:20 pm)
[PATCH 2/8] sysfs: Merge sysfs_rename_dir and sysfs_move_dir, Eric W. Biederman, (Thu Aug 21, 2:34 am)
[PATCH 3/8] sysfs: Implement sysfs_delete_link and sysfs_ren..., Eric W. Biederman, (Thu Aug 21, 2:35 am)
[PATCH 4/8] driver core: Implement tagged directory support ..., Eric W. Biederman, (Thu Aug 21, 2:37 am)
[PATCH 5/8] sysfs: Remove sysfs_create_link_nowarn, Eric W. Biederman, (Thu Aug 21, 2:36 am)
[PATCH 6/8] Revert "netns: Fix device renaming for sysfs", Eric W. Biederman, (Thu Aug 21, 2:38 am)
[PATCH 7/8] netns: Enable tagging for net_class directories ..., Eric W. Biederman, (Thu Aug 21, 2:39 am)
[PATCH 8/8] sysfs: user namespaces: fix bug with clone(CLONE..., Eric W. Biederman, (Thu Aug 21, 2:40 am)
Re: [PATCH 0/8] sysfs namespace support, David Miller, (Thu Aug 21, 2:37 am)
Re: [PATCH 09/15] sysfs: Implement sysfs tagged directory su..., Eric W. Biederman, (Wed Aug 20, 2:58 am)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Sun Jul 13, 9:54 pm)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Fri Jul 18, 4:19 pm)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Wed Jul 16, 1:41 am)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Wed Jul 16, 2:32 am)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Wed Jul 16, 5:09 pm)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Wed Jul 16, 3:07 pm)
[PATCH 13/15] Revert "netns: Fix device renaming for sysfs", Eric W. Biederman, (Thu Jul 3, 9:21 pm)