md: Fix bitmap offset calculations
authorGoldwyn Rodrigues <rgoldwyn@suse.de>
Tue, 24 Mar 2015 16:29:05 +0000 (11:29 -0500)
committerNeilBrown <neilb@suse.de>
Wed, 25 Mar 2015 02:07:55 +0000 (13:07 +1100)
The calculations of bitmap offset is incorrect with respect to bits to bytes
conversion.

Also, remove an irrelevant duplicate message.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/bitmap.c

index ac79fef681434938ce872fb6b9ce54548853da65..e98db04eb4f9b108973d003db355895d00dbfc2c 100644 (file)
@@ -575,7 +575,9 @@ re_read:
 
                sector_div(bm_blocks,
                           bitmap->mddev->bitmap_info.chunksize >> 9);
-               bm_blocks = bm_blocks << 3;
+               /* bits to bytes */
+               bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t);
+               /* to 4k blocks */
                bm_blocks = DIV_ROUND_UP_SECTOR_T(bm_blocks, 4096);
                bitmap->mddev->bitmap_info.offset += bitmap->cluster_slot * (bm_blocks << 3);
                pr_info("%s:%d bm slot: %d offset: %llu\n", __func__, __LINE__,
@@ -672,9 +674,6 @@ out:
                        goto out_no_sb;
                }
                bitmap->cluster_slot = md_cluster_ops->slot_number(bitmap->mddev);
-               pr_info("%s:%d bm slot: %d offset: %llu\n", __func__, __LINE__,
-                       bitmap->cluster_slot,
-                       (unsigned long long)bitmap->mddev->bitmap_info.offset);
                goto re_read;
        }