diff options
author | Artur Paszkiewicz <artur.paszkiewicz@intel.com> | 2016-11-10 11:50:53 +0100 |
---|---|---|
committer | Jes Sorensen <Jes.Sorensen@redhat.com> | 2016-11-16 15:56:39 +0100 |
commit | 561ad5597bf472f8114260d144a5e8ba5c7246d5 (patch) | |
tree | 34b08ecabe680f23ca61110809771eabc5833f5d /mdadm.h | |
parent | Lib.c: Fix geting devname for devices with long path (diff) | |
download | mdadm-561ad5597bf472f8114260d144a5e8ba5c7246d5.tar.xz mdadm-561ad5597bf472f8114260d144a5e8ba5c7246d5.zip |
super1: make internal bitmap size calculations more consistent
Determining internal bitmap size is performed using two different
functions (bitmap_sectors() and calc_bitmap_size()) and in
getinfo_super1() it is calculated in yet another way. Each of these
methods give slightly different results. The most accurate is
calc_bitmap_size() but it also has a rounding issue. So:
- fix the rounding issue in calc_bitmap_size() using bitmap_bits()
- replace usages of bitmap_sectors() and open-coded calculations with
calc_bitmap_size()
- remove bitmap_sectors()
- move bitmap_bits() to mdadm.h as inline - otherwise mdassemble won't
compile (it does not use bitmap.c)
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Diffstat (limited to 'mdadm.h')
-rwxr-xr-x | mdadm.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1331,7 +1331,14 @@ extern int CreateBitmap(char *filename, int force, char uuid[16], extern int ExamineBitmap(char *filename, int brief, struct supertype *st); extern int Write_rules(char *rule_name); extern int bitmap_update_uuid(int fd, int *uuid, int swap); -extern unsigned long bitmap_sectors(struct bitmap_super_s *bsb); + +/* calculate the size of the bitmap given the array size and bitmap chunksize */ +static inline unsigned long long +bitmap_bits(unsigned long long array_size, unsigned long chunksize) +{ + return (array_size * 512 + chunksize - 1) / chunksize; +} + extern int Dump_metadata(char *dev, char *dir, struct context *c, struct supertype *st); extern int Restore_metadata(char *dev, char *dir, struct context *c, |