dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/allocate-buffer-to-support-maximum-sector-size.patch

2c1b57
commit 853375734edcfd70ba64b444b9e69f7e336a30b7
2c1b57
Author: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
2c1b57
Date:   Tue May 9 12:25:44 2017 +0200
2c1b57
2c1b57
    imsm: allocate buffer to support maximum sector size
2c1b57
    
2c1b57
    Allocate migration record buffer to support maximum sector size. Disk with
2c1b57
    non-matching sector size is not going to be included in the array, however
2c1b57
    some preparation/cleanup actions still take place on it and they would
2c1b57
    cause a crash. Clear migration record using sector size of the disk (not
2c1b57
    array) as they might not match.
2c1b57
    
2c1b57
    Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
2c1b57
    Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
2c1b57
    Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2c1b57
2c1b57
diff --git a/super-intel.c b/super-intel.c
2c1b57
index 2a5d848..cfb10d5 100644
2c1b57
--- a/super-intel.c
2c1b57
+++ b/super-intel.c
2c1b57
@@ -4229,8 +4229,8 @@ static int load_imsm_mpb(int fd, struct intel_super *super, char *devname)
2c1b57
 	sectors = mpb_sectors(anchor, sector_size) - 1;
2c1b57
 	free(anchor);
2c1b57
 
2c1b57
-	if (posix_memalign(&super->migr_rec_buf, sector_size,
2c1b57
-	    MIGR_REC_BUF_SECTORS*sector_size) != 0) {
2c1b57
+	if (posix_memalign(&super->migr_rec_buf, MAX_SECTOR_SIZE,
2c1b57
+	    MIGR_REC_BUF_SECTORS*MAX_SECTOR_SIZE) != 0) {
2c1b57
 		pr_err("could not allocate migr_rec buffer\n");
2c1b57
 		free(super->buf);
2c1b57
 		return 2;
2c1b57
@@ -5258,8 +5258,9 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
2c1b57
 			pr_err("could not allocate new mpb\n");
2c1b57
 			return 0;
2c1b57
 		}
2c1b57
-		if (posix_memalign(&super->migr_rec_buf, sector_size,
2c1b57
-				   MIGR_REC_BUF_SECTORS*sector_size) != 0) {
2c1b57
+		if (posix_memalign(&super->migr_rec_buf, MAX_SECTOR_SIZE,
2c1b57
+				   MIGR_REC_BUF_SECTORS*
2c1b57
+				   MAX_SECTOR_SIZE) != 0) {
2c1b57
 			pr_err("could not allocate migr_rec buffer\n");
2c1b57
 			free(super->buf);
2c1b57
 			free(super);
2c1b57
@@ -5719,12 +5720,12 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
2c1b57
 	}
2c1b57
 
2c1b57
 	/* clear migr_rec when adding disk to container */
2c1b57
-	memset(super->migr_rec_buf, 0, MIGR_REC_BUF_SECTORS*super->sector_size);
2c1b57
-	if (lseek64(fd, size - MIGR_REC_SECTOR_POSITION*super->sector_size,
2c1b57
+	memset(super->migr_rec_buf, 0, MIGR_REC_BUF_SECTORS*MAX_SECTOR_SIZE);
2c1b57
+	if (lseek64(fd, size - MIGR_REC_SECTOR_POSITION*member_sector_size,
2c1b57
 	    SEEK_SET) >= 0) {
2c1b57
 		if ((unsigned int)write(fd, super->migr_rec_buf,
2c1b57
-		    MIGR_REC_BUF_SECTORS*super->sector_size) !=
2c1b57
-		    MIGR_REC_BUF_SECTORS*super->sector_size)
2c1b57
+		    MIGR_REC_BUF_SECTORS*member_sector_size) !=
2c1b57
+		    MIGR_REC_BUF_SECTORS*member_sector_size)
2c1b57
 			perror("Write migr_rec failed");
2c1b57
 	}
2c1b57
 
2c1b57
@@ -5916,7 +5917,7 @@ static int write_super_imsm(struct supertype *st, int doclose)
2c1b57
 	}
2c1b57
 	if (clear_migration_record)
2c1b57
 		memset(super->migr_rec_buf, 0,
2c1b57
-		    MIGR_REC_BUF_SECTORS*sector_size);
2c1b57
+		    MIGR_REC_BUF_SECTORS*MAX_SECTOR_SIZE);
2c1b57
 
2c1b57
 	if (sector_size == 4096)
2c1b57
 		convert_to_4k(super);
2c1b57
@@ -11770,7 +11771,7 @@ static int imsm_manage_reshape(
2c1b57
 	/* clear migr_rec on disks after successful migration */
2c1b57
 	struct dl *d;
2c1b57
 
2c1b57
-	memset(super->migr_rec_buf, 0, MIGR_REC_BUF_SECTORS*sector_size);
2c1b57
+	memset(super->migr_rec_buf, 0, MIGR_REC_BUF_SECTORS*MAX_SECTOR_SIZE);
2c1b57
 	for (d = super->disks; d; d = d->next) {
2c1b57
 		if (d->index < 0 || is_failed(&d->disk))
2c1b57
 			continue;