Skip to content

md: add a control device for array management

Abd-Alrhman Masalkhi dm-devel linux-raid lkml sashiko-reviews 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2md: make mddev lookup and ioctl helpers non-staticdrivers/md/md.c drivers/md/md.h+10 -50 replies
2/2md: add a control device for array managementdrivers/md/Makefile drivers/md/md-ctl.c drivers/md/md.c +3 more+748 -73 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] md: add a control device for array management

All md management ioctls (SET_ARRAY_INFO, ADD_NEW_DISK, RUN_ARRAY, STOP_ARRAY, ...) are issued on the md block device itself, so the caller must hold the array open while it configures or stops it.

This is a problem for STOP_ARRAY and STOP_ARRAY_RO. Before the array is stopped, the page cache must be flushed, and no other task may have the device open or be writing to it. The issue arises when several tasks share the same file descriptor table, as they count as a single opener. Consequently, one task may still be writing while another task flushes the page cache and stops the array. A write within this window can race with the stop operation.

Add a misc character device, /dev/md-control, with a fixed minor MD_CTRL_MINOR. The control device is not tied to any md device, each request specifies the array in the payload, either by name, by UUID or by device number, without the need to open the md block device.

The new ioctls use the existing MD_MAJOR ioctl type, starting at 0x40, with an MD_ prefix. Every request structure has a flags field. Unknown flags are rejected with -EINVAL.

Each new command matches an existing block device ioctl with only one exception. The STOP_ARRAY_RO has no separate command, it is handled via MD_STOP_ARRAY with the MD_RO_FLAG set.

New 64-bit structures, including mdu_ioctl, are introduced (mdu_array_info64, mdu_disk_info64, mdu_param64, mdu_bitmap_file64, and mdu_version64) to resolve padding and overflow issues in fields such as size, ctime, and utime.

The existing ioctl on the md block device is unchanged, but a warning message will be printed to recommend upgrading mdadm.

The mdadm tool has been updated accordingly, and the mdadm patches will be posted to the linux-raid mailing list shortly.

Abd-Alrhman Masalkhi (2):
md: make mddev lookup and ioctl helpers non-static
md: add a control device for array management

 drivers/md/Makefile            |   2 +-
 drivers/md/md-ctl.c            | 597 +++++++++++++++++++++++++++++++++
 drivers/md/md.c                |  41 ++-
 drivers/md/md.h                |  10 +
 include/linux/miscdevice.h     |   1 +
 include/uapi/linux/raid/md_u.h | 119 +++++++
 6 files changed, 758 insertions(+), 12 deletions(-)
 create mode 100644 drivers/md/md-ctl.c
Signature · 1 line
2.43.0