]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Some fixes to make failures in ddf get handled properly.
authorNeil Brown <neilb@suse.de>
Thu, 12 Jun 2008 00:13:28 +0000 (10:13 +1000)
committerNeil Brown <neilb@suse.de>
Thu, 12 Jun 2008 00:13:28 +0000 (10:13 +1000)
monitor.c
super-ddf.c

index d1f7c9e29cb6f006d0902f44f5b9f10ad225feb6..f46f7b128bb81b256141521055d6589071afb2d2 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -225,7 +225,7 @@ static int read_and_act(struct active_array *a)
        a->curr_action = read_action(a->action_fd);
        for (mdi = a->info.devs; mdi ; mdi = mdi->next) {
                mdi->next_state = 0;
-               if (mdi->state_fd > 0)
+               if (mdi->state_fd >= 0)
                        mdi->curr_state = read_dev_state(mdi->state_fd);
        }
 
@@ -307,16 +307,16 @@ static int read_and_act(struct active_array *a)
        if (a->next_action != bad_action)
                write_attr(sync_actions[a->next_action], a->action_fd);
        for (mdi = a->info.devs; mdi ; mdi = mdi->next) {
-               if (mdi->next_state == DS_REMOVE && mdi->state_fd > 0) {
-                       int remove_err;
+               if (mdi->next_state == DS_REMOVE && mdi->state_fd >= 0) {
+                       int remove_result;
 
                        write_attr("-blocked", mdi->state_fd);
                        /* the kernel may not be able to immediately remove the
                         * disk, we can simply wait until the next event to try
                         * again.
                         */
-                       remove_err = write_attr("remove", mdi->state_fd);
-                       if (!remove_err) {
+                       remove_result = write_attr("remove", mdi->state_fd);
+                       if (remove_result > 0) {
                                close(mdi->state_fd);
                                mdi->state_fd = -1;
                        }
index 9dbadfb451d116c59fb3844e91d9805190adde58..66fdb80d50b0799fff186d2652246e6c9f46f4e7 100644 (file)
@@ -2664,8 +2664,8 @@ static void ddf_set_disk(struct active_array *a, int n, int state)
                pd = find_phys(ddf, vc->phys_refnum[i]);
                if (pd < 0)
                        continue;
-               st = ddf->phys->entries[pd].state;
-               if ((state & (DDF_Online|DDF_Failed|DDF_Rebuilding))
+               st = __be16_to_cpu(ddf->phys->entries[pd].state);
+               if ((st & (DDF_Online|DDF_Failed|DDF_Rebuilding))
                    == DDF_Online)
                        working++;
        }