From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Snitzer Subject: Re: dm mpath: Fix a dm_blk_ioctl() deadlock Date: Tue, 28 Jun 2016 14:15:26 -0400 Message-ID: <20160628181526.GA8013@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: Bart Van Assche Cc: device-mapper development List-Id: dm-devel.ids On Tue, Jun 28 2016 at 5:07am -0400, Bart Van Assche wrote: > Avoid that submitting an ioctl to a dm device while an underlying > block device is being removed triggers a deadlock. The call traces > reported by SysRq-w if the deadlock occurs are as follows: > > sysrq: SysRq : Show Blocked State > task PC stack pid father > systemd-udevd D ffff8803683f7878 0 6684 494 0x00000006 > Call Trace: > [] schedule+0x37/0x90 > [] schedule_timeout+0x18b/0x230 > [] io_schedule_timeout+0x9f/0x110 > [] bit_wait_io+0x16/0x60 > [] __wait_on_bit_lock+0x49/0xa0 > [] __lock_page+0xb6/0xc0 > [] truncate_inode_pages_range+0x444/0x790 > [] truncate_inode_pages+0x10/0x20 > [] kill_bdev+0x30/0x40 > [] __blkdev_put+0x71/0x360 > [] blkdev_put+0x49/0x170 > [] blkdev_close+0x20/0x30 > [] __fput+0xe8/0x1f0 > [] ____fput+0x9/0x10 > [] task_work_run+0x7c/0xb0 > [] do_exit+0x3b7/0xb10 > [] do_group_exit+0x4b/0xc0 > [] get_signal+0x1c5/0x7f0 > [] do_signal+0x23/0x700 > [] exit_to_usermode_loop+0x73/0xb0 > [] syscall_return_slowpath+0xb0/0xc0 > [] entry_SYSCALL_64_fastpath+0xaa/0xac > systemd-udevd D ffff880062613cd8 0 6767 494 0x00000000 > Call Trace: > [] schedule+0x37/0x90 > [] schedule_timeout+0x157/0x230 > [] msleep+0x33/0x40 > [] dm_grab_bdev_for_ioctl+0x7b/0x150 [dm_mod] > [] dm_blk_ioctl+0x35/0x80 [dm_mod] > [] blkdev_ioctl+0x25b/0x980 > [] block_ioctl+0x38/0x40 > [] do_vfs_ioctl+0x8e/0x660 > [] SyS_ioctl+0x3c/0x70 > [] entry_SYSCALL_64_fastpath+0x1c/0xac > > Signed-off-by: Bart Van Assche > Cc: > --- > drivers/md/dm.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/md/dm.c b/drivers/md/dm.c > index 1b2f962..f3564e1 100644 > --- a/drivers/md/dm.c > +++ b/drivers/md/dm.c > @@ -630,7 +630,8 @@ retry: > > out: > dm_put_live_table(md, srcu_idx); > - if (r == -ENOTCONN && !fatal_signal_pending(current)) { > + if (r == -ENOTCONN && !fatal_signal_pending(current) && > + !blk_queue_dying(bdev_get_queue(*bdev))) { > msleep(10); > goto retry; > } > -- > 2.8.4 Hi Bart, This patch doesn't make sense. In the context of dm-mpath.c:multipath_prepare_ioctl, *bdev is only valid if r == 0. But r == -ENOTCONN so how can *bdev be valid? Mike