mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-12 12:22:42 +00:00
Merge branch 'for-jens-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen into for-3.19/drivers
Konrad writes: These are two fixes for Xen blkfront. They harden how it deals with broken backends.
This commit is contained in:
commit
d8ead9b763
@ -126,7 +126,6 @@ struct blkfront_info
|
|||||||
unsigned int persistent_gnts_c;
|
unsigned int persistent_gnts_c;
|
||||||
unsigned long shadow_free;
|
unsigned long shadow_free;
|
||||||
unsigned int feature_flush;
|
unsigned int feature_flush;
|
||||||
unsigned int flush_op;
|
|
||||||
unsigned int feature_discard:1;
|
unsigned int feature_discard:1;
|
||||||
unsigned int feature_secdiscard:1;
|
unsigned int feature_secdiscard:1;
|
||||||
unsigned int discard_granularity;
|
unsigned int discard_granularity;
|
||||||
@ -479,7 +478,19 @@ static int blkif_queue_request(struct request *req)
|
|||||||
* way. (It's also a FLUSH+FUA, since it is
|
* way. (It's also a FLUSH+FUA, since it is
|
||||||
* guaranteed ordered WRT previous writes.)
|
* guaranteed ordered WRT previous writes.)
|
||||||
*/
|
*/
|
||||||
ring_req->operation = info->flush_op;
|
switch (info->feature_flush &
|
||||||
|
((REQ_FLUSH|REQ_FUA))) {
|
||||||
|
case REQ_FLUSH|REQ_FUA:
|
||||||
|
ring_req->operation =
|
||||||
|
BLKIF_OP_WRITE_BARRIER;
|
||||||
|
break;
|
||||||
|
case REQ_FLUSH:
|
||||||
|
ring_req->operation =
|
||||||
|
BLKIF_OP_FLUSH_DISKCACHE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ring_req->operation = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ring_req->u.rw.nr_segments = nseg;
|
ring_req->u.rw.nr_segments = nseg;
|
||||||
}
|
}
|
||||||
@ -582,12 +593,14 @@ static inline void flush_requests(struct blkfront_info *info)
|
|||||||
notify_remote_via_irq(info->irq);
|
notify_remote_via_irq(info->irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool blkif_request_flush_valid(struct request *req,
|
static inline bool blkif_request_flush_invalid(struct request *req,
|
||||||
struct blkfront_info *info)
|
struct blkfront_info *info)
|
||||||
{
|
{
|
||||||
return ((req->cmd_type != REQ_TYPE_FS) ||
|
return ((req->cmd_type != REQ_TYPE_FS) ||
|
||||||
((req->cmd_flags & (REQ_FLUSH | REQ_FUA)) &&
|
((req->cmd_flags & REQ_FLUSH) &&
|
||||||
!info->flush_op));
|
!(info->feature_flush & REQ_FLUSH)) ||
|
||||||
|
((req->cmd_flags & REQ_FUA) &&
|
||||||
|
!(info->feature_flush & REQ_FUA)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -612,8 +625,8 @@ static void do_blkif_request(struct request_queue *rq)
|
|||||||
|
|
||||||
blk_start_request(req);
|
blk_start_request(req);
|
||||||
|
|
||||||
if (blkif_request_flush_valid(req, info)) {
|
if (blkif_request_flush_invalid(req, info)) {
|
||||||
__blk_end_request_all(req, -EIO);
|
__blk_end_request_all(req, -EOPNOTSUPP);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,20 +696,26 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *flush_info(unsigned int feature_flush)
|
||||||
|
{
|
||||||
|
switch (feature_flush & ((REQ_FLUSH | REQ_FUA))) {
|
||||||
|
case REQ_FLUSH|REQ_FUA:
|
||||||
|
return "barrier: enabled;";
|
||||||
|
case REQ_FLUSH:
|
||||||
|
return "flush diskcache: enabled;";
|
||||||
|
default:
|
||||||
|
return "barrier or flush: disabled;";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void xlvbd_flush(struct blkfront_info *info)
|
static void xlvbd_flush(struct blkfront_info *info)
|
||||||
{
|
{
|
||||||
blk_queue_flush(info->rq, info->feature_flush);
|
blk_queue_flush(info->rq, info->feature_flush);
|
||||||
printk(KERN_INFO "blkfront: %s: %s: %s %s %s %s %s\n",
|
pr_info("blkfront: %s: %s %s %s %s %s\n",
|
||||||
info->gd->disk_name,
|
info->gd->disk_name, flush_info(info->feature_flush),
|
||||||
info->flush_op == BLKIF_OP_WRITE_BARRIER ?
|
"persistent grants:", info->feature_persistent ?
|
||||||
"barrier" : (info->flush_op == BLKIF_OP_FLUSH_DISKCACHE ?
|
"enabled;" : "disabled;", "indirect descriptors:",
|
||||||
"flush diskcache" : "barrier or flush"),
|
info->max_indirect_segments ? "enabled;" : "disabled;");
|
||||||
info->feature_flush ? "enabled;" : "disabled;",
|
|
||||||
"persistent grants:",
|
|
||||||
info->feature_persistent ? "enabled;" : "disabled;",
|
|
||||||
"indirect descriptors:",
|
|
||||||
info->max_indirect_segments ? "enabled;" : "disabled;");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int xen_translate_vdev(int vdevice, int *minor, unsigned int *offset)
|
static int xen_translate_vdev(int vdevice, int *minor, unsigned int *offset)
|
||||||
@ -1188,7 +1207,6 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
|
|||||||
if (error == -EOPNOTSUPP)
|
if (error == -EOPNOTSUPP)
|
||||||
error = 0;
|
error = 0;
|
||||||
info->feature_flush = 0;
|
info->feature_flush = 0;
|
||||||
info->flush_op = 0;
|
|
||||||
xlvbd_flush(info);
|
xlvbd_flush(info);
|
||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
@ -1808,7 +1826,6 @@ static void blkfront_connect(struct blkfront_info *info)
|
|||||||
physical_sector_size = sector_size;
|
physical_sector_size = sector_size;
|
||||||
|
|
||||||
info->feature_flush = 0;
|
info->feature_flush = 0;
|
||||||
info->flush_op = 0;
|
|
||||||
|
|
||||||
err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
|
err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
|
||||||
"feature-barrier", "%d", &barrier,
|
"feature-barrier", "%d", &barrier,
|
||||||
@ -1821,10 +1838,8 @@ static void blkfront_connect(struct blkfront_info *info)
|
|||||||
*
|
*
|
||||||
* If there are barriers, then we use flush.
|
* If there are barriers, then we use flush.
|
||||||
*/
|
*/
|
||||||
if (!err && barrier) {
|
if (!err && barrier)
|
||||||
info->feature_flush = REQ_FLUSH | REQ_FUA;
|
info->feature_flush = REQ_FLUSH | REQ_FUA;
|
||||||
info->flush_op = BLKIF_OP_WRITE_BARRIER;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* And if there is "feature-flush-cache" use that above
|
* And if there is "feature-flush-cache" use that above
|
||||||
* barriers.
|
* barriers.
|
||||||
@ -1833,10 +1848,8 @@ static void blkfront_connect(struct blkfront_info *info)
|
|||||||
"feature-flush-cache", "%d", &flush,
|
"feature-flush-cache", "%d", &flush,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (!err && flush) {
|
if (!err && flush)
|
||||||
info->feature_flush = REQ_FLUSH;
|
info->feature_flush = REQ_FLUSH;
|
||||||
info->flush_op = BLKIF_OP_FLUSH_DISKCACHE;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
|
err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
|
||||||
"feature-discard", "%d", &discard,
|
"feature-discard", "%d", &discard,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user