diff options
-rw-r--r-- | drivers/block/xen-blkfront.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 1e406f0331e7..763a315712cc 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -1118,16 +1118,33 @@ static int blkfront_is_ready(struct xenbus_device *dev) | |||
1118 | 1118 | ||
1119 | static int blkif_open(struct block_device *bdev, fmode_t mode) | 1119 | static int blkif_open(struct block_device *bdev, fmode_t mode) |
1120 | { | 1120 | { |
1121 | struct blkfront_info *info = bdev->bd_disk->private_data; | 1121 | struct gendisk *disk = bdev->bd_disk; |
1122 | 1122 | struct blkfront_info *info; | |
1123 | if (!info->xbdev) | 1123 | int err = 0; |
1124 | return -ENODEV; | ||
1125 | 1124 | ||
1126 | lock_kernel(); | 1125 | lock_kernel(); |
1127 | info->users++; | ||
1128 | unlock_kernel(); | ||
1129 | 1126 | ||
1130 | return 0; | 1127 | info = disk->private_data; |
1128 | if (!info) { | ||
1129 | /* xbdev gone */ | ||
1130 | err = -ERESTARTSYS; | ||
1131 | goto out; | ||
1132 | } | ||
1133 | |||
1134 | mutex_lock(&info->mutex); | ||
1135 | |||
1136 | if (!info->gd) | ||
1137 | /* xbdev is closed */ | ||
1138 | err = -ERESTARTSYS; | ||
1139 | |||
1140 | mutex_unlock(&info->mutex); | ||
1141 | |||
1142 | if (!err) | ||
1143 | ++info->users; | ||
1144 | |||
1145 | unlock_kernel(); | ||
1146 | out: | ||
1147 | return err; | ||
1131 | } | 1148 | } |
1132 | 1149 | ||
1133 | static int blkif_release(struct gendisk *disk, fmode_t mode) | 1150 | static int blkif_release(struct gendisk *disk, fmode_t mode) |