aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/xen-blkback/xenbus.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-02 17:33:37 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-02 17:33:37 -0400
commiteb1574270a6de8fb8d31ffc3b021e30df0afcda3 (patch)
treed154ba369f222f5108ed1a2462d815d7faadc2e5 /drivers/block/xen-blkback/xenbus.c
parentaac10aaa8cc65a6fef6f5bc7d0b96035b0225a61 (diff)
parent69964ea4c7b68c9399f7977aa5b9aa6539a6a98a (diff)
Merge 3.4-rc5 into driver-core-next
This was done to resolve a merge issue with the init/main.c file. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/block/xen-blkback/xenbus.c')
-rw-r--r--drivers/block/xen-blkback/xenbus.c89
1 files changed, 32 insertions, 57 deletions
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 24a2fb57e5d0..4f66171c6683 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));