diff options
author | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2021-05-17 16:39:03 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2021-05-26 13:26:34 +0200 |
commit | 1f5d54a06df01ca3032ca2d29159584cab7d7509 (patch) | |
tree | 9c08f26bce615f9fedfc4becf9e14394756afe67 | |
parent | imsm: Limit support to the lowest namespace (diff) | |
download | mdadm-1f5d54a06df01ca3032ca2d29159584cab7d7509.tar.xz mdadm-1f5d54a06df01ca3032ca2d29159584cab7d7509.zip |
Manage: Call validate_geometry when adding drive to external container
When adding drive to container call validate_geometry to verify whether
drive is supported and can be addded to container.
Remove unused parameters from validate_geometry_imsm_container().
There is no need to pass them.
Don't calculate freesize if it is not mandatory. Make it configurable.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
-rw-r--r-- | Manage.c | 7 | ||||
-rw-r--r-- | super-ddf.c | 9 | ||||
-rw-r--r-- | super-intel.c | 19 |
3 files changed, 19 insertions, 16 deletions
@@ -992,6 +992,13 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv, return -1; } + /* Check if metadata handler is able to accept the drive */ + if (!tst->ss->validate_geometry(tst, LEVEL_CONTAINER, 0, 1, NULL, + 0, 0, dv->devname, NULL, 0, 1)) { + close(container_fd); + return -1; + } + Kill(dv->devname, NULL, 0, -1, 0); dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT); if (tst->ss->add_to_super(tst, &disc, dfd, diff --git a/super-ddf.c b/super-ddf.c index 23147620..80a40f84 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -3475,10 +3475,11 @@ validate_geometry_ddf_container(struct supertype *st, return 0; } close(fd); - - *freesize = avail_size_ddf(st, ldsize >> 9, INVALID_SECTORS); - if (*freesize == 0) - return 0; + if (freesize) { + *freesize = avail_size_ddf(st, ldsize >> 9, INVALID_SECTORS); + if (*freesize == 0) + return 0; + } return 1; } diff --git a/super-intel.c b/super-intel.c index fdcefb61..fe45d933 100644 --- a/super-intel.c +++ b/super-intel.c @@ -6652,8 +6652,7 @@ static int store_super_imsm(struct supertype *st, int fd) } static int validate_geometry_imsm_container(struct supertype *st, int level, - int layout, int raiddisks, int chunk, - unsigned long long size, + int raiddisks, unsigned long long data_offset, char *dev, unsigned long long *freesize, @@ -6725,8 +6724,8 @@ static int validate_geometry_imsm_container(struct supertype *st, int level, } } } - - *freesize = avail_size_imsm(st, ldsize >> 9, data_offset); + if (freesize) + *freesize = avail_size_imsm(st, ldsize >> 9, data_offset); rv = 1; exit: if (super) @@ -7586,15 +7585,11 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, * if given unused devices create a container * if given given devices in a container create a member volume */ - if (level == LEVEL_CONTAINER) { + if (level == LEVEL_CONTAINER) /* Must be a fresh device to add to a container */ - return validate_geometry_imsm_container(st, level, layout, - raiddisks, - *chunk, - size, data_offset, - dev, freesize, - verbose); - } + return validate_geometry_imsm_container(st, level, raiddisks, + data_offset, dev, + freesize, verbose); /* * Size is given in sectors. |