]> git.baikalelectronics.ru Git - kernel.git/commit
md: don't update recovery_cp when curr_resync is ACTIVE
authorHou Tao <houtao1@huawei.com>
Tue, 31 Jan 2023 07:07:19 +0000 (15:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:34:10 +0000 (09:34 +0100)
commit9c435daa9da40821d39e18352bc305314bb482de
treec1a771aa3fd212dcd72810748a0f9e16bde5ab4e
parent4a6a91a28dd1da8b162f41624e266378090ce6f9
md: don't update recovery_cp when curr_resync is ACTIVE

commit e7baa3bd45bb8f214a4d76d0ba0c1e5df341c287 upstream.

Don't update recovery_cp when curr_resync is MD_RESYNC_ACTIVE, otherwise
md may skip the resync of the first 3 sectors if the resync procedure is
interrupted before the first calling of ->sync_request() as shown below:

md_do_sync thread          control thread
  // setup resync
  mddev->recovery_cp = 0
  j = 0
  mddev->curr_resync = MD_RESYNC_ACTIVE

                             // e.g., set array as idle
                             set_bit(MD_RECOVERY_INTR, &&mddev_recovery)
  // resync loop
  // check INTR before calling sync_request
  !test_bit(MD_RECOVERY_INTR, &mddev->recovery

  // resync interrupted
  // update recovery_cp from 0 to 3
  // the resync of three 3 sectors will be skipped
  mddev->recovery_cp = 3

Fixes: a8b70291a549 ("md: Use enum for overloaded magic numbers used by mddev->curr_resync")
Cc: stable@vger.kernel.org # 6.0+
Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/md.c