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

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