From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:50440 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752127AbdK2CAe (ORCPT ); Tue, 28 Nov 2017 21:00:34 -0500 From: NeilBrown To: gregkh@linuxfoundation.org, kumba@gentoo.org, shli@fb.com Date: Wed, 29 Nov 2017 13:00:25 +1100 Cc: stable@vger.kernel.org Subject: Re: FAILED: patch "[PATCH] md: forbid a RAID5 from having both a bitmap and a journal." failed to apply to 4.14-stable tree In-Reply-To: <1511796203245200@kroah.com> References: <1511796203245200@kroah.com> Message-ID: <877eu9yhc6.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: stable-owner@vger.kernel.org List-ID: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Subject: [PATCH] md: forbid a RAID5 from having both a bitmap and a journal. commit 230b55fa8d64007339319539f8f8e68114d08529 upstream. Having both a bitmap and a journal is pointless. Attempting to do so can corrupt the bitmap if the journal replay happens before the bitmap is initialized. Rather than try to avoid this corruption, simply refuse to allow arrays with both a bitmap and a journal. So: - if raid5_run sees both are present, fail. - if adding a bitmap finds a journal is present, fail - if adding a journal finds a bitmap is present, fail. Cc: stable@vger.kernel.org (4.10+) Signed-off-by: NeilBrown Tested-by: Joshua Kinard Acked-by: Joshua Kinard Signed-off-by: Shaohua Li =2D-- drivers/md/bitmap.c | 6 ++++++ drivers/md/md.c | 2 +- drivers/md/raid5.c | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) This commit only had problems due to a filename change. diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index d2121637b4ab..90231c7a6791 100644 =2D-- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -1816,6 +1816,12 @@ struct bitmap *bitmap_create(struct mddev *mddev, in= t slot) =20 BUG_ON(file && mddev->bitmap_info.offset); =20 + if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) { + pr_notice("md/raid:%s: array with journal cannot have bitmap\n", + mdname(mddev)); + return ERR_PTR(-EBUSY); + } + bitmap =3D kzalloc(sizeof(*bitmap), GFP_KERNEL); if (!bitmap) return ERR_PTR(-ENOMEM); diff --git a/drivers/md/md.c b/drivers/md/md.c index 0ff1bbf6c90e..450a2429be3d 100644 =2D-- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -6362,7 +6362,7 @@ static int add_new_disk(struct mddev *mddev, mdu_disk= _info_t *info) break; } } =2D if (has_journal) { + if (has_journal || mddev->bitmap) { export_rdev(rdev); return -EBUSY; } diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 928e24a07133..7aed69a4f655 100644 =2D-- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -7156,6 +7156,13 @@ static int raid5_run(struct mddev *mddev) min_offset_diff =3D diff; } =20 + if ((test_bit(MD_HAS_JOURNAL, &mddev->flags) || journal_dev) && + (mddev->bitmap_info.offset || mddev->bitmap_info.file)) { + pr_notice("md/raid:%s: array cannot have both journal and bitmap\n", + mdname(mddev)); + return -EINVAL; + } + if (mddev->reshape_position !=3D MaxSector) { /* Check that we can continue the reshape. * Difficulties arise if the stripe we would write to =2D-=20 2.14.0.rc0.dirty --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAloeFLoACgkQOeye3VZi gbnTTxAAvOv+sNufZPee0icvzPXBRtsaaJnaTL0FxXdI9GuwLFO/WBgp3u3zps0/ +A+w0Lx4Na7OaIWy6wUSoO7O9kybfqQkwAPGbwTexfaby0yugVd8gDW8646jlcz5 XLRQoz9VeWAjv5q8Fyk97Bp62BAjwXjMmYdlCjCsZlScjVx0cDMF3mRCQZ4li3wf PDzBFYhMGEXUBEqxDo88KCTSuVDt0M/gyEkG+uDpSF9vaXM94YomR0fK61LEv6Jd FSBFN6t6rOLtc5nl5EOPAF+jIPqvqu0XmeKrO8Hn/TdI5pmLRFKXkBQz2/0S9IX+ COOCWW5H0jmCH2aO/ewLDnsgrNlOgI2c8cJTbOEsb28IgbJeb7l3ITjjA0AHsY/m MOrI6BTslAGdJIvvVXWeNh2AxHsQJhZv4poHmREKhP6XrZ58rUictzsooQrsfigE IwCYs2ucwCIWhtyR4KM5nDiIhdbKhYfAYHupfgHyCDhsyGD4XAR7VLB7ea5JmRsd PpFChlP4/EUvZckn7Qm1eC9jIK1SlxSl4Lj/v0H5G4CLRC+/iiDNKVEDYQq73XKW nJeFxIfVFrYDjkvcXSRAZulABch5/4TCMOaMnWJbh4Oa/bH0U8ypzGMGysQVUx+F z7D01IXYWUqzchUWgDp1RH0xjG/gfyVK/TE3bpS9NGQfIi3BGZk= =/X/Y -----END PGP SIGNATURE----- --=-=-=--