mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-26 14:20:50 +07:00
xen/blkfront: improve protection against issuing unsupported REQ_FUA
Guard against issuing unsupported REQ_FUA and REQ_FLUSH was introduced ind11e61583
and was factored out into blkif_request_flush_valid() in0f1ca65ee
. 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>
This commit is contained in:
parent
9af8785a38
commit
ad42d391ae
@ -582,12 +582,14 @@ static inline void flush_requests(struct blkfront_info *info)
|
||||
notify_remote_via_irq(info->irq);
|
||||
}
|
||||
|
||||
static inline bool blkif_request_flush_valid(struct request *req,
|
||||
struct blkfront_info *info)
|
||||
static inline bool blkif_request_flush_invalid(struct request *req,
|
||||
struct blkfront_info *info)
|
||||
{
|
||||
return ((req->cmd_type != REQ_TYPE_FS) ||
|
||||
((req->cmd_flags & (REQ_FLUSH | REQ_FUA)) &&
|
||||
!info->flush_op));
|
||||
((req->cmd_flags & REQ_FLUSH) &&
|
||||
!(info->feature_flush & REQ_FLUSH)) ||
|
||||
((req->cmd_flags & REQ_FUA) &&
|
||||
!(info->feature_flush & REQ_FUA)));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -612,8 +614,8 @@ static void do_blkif_request(struct request_queue *rq)
|
||||
|
||||
blk_start_request(req);
|
||||
|
||||
if (blkif_request_flush_valid(req, info)) {
|
||||
__blk_end_request_all(req, -EIO);
|
||||
if (blkif_request_flush_invalid(req, info)) {
|
||||
__blk_end_request_all(req, -EOPNOTSUPP);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user