Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3435752imu; Sun, 11 Nov 2018 15:03:34 -0800 (PST) X-Google-Smtp-Source: AJdET5eRLTam1bjSkXmRINyLjKj/VnmHMe2AWZGAxR6L7O9iZgbhA7GeE5JVuzUc2IM0JtR3Uusu X-Received: by 2002:a17:902:9698:: with SMTP id n24-v6mr18116538plp.9.1541977414445; Sun, 11 Nov 2018 15:03:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977414; cv=none; d=google.com; s=arc-20160816; b=YyFFyyTMvSxOEZP4V+lvoCno3ydGXNyNJcSZ/GUIOmwaK7eIXNx5WYYQutAVL24ocm 73Kg3CSvabii4m80FZc9+Av6HCOnFWtJ0G+do4/cr24s9WGLQDCtkwH8TN/0lIiNZjOe eXgBVaGoQWgGIAoiYghXOHH0qWG/UWKRN2ZI90pHxscXk1xdqvX9izvLzqqERj/9IQKd 93sqH+U+ibQaLvvconKUuacfbTMrfXmJSshDPdVaLpNu1EsdzdZDHq4LYJtOXh3U7Yqi 5NAmUYrPHsVr0EayN0WS7YnAQygaFnP3fRxvSgrf7CqKCJK8tcQk3TqF/zx93SaLMLBi gl+A== 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=l3Dh+sc3BKaArDDtUUrZOKUxU4BqqDvcLsaqmd0fTYw=; b=Rcsr05tGGUcjb4y2VQcV1JxM8tMDfEPiHHDb/iLMAy9R3qS8Fd217LGdPcAUb7kL9T l3Jbhu1+OUUqJw1pJWj4CuCKveIyix48gT76uF2bSmcMQSICov7DoAtbe7yqigF34jpa xq5UPa0y2xw/OoZ8VoJkOhINKW/NFJ2vSBaHuYXm7U0INVNaWYkCKYp79Ty7Yx6+bKiq 6mu9yX26hnJB7SFn8hnYaE2C6a79FbYTaQkgaaTMx7LLB1/efRC4XsfNG3kSJbYu4/hU BXaA/GoElSYg7bxNjiz/rsqygkTx4el4HTYC2CLMVcBBCK8kRUChxV3ZOMIhO1+41yk1 8Zmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PB+704R3; 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 37-v6si16283892ple.389.2018.11.11.15.03.19; Sun, 11 Nov 2018 15:03:34 -0800 (PST) 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=PB+704R3; 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 S2390659AbeKLIWa (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:51836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390631AbeKLIW2 (ORCPT ); Mon, 12 Nov 2018 03:22:28 -0500 Received: from localhost (unknown [206.108.79.134]) (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 59C07224B3; Sun, 11 Nov 2018 22:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975551; bh=31r5wzA77M70K5CF9GbB2sFli5NId+iCtZh5f2IBTqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PB+704R32m6kL1xqnWN3z7dYNIXRmz7VM2OEbNLcb1pgetNmUY8LrDgwTlxn0MIFM YOyj5856Cp3HB4r5LjTMZkpMV/MldOjYKMVeOyS3K3afmPBDgUSIe6F2ArTpHPHmit 5UKQyRX09Q2OmRIH7TP3D1PCcWiWpMgep+jhHTyE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gioh Kim , Guoqing Jiang , Shaohua Li , Sasha Levin Subject: [PATCH 4.14 092/222] MD: fix invalid stored role for a disk Date: Sun, 11 Nov 2018 14:23:09 -0800 Message-Id: <20181111221656.187877906@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shaohua Li [ Upstream commit d595567dc4f0c1d90685ec1e2e296e2cad2643ac ] If we change the number of array's device after device is removed from array, then add the device back to array, we can see that device is added as active role instead of spare which we expected. Please see the below link for details: https://marc.info/?l=linux-raid&m=153736982015076&w=2 This is caused by that we prefer to use device's previous role which is recorded by saved_raid_disk, but we should respect the new number of conf->raid_disks since it could be changed after device is removed. Reported-by: Gioh Kim Tested-by: Gioh Kim Acked-by: Guoqing Jiang Signed-off-by: Shaohua Li Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/md/md.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1766,6 +1766,10 @@ static int super_1_validate(struct mddev } else set_bit(In_sync, &rdev->flags); rdev->raid_disk = role; + if (role >= mddev->raid_disks) { + rdev->saved_raid_disk = -1; + rdev->raid_disk = -1; + } break; } if (sb->devflags & WriteMostly1)