Re: [PATCH] sysfs: differentiate between locking links and non-links

From: AmÃrico Wang
Date: Tue Feb 09 2010 - 21:08:56 EST


On Wed, Feb 10, 2010 at 9:09 AM, Neil Brown <neilb@xxxxxxx> wrote:
>
> Hi,
> ÂI've just spent a while sorting out some lockdep complaints triggered
> Âby the recent addition of the "s_active" lockdep annotation in sysfs
> Â(commit 846f99749ab68bbc7f75c74fec305de675b1a1bf)
>
> ÂSome of them are genuine and I have submitted a fix for those.
> ÂSome are, I think, debatable and I get to that is a minute. ÂI've
> Âsubmitted a fix for them anyway.
> ÂBut some are to my mind clearly bogus and I'm hoping that can be
> Âfixed by the change below (or similar).
> ÂThe 'bogus' ones are triggered by writing to a sysfs attribute file
> Âfor which the handler tries to delete a symlink from sysfs.
> ÂThis appears to be a recursion on s_active as s_active is held while
> Âthe handler runs and is again needed to effect the delete. ÂHowever
> Âas the thing being deleted is a symlink, it is very clearly a
> Âdifferent object to the thing triggering the delete, so there is no
> Âreal loop.
>
> ÂThe following patch splits the lockdep context in two - one for
> Âsymlink and one for everything else. ÂThis removes the apparent loop.
> Â(An example report can be seen in
> Â Â http://bugzilla.kernel.org/show_bug.cgi?id=15142).
>
> ÂThe "debatable" dependency loops happen when writing to one attribute
> Âcauses a different attribute to be deleted. ÂIn my (md) case this can
> Âactually cause a deadlock as both the attributes take the same lock
> Âwhile the handler is running. ÂThis is because deleting the attribute
> Âwill block until the all accesses of that attribute have completed (I
> Âthink).
> ÂHowever it should be possible to delete a name from sysfs while there
> Âare still accesses pending (it works for normal files!!). ÂSo if
> Âsysfs could be changed to simply unlink the file and leave deletion to
> Âhappen when the refcount become zero it would certainly make my life
> Âa lot easier, and allow the removal of some ugly code from md.c.
> ÂI don't know sysfs well enough to suggest a patch though.
>

Hi, Neil,

Thanks for your patch.

This bug report is new for me. Recently we received lots of sysfs lockdep
warnings, I am working on a patch to fix all the bogus ones.

However, this one is _not_ similar to the other cases, as you decribed.
This patch could fix the problem, but not a good fix, IMO. We need more
work in sysfs layer to fix this kind of things. I will take care of this.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/