aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/xen-blkback/blkback.c19
-rw-r--r--drivers/block/xen-blkback/common.h6
-rw-r--r--drivers/block/xen-blkback/xenbus.c89
3 files changed, 40 insertions, 74 deletions
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 70caa8969972..73f196ca713f 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -398,21 +398,18 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
398 int err = 0; 398 int err = 0;
399 int status = BLKIF_RSP_OKAY; 399 int status = BLKIF_RSP_OKAY;
400 struct block_device *bdev = blkif->vbd.bdev; 400 struct block_device *bdev = blkif->vbd.bdev;
401 unsigned long secure;
401 402
402 blkif->st_ds_req++; 403 blkif->st_ds_req++;
403 404
404 xen_blkif_get(blkif); 405 xen_blkif_get(blkif);
405 if (blkif->blk_backend_type == BLKIF_BACKEND_PHY || 406 secure = (blkif->vbd.discard_secure &&
406 blkif->blk_backend_type == BLKIF_BACKEND_FILE) { 407 (req->u.discard.flag & BLKIF_DISCARD_SECURE)) ?
407 unsigned long secure = (blkif->vbd.discard_secure && 408 BLKDEV_DISCARD_SECURE : 0;
408 (req->u.discard.flag & BLKIF_DISCARD_SECURE)) ? 409
409 BLKDEV_DISCARD_SECURE : 0; 410 err = blkdev_issue_discard(bdev, req->u.discard.sector_number,
410 err = blkdev_issue_discard(bdev, 411 req->u.discard.nr_sectors,
411 req->u.discard.sector_number, 412 GFP_KERNEL, secure);
412 req->u.discard.nr_sectors,
413 GFP_KERNEL, secure);
414 } else
415 err = -EOPNOTSUPP;
416 413
417 if (err == -EOPNOTSUPP) { 414 if (err == -EOPNOTSUPP) {
418 pr_debug(DRV_PFX "discard op failed, not supported\n"); 415 pr_debug(DRV_PFX "discard op failed, not supported\n");
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index d0ee7edc9be8..773cf27dc23f 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -146,11 +146,6 @@ enum blkif_protocol {
146 BLKIF_PROTOCOL_X86_64 = 3, 146 BLKIF_PROTOCOL_X86_64 = 3,
147}; 147};
148 148
149enum blkif_backend_type {
150 BLKIF_BACKEND_PHY = 1,
151 BLKIF_BACKEND_FILE = 2,
152};
153
154struct xen_vbd { 149struct xen_vbd {
155 /* What the domain refers to this vbd as. */ 150 /* What the domain refers to this vbd as. */
156 blkif_vdev_t handle; 151 blkif_vdev_t handle;
@@ -177,7 +172,6 @@ struct xen_blkif {
177 unsigned int irq; 172 unsigned int irq;
178 /* Comms information. */ 173 /* Comms information. */
179 enum blkif_protocol blk_protocol; 174 enum blkif_protocol blk_protocol;
180 enum blkif_backend_type blk_backend_type;
181 union blkif_back_rings blk_rings; 175 union blkif_back_rings blk_rings;
182 void *blk_ring; 176 void *blk_ring;
183 /* The VBD attached to this interface. */ 177 /* The VBD attached to this interface. */
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 24a2fb57e5d0..89860f34a7ec 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -381,72 +381,49 @@ int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt,
381 err = xenbus_printf(xbt, dev->nodename, "feature-flush-cache", 381 err = xenbus_printf(xbt, dev->nodename, "feature-flush-cache",
382 "%d", state); 382 "%d", state);
383 if (err) 383 if (err)
384 xenbus_dev_fatal(dev, err, "writing feature-flush-cache"); 384 dev_warn(&dev->dev, "writing feature-flush-cache (%d)", err);
385 385
386 return err; 386 return err;
387} 387}
388 388
389int xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be) 389static void xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be)
390{ 390{
391 struct xenbus_device *dev = be->dev; 391 struct xenbus_device *dev = be->dev;
392 struct xen_blkif *blkif = be->blkif; 392 struct xen_blkif *blkif = be->blkif;
393 char *type;
394 int err; 393 int err;
395 int state = 0; 394 int state = 0;
395 struct block_device *bdev = be->blkif->vbd.bdev;
396 struct request_queue *q = bdev_get_queue(bdev);
396 397
397 type = xenbus_read(XBT_NIL, dev->nodename, "type", NULL); 398 if (blk_queue_discard(q)) {
398 if (!IS_ERR(type)) { 399 err = xenbus_printf(xbt, dev->nodename,
399 if (strncmp(type, "file", 4) == 0) { 400 "discard-granularity", "%u",
400 state = 1; 401 q->limits.discard_granularity);
401 blkif->blk_backend_type = BLKIF_BACKEND_FILE; 402 if (err) {
403 dev_warn(&dev->dev, "writing discard-granularity (%d)", err);
404 return;
402 } 405 }
403 if (strncmp(type, "phy", 3) == 0) { 406 err = xenbus_printf(xbt, dev->nodename,
404 struct block_device *bdev = be->blkif->vbd.bdev; 407 "discard-alignment", "%u",
405 struct request_queue *q = bdev_get_queue(bdev); 408 q->limits.discard_alignment);
406 if (blk_queue_discard(q)) { 409 if (err) {
407 err = xenbus_printf(xbt, dev->nodename, 410 dev_warn(&dev->dev, "writing discard-alignment (%d)", err);
408 "discard-granularity", "%u", 411 return;
409 q->limits.discard_granularity); 412 }
410 if (err) { 413 state = 1;
411 xenbus_dev_fatal(dev, err, 414 /* Optional. */
412 "writing discard-granularity"); 415 err = xenbus_printf(xbt, dev->nodename,
413 goto kfree; 416 "discard-secure", "%d",
414 } 417 blkif->vbd.discard_secure);
415 err = xenbus_printf(xbt, dev->nodename, 418 if (err) {
416 "discard-alignment", "%u", 419 dev_warn(dev-dev, "writing discard-secure (%d)", err);
417 q->limits.discard_alignment); 420 return;
418 if (err) {
419 xenbus_dev_fatal(dev, err,
420 "writing discard-alignment");
421 goto kfree;
422 }
423 state = 1;
424 blkif->blk_backend_type = BLKIF_BACKEND_PHY;
425 }
426 /* Optional. */
427 err = xenbus_printf(xbt, dev->nodename,
428 "discard-secure", "%d",
429 blkif->vbd.discard_secure);
430 if (err) {
431 xenbus_dev_fatal(dev, err,
432 "writting discard-secure");
433 goto kfree;
434 }
435 } 421 }
436 } else {
437 err = PTR_ERR(type);
438 xenbus_dev_fatal(dev, err, "reading type");
439 goto out;
440 } 422 }
441
442 err = xenbus_printf(xbt, dev->nodename, "feature-discard", 423 err = xenbus_printf(xbt, dev->nodename, "feature-discard",
443 "%d", state); 424 "%d", state);
444 if (err) 425 if (err)
445 xenbus_dev_fatal(dev, err, "writing feature-discard"); 426 dev_warn(&dev->dev, "writing feature-discard (%d)", err);
446kfree:
447 kfree(type);
448out:
449 return err;
450} 427}
451int xen_blkbk_barrier(struct xenbus_transaction xbt, 428int xen_blkbk_barrier(struct xenbus_transaction xbt,
452 struct backend_info *be, int state) 429 struct backend_info *be, int state)
@@ -457,7 +434,7 @@ int xen_blkbk_barrier(struct xenbus_transaction xbt,
457 err = xenbus_printf(xbt, dev->nodename, "feature-barrier", 434 err = xenbus_printf(xbt, dev->nodename, "feature-barrier",
458 "%d", state); 435 "%d", state);
459 if (err) 436 if (err)
460 xenbus_dev_fatal(dev, err, "writing feature-barrier"); 437 dev_warn(&dev->dev, "writing feature-barrier (%d)", err);
461 438
462 return err; 439 return err;
463} 440}
@@ -689,14 +666,12 @@ again:
689 return; 666 return;
690 } 667 }
691 668
692 err = xen_blkbk_flush_diskcache(xbt, be, be->blkif->vbd.flush_support); 669 /* If we can't advertise it is OK. */
693 if (err) 670 xen_blkbk_flush_diskcache(xbt, be, be->blkif->vbd.flush_support);
694 goto abort;
695 671
696 err = xen_blkbk_discard(xbt, be); 672 xen_blkbk_discard(xbt, be);
697 673
698 /* If we can't advertise it is OK. */ 674 xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
699 err = xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
700 675
701 err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu", 676 err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu",
702 (unsigned long long)vbd_sz(&be->blkif->vbd)); 677 (unsigned long long)vbd_sz(&be->blkif->vbd));