~ubuntu-branches/ubuntu/karmic/mdadm/karmic

« back to all changes in this revision

Viewing changes to Monitor.c

  • Committer: Package Import Robot
  • Author(s): Scott James Remnant
  • Date: 2007-12-12 22:35:09 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20071212223509-10l2hitpp068jr53
Tags: 2.6.3+200709292116+4450e59-3ubuntu1
* Merge from debian unstable, remaining changes:
 * md activation:
  - We now have a single udev rule for both the real system and the
    initramfs, since doing things differently there will only result in bugs
    and confusion.
  - This rule runs "mdadm --assemble --scan --no-degraded", automatically
    activating any non-degraded device as their components are detected.
  - Drop the mdadm-raid init script, since this does the same thing.
  - Also drop mdadm-startall which uses the mdadm-raid init script, and its
    associated sgml file (thus dropping the build-dep on docbook-to-man)
  - Simplify the configuration, since we always autostart all devices so do
    not need to specify any required root devices, etc.
  - Drop the deprecated mdrun entirely.
  - Since udev autostarts arrays, much of the initramfs script can be
    dropped.
 * Install a new udev rule at 65 which runs vol_id on clean raid arrays.
   This will cause lvm, etc. to be run (since there is vol_id information
   present for the enclosed filesystem).
 * Depend on initramfs-tools, specifically a version that doesn't ship
   the mdrun script.  This way we can clean out a lot of the upgrade handling
   from the initramfs hook.
 * Just get initramfs to load the modules for us

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include        "md_p.h"
32
32
#include        "md_u.h"
33
33
#include        <sys/wait.h>
34
 
#include        <sys/signal.h>
35
 
#include        <values.h>
 
34
#include        <signal.h>
 
35
#include        <limits.h>
36
36
#include        <syslog.h>
37
37
 
38
38
static void alert(char *event, char *dev, char *disc, char *mailaddr, char *mailfrom,
172
172
                        st->utime = 0;
173
173
                        st->next = statelist;
174
174
                        st->err = 0;
175
 
                        st->devnum = MAXINT;
 
175
                        st->devnum = INT_MAX;
176
176
                        st->percent = -2;
177
177
                        st->expected_spares = mdlist->spare_disks;
178
178
                        if (mdlist->spare_group)
192
192
                        st->utime = 0;
193
193
                        st->next = statelist;
194
194
                        st->err = 0;
195
 
                        st->devnum = MAXINT;
 
195
                        st->devnum = INT_MAX;
196
196
                        st->percent = -2;
197
197
                        st->expected_spares = -1;
198
198
                        st->spare_group = NULL;
234
234
*/                              st->err=1;
235
235
                                continue;
236
236
                        }
 
237
                        fcntl(fd, F_SETFD, FD_CLOEXEC);
237
238
                        if (ioctl(fd, GET_ARRAY_INFO, &array)<0) {
238
239
                                if (!st->err)
239
240
                                        alert("DeviceDisappeared", dev, NULL,
244
245
                                close(fd);
245
246
                                continue;
246
247
                        }
247
 
                        if (array.level != 1 && array.level != 5 && array.level != -4 &&
248
 
                                array.level != 6 && array.level != 10) {
 
248
                        /* It's much easier to list what array levels can't
 
249
                         * have a device disappear than all of them that can
 
250
                         */
 
251
                        if (array.level == 0 || array.level == -1) {
249
252
                                if (!st->err)
250
253
                                        alert("DeviceDisappeared", dev, "Wrong-Level",
251
254
                                              mailaddr, mailfrom, alert_cmd, dosyslog);
253
256
                                close(fd);
254
257
                                continue;
255
258
                        }
256
 
                        if (st->devnum == MAXINT) {
 
259
                        if (st->devnum == INT_MAX) {
257
260
                                struct stat stb;
258
261
                                if (fstat(fd, &stb) == 0 &&
259
262
                                    (S_IFMT&stb.st_mode)==S_IFBLK) {
266
269
 
267
270
                        for (mse2 = mdstat ; mse2 ; mse2=mse2->next)
268
271
                                if (mse2->devnum == st->devnum) {
269
 
                                        mse2->devnum = MAXINT; /* flag it as "used" */
 
272
                                        mse2->devnum = INT_MAX; /* flag it as "used" */
270
273
                                        mse = mse2;
271
274
                                }
272
275
 
328
331
                        for (i=0; i<MaxDisks && i <= array.raid_disks + array.nr_disks;
329
332
                             i++) {
330
333
                                mdu_disk_info_t disc;
 
334
                                disc.number = i;
331
335
                                if (ioctl(fd, GET_DISK_INFO, &disc) >= 0) {
332
336
                                        info[i].state = disc.state;
333
337
                                        info[i].major = disc.major;
398
402
                if (scan) {
399
403
                        struct mdstat_ent *mse;
400
404
                        for (mse=mdstat; mse; mse=mse->next) 
401
 
                                if (mse->devnum != MAXINT &&
402
 
                                    (strcmp(mse->level, "raid1")==0 ||
403
 
                                     strcmp(mse->level, "raid5")==0 ||
404
 
                                     strcmp(mse->level, "multipath")==0)
 
405
                                if (mse->devnum != INT_MAX &&
 
406
                                    (strcmp(mse->level, "raid0")!=0 &&
 
407
                                     strcmp(mse->level, "linear")!=0)
405
408
                                        ) {
406
409
                                        struct state *st = malloc(sizeof *st);
407
410
                                        mdu_array_info_t array;