[PATCH 09/13] Manage: check device policies in manage_add_external()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Only IMSM is going to use device policies so it is added to
manage_add_external(). Test policies before adding the drive to
container.

The change blocks adding new device to the container which already
contains not matching devices

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@xxxxxxxxxxxxxxx>
---
 Manage.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Manage.c b/Manage.c
index 969d0ea9d81f..96e5ee5427a2 100644
--- a/Manage.c
+++ b/Manage.c
@@ -704,6 +704,7 @@ mdadm_status_t manage_add_external(struct supertype *st, int fd, char *disk_name
 {
 	mdadm_status_t rv = MDADM_STATUS_ERROR;
 	char container_devpath[MD_NAME_MAX];
+	struct dev_policy *pols = NULL;
 	struct mdinfo new_mdi;
 	struct mdinfo *sra = NULL;
 	int container_fd;
@@ -722,6 +723,9 @@ mdadm_status_t manage_add_external(struct supertype *st, int fd, char *disk_name
 				       0, 1))
 		goto out;
 
+	if (mddev_test_and_add_drive_policies(st, &pols, container_fd, 1))
+		goto out;
+
 	Kill(disk_name, NULL, 0, -1, 0);
 
 	disk_fd = dev_open(disk_name, O_RDWR | O_EXCL | O_DIRECT);
@@ -730,6 +734,9 @@ mdadm_status_t manage_add_external(struct supertype *st, int fd, char *disk_name
 		goto out;
 	}
 
+	if (drive_test_and_add_policies(st, &pols, disk_fd, 1))
+		goto out;
+
 	if (st->ss->add_to_super(st, disc, disk_fd, disk_name, INVALID_SECTORS))
 		goto out;
 
@@ -760,6 +767,7 @@ mdadm_status_t manage_add_external(struct supertype *st, int fd, char *disk_name
 
 out:
 	close(container_fd);
+	dev_policy_free(pols);
 
 	if (sra)
 		sysfs_free(sra);
-- 
2.35.3





[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux