Skip to content

Commit d981ed8

Browse files
XiaoNi87liu-song-6
authored andcommitted
md: Add new_level sysfs interface
Now reshape supports two ways: with backup file or without backup file. For the situation without backup file, it needs to change data offset. It doesn't need systemd service mdadm-grow-continue. So it can finish the reshape job in one process environment. It can know the new level from mdadm --grow command and can change to new level after reshape finishes. For the situation with backup file, it needs systemd service mdadm-grow-continue to monitor reshape progress. So there are two process envolved. One is mdadm --grow command whick kicks off reshape and wakes up mdadm-grow-continue service. The second process is the service, which doesn't know the new level from the first process. In kernel space mddev->new_level is used to record the new level when doing reshape. This patch adds a new interface to help mdadm update new_level and sync it to metadata. Then mdadm-grow-continue can read the right new_level. Commit log revised by Song Liu. Please refer to the link for more details. Signed-off-by: Xiao Ni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Song Liu <[email protected]>
1 parent 2d2b3bc commit d981ed8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/md/md.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4052,6 +4052,34 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
40524052
static struct md_sysfs_entry md_level =
40534053
__ATTR(level, S_IRUGO|S_IWUSR, level_show, level_store);
40544054

4055+
static ssize_t
4056+
new_level_show(struct mddev *mddev, char *page)
4057+
{
4058+
return sprintf(page, "%d\n", mddev->new_level);
4059+
}
4060+
4061+
static ssize_t
4062+
new_level_store(struct mddev *mddev, const char *buf, size_t len)
4063+
{
4064+
unsigned int n;
4065+
int err;
4066+
4067+
err = kstrtouint(buf, 10, &n);
4068+
if (err < 0)
4069+
return err;
4070+
err = mddev_lock(mddev);
4071+
if (err)
4072+
return err;
4073+
4074+
mddev->new_level = n;
4075+
md_update_sb(mddev, 1);
4076+
4077+
mddev_unlock(mddev);
4078+
return len;
4079+
}
4080+
static struct md_sysfs_entry md_new_level =
4081+
__ATTR(new_level, 0664, new_level_show, new_level_store);
4082+
40554083
static ssize_t
40564084
layout_show(struct mddev *mddev, char *page)
40574085
{
@@ -5583,6 +5611,7 @@ __ATTR(serialize_policy, S_IRUGO | S_IWUSR, serialize_policy_show,
55835611

55845612
static struct attribute *md_default_attrs[] = {
55855613
&md_level.attr,
5614+
&md_new_level.attr,
55865615
&md_layout.attr,
55875616
&md_raid_disks.attr,
55885617
&md_uuid.attr,

0 commit comments

Comments
 (0)