From: "tj@kernel.org" <tj@kernel.org>
To: Bart Van Assche <Bart.VanAssche@wdc.com>
Cc: "mingo@kernel.org" <mingo@kernel.org>,
"jthumshirn@suse.de" <jthumshirn@suse.de>,
"oleg@redhat.com" <oleg@redhat.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
"ebiederm@xmission.com" <ebiederm@xmission.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"hare@suse.com" <hare@suse.com>,
"jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>
Subject: Re: [PATCH, RESEND] Avoid that SCSI device removal through sysfs triggers a deadlock
Date: Thu, 26 Jul 2018 07:14:35 -0700 [thread overview]
Message-ID: <20180726141435.GV1934745@devbig577.frc2.facebook.com> (raw)
In-Reply-To: <4dbd740c0555eb1bfcb4181eeaca5e397b6ab63c.camel@wdc.com>
Hello,
On Thu, Jul 26, 2018 at 02:09:41PM +0000, Bart Van Assche wrote:
> On Thu, 2018-07-26 at 06:35 -0700, Tejun Heo wrote:
> > Making removal asynchronous this way sometimes causes issues because
> > whether the user sees the device released or not is racy.
> > kernfs/sysfs have mechanisms to deal with these cases - remove_self
> > and kernfs_break_active_protection(). Have you looked at those?
>
> Hello Tejun,
>
> The call stack in the patch description shows that sdev_store_delete() is
> involved in the deadlock. The implementation of that function is as follows:
>
> static ssize_t
> sdev_store_delete(struct device *dev, struct device_attribute *attr,
> const char *buf, size_t count)
> {
> if (device_remove_file_self(dev, attr))
> scsi_remove_device(to_scsi_device(dev));
> return count;
> };
>
> device_remove_file_self() calls sysfs_remove_file_self() and that last
> function calls kernfs_remove_self(). In other words, kernfs_remove_self()
> is already being used. Please let me know if I misunderstood your comment.
So, here, because scsi_remove_device() is the one involved in the
circular dependency, just breaking the dependency chain on the file
itself (self removal) isn't enough. You can wrap the whole operation
with kernfs_break_active_protection() to also move
scsi_remove_device() invocation outside the kernfs synchronization.
This will need to be piped through sysfs but shouldn't be too complex.
Thanks.
--
tejun
next prev parent reply other threads:[~2018-07-26 15:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 17:38 [PATCH, RESEND] Avoid that SCSI device removal through sysfs triggers a deadlock Bart Van Assche
2018-07-26 1:47 ` Martin K. Petersen
2018-07-26 11:46 ` Johannes Thumshirn
2018-07-26 12:50 ` Jack Wang
2018-07-26 13:35 ` Tejun Heo
2018-07-26 14:09 ` Bart Van Assche
2018-07-26 14:14 ` tj [this message]
2018-07-26 21:57 ` Bart Van Assche
2018-07-30 14:13 ` tj
2018-07-30 17:28 ` Bart Van Assche
2018-07-30 17:31 ` tj
2018-07-30 17:50 ` Bart Van Assche
2018-07-30 17:57 ` tj
2018-07-29 4:03 ` Bart Van Assche
2018-07-30 14:17 ` tj
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=20180726141435.GV1934745@devbig577.frc2.facebook.com \
--to=tj@kernel.org \
--cc=Bart.VanAssche@wdc.com \
--cc=ebiederm@xmission.com \
--cc=hare@suse.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=jthumshirn@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=stable@vger.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