aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/xen-blkback
diff options
context:
space:
mode:
authorLi Dongyang <lidongyang@novell.com>2011-11-10 02:52:06 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-11-18 13:28:05 -0500
commitae18be11b5ccc3be9e268592616488c5f9d987f5 (patch)
tree4f8a98990f946d8d82ffdb4d43c1120cd4e97a26 /drivers/block/xen-blkback
parent421463526fd1d8b5cb575baca12667c1005a110b (diff)
xen-blkback: convert hole punching to discard request on loop devices
As of dfaa2ef68e80c378e610e3c8c536f1c239e8d3ef, loop devices support discard request now. We could just issue a discard request, and the loop driver will punch the hole for us, so we don't need to touch the internals of loop device and punch the hole ourselves, Thanks. V0->V1: rebased on devel/for-jens-3.3 Signed-off-by: Li Dongyang <lidongyang@novell.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/block/xen-blkback')
-rw-r--r--drivers/block/xen-blkback/blkback.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index b058de7825f5..0088bf60f368 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -39,9 +39,6 @@
39#include <linux/list.h> 39#include <linux/list.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/freezer.h> 41#include <linux/freezer.h>
42#include <linux/loop.h>
43#include <linux/falloc.h>
44#include <linux/fs.h>
45 42
46#include <xen/events.h> 43#include <xen/events.h>
47#include <xen/page.h> 44#include <xen/page.h>
@@ -426,27 +423,15 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
426 blkif->st_ds_req++; 423 blkif->st_ds_req++;
427 424
428 xen_blkif_get(blkif); 425 xen_blkif_get(blkif);
429 if (blkif->blk_backend_type == BLKIF_BACKEND_PHY) { 426 if (blkif->blk_backend_type == BLKIF_BACKEND_PHY ||
427 blkif->blk_backend_type == BLKIF_BACKEND_FILE) {
430 unsigned long secure = (blkif->vbd.discard_secure && 428 unsigned long secure = (blkif->vbd.discard_secure &&
431 (req->u.discard.flag & BLKIF_DISCARD_SECURE)) ? 429 (req->u.discard.flag & BLKIF_DISCARD_SECURE)) ?
432 BLKDEV_DISCARD_SECURE : 0; 430 BLKDEV_DISCARD_SECURE : 0;
433 /* just forward the discard request */
434 err = blkdev_issue_discard(bdev, 431 err = blkdev_issue_discard(bdev,
435 req->u.discard.sector_number, 432 req->u.discard.sector_number,
436 req->u.discard.nr_sectors, 433 req->u.discard.nr_sectors,
437 GFP_KERNEL, secure); 434 GFP_KERNEL, secure);
438 } else if (blkif->blk_backend_type == BLKIF_BACKEND_FILE) {
439 /* punch a hole in the backing file */
440 struct loop_device *lo = bdev->bd_disk->private_data;
441 struct file *file = lo->lo_backing_file;
442
443 if (file->f_op->fallocate)
444 err = file->f_op->fallocate(file,
445 FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE,
446 req->u.discard.sector_number << 9,
447 req->u.discard.nr_sectors << 9);
448 else
449 err = -EOPNOTSUPP;
450 } else 435 } else
451 err = -EOPNOTSUPP; 436 err = -EOPNOTSUPP;
452 437