xen-blkfront.c (20c7775aecea04d8ca322039969d49dcf568e0e9) xen-blkfront.c (977115c0f664e016a6b2774d4f97116ade23d732)
1/*
2 * blkfront.c
3 *
4 * XenLinux virtual block device driver.
5 *
6 * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
7 * Modifications by Mark A. Williamson are (c) Intel Research Cambridge
8 * Copyright (c) 2004, Christian Limpach

--- 2139 unchanged lines hidden (view full) ---

2148 mutex_lock(&info->mutex);
2149
2150 if (xbdev->state == XenbusStateClosing) {
2151 mutex_unlock(&info->mutex);
2152 return;
2153 }
2154
2155 if (info->gd)
1/*
2 * blkfront.c
3 *
4 * XenLinux virtual block device driver.
5 *
6 * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
7 * Modifications by Mark A. Williamson are (c) Intel Research Cambridge
8 * Copyright (c) 2004, Christian Limpach

--- 2139 unchanged lines hidden (view full) ---

2148 mutex_lock(&info->mutex);
2149
2150 if (xbdev->state == XenbusStateClosing) {
2151 mutex_unlock(&info->mutex);
2152 return;
2153 }
2154
2155 if (info->gd)
2156 bdev = bdget_disk(info->gd, 0);
2156 bdev = bdgrab(info->gd->part0);
2157
2158 mutex_unlock(&info->mutex);
2159
2160 if (!bdev) {
2161 xenbus_frontend_closed(xbdev);
2162 return;
2163 }
2164

--- 200 unchanged lines hidden (view full) ---

2365 * a capacity change; update the capacity.
2366 */
2367 err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
2368 "sectors", "%Lu", &sectors);
2369 if (XENBUS_EXIST_ERR(err))
2370 return;
2371 printk(KERN_INFO "Setting capacity to %Lu\n",
2372 sectors);
2157
2158 mutex_unlock(&info->mutex);
2159
2160 if (!bdev) {
2161 xenbus_frontend_closed(xbdev);
2162 return;
2163 }
2164

--- 200 unchanged lines hidden (view full) ---

