~ubuntu-branches/ubuntu/utopic/mdadm/utopic

« back to all changes in this revision

Viewing changes to Monitor.c

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2012-06-15 15:31:59 UTC
  • mfrom: (1.1.30 sid)
  • Revision ID: package-import@ubuntu.com-20120615153159-9lp7jykbq7vua4bo
Tags: 3.2.5-1ubuntu1
* Merge from Debian testing. (LP: #920324)  Remaining changes:
  - Call checks in local-premount to avoid race condition with udev
    and opening a degraded array.
  - d/initramfs/mdadm-functions: Record in /run when boot-degraded 
    question has been asked so that it is only asked once
  - pass --test to mdadm to enable result codes for degraded arrays. 
  - debian/control: we need udev and util-linux in the right version. We
    also remove the build dependency from quilt and docbook-to-man as both
    are not used in Ubuntus mdadm.
  - debian/initramfs/hook: kept the Ubuntus version for handling the absence
    of active raid arrays in <initramfs>/etc/mdadm/mdadm.conf
  - debian/initramfs/script.local-top.DEBIAN, debian/mdadm-startall,
    debian/mdadm.raid.DEBIAN: removed. udev does its job now instead.
  - debian/mdadm-startall.sgml, debian/mdadm-startall.8: documentation of
    unused startall script
  - debian/mdadm.config, debian/mdadm.postinst - let udev do the handling
    instead. Resolved merge conflict by keeping Ubuntu's version.
  - debian/mdadm.postinst, debian/mdadm.config, initramfs/init-premount:
    boot-degraded enablement; maintain udev starting of RAID devices;
    init-premount hook script for the initramfs, to provide information at
    boot
  - debian/mkconf.in is the older mkconf. Kept the Ubuntu version.
  - debian/rules: Kept Ubuntus version for installing apport hooks, not
    installing un-used startall script.
  - debian/install-rc, check.d/_numbers, check.d/root_on_raid: Ubuntu partman
    installer changes
  - debian/presubj: Dropped this unused bug reporting file. Instead use
    source_mdadm.py act as an apport hook for bug handling.
  - d/p/debian-changes-3.1.4-1+8efb9d1ubuntu4: mdadm udev rule
    incrementally adds mdadm member when detected. Starting such an
    array in degraded mode is possible by mdadm -IRs. Using mdadm
    -ARs without stopping the array first does nothing when no
    mdarray-unassociated device is available. Using mdadm -IRs to
    start a previously partially assembled array through incremental
    mode. Keeping the mdadm -ARs for assembling arrays which were for
    some reason not assembled through incremental mode (i.e through
    mdadm's udev rule).

* Additional Ubuntu changes:
    - debian/initramfs/local-premount: add call wait_for_udev to wait a
    little longer for RAID devices to appear (LP: #942106)

* Dropped Ubuntu changes:
  - Build udeb with -O2 on ppc64, working around a link error. Builds
    fine without it on debian.
  - rename debian/mdadm.vol_id.udev to debian/mdadm.mdadm-blkid.udev so
    that the rules file ends up with a more reasonable name. debian/rules
    changes for adding ubuntu's udev rule corresponding to mdadm. As we
    are now using 'upstream' udev rules see 3.2.3-2ubuntu2.

* Changes to Ubuntu changes:
  - debian/source_mdadm.py: make apport hook python 2 and 3 compatible
    (LP: #1013171).

* New upstream release closes this bugs:
  - mdadm --detail --scan segfaults during update-initramfs (LP: #969384)

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
static void alert(char *event, char *dev, char *disc, struct alert_info *info);
70
70
static int check_array(struct state *st, struct mdstat_ent *mdstat,
71
71
                       int test, struct alert_info *info,
72
 
                       int increments);
 
72
                       int increments, char *prefer);
73
73
static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
74
74
                          int test, struct alert_info *info);
75
75
static void try_spare_migration(struct state *statelist, struct alert_info *info);
79
79
            char *mailaddr, char *alert_cmd,
80
80
            int period, int daemonise, int scan, int oneshot,
81
81
            int dosyslog, int test, char *pidfile, int increments,
82
 
            int share)
 
82
            int share, char *prefer)
83
83
{
84
84
        /*
85
85
         * Every few seconds, scan every md device looking for changes
221
221
                mdstat = mdstat_read(oneshot?0:1, 0);
222
222
 
223
223
                for (st=statelist; st; st=st->next)
224
 
                        if (check_array(st, mdstat, test, &info, increments))
 
224
                        if (check_array(st, mdstat, test, &info,
 
225
                                        increments, prefer))
225
226
                                anydegraded = 1;
226
227
                
227
228
                /* now check if there are any new devices found in mdstat */
294
295
        int pid, rv;
295
296
        FILE *fp;
296
297
        char dir[20];
 
298
        char path[100];
297
299
        struct stat buf;
298
 
        fp = fopen("/var/run/mdadm/autorebuild.pid", "r");
 
300
        sprintf(path, "%s/autorebuild.pid", MDMON_DIR);
 
301
        fp = fopen(path, "r");
299
302
        if (fp) {
300
303
                if (fscanf(fp, "%d", &pid) != 1)
301
304
                        pid = -1;
317
320
                fclose(fp);
318
321
        }
319
322
        if (scan) {
320
 
                if (mkdir("/var/run/mdadm", S_IRWXU) < 0 &&
 
323
                if (mkdir(MDMON_DIR, S_IRWXU) < 0 &&
321
324
                    errno != EEXIST) {
322
325
                        fprintf(stderr, Name ": Can't create "
323
326
                                "autorebuild.pid file\n");
324
327
                } else {
325
 
                        fp = fopen("/var/run/mdadm/autorebuild.pid", "w");
 
328
                        fp = fopen(path, "w");
326
329
                        if (!fp)
327
330
                                fprintf(stderr, Name ": Cannot create"
328
331
                                        " autorebuild.pid"
443
446
 
444
447
static int check_array(struct state *st, struct mdstat_ent *mdstat,
445
448
                       int test, struct alert_info *ainfo,
446
 
                       int increments)
 
449
                       int increments, char *prefer)
447
450
{
448
451
        /* Update the state 'st' to reflect any changes shown in mdstat,
449
452
         * or found by directly examining the array, and return
563
566
                struct mdinfo *sra =
564
567
                        sysfs_read(-1, st->devnum, GET_MISMATCH);
565
568
                if (sra && sra->mismatch_cnt > 0) {
566
 
                        char cnt[40];
567
 
                        sprintf(cnt, " mismatches found: %d (on raid level %d)",
 
569
                        char cnt[80];
 
570
                        snprintf(cnt, sizeof(cnt),
 
571
                                 " mismatches found: %d (on raid level %d)",
568
572
                                sra->mismatch_cnt, array.level);
569
573
                        alert("RebuildFinished", dev, cnt, ainfo);
570
574
                } else
614
618
                        disc.major = disc.minor = 0;
615
619
                } else if (info[i].major || info[i].minor) {
616
620
                        newstate = info[i].state;
617
 
                        dv = map_dev(info[i].major, info[i].minor, 1);
 
621
                        dv = map_dev_preferred(
 
622
                                info[i].major, info[i].minor, 1,
 
623
                                prefer);
618
624
                        disc.state = newstate;
619
625
                        disc.major = info[i].major;
620
626
                        disc.minor = info[i].minor;
626
632
                        disc.major = disc.minor = 0;
627
633
                }
628
634
                if (dv == NULL && st->devid[i])
629
 
                        dv = map_dev(major(st->devid[i]),
630
 
                                     minor(st->devid[i]), 1);
 
635
                        dv = map_dev_preferred(
 
636
                                major(st->devid[i]),
 
637
                                minor(st->devid[i]), 1, prefer);
631
638
                change = newstate ^ st->devstate[i];
632
639
                if (st->utime && change && !st->err) {
633
640
                        if (i < array.raid_disks &&