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);
}
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;
}
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++;
}