diff options
author | Xiao Ni <xni@redhat.com> | 2020-10-28 07:04:24 +0100 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2021-03-03 15:29:13 +0100 |
commit | 1fe2e1007310778d0551d5c34317e5318507399d (patch) | |
tree | e2a913303e65cb811b3e8a52510b29ec8cff1e3f /super1.c | |
parent | Dump: get stat from a wrong metadata file when restoring metadata (diff) | |
download | mdadm-1fe2e1007310778d0551d5c34317e5318507399d.tar.xz mdadm-1fe2e1007310778d0551d5c34317e5318507399d.zip |
mdadm/bitmap: locate bitmap calcuate bitmap position wrongly
Now it only adds bitmap offset based on cluster nodes. It's not right. It needs to
add per node bitmap space to find next node bitmap position.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to '')
-rw-r--r-- | super1.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -2582,8 +2582,9 @@ add_internal_bitmap1(struct supertype *st, static int locate_bitmap1(struct supertype *st, int fd, int node_num) { - unsigned long long offset; + unsigned long long offset, bm_sectors_per_node; struct mdp_superblock_1 *sb; + bitmap_super_t *bms; int mustfree = 0; int ret; @@ -2598,8 +2599,13 @@ static int locate_bitmap1(struct supertype *st, int fd, int node_num) ret = 0; else ret = -1; - offset = __le64_to_cpu(sb->super_offset); - offset += (int32_t) __le32_to_cpu(sb->bitmap_offset) * (node_num + 1); + + offset = __le64_to_cpu(sb->super_offset) + __le32_to_cpu(sb->bitmap_offset); + if (node_num) { + bms = (bitmap_super_t*)(((char*)sb)+MAX_SB_SIZE); + bm_sectors_per_node = calc_bitmap_size(bms, 4096) >> 9; + offset += bm_sectors_per_node * node_num; + } if (mustfree) free(sb); lseek64(fd, offset<<9, 0); |