2365 * a capacity change; update the capacity.
2366 */
2367 err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
2368 "sectors", "%Lu", &sectors);
2369 if (XENBUS_EXIST_ERR(err))
2370 return;
2371 printk(KERN_INFO "Setting capacity to %Lu\n",
2372 sectors);
2373 set_capacity_revalidate_and_notify(info->gd, sectors, true);
2373 set_capacity_and_notify(info->gd, sectors);
2374
2375 return;
2376 case BLKIF_STATE_SUSPENDED:
2377 /*
2378 * If we are recovering from suspension, we need to wait
2379 * for the backend to announce it's features before
2380 * reconnecting, at least we need to know if the backend
2381 * supports indirect descriptors, and how many.

--- 131 unchanged lines hidden (view full) ---

2513 return 0;
2514
2515 blkif_free(info, 0);
2516
2517 mutex_lock(&info->mutex);
2518
2519 disk = info->gd;
2520 if (disk)
2374
2375 return;
2376 case BLKIF_STATE_SUSPENDED:
2377 /*
2378 * If we are recovering from suspension, we need to wait
2379 * for the backend to announce it's features before
2380 * reconnecting, at least we need to know if the backend
2381 * supports indirect descriptors, and how many.

--- 131 unchanged lines hidden (view full) ---

2513 return 0;
2514
2515 blkif_free(info, 0);
2516
2517 mutex_lock(&info->mutex);
2518
2519 disk = info->gd;
2520 if (disk)
2521 bdev = bdget_disk(disk, 0);
2521 bdev = bdgrab(disk->part0);
2522
2523 info->xbdev = NULL;
2524 mutex_unlock(&info->mutex);
2525
2526 if (!bdev) {
2527 mutex_lock(&blkfront_mutex);
2528 free_info(info);
2529 mutex_unlock(&blkfront_mutex);

--- 60 unchanged lines hidden (view full) ---

2590out:
2591 mutex_unlock(&blkfront_mutex);
2592 return err;
2593}
2594
2595static void blkif_release(struct gendisk *disk, fmode_t mode)
2596{
2597 struct blkfront_info *info = disk->private_data;
2522
2523 info->xbdev = NULL;
2524 mutex_unlock(&info->mutex);
2525
2526 if (!bdev) {
2527 mutex_lock(&blkfront_mutex);
2528 free_info(info);
2529 mutex_unlock(&blkfront_mutex);

--- 60 unchanged lines hidden (view full) ---

2590out:
2591 mutex_unlock(&blkfront_mutex);
2592 return err;
2593}
2594
2595static void blkif_release(struct gendisk *disk, fmode_t mode)
2596{
2597 struct blkfront_info *info = disk->private_data;
2598 struct block_device *bdev;
2599 struct xenbus_device *xbdev;
2600
2601 mutex_lock(&blkfront_mutex);
2598 struct xenbus_device *xbdev;
2599
2600 mutex_lock(&blkfront_mutex);
2602
2603 bdev = bdget_disk(disk, 0);
2604
2605 if (!bdev) {
2606 WARN(1, "Block device %s yanked out from us!\n", disk->disk_name);
2601 if (disk->part0->bd_openers)
2607 goto out_mutex;
2602 goto out_mutex;
2608 }
2609 if (bdev->bd_openers)
2610 goto out;
2611
2612 /*
2613 * Check if we have been instructed to close. We will have
2614 * deferred this request, because the bdev was still open.
2615 */
2616
2617 mutex_lock(&info->mutex);
2618 xbdev = info->xbdev;
2619
2620 if (xbdev && xbdev->state == XenbusStateClosing) {
2621 /* pending switch to state closed */
2603
2604 /*
2605 * Check if we have been instructed to close. We will have
2606 * deferred this request, because the bdev was still open.
2607 */
2608
2609 mutex_lock(&info->mutex);
2610 xbdev = info->xbdev;
2611
2612 if (xbdev && xbdev->state == XenbusStateClosing) {
2613 /* pending switch to state closed */
2622 dev_info(disk_to_dev(bdev->bd_disk), "releasing disk\n");
2614 dev_info(disk_to_dev(disk), "releasing disk\n");
2623 xlvbd_release_gendisk(info);
2624 xenbus_frontend_closed(info->xbdev);
2625 }
2626
2627 mutex_unlock(&info->mutex);
2628
2629 if (!xbdev) {
2630 /* sudden device removal */
2615 xlvbd_release_gendisk(info);
2616 xenbus_frontend_closed(info->xbdev);
2617 }
2618
2619 mutex_unlock(&info->mutex);
2620
2621 if (!xbdev) {
2622 /* sudden device removal */
2631 dev_info(disk_to_dev(bdev->bd_disk), "releasing disk\n");
2623 dev_info(disk_to_dev(disk), "releasing disk\n");
2632 xlvbd_release_gendisk(info);
2633 disk->private_data = NULL;
2634 free_info(info);
2635 }
2636
2624 xlvbd_release_gendisk(info);
2625 disk->private_data = NULL;
2626 free_info(info);
2627 }
2628
2637out:
2638 bdput(bdev);
2639out_mutex:
2640 mutex_unlock(&blkfront_mutex);
2641}
2642
2643static const struct block_device_operations xlvbd_block_fops =
2644{
2645 .owner = THIS_MODULE,
2646 .open = blkif_open,

--- 136 unchanged lines hidden ---
2629out_mutex:
2630 mutex_unlock(&blkfront_mutex);
2631}
2632
2633static const struct block_device_operations xlvbd_block_fops =
2634{
2635 .owner = THIS_MODULE,
2636 .open = blkif_open,

--- 136 unchanged lines hidden ---