Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3930189imm; Mon, 8 Oct 2018 11:52:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV60lKcpha/VYxnxEBcX/zBoNd+G3tOMoXHzpn3mVWel1gMITuRUYcDg+3awkPtq7ok8yAMa4 X-Received: by 2002:a63:6d83:: with SMTP id i125-v6mr21669075pgc.215.1539024740316; Mon, 08 Oct 2018 11:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024740; cv=none; d=google.com; s=arc-20160816; b=iLYdJPGBXqfG3KcFPKhBhXcg3TGLUJZH1t/o45+gnBGpD/oe0gRlZxM1S8R+Q86dbL ag9tPIahSYfBiauN0e0rGKcdgjruH/oG3JYvis1RcWu0b7XSqv8SZLvlsbBnluolKcjd J0gS9+xJK6Lbjzmtq+IjhpaZyjqKind17C6KdywGaS+IwA8rWpogzIhof64xWixasyAc BK3PAZoLegvme4DOapyH5QJSGqw9vmAzt1WGmz+EZja50/6TuoBcjW2E+ka/46gBKgb7 rj0sNnRjXSK/Wg/7h7eWL8cH/CgcKRt5tqfC+iTQCJYDDSmEdDQe345jZVf3cK+0wyv5 lofQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gVMAyK3viDBS5LcqMhSEkJLIkly0MocZv8i87X08Gi4=; b=gQ/o1W700praPedhGY7qfWAliHWwbjhdy5EhZo4NBQLC0zNly00OpekeUmy26xETjW SpmTYiZaBM0+chXCNgw24CJJY3DjowS0UN/6OhVINV/7X7sfr2mCDXxBk4wQfwyMljH8 1YBbUfXMgLFckYIUUJO81wh1EOc/3HxLqeI3o562Vjn8Vo4u5HkQkwK1GS4ztRd1Cb8L qMh072sTb0K2ea/VnwjGkWHahCUG+1MU7jSkd6OdcnT7usenNnH/KnKerdEYmzsgKw+m xJjQNNyRPBFRQTJb0/H/kboyUTiJPetwsPCQsohV/J/vLzD0z+KcpaDau66IsLsWIhC2 8vfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cbWp3Soe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10-v6si21205496pli.202.2018.10.08.11.52.05; Mon, 08 Oct 2018 11:52:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cbWp3Soe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732437AbeJICFE (ORCPT + 99 others); Mon, 8 Oct 2018 22:05:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:55100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732099AbeJICFE (ORCPT ); Mon, 8 Oct 2018 22:05:04 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED87A2087D; Mon, 8 Oct 2018 18:51:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024716; bh=g4EHOwaHPfqBFHJI5i9AB1PZvDWmnbg/QZwdfy/YhAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cbWp3SoeCmlZjR9S6c8qKlF3SxJ4OBZIS8ZGDGLK5mcrXIDPZqviclHbs5HWGVxm2 bVn20IMCc7BrglbdmRhk1DRQHdLWxzkn2DySElKUv3Af1zzaEIN6Hzt5/rdHIIEeZX lO1/1ICmLGGtC7aqra2N/fsIihc+u6ZQz4ODXB5k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heinz Mauelshagen , Mike Snitzer , Sasha Levin Subject: [PATCH 4.18 113/168] dm raid: fix stripe adding reshape deadlock Date: Mon, 8 Oct 2018 20:31:33 +0200 Message-Id: <20181008175624.344860454@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Heinz Mauelshagen [ Upstream commit 644e2537fdc77baeeefc829524937bca64329f82 ] When initiating a stripe adding reshape, a deadlock between md_stop_writes() waiting for the sync thread to stop and the running sync thread waiting for inactive stripes occurs (this frequently happens on single-core but rarely on multi-core systems). Fix this deadlock by setting MD_RECOVERY_WAIT to have the main MD resynchronization thread worker (md_do_sync()) bail out when initiating the reshape via constructor arguments. Signed-off-by: Heinz Mauelshagen Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-raid.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -3869,14 +3869,13 @@ static int rs_start_reshape(struct raid_ struct mddev *mddev = &rs->md; struct md_personality *pers = mddev->pers; + /* Don't allow the sync thread to work until the table gets reloaded. */ + set_bit(MD_RECOVERY_WAIT, &mddev->recovery); + r = rs_setup_reshape(rs); if (r) return r; - /* Need to be resumed to be able to start reshape, recovery is frozen until raid_resume() though */ - if (test_and_clear_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags)) - mddev_resume(mddev); - /* * Check any reshape constraints enforced by the personalility * @@ -3900,10 +3899,6 @@ static int rs_start_reshape(struct raid_ } } - /* Suspend because a resume will happen in raid_resume() */ - set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags); - mddev_suspend(mddev); - /* * Now reshape got set up, update superblocks to * reflect the fact so that a table reload will