lkml.org 
[lkml]   [2009]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 04/20] sysfs: Handle the general case of removing of directories with subdirectories
Eric W. Biederman wrote:
>> I agree we should be heading this way but what happens to attributes
>> or directories living below the subdirectories? If it's gonna handle
>> recursive case, I think it better do it properly. I had patches of
>> similar effect.
>
> I do handle it properly. sysfs_get_one finds the deepest child of the
> first directory entry. Then I remove it. And I repeat until done.
>
> The locking is correct, something that is much more difficult to
> tell with your version.

Why? :-)

> By grabbing and dropping the sysfs_mutex things are simpler, and they
> get even simpler in future patches.
>
> Now looking at that code in detail there is a question of what happens if
> we add a directory entry while we are recursively deleting a directory.
> Neither your patch, my patch, nor the existing code handle that case
> (assuming the sysfs_dirent) was looked up before it is removed from it's
> parent directory. I expect another patch is called for to plug that
> theoretical gap.
>
> I expect the way to close that hole is to have an extra flag that says
> we are removing a directory entry and refuse to add if that flag is
> set.
>
> I would prefer to only remove empty directories. But when I
> instrumented things up I found cases where that does indeed happen.

IIRC, my version did the whole thing while holding sysfs_mutex, so
it's safe against such races. I can't really see why ops like this
can't be atomic in sysfs. I don't really care how things are done but
please make it atomic.

Thanks.

--
tejun


\
 
 \ /
  Last update: 2009-05-21 09:39    [W:0.271 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site