From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bn3nam01on0104.outbound.protection.outlook.com ([104.47.33.104]:2464 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032278AbeCAPhw (ORCPT ); Thu, 1 Mar 2018 10:37:52 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Arnd Bergmann , NeilBrown , Sasha Levin Subject: [added to the 4.1 stable tree] md: avoid warning for 32-bit sector_t Date: Thu, 1 Mar 2018 15:27:15 +0000 Message-ID: <20180301152116.1486-446-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Arnd Bergmann This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 3312c951efaba55080958974047414576b9e5d63 ] When CONFIG_LBDAF is not set, sector_t is only 32-bits wide, which means we cannot have devices with more than 2TB, and the code that is trying to handle compatibility support for large devices in md version 0.90 is meaningless but also causes a compile-time warning: drivers/md/md.c: In function 'super_90_load': drivers/md/md.c:1029:19: warning: large integer implicitly truncated to uns= igned type [-Woverflow] drivers/md/md.c: In function 'super_90_rdev_size_change': drivers/md/md.c:1323:17: warning: large integer implicitly truncated to uns= igned type [-Woverflow] This adds a check for CONFIG_LBDAF to avoid even getting into this code path, and also adds an explicit cast to let the compiler know it doesn't have to warn about the truncation. Signed-off-by: Arnd Bergmann Signed-off-by: NeilBrown Signed-off-by: Sasha Levin --- drivers/md/md.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 1fdcd5735418..03bcc1ab2e9d 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1043,8 +1043,9 @@ static int super_90_load(struct md_rdev *rdev, struct= md_rdev *refdev, int minor * (not needed for Linear and RAID0 as metadata doesn't * record this size) */ - if (rdev->sectors >=3D (2ULL << 32) && sb->level >=3D 1) - rdev->sectors =3D (2ULL << 32) - 2; + if (IS_ENABLED(CONFIG_LBDAF) && (u64)rdev->sectors >=3D (2ULL << 32) && + sb->level >=3D 1) + rdev->sectors =3D (sector_t)(2ULL << 32) - 2; =20 if (rdev->sectors < ((sector_t)sb->size) * 2 && sb->level >=3D 1) /* "this cannot possibly happen" ... */ @@ -1337,8 +1338,9 @@ super_90_rdev_size_change(struct md_rdev *rdev, secto= r_t num_sectors) /* Limit to 4TB as metadata cannot record more than that. * 4TB =3D=3D 2^32 KB, or 2*2^32 sectors. */ - if (num_sectors >=3D (2ULL << 32) && rdev->mddev->level >=3D 1) - num_sectors =3D (2ULL << 32) - 2; + if (IS_ENABLED(CONFIG_LBDAF) && (u64)num_sectors >=3D (2ULL << 32) && + rdev->mddev->level >=3D 1) + num_sectors =3D (sector_t)(2ULL << 32) - 2; md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size, rdev->sb_page); md_super_wait(rdev->mddev); --=20 2.14.1