summaryrefslogtreecommitdiff
path: root/debian/patches/0005-imsm-add-functions-to-get-and-set-imsm-dev-size.patch
blob: dfdc7f3a62162d6dbb3ed8b84c8b8822cb023c73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
From fcc2c9daede11fcc67e4032fd6fa8da198aaa319 Mon Sep 17 00:00:00 2001
From: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Date: Thu, 5 Apr 2018 13:38:36 +0200
Subject: [PATCH 5/9] imsm: add functions to get and set imsm dev size

Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
 super-intel.c | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 52011e5b..fe2a705b 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -1201,6 +1201,13 @@ static unsigned long long num_data_stripes(struct imsm_map *map)
 	return join_u32(map->num_data_stripes_lo, map->num_data_stripes_hi);
 }
 
+static unsigned long long imsm_dev_size(struct imsm_dev *dev)
+{
+	if (dev == NULL)
+		return 0;
+	return join_u32(dev->size_low, dev->size_high);
+}
+
 static void set_total_blocks(struct imsm_disk *disk, unsigned long long n)
 {
 	split_ull(n, &disk->total_blocks_lo, &disk->total_blocks_hi);
@@ -1221,6 +1228,11 @@ static void set_num_data_stripes(struct imsm_map *map, unsigned long long n)
 	split_ull(n, &map->num_data_stripes_lo, &map->num_data_stripes_hi);
 }
 
+static void set_imsm_dev_size(struct imsm_dev *dev, unsigned long long n)
+{
+	split_ull(n, &dev->size_low, &dev->size_high);
+}
+
 static struct extent *get_extents(struct intel_super *super, struct dl *dl)
 {
 	/* find a list of used extents on the given physical device */
@@ -1503,9 +1515,7 @@ static void print_imsm_dev(struct intel_super *super,
 	} else
 		printf("      This Slot : ?\n");
 	printf("    Sector Size : %u\n", super->sector_size);
-	sz = __le32_to_cpu(dev->size_high);
-	sz <<= 32;
-	sz += __le32_to_cpu(dev->size_low);
+	sz = imsm_dev_size(dev);
 	printf("     Array Size : %llu%s\n",
 		   (unsigned long long)sz * 512 / super->sector_size,
 	       human_size(sz * 512));
@@ -1634,8 +1644,7 @@ void convert_to_4k(struct intel_super *super)
 		struct imsm_dev *dev = __get_imsm_dev(mpb, i);
 		struct imsm_map *map = get_imsm_map(dev, MAP_0);
 		/* dev */
-		split_ull((join_u32(dev->size_low, dev->size_high)/IMSM_4K_DIV),
-				 &dev->size_low, &dev->size_high);
+		set_imsm_dev_size(dev, imsm_dev_size(dev)/IMSM_4K_DIV);
 		dev->vol.curr_migr_unit /= IMSM_4K_DIV;
 
 		/* map0 */
@@ -1762,8 +1771,7 @@ void convert_from_4k(struct intel_super *super)
 		struct imsm_dev *dev = __get_imsm_dev(mpb, i);
 		struct imsm_map *map = get_imsm_map(dev, MAP_0);
 		/* dev */
-		split_ull((join_u32(dev->size_low, dev->size_high)*IMSM_4K_DIV),
-				 &dev->size_low, &dev->size_high);
+		set_imsm_dev_size(dev, imsm_dev_size(dev)*IMSM_4K_DIV);
 		dev->vol.curr_migr_unit *= IMSM_4K_DIV;
 
 		/* map0 */
@@ -3240,9 +3248,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
 	info->array.chunk_size	  =
 		__le16_to_cpu(map_to_analyse->blocks_per_strip) << 9;
 	info->array.state	  = !(dev->vol.dirty & RAIDVOL_DIRTY);
-	info->custom_array_size   = __le32_to_cpu(dev->size_high);
-	info->custom_array_size   <<= 32;
-	info->custom_array_size   |= __le32_to_cpu(dev->size_low);
+	info->custom_array_size   = imsm_dev_size(dev);
 	info->recovery_blocked = imsm_reshape_blocks_arrays_changes(st->sb);
 
 	if (is_gen_migration(dev)) {
@@ -5370,8 +5376,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
 	array_blocks = round_size_to_mb(array_blocks, data_disks);
 	size_per_member = array_blocks / data_disks;
 
-	dev->size_low = __cpu_to_le32((__u32) array_blocks);
-	dev->size_high = __cpu_to_le32((__u32) (array_blocks >> 32));
+	set_imsm_dev_size(dev, array_blocks);
 	dev->status = (DEV_READ_COALESCING | DEV_WRITE_COALESCING);
 	vol = &dev->vol;
 	vol->migr_state = 0;
@@ -7733,7 +7738,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
 						 level, /* RAID level */
 						 imsm_level_to_layout(level),
 						 map->num_members, /* raid disks */
-						 &chunk, join_u32(dev->size_low, dev->size_high),
+						 &chunk, imsm_dev_size(dev),
 						 1 /* verbose */)) {
 			pr_err("IMSM RAID geometry validation failed.  Array %s activation is blocked.\n",
 				dev->volume);
@@ -8143,9 +8148,7 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev,
 		/* when problems occures
 		 * return current array_blocks value
 		 */
-		array_blocks = __le32_to_cpu(dev->size_high);
-		array_blocks = array_blocks << 32;
-		array_blocks += __le32_to_cpu(dev->size_low);
+		array_blocks = imsm_dev_size(dev);
 
 		return array_blocks;
 	}
@@ -8165,8 +8168,7 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev,
 	}
 
 	array_blocks = round_size_to_mb(array_blocks, used_disks);
-	dev->size_low = __cpu_to_le32((__u32)array_blocks);
-	dev->size_high = __cpu_to_le32((__u32)(array_blocks >> 32));
+	set_imsm_dev_size(dev, array_blocks);
 
 	return array_blocks;
 }
@@ -9139,8 +9141,7 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration *
 				map->blocks_per_strip =
 					__cpu_to_le16(u->new_chunksize * 2);
 				num_data_stripes =
-					(join_u32(dev->size_low, dev->size_high)
-					/ used_disks);
+					imsm_dev_size(dev) / used_disks;
 				num_data_stripes /= map->blocks_per_strip;
 				num_data_stripes /= map->num_domains;
 				set_num_data_stripes(map, num_data_stripes);
-- 
2.17.0