]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/block/nbd.c
nbd: do not allow two clients at the same time
[linux-2.6-omap-h63xx.git] / drivers / block / nbd.c
index 7bcc1d8bc96724add86213f7f85ec01ed48a8314..34f80fa6fed16d379733e3db018f765831e09778 100644 (file)
@@ -406,6 +406,7 @@ static int nbd_do_it(struct nbd_device *lo)
        ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
        if (ret) {
                printk(KERN_ERR "nbd: sysfs_create_file failed!");
+               lo->pid = 0;
                return ret;
        }
 
@@ -413,6 +414,7 @@ static int nbd_do_it(struct nbd_device *lo)
                nbd_end_request(req);
 
        sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
+       lo->pid = 0;
        return 0;
 }
 
@@ -648,6 +650,8 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
                set_capacity(lo->disk, lo->bytesize >> 9);
                return 0;
        case NBD_DO_IT:
+               if (lo->pid)
+                       return -EBUSY;
                if (!lo->file)
                        return -EINVAL;
                thread = kthread_create(nbd_thread, lo, lo->disk->disk_name);