Dear md/dm developers,
As I already pointed out on the ataraid-list, I have made a small patch for dmraid, so it will use the dm-raid target in state of the dm-raid45 target to handle raid4 and riad5 setups. This patch is added to this e-mail. To put it in context I use dmraid to detect my fakeraid, which is shared with a Windows OS. There were some things I could not figure out and would like to ask three questions regarding the arguments passed to the module. - First a more general question does it look okay to you what I have implemented? - Second what to do with the offset variable that is given by the metadata on the disk? On the other dmraid related modules the disk information is passed like [dev][offset]. With the dm-raid module it changed to [meta-dev][data-dev]. In the patch I ignore the meta-dev and just pass "- path_to_dev" to the module. This will work as the offset given by the metadata on my disks are equal to zero, the same value that is automatically set by the module. What does one have to do if the metadata on the disk says that the offset is not equal to zero? - Last I would like to build up the argument string more generally. Like concatenate the argument strings depending on some if statements, like if(need_sync) num_arg += 2; arguments = arguments + sprintf("rebuild %d", rebuild_drive.data.i32); fi And then pass the final string using p_fmt(lc, table, "0 %U %s %s %u %s", sectors, dm_type, raid_type, num_arg, arguments). This will make the code easier to read and quicker to hack/change/code. Thanks, Mark-Willem Jansen P.S.: The patch is a modified version of the one I send to the ataraid-list some weeks ago. |
From 56b9dfc173c998d26a60f8263a1bce24cd858ae6 Mon Sep 17 00:00:00 2001 From: Mark-Willem Jansen <rawnar@xxxxxxxxxxxxxxxxxxxxx> Date: Sun, 15 Apr 2012 01:03:46 +0200 Subject: [PATCH] Changed from dm-raid45 to dm-raid for handling RAID4/5 --- 1.0.0.rc16/lib/activate/activate.c | 42 +++++++++++++++++++++++++++--------- 1.0.0.rc16/lib/metadata/metadata.c | 10 ++++----- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/1.0.0.rc16/lib/activate/activate.c b/1.0.0.rc16/lib/activate/activate.c index 05bd610..6b331c2 100644 --- a/1.0.0.rc16/lib/activate/activate.c +++ b/1.0.0.rc16/lib/activate/activate.c @@ -118,6 +118,15 @@ _dm_path_offset(struct lib_context *lc, char **table, valid ? path : lc->path.error, offset); } +/* Push meta path and data path onto a table. */ +static int +_dm_meta_data_path(struct lib_context *lc, char **table, + int valid, const char *path) +{ + return p_fmt(lc, table, " - %s", + valid ? path : lc->path.error); +} + /* * Create dm table for linear mapping. */ @@ -542,19 +551,32 @@ _dm_raid45_bol(struct lib_context *lc, char **table, struct raid_set *rs, { int need_sync = rs_need_sync(rs); struct handler_info rebuild_drive; + unsigned int num_raid_params; + char *raid_params; /* Get drive as rebuild target. */ rebuild_drive.data.i32 = -1; if (need_sync && !get_rebuild_drive(lc, rs, &rebuild_drive)) return 0; - return p_fmt(lc, table, "0 %U %s core 2 %u %s %s 1 %u %u %d", - sectors, get_dm_type(lc, rs->type), - calc_region_size(lc, - total_sectors(lc, rs) / - _dm_raid_devs(lc, rs, 0)), - (need_sync) ? "sync" : "nosync", get_type(lc, rs->type), - rs->stride, members, rebuild_drive.data.i32); + if (!need_sync) { + return p_fmt(lc, table, "0 %U %s %s 4 %u nosync region_size %u %u", + sectors, + get_dm_type(lc, rs->type), get_type(lc, rs->type), + rs->stride, + calc_region_size(lc, + total_sectors(lc, rs) / _dm_raid_devs(lc, rs, 0)), + members); + } else { + return p_fmt(lc, table, "0 %U %s %s 6 %u sync rebuild %u region_size %u %u", + sectors, + get_dm_type(lc, rs->type), get_type(lc, rs->type), + rs->stride, + rebuild_drive.data.i32, + calc_region_size(lc, + total_sectors(lc, rs) / _dm_raid_devs(lc, rs, 0)), + members); + } } /* Create "error target" name based on raid set name. */ @@ -759,7 +781,7 @@ dm_raid45(struct lib_context *lc, char **table, struct raid_set *rs) if (!(path = mkdm_path(lc, r->name))) goto err; - ret = _dm_path_offset(lc, table, valid_rs(r), path, 0); + ret = _dm_meta_data_path(lc, table, valid_rs(r), path); dbg_free(path); if (!ret) @@ -768,8 +790,8 @@ dm_raid45(struct lib_context *lc, char **table, struct raid_set *rs) /* Lowest level RAID devices. */ list_for_each_entry(rd, &rs->devs, devs) { - if (!_dm_path_offset(lc, table, valid_rd(rd), - rd->di->path, rd->offset)) + if (!_dm_meta_data_path(lc, table, valid_rd(rd), + rd->di->path)) goto err; } diff --git a/1.0.0.rc16/lib/metadata/metadata.c b/1.0.0.rc16/lib/metadata/metadata.c index e8780ed..1e55ed0 100644 --- a/1.0.0.rc16/lib/metadata/metadata.c +++ b/1.0.0.rc16/lib/metadata/metadata.c @@ -31,11 +31,11 @@ static const struct { { t_linear, "linear", "linear"}, { t_raid0, "stripe", "striped"}, { t_raid1, "mirror", "mirror"}, - { t_raid4, "raid4", "raid45"}, - { t_raid5_ls, "raid5_ls", "raid45"}, - { t_raid5_rs, "raid5_rs", "raid45"}, - { t_raid5_la, "raid5_la", "raid45"}, - { t_raid5_ra, "raid5_ra", "raid45"}, + { t_raid4, "raid4", "raid"}, + { t_raid5_ls, "raid5_ls", "raid"}, + { t_raid5_rs, "raid5_rs", "raid"}, + { t_raid5_la, "raid5_la", "raid"}, + { t_raid5_ra, "raid5_ra", "raid"}, { t_raid6, "raid6", NULL}, }; -- 1.7.9.5
-- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel