LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Tejun Heo <tj@kernel.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
Bart Van Assche <bvanassche@acm.org>,
James Bottomley <jbottomley@parallels.com>,
Hannes Reinecke <hare@suse.de>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: sysfs methods can race with ->remove
Date: Mon, 26 Jan 2015 09:19:50 -0800 [thread overview]
Message-ID: <20150126171950.GA9015@infradead.org> (raw)
In-Reply-To: <20150115194031.GE28195@htj.dyndns.org>
On Thu, Jan 15, 2015 at 02:40:31PM -0500, Tejun Heo wrote:
> > If a method is registered by the driver, then the driver will
> > unregister it when the ->remove routine runs. I don't know for
> > certain, but I would expect that the sysfs/kernfs core will make sure
> > that any existing method calls complete before unregister returns.
> > This would prevent races.
>
> Yes, attribute deletions are blocked till the on-going sysfs
> read/write operations are finished and further rw accesses are failed.
Btw, where do we do that? I did a walk through the code starting
from device_del, but must have missed the obvious.
> > The sriov_numvfs_store method does have the same problem, and so does
> > the reset_store method (by way of pci_reset_function ->
> > pci_dev_save_and_disable -> pci_reset_notify).
> >
> > Tejun, is my analysis correct? How should we fix these races?
>
> I'm not really following what the actual problem case is, so SCSI
> subsystem store methods are derefing dev->driver without synchronizing
> against detach events? If that's the case, the solution would be
> synchronizing against attach/detach events? Sorry if I'm being
> totally idiotic. I'm having a bit of hard time jumping right in. :)
No problem. That's the basic situation we are talking about. I have
a serie fixing some long standing issues in the device model integration
in SCSI, and pointed out a possible issue in that area.
So what is the proper lock to take to prevent ->remove from beeing
called while in such a method? A mentioned about I tried to peel
through all the layers of the onion^H^H^H^H^Hdriver core, but so far
couldn't find anything obvious.
next prev parent reply other threads:[~2015-01-26 17:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20150108131508.GA31022@infradead.org>
[not found] ` <Pine.LNX.4.44L0.1501121116220.1707-100000@iolanthe.rowland.org>
2015-01-14 9:33 ` [PATCH for v3.19, v2] Avoid that sd_shutdown() triggers a kernel warning Christoph Hellwig
2015-01-14 15:07 ` Alan Stern
2015-01-15 16:06 ` Christoph Hellwig
2015-01-15 18:22 ` sysfs methods can race with ->remove Alan Stern
2015-01-15 19:40 ` Tejun Heo
2015-01-26 17:19 ` Christoph Hellwig [this message]
2015-01-26 18:38 ` Alan Stern
2015-01-20 15:11 ` [PATCH for v3.19, v2] Avoid that sd_shutdown() triggers a kernel warning Alan Stern
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=20150126171950.GA9015@infradead.org \
--to=hch@infradead.org \
--cc=bvanassche@acm.org \
--cc=gregkh@linuxfoundation.org \
--cc=hare@suse.de \
--cc=jbottomley@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=tj@kernel.org \
--subject='Re: sysfs methods can race with ->remove' \
/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
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).