aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/xen-blkfront.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/xen-blkfront.c')
-rw-r--r--drivers/block/xen-blkfront.c43
1 files changed, 12 insertions, 31 deletions
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 50ec6f834996..0b1eea643262 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -95,7 +95,7 @@ struct blkfront_info
95 struct gnttab_free_callback callback; 95 struct gnttab_free_callback callback;
96 struct blk_shadow shadow[BLK_RING_SIZE]; 96 struct blk_shadow shadow[BLK_RING_SIZE];
97 unsigned long shadow_free; 97 unsigned long shadow_free;
98 int feature_barrier; 98 unsigned int feature_flush;
99 int is_ready; 99 int is_ready;
100}; 100};
101 101
@@ -418,25 +418,12 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
418} 418}
419 419
420 420
421static int xlvbd_barrier(struct blkfront_info *info) 421static void xlvbd_flush(struct blkfront_info *info)
422{ 422{
423 int err; 423 blk_queue_flush(info->rq, info->feature_flush);
424 const char *barrier;
425
426 switch (info->feature_barrier) {
427 case QUEUE_ORDERED_DRAIN: barrier = "enabled"; break;
428 case QUEUE_ORDERED_NONE: barrier = "disabled"; break;
429 default: return -EINVAL;
430 }
431
432 err = blk_queue_ordered(info->rq, info->feature_barrier);
433
434 if (err)
435 return err;
436
437 printk(KERN_INFO "blkfront: %s: barriers %s\n", 424 printk(KERN_INFO "blkfront: %s: barriers %s\n",
438 info->gd->disk_name, barrier); 425 info->gd->disk_name,
439 return 0; 426 info->feature_flush ? "enabled" : "disabled");
440} 427}
441 428
442 429
@@ -515,7 +502,7 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity,
515 info->rq = gd->queue; 502 info->rq = gd->queue;
516 info->gd = gd; 503 info->gd = gd;
517 504
518 xlvbd_barrier(info); 505 xlvbd_flush(info);
519 506
520 if (vdisk_info & VDISK_READONLY) 507 if (vdisk_info & VDISK_READONLY)
521 set_disk_ro(gd, 1); 508 set_disk_ro(gd, 1);
@@ -661,8 +648,8 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
661 printk(KERN_WARNING "blkfront: %s: write barrier op failed\n", 648 printk(KERN_WARNING "blkfront: %s: write barrier op failed\n",
662 info->gd->disk_name); 649 info->gd->disk_name);
663 error = -EOPNOTSUPP; 650 error = -EOPNOTSUPP;
664 info->feature_barrier = QUEUE_ORDERED_NONE; 651 info->feature_flush = 0;
665 xlvbd_barrier(info); 652 xlvbd_flush(info);
666 } 653 }
667 /* fall through */ 654 /* fall through */
668 case BLKIF_OP_READ: 655 case BLKIF_OP_READ:
@@ -1075,19 +1062,13 @@ static void blkfront_connect(struct blkfront_info *info)
1075 /* 1062 /*
1076 * If there's no "feature-barrier" defined, then it means 1063 * If there's no "feature-barrier" defined, then it means
1077 * we're dealing with a very old backend which writes 1064 * we're dealing with a very old backend which writes
1078 * synchronously; draining will do what needs to get done. 1065 * synchronously; nothing to do.
1079 * 1066 *
1080 * If there are barriers, then we use flush. 1067 * If there are barriers, then we use flush.
1081 *
1082 * If barriers are not supported, then there's no much we can
1083 * do, so just set ordering to NONE.
1084 */ 1068 */
1085 if (err) 1069 info->feature_flush = 0;
1086 info->feature_barrier = QUEUE_ORDERED_DRAIN; 1070 if (!err && barrier)
1087 else if (barrier) 1071 info->feature_flush = REQ_FLUSH;
1088 info->feature_barrier = QUEUE_ORDERED_DRAIN_FLUSH;
1089 else
1090 info->feature_barrier = QUEUE_ORDERED_NONE;
1091 1072
1092 err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size); 1073 err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size);
1093 if (err) { 1074 if (err) {