Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2428829imj; Mon, 18 Feb 2019 05:57:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IYKVb5Y5dDV479p03LF71kjuIU++AVL1p8NG/HHEvnAiVIGAXQH8aN3+AP/tzqRiod4qYYt X-Received: by 2002:a17:902:3283:: with SMTP id z3mr25785645plb.76.1550498266990; Mon, 18 Feb 2019 05:57:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550498266; cv=none; d=google.com; s=arc-20160816; b=aWt3yJyBWoyhZMeT4gfxM9BGcURJibcy5FmCpNMvNaiQvBnXsprcvP+FPsB8hRGzez t+OnJQpYqzJ25E6o3Fbdx33o+hVy6Ks+aji8KyPcrZWZmzOK758xirztVqpQ0mQB9CU+ KgkmRql/75lP2nbbnYlo0I7mpRZiCvghWDsDG1A2KY+I3V972t6MXG1fob4mwD4evcPO gIgYDeylaV+k9H4kpj8Hai4YQazis5yt1zJwbMbQjrKYwamhNnlpN7pVnCzDFBj/MW2Z q00mpTK6tPCXN52Qj3GUcfXWQ43rmKsw4GzKNWHbO7YeFOhrgTF7Y6jF2cw4Xwz34l6l sw3Q== 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=ju25CGfFeq0frKWSAeA4J+Gva5G/yFxy50Fy/Bz8tBw=; b=yL5svfEj5sFvowIy3RzsTojH5BAgO2kDPe6f5736rFBg3GhPJ+wPPVc11NQtHWYXJN 8cALCyeGWgbuCVhy39HO/JNb2okDof8fkQje5naN8vqV8ERRlqUHdye1F+VRUVo2Pu30 NuDasNsXZpm7NTaal4ftZqv4aBcmj5sVQ+bSgoQPJRbXxZyWbdhr4VOv77JiR0hXlmKa bRtRAUCl/V/KLZGe95Tc6HgbepNlXfr2BVFyHrUsHhryRK0MbKlqQvmmjro9OabID1SM DanSR1YVzJJXUrCctYh67pkyhr8x+MGF4ftna2Ezyhess1vIDLiMCWSTzFb0tHQ/g4gj IQxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="pnmbb9/a"; 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 r17si12260420pgv.329.2019.02.18.05.57.31; Mon, 18 Feb 2019 05:57:46 -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="pnmbb9/a"; 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 S1730949AbfBRN4l (ORCPT + 99 others); Mon, 18 Feb 2019 08:56:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:36902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733245AbfBRN4j (ORCPT ); Mon, 18 Feb 2019 08:56:39 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 DBE06217D9; Mon, 18 Feb 2019 13:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498198; bh=6+8eCPrMMsgOWUPSZkyKBmxhdsQ2I/LU4UQPABVGEYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pnmbb9/a7wAIfj20s2J2nNzfAdK01qCACu6fJJ1QJ8tyAK0VJiiAi3Gra4pM0f/Vp CX3a+hpUkX9j7X0XQuI4fJfuBNAPd8HvX3t8jzIzf1JE2xVeAFfULul2TQ7sN29IZB KzYLmO8Q4nD9WrHwJJt2zXoKHceNpClKlZs65T/U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Wang , Nate Dailey , Song Liu Subject: [PATCH 4.14 55/62] md/raid1: dont clear bitmap bits on interrupted recovery. Date: Mon, 18 Feb 2019 14:44:01 +0100 Message-Id: <20190218133510.482165160@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133505.801423074@linuxfoundation.org> References: <20190218133505.801423074@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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: Nate Dailey commit dfcc34c99f3ebc16b787b118763bf9cb6b1efc7a upstream. sync_request_write no longer submits writes to a Faulty device. This has the unfortunate side effect that bitmap bits can be incorrectly cleared if a recovery is interrupted (previously, end_sync_write would have prevented this). This means the next recovery may not copy everything it should, potentially corrupting data. Add a function for doing the proper md_bitmap_end_sync, called from end_sync_write and the Faulty case in sync_request_write. backport note to 4.14: s/md_bitmap_end_sync/bitmap_end_sync Cc: stable@vger.kernel.org 4.14+ Fixes: 0c9d5b127f69 ("md/raid1: avoid reusing a resync bio after error handling.") Reviewed-by: Jack Wang Tested-by: Jack Wang Signed-off-by: Nate Dailey Signed-off-by: Song Liu Signed-off-by: Greg Kroah-Hartman --- drivers/md/raid1.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1854,6 +1854,20 @@ static void end_sync_read(struct bio *bi reschedule_retry(r1_bio); } +static void abort_sync_write(struct mddev *mddev, struct r1bio *r1_bio) +{ + sector_t sync_blocks = 0; + sector_t s = r1_bio->sector; + long sectors_to_go = r1_bio->sectors; + + /* make sure these bits don't get cleared. */ + do { + bitmap_end_sync(mddev->bitmap, s, &sync_blocks, 1); + s += sync_blocks; + sectors_to_go -= sync_blocks; + } while (sectors_to_go > 0); +} + static void end_sync_write(struct bio *bio) { int uptodate = !bio->bi_status; @@ -1865,16 +1879,7 @@ static void end_sync_write(struct bio *b struct md_rdev *rdev = conf->mirrors[find_bio_disk(r1_bio, bio)].rdev; if (!uptodate) { - sector_t sync_blocks = 0; - sector_t s = r1_bio->sector; - long sectors_to_go = r1_bio->sectors; - /* make sure these bits doesn't get cleared. */ - do { - bitmap_end_sync(mddev->bitmap, s, - &sync_blocks, 1); - s += sync_blocks; - sectors_to_go -= sync_blocks; - } while (sectors_to_go > 0); + abort_sync_write(mddev, r1_bio); set_bit(WriteErrorSeen, &rdev->flags); if (!test_and_set_bit(WantReplacement, &rdev->flags)) set_bit(MD_RECOVERY_NEEDED, & @@ -2164,8 +2169,10 @@ static void sync_request_write(struct md (i == r1_bio->read_disk || !test_bit(MD_RECOVERY_SYNC, &mddev->recovery)))) continue; - if (test_bit(Faulty, &conf->mirrors[i].rdev->flags)) + if (test_bit(Faulty, &conf->mirrors[i].rdev->flags)) { + abort_sync_write(mddev, r1_bio); continue; + } bio_set_op_attrs(wbio, REQ_OP_WRITE, 0); if (test_bit(FailFast, &conf->mirrors[i].rdev->flags))