Changeset 2989 in MondoRescue


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
Location:
branches/3.0/mondo/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/common/libmondo-raid.c

    r2982 r2989  
    598598{
    599599    FILE *fin;
    600     char *tmp;
    601600    char *label;
    602601    char *value;
     
    604603    int v;
    605604
    606     malloc_string(tmp);
    607     malloc_string(label);
    608     malloc_string(value);
    609605    assert(raidlist != NULL);
    610606    assert_string_is_neither_NULL_nor_zerolength(fname);
     
    613609        log_it("Raidtab is very small or non-existent. Ignoring it.");
    614610        raidlist->entries = 0;
    615         paranoid_free(tmp);
    616         paranoid_free(label);
    617         paranoid_free(value);
    618611        return (0);
    619612    }
    620613    if (!(fin = fopen(fname, "r"))) {
    621614        log_it("Cannot open raidtab");
    622         paranoid_free(tmp);
    623         paranoid_free(label);
    624         paranoid_free(value);
    625615        return (1);
    626616    }
     617    malloc_string(label);
     618    malloc_string(value);
    627619    items = 0;
    628620    log_it("Loading raidtab...");
     
    636628            strcpy(raidlist->el[items].additional_vars.el[v].label, label);
    637629            strcpy(raidlist->el[items].additional_vars.el[v].value, value);
     630            log_msg(2,"Found raidtab entry Label: %s Value: %s",raidlist->el[items].additional_vars.el[v].label,raidlist->el[items].additional_vars.el[v].value);
    638631            v++;
    639632            get_next_raidtab_line(fin, label, value);
    640             log_it(tmp);
    641633        }
    642634        raidlist->el[items].additional_vars.entries = v;
     
    658650    log_msg(1, "Raidtab loaded successfully.");
    659651    log_msg(1, "%d RAID devices in raidtab", items);
    660     paranoid_free(tmp);
    661652    paranoid_free(label);
    662653    paranoid_free(value);
     
    710701            raidrec->raid_level = atoi(value);
    711702        }
     703        log_msg(4,"Found raid level %d",raidrec->raid_level);
    712704    } else if (!strcmp(label, "nr-raid-disks")) {   /* ignore it */
    713705    } else if (!strcmp(label, "nr-spare-disks")) {  /* ignore it */
     
    730722            log_msg(1, "Unknown RAID parity algorithm '%s'\n.", value);
    731723        }
     724        log_msg(4,"Found raid parity %d",raidrec->parity);
    732725    } else if (!strcmp(label, "device")) {
    733726        get_next_raidtab_line(fin, labelB, valueB);
     
    755748        strcpy(raidrec->additional_vars.el[v].label, label);
    756749        strcpy(raidrec->additional_vars.el[v].value, value);
    757         raidrec->additional_vars.entries = ++v;
     750        log_msg(4,"Found additional raid pair #%d: %s / %s",v,raidrec->additional_vars.el[v].label,raidrec->additional_vars.el[v].value);
     751        v++;
     752        raidrec->additional_vars.entries = v;
    758753    }
    759754    paranoid_free(labelB);
     
    10421037            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "UUID");
    10431038            mr_asprintf(&cmd,"mdadm --detail %s | grep UUID | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
     1039            mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
     1040            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp);
     1041            mr_free(strtmp);
     1042            v++;
     1043            // store the Version value in the additional_vars structure
     1044            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "Version");
     1045            mr_asprintf(&cmd,"mdadm --detail %s | grep Version | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
    10441046            mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
    10451047            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp);
  • 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.