]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/md/raid1.c
md: provide appropriate return value for spare_active functions.
[net-next-2.6.git] / drivers / md / raid1.c
index 0e1abf1bb38e755a1ea24359f87cc46b820f8b45..64d96526a9ccd20c0b93c8b10cca172d036b4177 100644 (file)
@@ -1120,6 +1120,8 @@ static int raid1_spare_active(mddev_t *mddev)
 {
        int i;
        conf_t *conf = mddev->private;
+       int count = 0;
+       unsigned long flags;
 
        /*
         * Find all failed disks within the RAID1 configuration 
@@ -1131,16 +1133,16 @@ static int raid1_spare_active(mddev_t *mddev)
                if (rdev
                    && !test_bit(Faulty, &rdev->flags)
                    && !test_and_set_bit(In_sync, &rdev->flags)) {
-                       unsigned long flags;
-                       spin_lock_irqsave(&conf->device_lock, flags);
-                       mddev->degraded--;
-                       spin_unlock_irqrestore(&conf->device_lock, flags);
+                       count++;
                        sysfs_notify_dirent(rdev->sysfs_state);
                }
        }
+       spin_lock_irqsave(&conf->device_lock, flags);
+       mddev->degraded -= count;
+       spin_unlock_irqrestore(&conf->device_lock, flags);
 
        print_conf(conf);
-       return 0;
+       return count;
 }