]> Pileus Git - ~andy/linux/blobdiff - drivers/md/md.c
[PATCH] dm: fix alloc_dev error path
[~andy/linux] / drivers / md / md.c
index c0da5eedc2453673e0d0b8659073f041f604cb5d..8dbab2ef38857f1f0cff938701869e3b067d7b44 100644 (file)
@@ -1597,6 +1597,19 @@ void md_update_sb(mddev_t * mddev)
 
 repeat:
        spin_lock_irq(&mddev->write_lock);
+
+       if (mddev->degraded && mddev->sb_dirty == 3)
+               /* If the array is degraded, then skipping spares is both
+                * dangerous and fairly pointless.
+                * Dangerous because a device that was removed from the array
+                * might have a event_count that still looks up-to-date,
+                * so it can be re-added without a resync.
+                * Pointless because if there are any spares to skip,
+                * then a recovery will happen and soon that array won't
+                * be degraded any more and the spare can go back to sleep then.
+                */
+               mddev->sb_dirty = 1;
+
        sync_req = mddev->in_sync;
        mddev->utime = get_seconds();
        if (mddev->sb_dirty == 3)
@@ -1926,6 +1939,8 @@ rdev_attr_store(struct kobject *kobj, struct attribute *attr,
 
        if (!entry->store)
                return -EIO;
+       if (!capable(CAP_SYS_ADMIN))
+               return -EACCES;
        return entry->store(rdev, page, length);
 }
 
@@ -2859,6 +2874,8 @@ md_attr_store(struct kobject *kobj, struct attribute *attr,
 
        if (!entry->store)
                return -EIO;
+       if (!capable(CAP_SYS_ADMIN))
+               return -EACCES;
        rv = mddev_lock(mddev);
        if (!rv) {
                rv = entry->store(mddev, page, length);
@@ -4588,6 +4605,8 @@ void md_error(mddev_t *mddev, mdk_rdev_t *rdev)
                __builtin_return_address(0),__builtin_return_address(1),
                __builtin_return_address(2),__builtin_return_address(3));
 */
+       if (!mddev->pers)
+               return;
        if (!mddev->pers->error_handler)
                return;
        mddev->pers->error_handler(mddev,rdev);