Received: by 10.213.65.68 with SMTP id h4csp468012imn; Fri, 16 Mar 2018 08:39:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELvrajhToRbupH+gcBGQ7jP4RfMTdgNaGh18xUYUHr84B8fwsTCJPidzRmOZIr3iFQqhw271 X-Received: by 10.99.0.2 with SMTP id 2mr1872645pga.106.1521214775233; Fri, 16 Mar 2018 08:39:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521214775; cv=none; d=google.com; s=arc-20160816; b=V3XRYV+664n9iHw43HRzVf6Dp2aNceUARiu7SFHVCtMJ6S69LxomnV5H23+pBPQz5l Pyery7agadrQGxMG0K7qQboxJDZEwfln2vgCUfID+C5LFGOOx8KCL1nWw+t6BaSRvBhU q3Jaxk3aNd9TilXJzelro5mI73RMzVLwgz7YhC6ROVxUPlD9sTPLTOii65NoOM4iA3/Y 0e4EG1lBHJZIMy4WlfxYzwdiX0hbtf2+iUPrIRI2tBWQO5odfzSYAdRIvayw37IxDIU3 Syl2Gd79Gi3ng3ks/pCrqGwm6CkHgVPsuJw01/JUiXgIjtqJDjQ5WzwL7JNkpVIYU+xp UMOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vRfUS9Z+nfZejyIXr4j7S1c3atAIbWVehX+U+FJoAPg=; b=Uhwa2iMpb9NPPBMCumn/hEVyoC7h6WyUgUU2DkMlYKDYn+GpxVWDQlSKcv4ThVKKnq LV9KX1su9//vPaYmgCjF+IJNnXrf0jBikS5NUGpxUWB14UVTUM5G83AvZdlNXKHvcYyV QuK1+VlRsZhMSob37IHLloGdrguPy4qh+iTthwzChFDnhZmfogzyEgMCyIDBmidIJHH0 dWig+uBekncp7BYZk/M1IE/xTzZs1g3s/2rlfz9tOGcHVpJWuT0/4NxtpIqjgYhv1/fl JP3w0YL1nmf7/+UgaBpPRHxe8ekBV/52AbZnb34H9JOO4Ue5dZ4BTbc3WNFs5E2e2KFO Hz8w== ARC-Authentication-Results: i=1; mx.google.com; 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 t9-v6si6270886plq.321.2018.03.16.08.39.21; Fri, 16 Mar 2018 08:39:35 -0700 (PDT) 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; 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 S964836AbeCPPhu (ORCPT + 99 others); Fri, 16 Mar 2018 11:37:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41728 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933904AbeCPPhr (ORCPT ); Fri, 16 Mar 2018 11:37:47 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 05EAF1248; Fri, 16 Mar 2018 15:37:45 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heinz Mauelshagen , Mike Snitzer , Sasha Levin Subject: [PATCH 4.14 086/109] dm raid: fix raid set size revalidation Date: Fri, 16 Mar 2018 16:23:55 +0100 Message-Id: <20180316152334.604059087@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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: Heinz Mauelshagen [ Upstream commit 61e06e2c3ebd986050958513bfa40dceed756f8f ] The raid set size is being revalidated unconditionally before a reshaping conversion is started. MD requires the size to only be reduced in case of a stripe removing (i.e. shrinking) reshape but not when growing because the raid array has to stay small until after the growing reshape finishes. Fix by avoiding the size revalidation in preresume unless a shrinking reshape is requested. Signed-off-by: Heinz Mauelshagen Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-raid.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -675,15 +675,11 @@ static struct raid_type *get_raid_type_b return NULL; } -/* - * Conditionally change bdev capacity of @rs - * in case of a disk add/remove reshape - */ -static void rs_set_capacity(struct raid_set *rs) +/* Adjust rdev sectors */ +static void rs_set_rdev_sectors(struct raid_set *rs) { struct mddev *mddev = &rs->md; struct md_rdev *rdev; - struct gendisk *gendisk = dm_disk(dm_table_get_md(rs->ti->table)); /* * raid10 sets rdev->sector to the device size, which @@ -692,8 +688,16 @@ static void rs_set_capacity(struct raid_ rdev_for_each(rdev, mddev) if (!test_bit(Journal, &rdev->flags)) rdev->sectors = mddev->dev_sectors; +} - set_capacity(gendisk, mddev->array_sectors); +/* + * Change bdev capacity of @rs in case of a disk add/remove reshape + */ +static void rs_set_capacity(struct raid_set *rs) +{ + struct gendisk *gendisk = dm_disk(dm_table_get_md(rs->ti->table)); + + set_capacity(gendisk, rs->md.array_sectors); revalidate_disk(gendisk); } @@ -1674,8 +1678,11 @@ static void do_table_event(struct work_s struct raid_set *rs = container_of(ws, struct raid_set, md.event_work); smp_rmb(); /* Make sure we access most actual mddev properties */ - if (!rs_is_reshaping(rs)) + if (!rs_is_reshaping(rs)) { + if (rs_is_raid10(rs)) + rs_set_rdev_sectors(rs); rs_set_capacity(rs); + } dm_table_event(rs->ti->table); } @@ -3845,11 +3852,10 @@ static int raid_preresume(struct dm_targ mddev->resync_min = mddev->recovery_cp; } - rs_set_capacity(rs); - /* Check for any reshape request unless new raid set */ if (test_and_clear_bit(RT_FLAG_RESHAPE_RS, &rs->runtime_flags)) { /* Initiate a reshape. */ + rs_set_rdev_sectors(rs); mddev_lock_nointr(mddev); r = rs_start_reshape(rs); mddev_unlock(mddev); @@ -3878,6 +3884,10 @@ static void raid_resume(struct dm_target mddev->ro = 0; mddev->in_sync = 0; + /* Only reduce raid set size before running a disk removing reshape. */ + if (mddev->delta_disks < 0) + rs_set_capacity(rs); + /* * Keep the RAID set frozen if reshape/rebuild flags are set. * The RAID set is unfrozen once the next table load/resume,