diff options
| author | Vitaly Kuznetsov <vkuznets@redhat.com> | 2014-12-01 08:01:13 -0500 |
|---|---|---|
| committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2014-12-10 12:20:07 -0500 |
| commit | ad42d391ae388bd4ce4d53e8d7b4089cfdcba411 (patch) | |
| tree | 3002687530aded859fba77ba63e5f7e1e73847fd | |
| parent | 9af8785a38d4528d6675247f873b0f1ae29f3be8 (diff) | |
xen/blkfront: improve protection against issuing unsupported REQ_FUA
Guard against issuing unsupported REQ_FUA and REQ_FLUSH was introduced
in d11e61583 and was factored out into blkif_request_flush_valid() in
0f1ca65ee. However:
1) This check in incomplete. In case we negotiated to feature_flush = REQ_FLUSH
and flush_op = BLKIF_OP_FLUSH_DISKCACHE (so FUA is unsupported) FUA request
will still pass the check.
2) blkif_request_flush_valid() is misnamed. It is bool but returns true when
the request is invalid.
3) When blkif_request_flush_valid() fails -EIO is being returned. It seems that
-EOPNOTSUPP is more appropriate here.
Fix all of the above issues.
This patch is based on the original patch by Laszlo Ersek and a comment by
Jeff Moyer.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
| -rw-r--r-- | drivers/block/xen-blkfront.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 5ac312f6e0be..2e6c10371b24 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
| @@ -582,12 +582,14 @@ static inline void flush_requests(struct blkfront_info *info) | |||
| 582 | notify_remote_via_irq(info->irq); | 582 | notify_remote_via_irq(info->irq); |
| 583 | } | 583 | } |
| 584 | 584 | ||
| 585 | static inline bool blkif_request_flush_valid(struct request *req, | 585 | static inline bool blkif_request_flush_invalid(struct request *req, |
| 586 | struct blkfront_info *info) | 586 | struct blkfront_info *info) |
| 587 | { | 587 | { |
| 588 | return ((req->cmd_type != REQ_TYPE_FS) || | 588 | return ((req->cmd_type != REQ_TYPE_FS) || |
| 589 | ((req->cmd_flags & (REQ_FLUSH | REQ_FUA)) && | 589 | ((req->cmd_flags & REQ_FLUSH) && |
| 590 | !info->flush_op)); | 590 | !(info->feature_flush & REQ_FLUSH)) || |
| 591 | ((req->cmd_flags & REQ_FUA) && | ||
| 592 | !(info->feature_flush & REQ_FUA))); | ||
| 591 | } | 593 | } |
| 592 | 594 | ||
| 593 | /* | 595 | /* |
| @@ -612,8 +614,8 @@ static void do_blkif_request(struct request_queue *rq) | |||
| 612 | 614 | ||
| 613 | blk_start_request(req); | 615 | blk_start_request(req); |
| 614 | 616 | ||
| 615 | if (blkif_request_flush_valid(req, info)) { | 617 | if (blkif_request_flush_invalid(req, info)) { |
| 616 | __blk_end_request_all(req, -EIO); | 618 | __blk_end_request_all(req, -EOPNOTSUPP); |
| 617 | continue; | 619 | continue; |
| 618 | } | 620 | } |
| 619 | 621 | ||
