Define and use SUPER1_SIZE for allocations
Use a #define rather than calculate the size of the superblock buffer on every allocation. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
b2bfdfa0fe
commit
4122675629
16
super1.c
16
super1.c
|
@ -93,6 +93,8 @@ struct mdp_superblock_1 {
|
||||||
/* bitmap super size is 256, but we round up to a sector for alignment */
|
/* bitmap super size is 256, but we round up to a sector for alignment */
|
||||||
#define BM_SUPER_SIZE 512
|
#define BM_SUPER_SIZE 512
|
||||||
#define MAX_DEVS ((int)(MAX_SB_SIZE - sizeof(struct mdp_superblock_1)) / 2)
|
#define MAX_DEVS ((int)(MAX_SB_SIZE - sizeof(struct mdp_superblock_1)) / 2)
|
||||||
|
#define SUPER1_SIZE (MAX_SB_SIZE + BM_SUPER_SIZE \
|
||||||
|
+ sizeof(struct misc_dev_info))
|
||||||
|
|
||||||
struct misc_dev_info {
|
struct misc_dev_info {
|
||||||
__u64 device_size;
|
__u64 device_size;
|
||||||
|
@ -841,8 +843,7 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info,
|
||||||
char defname[10];
|
char defname[10];
|
||||||
int sbsize;
|
int sbsize;
|
||||||
|
|
||||||
if (posix_memalign((void**)&sb, 512, (MAX_SB_SIZE + BM_SUPER_SIZE +
|
if (posix_memalign((void**)&sb, 512, SUPER1_SIZE) != 0) {
|
||||||
sizeof(struct misc_dev_info))) != 0) {
|
|
||||||
fprintf(stderr, Name
|
fprintf(stderr, Name
|
||||||
": %s could not allocate superblock\n", __func__);
|
": %s could not allocate superblock\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1227,15 +1228,12 @@ static int compare_super1(struct supertype *st, struct supertype *tst)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!first) {
|
if (!first) {
|
||||||
if (posix_memalign((void**)&first, 512,
|
if (posix_memalign((void**)&first, 512, SUPER1_SIZE) != 0) {
|
||||||
MAX_SB_SIZE + BM_SUPER_SIZE +
|
|
||||||
sizeof(struct misc_dev_info)) != 0) {
|
|
||||||
fprintf(stderr, Name
|
fprintf(stderr, Name
|
||||||
": %s could not allocate superblock\n", __func__);
|
": %s could not allocate superblock\n", __func__);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
memcpy(first, second, MAX_SB_SIZE + BM_SUPER_SIZE +
|
memcpy(first, second, SUPER1_SIZE);
|
||||||
sizeof(struct misc_dev_info));
|
|
||||||
st->sb = first;
|
st->sb = first;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1342,9 +1340,7 @@ static int load_super1(struct supertype *st, int fd, char *devname)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (posix_memalign((void**)&super, 512,
|
if (posix_memalign((void**)&super, 512, SUPER1_SIZE) != 0) {
|
||||||
MAX_SB_SIZE + BM_SUPER_SIZE +
|
|
||||||
sizeof(struct misc_dev_info)) != 0) {
|
|
||||||
fprintf(stderr, Name ": %s could not allocate superblock\n",
|
fprintf(stderr, Name ": %s could not allocate superblock\n",
|
||||||
__func__);
|
__func__);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue