]> git.hungrycats.org Git - linux/commitdiff
[PATCH] dm: Don't let the ioctl interface drop a suspended device
authorJoe Thornber <joe@fib011235813.fsnet.co.uk>
Wed, 8 Jan 2003 01:53:48 +0000 (17:53 -0800)
committerTrond Myklebust <trond.myklebust@fys.uio.no>
Wed, 8 Jan 2003 01:53:48 +0000 (17:53 -0800)
Don't let the ioctl interface drop a suspended device.

drivers/md/dm-ioctl.c

index 63e55021d967696ab82bd2f8547d4f190064a6cc..06bf868d59694319a096b15aef27cd72b1e78ed3 100644 (file)
@@ -812,6 +812,24 @@ static int remove(struct dm_ioctl *param, struct dm_ioctl *user)
                return -EINVAL;
        }
 
+       /*
+        * You may ask the interface to drop its reference to an
+        * in use device.  This is no different to unlinking a
+        * file that someone still has open.  The device will not
+        * actually be destroyed until the last opener closes it.
+        * The name and uuid of the device (both are interface
+        * properties) will be available for reuse immediately.
+        *
+        * You don't want to drop a _suspended_ device from the
+        * interface, since that will leave you with no way of
+        * resuming it.
+        */
+       if (dm_suspended(hc->md)) {
+               DMWARN("refusing to remove a suspended device.");
+               up_write(&_hash_lock);
+               return -EPERM;
+       }
+
        __hash_remove(hc);
        up_write(&_hash_lock);
        return 0;