]> git.ipfire.org Git - thirdparty/mdadm.git/commit
super1.c: avoid useless sync when bitmap switches from clustered to none
authorZhao Heming <heming.zhao@suse.com>
Wed, 3 Feb 2021 00:22:51 +0000 (08:22 +0800)
committerJes Sorensen <jsorensen@fb.com>
Wed, 3 Mar 2021 14:30:14 +0000 (09:30 -0500)
commitf7a6246bab1541d7208a5f0f9f0c6cac114e38da
tree7765126311e90745fa7acd25e5797e5bf31d4413
parente6561c4defe853eaa6be27da0bb6bbd36e197b1f
super1.c: avoid useless sync when bitmap switches from clustered to none

With kernel commit 480523feae58 ("md: only call set_in_sync() when it
is expected to succeed."), mddev->in_sync in clustered array is always
zero. It makes metadata resync_offset to always zero.
When assembling a clusterd array with "-U no-bitmap" option, kernel
md layer "mddev->resync_offset == 0" and "mddev->bitmap == NULL" will
trigger raid1 do sync on every bitmap chunk. the sync action is useless,
we should avoid it.

Related kernel flow:
```
md_do_sync
 mddev->pers->sync_request
  raid1_sync_request
   md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1)
    __bitmap_start_sync(bitmap, offset,&blocks1, degraded)
      if (bitmap == NULL) {/* FIXME or bitmap set as 'failed' */
        *blocks = 1024;
        return 1; /* always resync if no bitmap */
      }
```

Reprodusible steps:
```
node1 # mdadm -C /dev/md0 -b clustered -e 1.2 -n 2 -l mirror /dev/sd{a,b}
node1 # mdadm -Ss
(in another shell, executing & watching: watch -n 1 'cat /proc/mdstat')
node1 # mdadm -A -U no-bitmap /dev/md0 /dev/sd{a,b}
```

Signed-off-by: Zhao Heming <heming.zhao@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
super1.c