mdadm/0029-Manage-check-device-policies-in-manage_add_external.patch
Xiao Ni fbe794e269 Update to latest upstream
Update to 4.3 and backport other patches behind 4.3

Resolves: RHEL-30530

Signed-off-by: Xiao Ni <xni@redhat.com>
2024-03-29 17:30:23 +08:00

61 lines
1.8 KiB
Diff

From 1251db34616bf4890d86664abc5186e9106e9073 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Thu, 29 Feb 2024 12:52:13 +0100
Subject: [PATCH 29/41] Manage: check device policies in manage_add_external()
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@linux.intel.com>
---
Manage.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Manage.c b/Manage.c
index 969d0ea9..96e5ee54 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.40.1