Re: [PATCH 2/3] md: don't set In_sync if array is frozen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 7/26/19 4:47 AM, yuyufen wrote:
Hi, Guoqing


On 2019/7/24 17:09, Guoqing Jiang wrote:
When a disk is added to array, the following path is called in mdadm.

Manage_subdevs -> sysfs_freeze_array
                -> Manage_add
                -> sysfs_set_str(&info, NULL, "sync_action","idle")

Then from kernel side, Manage_add invokes the path (add_new_disk ->
validate_super = super_1_validate) to set In_sync flag.

Since In_sync means "device is in_sync with rest of array", and the new
added disk need to resync thread to help the synchronization of data.
And md_reap_sync_thread would call spare_active to set In_sync for the
new added disk finally. So don't set In_sync if array is in frozen.

Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx>
---
  drivers/md/md.c | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0ced0933d246..d0223316064d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1826,8 +1826,15 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
                  if (!(le32_to_cpu(sb->feature_map) &
                        MD_FEATURE_RECOVERY_BITMAP))
                      rdev->saved_raid_disk = -1;
-            } else
-                set_bit(In_sync, &rdev->flags);
+            } else {
+                /*
+                 * If the array is FROZEN, then the device can't
+                 * be in_sync with rest of array.
+                 */
+                if (!test_bit(MD_RECOVERY_FROZEN,
+                          &mddev->recovery))
+                    set_bit(In_sync, &rdev->flags);
+            }
              rdev->raid_disk = role;
              break;
          }

super_1_validate() set rdev with 'In_sync', while add_new_disk() will clear the flag bit again after that.

         clear_bit(In_sync, &rdev->flags); /* just to be sure */

So, I think there is no bad influence without test FROZEN. Am I ignoring anything?

Yes, you are right about it.

Though there is a small time window that the disk could be showed as 'U', I guess it is better to reduce the window so we can get the correct status as much as possible.

Thanks,
Guoqing



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux