summaryrefslogtreecommitdiffstats
path: root/sysfs.c
diff options
context:
space:
mode:
authorMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-11-05 13:07:16 +0100
committerMariusz Tkaczyk <mtkaczyk@kernel.org>2024-12-16 10:11:31 +0100
commitb9888145987e273a7613209721a68f75e060263e (patch)
treea62bdc1eb8137506a52ed257e1372bf99ea6727b /sysfs.c
parentsysfs: functions for writing md/<memb>/state (diff)
downloadmdadm-b9888145987e273a7613209721a68f75e060263e.tar.xz
mdadm-b9888145987e273a7613209721a68f75e060263e.zip
Incremental: Simplify remove logic
Incremental_remove() does not execute Manage_subdevs() now. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Diffstat (limited to 'sysfs.c')
-rw-r--r--sysfs.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sysfs.c b/sysfs.c
index 60b27459..c030d634 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -150,6 +150,29 @@ mdadm_status_t sysfs_set_memb_state_fd(int fd, memb_state_t state, int *err)
}
/**
+ * sysfs_set_memb_state() - write to member disk state file.
+ * @array_devnm: kernel name of the array.
+ * @memb_devnm: kernel name of member device.
+ * @state: value to write.
+ *
+ * Function expects that the device exists, error is unconditionally printed.
+ */
+mdadm_status_t sysfs_set_memb_state(char *array_devnm, char *memb_devnm, memb_state_t state)
+{
+ int state_fd = sysfs_open_memb_attr(array_devnm, memb_devnm, "state", O_RDWR);
+
+ if (!is_fd_valid(state_fd)) {
+ pr_err("Cannot open file descriptor to %s in array %s, aborting.\n",
+ memb_devnm, array_devnm);
+ return MDADM_STATUS_ERROR;
+ }
+
+ return sysfs_set_memb_state_fd(state_fd, state, NULL);
+
+ close_fd(&state_fd);
+}
+
+/**
* sysfs_get_container_devnm() - extract container device name.
* @mdi: md_info describes member array, with GET_VERSION option.
* @buf: buf to fill, must be MD_NAME_MAX.