mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Tejun Heo <tj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-kernel@vger.kernel.org,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	linux-fsdevel@vger.kernel.org, Kay Sievers <kay.sievers@vrfy.org>,
	Greg KH <greg@kroah.com>,
	"Eric W. Biederman" <ebiederm@aristanetworks.com>
Subject: Re: [PATCH 04/24] sysfs: Normalize removing sysfs directories.
Date: Sat, 30 May 2009 15:51:07 +0000	[thread overview]
Message-ID: <1243698667.5223.12.camel@mulgrave.int.hansenpartnership.com> (raw)
In-Reply-To: <m1bppaei52.fsf@fess.ebiederm.org>

On Sat, 2009-05-30 at 08:15 -0700, Eric W. Biederman wrote:
> James Bottomley <James.Bottomley@HansenPartnership.com> writes:
> 
> > On Sat, 2009-05-30 at 06:07 -0700, Eric W. Biederman wrote:
> >> Tejun Heo <tj@kernel.org> writes:
> >> 
> >> > Eric W. Biederman wrote:
> >> >>   Also, I'm quite uncomfortable with these things
> >> >>> being done in non-atomic manner.  It can be made to work but things
> >> >>> like this can lead to subtle race conditions and with the kind of
> >> >>> layering we put on top of sysfs (kobject, driver model, driver
> >> >>> midlayers and so on), it isn't all that easy to verify what's going
> >> >>> on, so NACK for this one.
> >> >> 
> >> >> Total nonsense.
> >> >> 
> >> >> Mucking about with sysfs after we start deleting a directory is a bug.
> >> >> At worst my change makes a buggy race slightly less deterministic.
> >> >> 
> >> >> I am not ready to consider keeping the current unnecessary atomic
> >> >> removal step.  That unnecessary atomicity makes the following patches
> >> >> more difficult, and requires a lot of unnecessary retesting.
> >> >> 
> >> >> What do you think the extra unnecessary atomicity helps protect?
> >> >
> >> > It's just not a clean API.  When people are trying to code things way
> >> > up in the stack, they aren't likely to look up the code to see what
> >> > assumptions are being made especially when the stack is deep and
> >> > complex and sysfs is near the bottom of the tall stack.  IMHO
> >> > implementing the usually expected semantics at this depth is worth
> >> > every effort.  It's just good implementation style which might look
> >> > like wasted effort but will harden the stack in the long run.  Plus,
> >> > it's not like making it atomic is difficult or anything.
> >> 
> >> I guess we are going to have to disagree on this one.
> >> 
> >> My take is simply that a correct user has to wait until no one else
> >> can find the kobject before calling kobject_del.  At which point
> >> races are impossible, and it doesn't matter if sysfs_mutex is held
> >> across the entire operation.
> >
> > I'm afraid this one isn't a valid assumption.  If you look in SCSI,
> > you'll see we do get objects after they've been removed from visibility.
> > We use it as part of the state model for how our objects work (objects
> > removed from visibility are dying, but we still need them to be findable
> > (and gettable).
> 
> I was not precise enough.  It appears I overlooked the fact that
> kobject_del is not always called from kobject_put by way of
> kobject_release.

OK ... just so you understand, I'm thinking about the device model
rather than kobjects.  device_del() can't be called from release methods
because they're often called from interrupt context and the mutex
requirements in device_del() mean it needs user context.

> Strictly the requirement is that after kobject_del we don't add,
> remove or otherwise manipulate sysfs attributes.  That is we don't
> call any of:
> 
> sysfs_add_file
> sysfs_create_file
> sysfs_create_bin_file
> sysfs_remove_file
> sysfs_remove_bin_file
> sysfs_create_link
> sysfs_remove_link
> sysfs_create_group
> sysfs_remove_group
> sysfs_create_subdir
> sysfs_remove_subdir
> 
> 
> Those all either oops or BUG today if you try it.  So I can't see how
> a subsystem could depend on those working.

It doesn't; you've altered your requirement.  We can fully buy into this
new relaxed one.

> Also there is sysfs_remove_dir (on a subdirectory) aka kobject_del on
> a child object after kobject_del on the parent object.
> 
> As best I can tell that only works by fluke today.

Yes, that's an artifact of the fact that the reference counted lifecycle
is on release ... del just happens at a certain point in it.  We don't
hold any counters that tell us what the visibility of our children are,
so it's possible to make a parent invisible by calling del simply
because you don't know.

> > Now, this could be altered as part of an object lifetime rewrite of SCSI
> > (and I suspect a few other subsystems) but it's certainly an open
> > question of whether the pain is worth the gain.
> 
> I won't tell you that sysfs, the kobject layer, or the device layer
> are the best thing since sliced bread.  I'm just trying to simplify
> the code and get the bugs out.

James



  reply	other threads:[~2009-05-30 15:51 UTC|newest]

Thread overview: 197+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-20  4:09 [PATCH 0/20] Sysfs cleanups Eric W. Biederman
2009-05-20 15:37 ` Greg KH
2009-05-20 23:04   ` Eric W. Biederman
2009-05-21  0:27 ` [PATCH 01/20] sysfs: Implement sysfs_rename_link Eric W. Biederman
2009-05-21  0:27   ` [PATCH 02/20] driver core: Use sysfs_rename_link in device_rename Eric W. Biederman
2009-05-21  0:27     ` [PATCH 03/20] sysfs: Remove now unnecessary error reporting suppression Eric W. Biederman
2009-05-21  0:27       ` [PATCH 04/20] sysfs: Handle the general case of removing of directories with subdirectories Eric W. Biederman
2009-05-21  0:27         ` [PATCH 05/20] sysfs: Rename sysfs_d_iput to sysfs_dentry_iput Eric W. Biederman
2009-05-21  0:28           ` [PATCH 06/20] sysfs: Use dentry_ops instead of directly playing with the dcache Eric W. Biederman
2009-05-21  0:28             ` [PATCH 07/20] sysfs: Simplify sysfs_chmod_file semantics Eric W. Biederman
2009-05-21  0:28               ` [PATCH 08/20] sysfs: Optimize just changing the sysfs file mode Eric W. Biederman
2009-05-21  0:28                 ` [PATCH 09/20] sysfs: Simplify iattr assignments Eric W. Biederman
2009-05-21  0:28                   ` [PATCH 10/20] sysfs: Fix locking and factor out sysfs_sd_setattr Eric W. Biederman
2009-05-21  0:28                     ` [PATCH 11/20] sysfs: Update s_iattr on link and unlink Eric W. Biederman
2009-05-21  0:28                       ` [PATCH 12/20] sysfs: Nicely indent sysfs_symlink_inode_operations Eric W. Biederman
2009-05-21  0:28                         ` [PATCH 13/20] sysfs: Implement sysfs_getattr & sysfs_permission Eric W. Biederman
2009-05-21  0:28                           ` [PATCH 14/20] sysfs: In sysfs_chmod_file lazily propagate the mode change Eric W. Biederman
2009-05-21  0:28                             ` [PATCH 15/20] sysfs: Kill sysfs_addrm_start and sysfs_addrm_finish Eric W. Biederman
2009-05-21  0:28                               ` [PATCH 16/20] sysfs: Propagate renames to the vfs on demand Eric W. Biederman
2009-05-21  0:28                                 ` [PATCH 17/20] sysfs: Merge sysfs_rename_dir and sysfs_move_dir Eric W. Biederman
2009-05-21  0:28                                   ` [PATCH 18/20] sysfs: Pass super_block to sysfs_get_inode Eric W. Biederman
2009-05-21  0:28                                     ` [PATCH 19/20] sysfs: Kill unused sysfs_sb variable Eric W. Biederman
2009-05-21  0:28                                       ` [PATCH 20/20] sysfs: Normalize error handling in sysfs_fill_inode Eric W. Biederman
2009-05-21  9:43                                         ` Tejun Heo
2009-05-21 10:29                                           ` Eric W. Biederman
2009-05-21  9:42                                   ` [PATCH 17/20] sysfs: Merge sysfs_rename_dir and sysfs_move_dir Tejun Heo
2009-05-21  9:41                                 ` [PATCH 16/20] sysfs: Propagate renames to the vfs on demand Tejun Heo
2009-05-21  9:31                               ` [PATCH 15/20] sysfs: Kill sysfs_addrm_start and sysfs_addrm_finish Tejun Heo
2009-05-21  9:16                             ` [PATCH 14/20] sysfs: In sysfs_chmod_file lazily propagate the mode change Tejun Heo
2009-05-21  9:14                           ` [PATCH 13/20] sysfs: Implement sysfs_getattr & sysfs_permission Tejun Heo
2009-05-21  7:42                         ` [PATCH 12/20] sysfs: Nicely indent sysfs_symlink_inode_operations Tejun Heo
2009-05-21  8:42                       ` [PATCH 11/20] sysfs: Update s_iattr on link and unlink Tejun Heo
2009-05-21  7:42                     ` [PATCH 10/20] sysfs: Fix locking and factor out sysfs_sd_setattr Tejun Heo
2009-05-21  7:31                   ` [PATCH 09/20] sysfs: Simplify iattr assignments Tejun Heo
2009-05-21  7:29                 ` [PATCH 08/20] sysfs: Optimize just changing the sysfs file mode Tejun Heo
2009-05-21  7:54                   ` Eric W. Biederman
2009-05-21  8:41                     ` Tejun Heo
2009-05-21  6:42               ` [PATCH 07/20] sysfs: Simplify sysfs_chmod_file semantics Tejun Heo
2009-05-21  6:41             ` [PATCH 06/20] sysfs: Use dentry_ops instead of directly playing with the dcache Tejun Heo
2009-05-21  7:37               ` Eric W. Biederman
2009-05-21  7:40                 ` Tejun Heo
2009-05-21  6:24           ` [PATCH 05/20] sysfs: Rename sysfs_d_iput to sysfs_dentry_iput Tejun Heo
2009-05-21  6:23         ` [PATCH 04/20] sysfs: Handle the general case of removing of directories with subdirectories Tejun Heo
2009-05-21  7:29           ` Eric W. Biederman
2009-05-21  7:36             ` Tejun Heo
2009-05-21  8:04               ` Eric W. Biederman
2009-05-21  8:37                 ` Tejun Heo
2009-05-21  9:18                   ` Eric W. Biederman
2009-05-21  9:28                     ` Tejun Heo
2009-05-23  6:33                       ` Eric W. Biederman
2009-05-23 11:35                         ` Kay Sievers
2009-05-23 20:09                           ` Eric W. Biederman
2009-05-23 20:46                             ` Kay Sievers
2009-05-21  5:37       ` [PATCH 03/20] sysfs: Remove now unnecessary error reporting suppression Tejun Heo
2009-05-21  6:12         ` Eric W. Biederman
2009-05-21  6:20           ` Tejun Heo
2009-05-21  1:49   ` [PATCH 01/20] sysfs: Implement sysfs_rename_link Tejun Heo
2009-05-21  5:35   ` Tejun Heo
2009-05-21 10:06     ` Kay Sievers
2009-05-21 10:29       ` Eric W. Biederman
2009-05-21 11:40         ` Kay Sievers
2009-05-28  0:14   ` Greg KH
2009-05-28  0:30     ` Kay Sievers
2009-05-28  0:37       ` Greg KH
2009-05-28 22:58         ` [PATCH 0/24] sysfs cleanups Eric W. Biederman
2009-05-28 23:00           ` [PATCH 01/24] sysfs: Implement sysfs_rename_link Eric W. Biederman
2009-05-28 23:00           ` [PATCH 02/24] driver core: Use sysfs_rename_link in device_rename Eric W. Biederman
2009-05-28 23:00           ` [PATCH 03/24] sysfs: Remove now unnecessary error reporting suppression Eric W. Biederman
2009-05-28 23:00           ` [PATCH 04/24] sysfs: Normalize removing sysfs directories Eric W. Biederman
2009-05-29  9:14             ` Tejun Heo
2009-05-29 16:52               ` Eric W. Biederman
2009-05-30 10:43                 ` Tejun Heo
2009-05-30 13:07                   ` Eric W. Biederman
2009-05-30 13:20                     ` Tejun Heo
2009-05-30 14:29                       ` Eric W. Biederman
2009-05-30 13:59                     ` Kay Sievers
2009-05-30 14:19                     ` James Bottomley
2009-05-30 15:15                       ` Eric W. Biederman
2009-05-30 15:51                         ` James Bottomley [this message]
2009-05-30 21:20                           ` Eric W. Biederman
2009-05-28 23:00           ` [PATCH 05/24] sysfs: Rename sysfs_d_iput to sysfs_dentry_iput Eric W. Biederman
2009-05-28 23:00           ` [PATCH 06/24] sysfs: Use dentry_ops instead of directly playing with the dcache Eric W. Biederman
2009-05-28 23:00           ` [PATCH 07/24] sysfs: Simplify sysfs_chmod_file semantics Eric W. Biederman
2009-05-28 23:00           ` [PATCH 08/24] sysfs: Optimize just changing the sysfs file mode Eric W. Biederman
2009-05-28 23:00           ` [PATCH 09/24] sysfs: Simplify iattr assignments Eric W. Biederman
2009-05-28 23:00           ` [PATCH 10/24] sysfs: Fix locking and factor out sysfs_sd_setattr Eric W. Biederman
2009-05-28 23:00           ` [PATCH 11/24] sysfs: Update s_iattr on link and unlink Eric W. Biederman
2009-05-28 23:00           ` [PATCH 12/24] sysfs: Nicely indent sysfs_symlink_inode_operations Eric W. Biederman
2009-05-28 23:00           ` [PATCH 13/24] sysfs: Implement sysfs_getattr & sysfs_permission Eric W. Biederman
2009-05-28 23:00           ` [PATCH 14/24] sysfs: In sysfs_chmod_file lazily propagate the mode change Eric W. Biederman
2009-05-28 23:00           ` [PATCH 15/24] sysfs: Kill sysfs_addrm_start and sysfs_addrm_finish Eric W. Biederman
2009-05-28 23:00           ` [PATCH 16/24] sysfs: Propagate renames to the vfs on demand Eric W. Biederman
2009-05-28 23:00           ` [PATCH 17/24] sysfs: Merge sysfs_rename_dir and sysfs_move_dir Eric W. Biederman
2009-05-28 23:00           ` [PATCH 18/24] sysfs: Pass super_block to sysfs_get_inode Eric W. Biederman
2009-05-28 23:01           ` [PATCH 19/24] sysfs: Kill unused sysfs_sb variable Eric W. Biederman
2009-05-28 23:01           ` [PATCH 20/24] sysfs: Normalize error handling in sysfs_fill_inode Eric W. Biederman
2009-05-28 23:01           ` [PATCH 21/24] sysfs: Rename sysfs_mv_dir sysfs_rename Eric W. Biederman
2009-05-28 23:01           ` [PATCH 22/24] sysfs: Make sysfs_rename_link atomic Eric W. Biederman
2009-05-29  9:16             ` Tejun Heo
2009-05-29 17:17               ` Eric W. Biederman
2009-05-30 10:48                 ` Tejun Heo
2009-05-28 23:01           ` [PATCH 23/24] driver core: Don't remove kobjects in device_shutdown Eric W. Biederman
2009-05-28 23:01           ` [PATCH 24/24] sysfs: In sysfs_add_one fail if the targe directory has been removed Eric W. Biederman
2009-05-29  9:18             ` Tejun Heo
2009-05-29 20:18           ` [PATCH 0/26] sysfs cleanups v3 Eric W. Biederman
2009-05-29 20:19             ` [PATCH 01/26] sysfs: Implement sysfs_rename_link Eric W. Biederman
2009-05-29 20:19             ` [PATCH 02/26] driver core: Use sysfs_rename_link in device_rename Eric W. Biederman
2009-05-29 20:19             ` [PATCH 03/26] sysfs: Remove now unnecessary error reporting suppression Eric W. Biederman
2009-05-29 20:19             ` [PATCH 04/26] sysfs: sysfs_remove_dir stop checking for bogus cases Eric W. Biederman
2009-06-03 23:53               ` Greg KH
2009-06-04  0:41                 ` Eric W. Biederman
2009-05-29 20:19             ` [PATCH 05/26] sysfs: Improve sysfs directory deletion debugging Eric W. Biederman
2009-05-29 20:19             ` [PATCH 06/26] sysfs: Don't hold addrm_start/addrm_finish over multiple removals Eric W. Biederman
2009-05-29 20:19             ` [PATCH 07/26] sysfs: Rename sysfs_d_iput to sysfs_dentry_iput Eric W. Biederman
2009-05-29 20:19             ` [PATCH 08/26] sysfs: Use dentry_ops instead of directly playing with the dcache Eric W. Biederman
2009-05-29 20:19             ` [PATCH 09/26] sysfs: Simplify sysfs_chmod_file semantics Eric W. Biederman
2009-05-29 20:19             ` [PATCH 10/26] sysfs: Optimize just changing the sysfs file mode Eric W. Biederman
2009-05-29 20:19             ` [PATCH 11/26] sysfs: Simplify iattr assignments Eric W. Biederman
2009-05-29 20:19             ` [PATCH 12/26] sysfs: Fix locking and factor out sysfs_sd_setattr Eric W. Biederman
2009-05-29 20:19             ` [PATCH 13/26] sysfs: Update s_iattr on link and unlink Eric W. Biederman
2009-05-29 20:19             ` [PATCH 14/26] sysfs: Nicely indent sysfs_symlink_inode_operations Eric W. Biederman
2009-05-29 20:19             ` [PATCH 15/26] sysfs: Implement sysfs_getattr & sysfs_permission Eric W. Biederman
2009-05-29 20:19             ` [PATCH 16/26] sysfs: In sysfs_chmod_file lazily propagate the mode change Eric W. Biederman
2009-05-29 20:19             ` [PATCH 17/26] sysfs: Kill sysfs_addrm_start and sysfs_addrm_finish Eric W. Biederman
2009-05-29 20:19             ` [PATCH 18/26] sysfs: Propagate renames to the vfs on demand Eric W. Biederman
2009-05-29 20:19             ` [PATCH 19/26] sysfs: Merge sysfs_rename_dir and sysfs_move_dir Eric W. Biederman
2009-05-29 20:19             ` [PATCH 20/26] sysfs: Pass super_block to sysfs_get_inode Eric W. Biederman
2009-05-29 20:19             ` [PATCH 21/26] sysfs: Kill unused sysfs_sb variable Eric W. Biederman
2009-05-29 20:19             ` [PATCH 22/26] sysfs: Normalize error handling in sysfs_fill_inode Eric W. Biederman
2009-05-29 20:19             ` [PATCH 23/26] sysfs: Rename sysfs_mv_dir sysfs_rename Eric W. Biederman
2009-05-29 20:19             ` [PATCH 24/26] sysfs: Make sysfs_rename_link atomic Eric W. Biederman
2009-05-29 20:19             ` [PATCH 25/26] driver core: Don't remove kobjects in device_shutdown Eric W. Biederman
2009-05-29 20:19             ` [PATCH 26/26] sysfs: In sysfs_add_one fail if the targe directory has been removed Eric W. Biederman
2009-05-28  1:51       ` [PATCH 01/20] sysfs: Implement sysfs_rename_link Eric W. Biederman
2009-05-23 20:13 ` [PATCH 21/20] sysfs: Rename sysfs_mv_dir sysfs_rename Eric W. Biederman
2009-05-23 20:13 ` [PATCH 22/20] sysfs: Make sysfs_rename_link atomic Eric W. Biederman
2009-05-23 21:32   ` Kay Sievers
2009-05-23 23:21     ` Kay Sievers
2009-05-24 13:03       ` Kay Sievers
2009-05-23 20:13 ` [PATCH 23/20] driver core: Don't remove kobjects in device_shutdown Eric W. Biederman
2009-05-23 22:15   ` Kay Sievers
2009-05-23 20:13 ` [PATCH 24/20] sysfs: In sysfs_add_one fail if the targe directory has been removed Eric W. Biederman
2009-05-23 21:29   ` Kay Sievers
2009-05-23 20:13 ` [PATCH 25/20] sysfs: Only support removing emtpy sysfs directories Eric W. Biederman
2009-05-23 21:27   ` Kay Sievers
2009-05-24 12:59     ` Kay Sievers
2009-05-24 14:17       ` Eric W. Biederman
2009-05-24 15:20         ` Kay Sievers
2009-05-25  2:06           ` Alan Stern
2009-05-25 11:45             ` Kay Sievers
2009-05-25 12:01               ` Kay Sievers
2009-05-25 15:49                 ` Alan Stern
2009-05-25 18:19                   ` Kay Sievers
2009-05-25 20:14                     ` Alan Stern
2009-05-26 16:27               ` Kay Sievers
2009-05-26 19:29                 ` Alan Stern
2009-05-26 21:09                   ` James Bottomley
2009-05-26 21:13                     ` Kay Sievers
2009-05-26 21:56                       ` Alan Stern
2009-05-26 22:03                         ` Kay Sievers
2009-05-26 23:49                           ` James Bottomley
2009-05-27  0:02                             ` Kay Sievers
2009-05-27  2:17                               ` Alan Stern
2009-05-27 11:35                                 ` Hannes Reinecke
2009-05-27 16:01                                   ` James Bottomley
2009-05-27 16:16                                     ` Alan Stern
2009-05-27 16:24                                       ` James Bottomley
2009-05-27 17:01                                         ` Alan Stern
2009-05-27 17:08                                           ` James Bottomley
2009-05-27 18:07                                             ` Alan Stern
2009-05-27 19:44                                               ` James Bottomley
2009-05-27 20:40                                                 ` Alan Stern
2009-05-27 20:49                                                   ` James Bottomley
2009-05-27 21:31                                                     ` Alan Stern
2009-05-27 21:42                                                       ` James Bottomley
2009-05-27 22:15                                                         ` Alan Stern
2009-05-27 22:22                                                           ` James Bottomley
2009-05-28 15:24                                                             ` Alan Stern
2009-05-28 15:45                                                               ` Eric W. Biederman
2009-05-28 17:51                                                                 ` Alan Stern
2009-05-28 18:21                                                               ` James Bottomley
2009-05-28 20:02                                                                 ` Alan Stern
2009-05-28 20:10                                                                   ` James Bottomley
2009-05-28 21:04                                                                     ` Alan Stern
2009-05-29 12:32                                                                       ` Hannes Reinecke
2009-05-29 20:08                                                                     ` Alan Stern
2009-05-27 18:00                                 ` Eric W. Biederman
2009-05-27 18:15                                   ` Alan Stern
2009-05-27 18:24                                     ` Eric W. Biederman
2009-05-27 21:38                                       ` Alan Stern
2009-05-27 22:06                                         ` Eric W. Biederman
2009-05-27 22:18                                           ` Alan Stern
2009-05-26 21:39                     ` Alan Stern
2009-05-25  7:44           ` Eric W. Biederman
2009-05-25  7:53             ` Eric W. Biederman
2009-05-25 10:51               ` Kay Sievers
2009-05-24  3:24   ` 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=1243698667.5223.12.camel@mulgrave.int.hansenpartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=cornelia.huck@de.ibm.com \
    --cc=ebiederm@aristanetworks.com \
    --cc=ebiederm@xmission.com \
    --cc=greg@kroah.com \
    --cc=gregkh@suse.de \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@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

all inboxes | Powered by JetHome®