|
|
dd3a91 |
commit 4b57ecf6cea134edff75a2f3a87ee48d52715c70
|
|
|
dd3a91 |
Author: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
|
|
|
dd3a91 |
Date: Tue May 9 12:25:47 2017 +0200
|
|
|
dd3a91 |
|
|
|
dd3a91 |
Add sector size as spare selection criterion
|
|
|
dd3a91 |
|
|
|
dd3a91 |
Add sector size as new spare selection criterion. Assume that 0 means
|
|
|
dd3a91 |
there is no requirement for the sector size in the array. Skip disks
|
|
|
dd3a91 |
with unsuitable sector size when looking for a spare to move across
|
|
|
dd3a91 |
containers.
|
|
|
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/Incremental.c b/Incremental.c
|
|
|
dd3a91 |
index fe9d644..30dc7a2 100644
|
|
|
dd3a91 |
--- a/Incremental.c
|
|
|
dd3a91 |
+++ b/Incremental.c
|
|
|
dd3a91 |
@@ -867,7 +867,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
|
|
|
dd3a91 |
struct domainlist *dl = NULL;
|
|
|
dd3a91 |
struct mdinfo *sra;
|
|
|
dd3a91 |
unsigned long long devsize;
|
|
|
dd3a91 |
- struct spare_criteria sc = {0};
|
|
|
dd3a91 |
+ struct spare_criteria sc = {0, 0};
|
|
|
dd3a91 |
|
|
|
dd3a91 |
if (is_subarray(mp->metadata))
|
|
|
dd3a91 |
continue;
|
|
|
dd3a91 |
@@ -1627,7 +1627,7 @@ static int Incremental_container(struct supertype *st, char *devname,
|
|
|
dd3a91 |
struct mdinfo *sinfo;
|
|
|
dd3a91 |
|
|
|
dd3a91 |
if (!sst->ss->load_container(sst, sfd, NULL)) {
|
|
|
dd3a91 |
- struct spare_criteria sc = {0};
|
|
|
dd3a91 |
+ struct spare_criteria sc = {0, 0};
|
|
|
dd3a91 |
|
|
|
dd3a91 |
if (st->ss->get_spare_criteria)
|
|
|
dd3a91 |
st->ss->get_spare_criteria(st, &sc);
|
|
|
dd3a91 |
diff --git a/Monitor.c b/Monitor.c
|
|
|
dd3a91 |
index 9a2baad..c96f8e8 100644
|
|
|
dd3a91 |
--- a/Monitor.c
|
|
|
dd3a91 |
+++ b/Monitor.c
|
|
|
dd3a91 |
@@ -731,6 +731,7 @@ static int get_required_spare_criteria(struct state *st,
|
|
|
dd3a91 |
if (!st->metadata ||
|
|
|
dd3a91 |
!st->metadata->ss->get_spare_criteria) {
|
|
|
dd3a91 |
sc->min_size = 0;
|
|
|
dd3a91 |
+ sc->sector_size = 0;
|
|
|
dd3a91 |
return 0;
|
|
|
dd3a91 |
}
|
|
|
dd3a91 |
|
|
|
dd3a91 |
@@ -787,6 +788,7 @@ static dev_t choose_spare(struct state *from, struct state *to,
|
|
|
dd3a91 |
from->devstate[d] == 0) {
|
|
|
dd3a91 |
struct dev_policy *pol;
|
|
|
dd3a91 |
unsigned long long dev_size;
|
|
|
dd3a91 |
+ unsigned int dev_sector_size;
|
|
|
dd3a91 |
|
|
|
dd3a91 |
if (to->metadata->ss->external &&
|
|
|
dd3a91 |
test_partition_from_id(from->devid[d]))
|
|
|
dd3a91 |
@@ -797,6 +799,12 @@ static dev_t choose_spare(struct state *from, struct state *to,
|
|
|
dd3a91 |
dev_size < sc->min_size)
|
|
|
dd3a91 |
continue;
|
|
|
dd3a91 |
|
|
|
dd3a91 |
+ if (sc->sector_size &&
|
|
|
dd3a91 |
+ dev_sector_size_from_id(from->devid[d],
|
|
|
dd3a91 |
+ &dev_sector_size) &&
|
|
|
dd3a91 |
+ sc->sector_size != dev_sector_size)
|
|
|
dd3a91 |
+ continue;
|
|
|
dd3a91 |
+
|
|
|
dd3a91 |
pol = devid_policy(from->devid[d]);
|
|
|
dd3a91 |
if (from->spare_group)
|
|
|
dd3a91 |
pol_add(&pol, pol_domain,
|
|
|
dd3a91 |
diff --git a/mdadm.h b/mdadm.h
|
|
|
dd3a91 |
index 8da7fd3..ec0a39e 100644
|
|
|
dd3a91 |
--- a/mdadm.h
|
|
|
dd3a91 |
+++ b/mdadm.h
|
|
|
dd3a91 |
@@ -363,6 +363,7 @@ struct createinfo {
|
|
|
dd3a91 |
|
|
|
dd3a91 |
struct spare_criteria {
|
|
|
dd3a91 |
unsigned long long min_size;
|
|
|
dd3a91 |
+ unsigned int sector_size;
|
|
|
dd3a91 |
};
|
|
|
dd3a91 |
|
|
|
dd3a91 |
enum mode {
|
|
|
dd3a91 |
@@ -947,6 +948,7 @@ extern struct superswitch {
|
|
|
dd3a91 |
/*
|
|
|
dd3a91 |
* Return spare criteria for array:
|
|
|
dd3a91 |
* - minimum disk size can be used in array;
|
|
|
dd3a91 |
+ * - sector size can be used in array.
|
|
|
dd3a91 |
* Return values: 0 - for success and -EINVAL on error.
|
|
|
dd3a91 |
*/
|
|
|
dd3a91 |
int (*get_spare_criteria)(struct supertype *st,
|
|
|
dd3a91 |
@@ -1189,6 +1191,7 @@ extern int get_dev_size(int fd, char *dname, unsigned long long *sizep);
|
|
|
dd3a91 |
extern int get_dev_sector_size(int fd, char *dname, unsigned int *sectsizep);
|
|
|
dd3a91 |
extern int must_be_container(int fd);
|
|
|
dd3a91 |
extern int dev_size_from_id(dev_t id, unsigned long long *size);
|
|
|
dd3a91 |
+extern int dev_sector_size_from_id(dev_t id, unsigned int *size);
|
|
|
dd3a91 |
void wait_for(char *dev, int fd);
|
|
|
dd3a91 |
|
|
|
dd3a91 |
/*
|
|
|
dd3a91 |
diff --git a/super-intel.c b/super-intel.c
|
|
|
dd3a91 |
index be973f8..ba6f810 100644
|
|
|
dd3a91 |
--- a/super-intel.c
|
|
|
dd3a91 |
+++ b/super-intel.c
|
|
|
dd3a91 |
@@ -1396,6 +1396,7 @@ int get_spare_criteria_imsm(struct supertype *st, struct spare_criteria *c)
|
|
|
dd3a91 |
unsigned long long size = 0;
|
|
|
dd3a91 |
|
|
|
dd3a91 |
c->min_size = 0;
|
|
|
dd3a91 |
+ c->sector_size = 0;
|
|
|
dd3a91 |
|
|
|
dd3a91 |
if (!super)
|
|
|
dd3a91 |
return -EINVAL;
|
|
|
dd3a91 |
@@ -1419,6 +1420,7 @@ int get_spare_criteria_imsm(struct supertype *st, struct spare_criteria *c)
|
|
|
dd3a91 |
size += imsm_min_reserved_sectors(super);
|
|
|
dd3a91 |
|
|
|
dd3a91 |
c->min_size = size * 512;
|
|
|
dd3a91 |
+ c->sector_size = super->sector_size;
|
|
|
dd3a91 |
|
|
|
dd3a91 |
return 0;
|
|
|
dd3a91 |
}
|
|
|
dd3a91 |
diff --git a/util.c b/util.c
|
|
|
dd3a91 |
index 8b3c67d..fc9cd3f 100644
|
|
|
dd3a91 |
--- a/util.c
|
|
|
dd3a91 |
+++ b/util.c
|
|
|
dd3a91 |
@@ -1265,6 +1265,23 @@ int dev_size_from_id(dev_t id, unsigned long long *size)
|
|
|
dd3a91 |
return 0;
|
|
|
dd3a91 |
}
|
|
|
dd3a91 |
|
|
|
dd3a91 |
+int dev_sector_size_from_id(dev_t id, unsigned int *size)
|
|
|
dd3a91 |
+{
|
|
|
dd3a91 |
+ char buf[20];
|
|
|
dd3a91 |
+ int fd;
|
|
|
dd3a91 |
+
|
|
|
dd3a91 |
+ sprintf(buf, "%d:%d", major(id), minor(id));
|
|
|
dd3a91 |
+ fd = dev_open(buf, O_RDONLY);
|
|
|
dd3a91 |
+ if (fd < 0)
|
|
|
dd3a91 |
+ return 0;
|
|
|
dd3a91 |
+ if (get_dev_sector_size(fd, NULL, size)) {
|
|
|
dd3a91 |
+ close(fd);
|
|
|
dd3a91 |
+ return 1;
|
|
|
dd3a91 |
+ }
|
|
|
dd3a91 |
+ close(fd);
|
|
|
dd3a91 |
+ return 0;
|
|
|
dd3a91 |
+}
|
|
|
dd3a91 |
+
|
|
|
dd3a91 |
struct supertype *dup_super(struct supertype *orig)
|
|
|
dd3a91 |
{
|
|
|
dd3a91 |
struct supertype *st;
|
|
|
dd3a91 |
@@ -2129,12 +2146,24 @@ struct mdinfo *container_choose_spares(struct supertype *st,
|
|
|
dd3a91 |
if (d->disk.state == 0) {
|
|
|
dd3a91 |
/* check if size is acceptable */
|
|
|
dd3a91 |
unsigned long long dev_size;
|
|
|
dd3a91 |
+ unsigned int dev_sector_size;
|
|
|
dd3a91 |
+ int size_valid = 0;
|
|
|
dd3a91 |
+ int sector_size_valid = 0;
|
|
|
dd3a91 |
+
|
|
|
dd3a91 |
dev_t dev = makedev(d->disk.major,d->disk.minor);
|
|
|
dd3a91 |
|
|
|
dd3a91 |
if (!criteria->min_size ||
|
|
|
dd3a91 |
(dev_size_from_id(dev, &dev_size) &&
|
|
|
dd3a91 |
dev_size >= criteria->min_size))
|
|
|
dd3a91 |
- found = 1;
|
|
|
dd3a91 |
+ size_valid = 1;
|
|
|
dd3a91 |
+
|
|
|
dd3a91 |
+ if (!criteria->sector_size ||
|
|
|
dd3a91 |
+ (dev_sector_size_from_id(dev, &dev_sector_size) &&
|
|
|
dd3a91 |
+ criteria->sector_size == dev_sector_size))
|
|
|
dd3a91 |
+ sector_size_valid = 1;
|
|
|
dd3a91 |
+
|
|
|
dd3a91 |
+ found = size_valid && sector_size_valid;
|
|
|
dd3a91 |
+
|
|
|
dd3a91 |
/* check if domain matches */
|
|
|
dd3a91 |
if (found && domlist) {
|
|
|
dd3a91 |
struct dev_policy *pol = devid_policy(dev);
|