Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3482001imu; Sun, 11 Nov 2018 16:06:12 -0800 (PST) X-Google-Smtp-Source: AJdET5eIqqcn514EEj7/1fwnSp0CPES5o8lDvnDR0pgjarD12vCYtJPS0gnmxBhZ8nrWNTdp/SN8 X-Received: by 2002:a63:608f:: with SMTP id u137mr15629901pgb.203.1541981172383; Sun, 11 Nov 2018 16:06:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981172; cv=none; d=google.com; s=arc-20160816; b=CkV7dXh/dJ4wYuFWjk8XjvJ6r0+haJlYXrLWvEZjxDDiDgbJ6tGbHq0cLIn4/pgDQS YjY/TTZw06RujbvrH3Twiswzsh9Ir3TMbOwVF6giHalNqu9hH9UvspVy+41wZLOmc9PW xm7mmncWcO7xzs+WKJv7Z2L7x9HCeHmHx6pB+KWd9mPe/enL07naPCCoCzTk4d3FP1FJ wJvr74FYfY/brRTTBJsr2mK8Cmv7OgXQ3pu21iQRt9z8dlfJpozS0mbvi3uvUF7tyhno Ld3Ip9llxQpuncb+kT4OuMzWAh0RzCG7CRGaJ9sBA3tvywBdpgn9iHLitI2FqeeTxu8a TM1g== 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=bcYrqhVmv+R8jkm6XZsgbAdLlDVTKHCavYUcatpn9zA=; b=gRNQx7BsZqlqkvpqCn1CDYK6Zr/XxSMNFclIyWD9DXn6dS4FzuZrIh5F/xs/p+wJxR ZKXHdWlfxutFTFEkdZhj3xdk48dvSUkuBP35bPHDYVodsR/RnNBPmdZ/aryqetNY2pg/ nIbf9jm6TVqBr/SXWOPjC9aj0o2xUfzdBXGfgSRJ1XS8LnQsS7ee/wA8SpteFyK/i1do eil4iLgujbqQqDYAKTLnzy2cWEt98PgEqGjz4OgoDi7Ke2R9bjqB+OHyGTa71aBPJjlk 2/ciz1Ixrf7KTnOVmqGLFiEjf2Qoq/NVcuTGwXM7TrlOkqk5iqS1umb7vXDxdpS1A/Vt I+Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v7M9XjQh; 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 g13-v6si15349657pfh.229.2018.11.11.16.05.57; Sun, 11 Nov 2018 16:06:12 -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=v7M9XjQh; 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 S1731950AbeKLIRo (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:34378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731856AbeKLIRn (ORCPT ); Mon, 12 Nov 2018 03:17:43 -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 ECDA722353; Sun, 11 Nov 2018 22:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975268; bh=L7DqfjicCa8Ybo5qFIwZRFazqISozngey83K/rJezIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v7M9XjQhFQ/xSf1C0PDaMYdyguhGJTOByI1QcgRS4oN56VLqsO7RcJmoA2JHWAt0I csiA6KD22tbPfyT6hJYmtQrOWOolbWMfjOm0VRyr2TCFq2o7PFkdltw0cMQDhyE8rU lPCqTTN+1I4rkwQaz07WHSRzfmPjqPbrq21Qs/JQ= 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.19 162/361] MD: fix invalid stored role for a disk Date: Sun, 11 Nov 2018 14:18:29 -0800 Message-Id: <20181111221643.157084537@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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 @@ -1776,6 +1776,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)