Ignore:
Timestamp:
Apr 4, 2012, 2:27:02 PM (12 years ago)
Author:
Bruno Cornec
Message:

r4626@localhost: bruno | 2012-03-30 16:24:25 +0200

  • Handle the md version as an additional param in raidtab per device to solve various bug reports, including the previous one mentioned today. Doesn't still fully work, as not generating correctly the -e option, whereas the raidrec structure is correct
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/mondorestore/mondo-prep.c

    r2988 r2989  
    565565  char *tmp = NULL;
    566566  char *tmp1 = NULL;
    567   char *oldmd = NULL;
    568   char *name;
    569   char *ver;
    570 
    571   malloc_string(name);
    572   malloc_string(ver);
    573  
     567
    574568  // leave straight away if raidlist is initial or has no entries
    575569  if (!raidlist || raidlist->entries == 0) {
     
    620614  // - faulty devices ignored
    621615  // - persistent superblock always used as this is recommended
    622   // As per bug #473, the parameter "-e 0.90" is used only when:
    623   //   1) It detects that system boots from Raid-1
    624   //   2) grub bootloader < v1 is used.
    625   // Otherwise it won't boot which is bad.
    626     if (read_cfg_var(g_mondo_cfg_file, "bootloader.name", name) != 0) {
    627             log_msg(2, "Unable to find bootloader.name param in %s conf file\n", g_mondo_cfg_file);
    628         strcpy(name,"NONE");
    629     }
    630     if (read_cfg_var(g_mondo_cfg_file, "bootloader.ver", ver) != 0) {
    631             log_msg(2, "No bootloader.ver param in %s conf file\n", g_mondo_cfg_file);
    632         strcpy(ver,"NONE");
    633     }
    634     if (strcmp(name,"GRUB") == 0) {
    635         if ((strstr(ver, "GRUB 0.9") != NULL) && (strcmp(raidlist->el[i].raid_device,device) == 0)) {
    636             mr_asprintf(&oldmd, "-e 0.90");
    637             log_it("Forcing old metadata (%s) for md on %s for old GRUB", oldmd, device);
    638         } else {
    639             mr_asprintf(&oldmd, "");
    640         }
    641     } else if ((strcmp(name,"LILO") == 0) && (strcmp(raidlist->el[i].raid_device,device) == 0)) {
    642         mr_asprintf(&oldmd, "-e 0.90");
    643         log_it("Forcing old metadata (%s) for md on %s for LILO", oldmd, device);
    644     } else {
    645         mr_asprintf(&oldmd, "");
    646     }
    647     mr_free(name);
    648     mr_free(ver);
    649         log_msg(4, "RAID oldmd: %s", oldmd);
    650 
    651   mr_asprintf(&program, "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d %s", raidlist->el[i].raid_device, level, raidlist->el[i].data_disks.entries, oldmd);
    652   mr_free(oldmd);
     616
     617  mr_asprintf(&program, "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", raidlist->el[i].raid_device, level, raidlist->el[i].data_disks.entries);
    653618  mr_free(level);
    654619        log_msg(4, "cmd built: %s", program);
    655   // Restoring the UUID stored at backup time of present
    656   for (v = 0; v <= raidlist->el[i].additional_vars.entries ; v++ ) {
     620  // Restoring the UUID and Version stored at backup time of present
     621  for (v = 0; v < raidlist->el[i].additional_vars.entries ; v++ ) {
     622      log_msg(4,"Working on additional param #%d (Label: %s)",v,raidlist->el[i].additional_vars.el[v].label);
    657623    if ((raidlist->el[i].additional_vars.el[v].label != NULL) && (strcmp(raidlist->el[i].additional_vars.el[v].label,"UUID") == 0)) {
    658624        // We have a UUID to handle
     
    663629            break;
    664630        } else {
    665             log_it("Unable to manage previous NULL UUID");
     631            log_msg(1,"Unable to manage previous NULL UUID");
     632        }
     633    }
     634    if ((raidlist->el[i].additional_vars.el[v].label != NULL) && (strcmp(raidlist->el[i].additional_vars.el[v].label,"Version") == 0)) {
     635        // We have a Version to handle
     636        if (raidlist->el[i].additional_vars.el[v].value != NULL) {
     637            // force its restoration in order to support all complex boot loader + md format cases
     638            // Also see bug #473
     639            log_it("Managing previous Version %s", raidlist->el[i].additional_vars.el[v].value);
     640            mr_strcat(program, " -e %s",raidlist->el[i].additional_vars.el[v].value);
     641            break;
     642        } else {
     643            log_msg(1,"Unable to manage previous NULL Version");
    666644        }
    667645    }
Note: See TracChangeset for help on using the changeset viewer.