DM RAID: Add message/status support for changing sync action
Subsystems (3)
PATCH 1/1 DM RAID: Add message/status support for changing sync action
DM RAID: Add message/status support for changing sync action
This patch adds a message interface to dm-raid to allow the user to more finely control the sync actions being performed by the MD driver. This gives the user the ability to initiate "check" and "repair" (i.e. scrubbing). Two additional fields have been added to the status output to provide more information about the type of sync action occurring and the results of those actions, specifically: <sync_action> and <mismatch_cnt>. This is essentially the device-mapper way of doing what MD controls through the 'sync_action' sysfs file and shows through the 'mismatch_cnt' sysfs file.
This is a first patch and I still have two concerns:
1) in 'raid_messages', reap_sync_thread() is not called when "frozen" or "idle" is issued like it would be in md.c:action_store() because it is not available to dm-raid.c. This hasn't prevented the thread from shutting down properly in my tests, but there may be something I'm not considering.
2) (and this is more of an LVM problem) The "in-sync ratio" field of the status output has generally been used to determine the progress of the initial synchronization or of rebuilding a device. "check" and "repair" have not been available options until now. So, if this ratio also shows the progress of a "check", older versions of LVM would seem to indicate (through the 'sync%' field) that the array is not in-sync, when in fact it is. Thus, this change might be perceived as a break to backwards compatability. (However, the old LVM tools would not be able to /issue/ a "check" command and should never run into this.) I don't see this as a problem for this patch, but I thought it should be
brought up and considered. Obviously, code in LVM will need to be
changed to adjust to this - perhaps to show the different types of sync actions that might be occurring.
drivers/md/dm-raid.c +115 -2
@@ -1287,6 +1287,7 @@ static int raid_status(struct dm_targetunsigned sz =0 ;int i, array_in_sync =0 ;sector_t sync; +char *sync_action_type ="idle" ;switch (type) {case STATUSTYPE_INFO :
@@ -1298,8 +1299,28 @@ static int raid_status(struct dm_target sync = rs->md.recovery_cp;if (sync >= rs->md.resync_max_sectors) { +/* +* Sync complete. +*/ array_in_sync =1 ; sync = rs->md.resync_max_sectors; + }else if (test_bit (MD_RECOVERY_CHECK , &rs->md.recovery)) { +/* +* If "check" is occurring, the array has undergone +* and initial sync and the health characters should +* not be 'a' anymore. +*/ + array_in_sync =1 ; + +/* +* FIXME: We could set this if we /don't/ want to +* display the pace of a 'check'. Right now, +* the 'sync_action' field and the ratio field +* work together to show what is being done. +* THIS MIGHT BE PERCEIVED AS BREAKING +* BACKWARDS COMPATIBILITY. +*/ +// sync = rs->md.resync_max_sectors; }else {/* * The array may be doing an initial sync, or it may
@@ -1311,6 +1332,7 @@ static int raid_status(struct dm_targetif (!test_bit (In_sync, &rs->dev[i].rdev.flags)) array_in_sync =1 ; } +/* * Status characters: * 'D' = Dead/Failed device
@@ -1339,6 +1361,41 @@ static int raid_status(struct dm_target (unsigned long long ) sync, (unsigned long long) rs->md.resync_max_sectors); +/* +* Sync action: +* See Documentation/device-mapper/dm-raid.c for +* information on each of these states. +*/ +if (test_bit (MD_RECOVERY_FROZEN , &rs->md.recovery)) + sync_action_type ="frozen" ; +else if (test_bit (MD_RECOVERY_RUNNING , &rs->md.recovery) || + (!rs->md.ro &&test_bit (MD_RECOVERY_NEEDED , + &rs->md.recovery))) { +if (test_bit (MD_RECOVERY_RESHAPE , &rs->md.recovery)) + sync_action_type ="reshape" ; +else if (test_bit (MD_RECOVERY_SYNC , &rs->md.recovery)) { +if (!test_bit (MD_RECOVERY_REQUESTED , + &rs->md.recovery)) + sync_action_type ="resync" ; +else if (test_bit (MD_RECOVERY_CHECK , + &rs->md.recovery)) + sync_action_type ="check" ; +else + sync_action_type ="repair" ; + }else if (test_bit (MD_RECOVERY_RECOVER , + &rs->md.recovery)) + sync_action_type ="recover" ; + } +DMEMIT (" %s" , sync_action_type); + +/* +* resync_mismatches/mismatch_cnt +* This field shows the number of discrepancies found when +* performing a "check" of the array. +*/ +DMEMIT (" %llu" , + (unsigned long long ) +atomic64_read (&rs->md.resync_mismatches));break ;case STATUSTYPE_TABLE :/* The string you would use to construct this array */
@@ -1427,7 +1484,62 @@ static int raid_status(struct dm_targetreturn 0 ; } -static int raid_iterate_devices (struct dm_target *ti,iterate_devices_callout_fn fn,void *data) +static int raid_message (struct dm_target *ti,unsigned argc,char **argv) +{ +struct raid_set *rs = ti->private; +struct mddev *mddev = &rs->md; + +if (!strcasecmp (argv[0 ],"reshape" )) { +DMERR ("Reshape not supported." ); +return -EINVAL ; + } + +if (!mddev->pers || !mddev->pers->sync_request) +return -EINVAL ; + +if (!strcasecmp (argv[0 ],"frozen" )) +set_bit (MD_RECOVERY_FROZEN , &mddev->recovery); +else +clear_bit (MD_RECOVERY_FROZEN , &mddev->recovery); + +if (!strcasecmp (argv[0 ],"idle" ) || !strcasecmp (argv[0 ],"frozen" )) { +if (mddev->sync_thread) { +set_bit (MD_RECOVERY_INTR , &mddev->recovery); +/* FIXME: add reap_sync_thread(mddev); ? */ + } + }else if (test_bit (MD_RECOVERY_RUNNING , &mddev->recovery) || +test_bit (MD_RECOVERY_NEEDED , &mddev->recovery)) +return -EBUSY ; +else if (!strcasecmp (argv[0 ],"resync" )) +set_bit (MD_RECOVERY_NEEDED , &mddev->recovery); +else if (!strcasecmp (argv[0 ],"recover" )) { +set_bit (MD_RECOVERY_RECOVER , &mddev->recovery); +set_bit (MD_RECOVERY_NEEDED , &mddev->recovery); + }else { +if (!strcasecmp (argv[0 ],"check" )) +set_bit (MD_RECOVERY_CHECK , &mddev->recovery); +else if (!!strcasecmp (argv[0 ],"repair" )) +return -EINVAL ; +set_bit (MD_RECOVERY_REQUESTED , &mddev->recovery); +set_bit (MD_RECOVERY_SYNC , &mddev->recovery); + } +if (mddev->ro ==2 ) { +/* A write to sync_action is enough to justify +* canceling read-auto mode +*/ + mddev->ro =0 ; +if (!mddev->suspended) +md_wakeup_thread (mddev->sync_thread); + } +set_bit (MD_RECOVERY_NEEDED , &mddev->recovery); +if (!mddev->suspended) +md_wakeup_thread (mddev->thread); + +return 0 ; +} + +static int raid_iterate_devices (struct dm_target *ti, +iterate_devices_callout_fn fn,void *data) {struct raid_set *rs = ti->private;unsigned i;
@@ -1484,12 +1596,13 @@ static void raid_resume(struct dm_targetstatic struct target_type raid_target = { .name ="raid" , - .version = {1 ,4 ,1 }, + .version = {1 ,4 ,2 }, .module =THIS_MODULE , .ctr = raid_ctr, .dtr = raid_dtr, .map = raid_map, .status = raid_status, + .message = raid_message, .iterate_devices = raid_iterate_devices, .io_hints = raid_io_hints, .presuspend = raid_presuspend,
Documentation/device-mapper/dm-raid.txt +64 -16
126 lines not on this page · raw message
Quoted 11 lines · On Fri, 15 Mar 2013 15:48:23 -0500 Jonathan Brassow <[email protected]> wrote:
DM RAID: Add message/status support for changing sync action
This patch adds a message interface to dm-raid to allow the user to more finely control the sync actions being performed by the MD driver. This gives the user the ability to initiate "check" and "repair" (i.e. scrubbing). Two additional fields have been added to the status output to provide more information about the type of sync action occurring and the results of those actions, specifically: <
sync_action> and <mismatch_cnt>. This is essentially the device-mapper way of doing what MD controls through the 'sync_action' sysfs file and shows through the 'mismatch_cnt' sysfs file.
Quoted 6 lines
This is a first patch and I still have two concerns:
1) in 'raid_messages',reap_sync_thread()is not called when "frozen" or "idle" is issued like it would be in md.c:action_store() because it is not available todm-raid.c. This hasn't prevented the thread from shutting down properly in my tests, but there may be something I'm not considering.
I think the only real need for the reap_sync_thread() call is to make the change synchronous. i.e. after "echo frozen > sync_action" completes, you know that the array actually is frozen, rather that it should be frozen very soon. This can be important for code which wants to set 'frozen', then manipulate the array in a way that would be prevented if it was still undergoing a resync/recovery/check/etc.
I'm don't know how much I actually depend on that property, but it sounds like a good one to have.
I would probably be OK to export reap_sync_thread() so that dm-raid can use it.
Quoted 5 lines
2) (and this is more of an LVM problem) The "in-sync ratio" field of the status output has generally been used to determine the progress of the initial synchronization or of rebuilding a device. "check" and "repair" have not been available options until now. So, if this ratio also shows the progress of a "check", older versions of LVM would seem to
Quoted 8 lines
indicate (through the 'sync%' field) that the array is not in-sync, when in fact it is. Thus, this change might be perceived as a break to backwards compatability. (However, the old LVM tools would not be able to /issue/ a "check" command and should never run into this.) I don't see this as a problem for this patch, but I thought it should be
brought up and considered. Obviously, code in LVM will need to be
changed to adjust to this - perhaps to show the different types of sync actions that might be occurring.
I see your point. I don't have any opinion on whether it is a real problem or just a theoretical one though.
In general, the patch looks good - particular as it includes documentation changes! When you get a very you are happy with I'll apply it.
Thanks,
NeilBrown
Quoted 7 lines · NeilBrown
In general, the patch looks good - particular as it includes documentation changes! When you get a very you are happy with I'll apply it.
Thanks,
NeilBrown
I'll be sending out a version 2, which is split into two patches and addresses the comments made.
brassow
Alasdair G Kergon
maintainerQuoted 1 line · Jon Brassow
DM RAID: Add message/status support for changing sync action
Quick points:
Quoted 1 line
Two additional fields
(which are *always* populated)
Quoted 1 line
have been added
appended
drivers/md/dm-raid.c static int raid_status(struct dm_target · line 1290
Quoted 7 lines
to the status output to provide more
information about the type of sync action occurring and the results of those actions, specifically: <sync_action> and <mismatch_cnt>. This is essentially the device-mapper way of doing what MD controls through the 'sync_action' sysfs file and shows through the 'mismatch_cnt' sysfs file.drivers/md/dm-raid.c +1
-0+char *sync_action_type ="idle" ;
(const?)
Quoted 15 lines
drivers/md/dm-raid.c +15
-0+/* +* Sync action: +* See Documentation/device-mapper/dm-raid.c for +* information on each of these states. +*/ +if (test_bit (MD_RECOVERY_FROZEN , &rs->md.recovery)) + sync_action_type ="frozen" ; +else if (test_bit (MD_RECOVERY_RUNNING , &rs->md.recovery) || + (!rs->md.ro &&test_bit (MD_RECOVERY_NEEDED , + &rs->md.recovery))) { +if (test_bit (MD_RECOVERY_RESHAPE , &rs->md.recovery)) + sync_action_type ="reshape" ; +else if (test_bit (MD_RECOVERY_SYNC , &rs->md.recovery)) { +if (!test_bit (MD_RECOVERY_REQUESTED , + &rs->md.recovery))
drivers/md/dm-raid.c static int raid_status(struct dm_target · line 1388
Quoted 10 lines
drivers/md/dm-raid.c +10
-0+ sync_action_type ="resync" ; + else if (test_bit(MD_RECOVERY_CHECK, + &rs->md.recovery)) + sync_action_type ="check" ; + else + sync_action_type ="repair" ; + }else if (test_bit (MD_RECOVERY_RECOVER , + &rs->md.recovery)) + sync_action_type ="recover" ; + }
Move this out into a fn that can simply return once it's selected the most appropriate string?
drivers/md/dm-raid.c static void raid_resume(struct dm_target · line 1599
Quoted 2 lines
drivers/md/dm-raid.c +1
-1- .version = {1, 4, 1}, + .version = {1, 4, 2},
1.5.0 - inc minor when the change affects interface or behaviour in a non-neglible way
Alasdair