xen/blkfront: improve protection against issuing unsupported REQ_FUA
Subsystems (3)
PATCH 1/1 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.
--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/block/xen-blkfront.c +8 -6
@@ -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 ; }
Signature · 1 line
1.9.3
Quoted 45 lines · Vitaly Kuznetsov
Guard against issuing unsupported
REQ_FUAandREQ_FLUSHwas introduced ind11e61583and was factored out intoblkif_request_flush_valid()in0f1ca65ee. However:
1) This check in incomplete. In case we negotiated tofeature_flush=REQ_FLUSHandflush_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) Whenblkif_request_flush_valid()fails-EIOis being returned. It seems that-EOPNOTSUPPis 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 <[email protected]>--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/block/xen-blkfront.c +6
-4@@ -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 ))); }/*
drivers/block/xen-blkfront.c static void do_blkif_request(struct request_queue *rq) · line 621
Quoted 10 lines
drivers/block/xen-blkfront.c +2
-2@@ -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 ; }
Not sure if there has been some feedback yet (I can't see anything threaded with this message in my inbox).
FWIW I consulted "Documentation/block/writeback_cache_control.txt" for this review. Apparently, REQ_FLUSH forces out "previously completed write requests", whereas REQ_FUA delays the IO completion signal for *this* request until "the data has been committed to non-volatile storage". So, indeed, support for REQ_FLUSH only does not guarantee that REQ_FUA can be served.
Thanks
Laszlo
Quoted 45 lines · Vitaly Kuznetsov
Guard against issuing unsupported
REQ_FUAandREQ_FLUSHwas introduced ind11e61583and was factored out intoblkif_request_flush_valid()in0f1ca65ee. However:
1) This check in incomplete. In case we negotiated tofeature_flush=REQ_FLUSHandflush_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) Whenblkif_request_flush_valid()fails-EIOis being returned. It seems that-EOPNOTSUPPis 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 <[email protected]>--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/block/xen-blkfront.c +6
-4@@ -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 ))); }/*
drivers/block/xen-blkfront.c static void do_blkif_request(struct request_queue *rq) · line 621
Quoted 10 lines
drivers/block/xen-blkfront.c +2
-2@@ -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 ; }
Not sure if there has been some feedback yet (I can't see anything threaded with this message in my inbox).
FWIW I consulted "Documentation/block/writeback_cache_control.txt" for this review. Apparently, REQ_FLUSH forces out "previously completed write requests", whereas REQ_FUA delays the IO completion signal for *this* request until "the data has been committed to non-volatile storage". So, indeed, support for REQ_FLUSH only does not guarantee that REQ_FUA can be served.
Thanks
Laszlo
Quoted 29 lines · Laszlo Ersek
Quoted 28 lines · Vitaly Kuznetsov
Guard against issuing unsupported
REQ_FUAandREQ_FLUSHwas introduced ind11e61583and was factored out intoblkif_request_flush_valid()in0f1ca65ee. However:
1) This check in incomplete. In case we negotiated tofeature_flush=REQ_FLUSHandflush_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) Whenblkif_request_flush_valid()fails-EIOis being returned. It seems that-EOPNOTSUPPis 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 <[email protected]>--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/block/xen-blkfront.c +0
-0@@ -582,12 +582,14 @@ static inline void flush_requests(struct blkfront_info *info)notify_remote_via_irq (info->irq); }
Quoted 12 lines
drivers/block/xen-blkfront.c static inline void flush_requests(struct blkfront_info *info) · line 592
Quoted 12 lines
drivers/block/xen-blkfront.c +6
-4-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 )));
Somewhat unrelated to the patch, but I am wondering whether we actually need flush_op field at all as it seems that it is unambiguously defined by REQ_FLUSH/REQ_FUA.
-boris
Quoted 29 lines
Quoted 5 lines
drivers/block/xen-blkfront.c +0
-0}/* drivers/block/xen-blkfront.c static void do_blkif_request(struct request_queue *rq) · line 621
Quoted 10 lines
drivers/block/xen-blkfront.c +2
-2@@ -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 ; }Not sure if there has been some feedback yet (I can't see anything threaded with this message in my inbox).
FWIW I consulted "
Documentation/block/writeback_cache_control.txt" for this review. Apparently,REQ_FLUSHforces out "previously completed write requests", whereasREQ_FUAdelays the IO completion signal for *this* request until "the data has been committed to non-volatile storage". So, indeed, support forREQ_FLUSHonly does not guarantee thatREQ_FUAcan be served.Reviewed-by Laszlo Ersek <[email protected]>Thanks
Laszlo
Quoted 29 lines · Laszlo Ersek
Quoted 28 lines · Vitaly Kuznetsov
Guard against issuing unsupported
REQ_FUAandREQ_FLUSHwas introduced ind11e61583and was factored out intoblkif_request_flush_valid()in0f1ca65ee. However:
1) This check in incomplete. In case we negotiated tofeature_flush=REQ_FLUSHandflush_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) Whenblkif_request_flush_valid()fails-EIOis being returned. It seems that-EOPNOTSUPPis 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 <[email protected]>--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/block/xen-blkfront.c +0
-0@@ -582,12 +582,14 @@ static inline void flush_requests(struct blkfront_info *info)notify_remote_via_irq (info->irq); }
Quoted 12 lines
drivers/block/xen-blkfront.c static inline void flush_requests(struct blkfront_info *info) · line 592
Quoted 12 lines
drivers/block/xen-blkfront.c +6
-4-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 )));
Somewhat unrelated to the patch, but I am wondering whether we actually need flush_op field at all as it seems that it is unambiguously defined by REQ_FLUSH/REQ_FUA.
-boris
Quoted 29 lines
Quoted 5 lines
drivers/block/xen-blkfront.c +0
-0}/* drivers/block/xen-blkfront.c static void do_blkif_request(struct request_queue *rq) · line 621
Quoted 10 lines
drivers/block/xen-blkfront.c +2
-2@@ -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 ; }Not sure if there has been some feedback yet (I can't see anything threaded with this message in my inbox).
FWIW I consulted "
Documentation/block/writeback_cache_control.txt" for this review. Apparently,REQ_FLUSHforces out "previously completed write requests", whereasREQ_FUAdelays the IO completion signal for *this* request until "the data has been committed to non-volatile storage". So, indeed, support forREQ_FLUSHonly does not guarantee thatREQ_FUAcan be served.Reviewed-by Laszlo Ersek <[email protected]>Thanks
Laszlo
Quoted 38 lines · Boris Ostrovsky
Quoted 37 lines · Laszlo Ersek
Quoted 36 lines · Vitaly Kuznetsov
Guard against issuing unsupported
REQ_FUAandREQ_FLUSHwas introduced ind11e61583and was factored out intoblkif_request_flush_valid()in0f1ca65ee. However:
1) This check in incomplete. In case we negotiated tofeature_flush=REQ_FLUSHandflush_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) Whenblkif_request_flush_valid()fails-EIOis being returned. It seems that-EOPNOTSUPPis 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 <[email protected]>--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/block/xen-blkfront.c +2
-3@@ -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));
Quoted 8 lines
Quoted 4 lines
drivers/block/xen-blkfront.c static inline void flush_requests(struct blkfront_info *info) · line 592
Quoted 4 lines
drivers/block/xen-blkfront.c +4
-0+ ((req->cmd_flags &REQ_FLUSH ) && + !(info->feature_flush &REQ_FLUSH )) || + ((req->cmd_flags &REQ_FUA ) && + !(info->feature_flush & REQ_FUA)));Somewhat unrelated to the patch, but I am wondering whether we actually need
flush_opfield at all as it seems that it is unambiguously defined by REQ_FLUSH/REQ_FUA.
I was under an impression it was added for readability sake but we definitely can remove it. If noone objects I'll send separate cleanup patch (don't want to mix these two).
Quoted 29 lines
-boris
Quoted 26 lines
drivers/block/xen-blkfront.c static void do_blkif_request(struct request_queue *rq) · line 621
Quoted 12 lines
drivers/block/xen-blkfront.c +2
-1}/* @@ -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 ; }Not sure if there has been some feedback yet (I can't see anything threaded with this message in my inbox).
FWIW I consulted "
Documentation/block/writeback_cache_control.txt" for this review. Apparently,REQ_FLUSHforces out "previously completed write requests", whereasREQ_FUAdelays the IO completion signal for *this* request until "the data has been committed to non-volatile storage". So, indeed, support forREQ_FLUSHonly does not guarantee thatREQ_FUAcan be served.Reviewed-by Laszlo Ersek <[email protected]>Thanks
Laszlo
Signature · 1 line
Vitaly
Quoted 38 lines · Boris Ostrovsky
Quoted 37 lines · Laszlo Ersek
Quoted 36 lines · Vitaly Kuznetsov
Guard against issuing unsupported
REQ_FUAandREQ_FLUSHwas introduced ind11e61583and was factored out intoblkif_request_flush_valid()in0f1ca65ee. However:
1) This check in incomplete. In case we negotiated tofeature_flush=REQ_FLUSHandflush_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) Whenblkif_request_flush_valid()fails-EIOis being returned. It seems that-EOPNOTSUPPis 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 <[email protected]>--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/block/xen-blkfront.c +2
-3@@ -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));
Quoted 8 lines
Quoted 4 lines
drivers/block/xen-blkfront.c static inline void flush_requests(struct blkfront_info *info) · line 592
Quoted 4 lines
drivers/block/xen-blkfront.c +4
-0+ ((req->cmd_flags &REQ_FLUSH ) && + !(info->feature_flush &REQ_FLUSH )) || + ((req->cmd_flags &REQ_FUA ) && + !(info->feature_flush & REQ_FUA)));Somewhat unrelated to the patch, but I am wondering whether we actually need
flush_opfield at all as it seems that it is unambiguously defined by REQ_FLUSH/REQ_FUA.
I was under an impression it was added for readability sake but we definitely can remove it. If noone objects I'll send separate cleanup patch (don't want to mix these two).
Quoted 29 lines
-boris
Quoted 26 lines
drivers/block/xen-blkfront.c static void do_blkif_request(struct request_queue *rq) · line 621
Quoted 12 lines
drivers/block/xen-blkfront.c +2
-1}/* @@ -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 ; }Not sure if there has been some feedback yet (I can't see anything threaded with this message in my inbox).
FWIW I consulted "
Documentation/block/writeback_cache_control.txt" for this review. Apparently,REQ_FLUSHforces out "previously completed write requests", whereasREQ_FUAdelays the IO completion signal for *this* request until "the data has been committed to non-volatile storage". So, indeed, support forREQ_FLUSHonly does not guarantee thatREQ_FUAcan be served.Reviewed-by Laszlo Ersek <[email protected]>Thanks
Laszlo
Signature · 1 line
Vitaly
PATCH RESEND 1/1 xen/blkfront: improve protection against issuing unsupported REQ_FUA
In reply to Vitaly KuznetsovGuard 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.
--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/block/xen-blkfront.c +8 -6
@@ -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 ; }
Signature · 1 line
1.9.3
Quoted 12 lines · Vitaly Kuznetsov
Guard against issuing unsupported
REQ_FUAandREQ_FLUSHwas introduced ind11e61583and was factored out intoblkif_request_flush_valid()in0f1ca65ee. However:
1) This check in incomplete. In case we negotiated tofeature_flush=REQ_FLUSHandflush_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) Whenblkif_request_flush_valid()fails-EIOis being returned. It seems that-EOPNOTSUPPis more appropriate here.
Fix all of the above issues.
Quoted 5 lines
This patch is based on the original patch by Laszlo Ersek and a comment by Jeff Moyer.
Signed-off-by Vitaly Kuznetsov <[email protected]>Reviewed-by Laszlo Ersek <[email protected]>
(although, as I mentioned last time, a companion patch to remove flush_op would be a good thing to have)
-boris
Quoted 38 lines
--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/block/xen-blkfront.c +8
-6@@ -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 ; }
Quoted 12 lines · Vitaly Kuznetsov
Guard against issuing unsupported
REQ_FUAandREQ_FLUSHwas introduced ind11e61583and was factored out intoblkif_request_flush_valid()in0f1ca65ee. However:
1) This check in incomplete. In case we negotiated tofeature_flush=REQ_FLUSHandflush_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) Whenblkif_request_flush_valid()fails-EIOis being returned. It seems that-EOPNOTSUPPis more appropriate here.
Fix all of the above issues.
Quoted 5 lines
This patch is based on the original patch by Laszlo Ersek and a comment by Jeff Moyer.
Signed-off-by Vitaly Kuznetsov <[email protected]>Reviewed-by Laszlo Ersek <[email protected]>
(although, as I mentioned last time, a companion patch to remove flush_op would be a good thing to have)
-boris
Quoted 38 lines
--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/block/xen-blkfront.c +8
-6@@ -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 ; }
Quoted 16 lines · Boris Ostrovsky
Quoted 15 lines · Vitaly Kuznetsov
Guard against issuing unsupported
REQ_FUAandREQ_FLUSHwas introduced ind11e61583and was factored out intoblkif_request_flush_valid()in0f1ca65ee. However:
1) This check in incomplete. In case we negotiated tofeature_flush=REQ_FLUSHandflush_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) Whenblkif_request_flush_valid()fails-EIOis being returned. It seems that-EOPNOTSUPPis 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.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Vitaly Kuznetsov <[email protected]>Reviewed-by Laszlo Ersek <[email protected]>Reviewed-by Boris Ostrovsky <[email protected]>(although, as I mentioned last time, a companion patch to remove
flush_opwould be a good thing to have)
Thanks, it is on my todo list but I'm trying to separate this (potential) bugfix from straight cleanup.
Quoted 36 lines
-boris
Quoted 34 lines
--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/block/xen-blkfront.c +8
-4@@ -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 ; }
Signature · 1 line
Vitaly
Quoted 16 lines · Boris Ostrovsky
Quoted 15 lines · Vitaly Kuznetsov
Guard against issuing unsupported
REQ_FUAandREQ_FLUSHwas introduced ind11e61583and was factored out intoblkif_request_flush_valid()in0f1ca65ee. However:
1) This check in incomplete. In case we negotiated tofeature_flush=REQ_FLUSHandflush_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) Whenblkif_request_flush_valid()fails-EIOis being returned. It seems that-EOPNOTSUPPis 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.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Vitaly Kuznetsov <[email protected]>Reviewed-by Laszlo Ersek <[email protected]>Reviewed-by Boris Ostrovsky <[email protected]>(although, as I mentioned last time, a companion patch to remove
flush_opwould be a good thing to have)
Thanks, it is on my todo list but I'm trying to separate this (potential) bugfix from straight cleanup.
Quoted 36 lines
-boris
Quoted 34 lines
--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/block/xen-blkfront.c +8
-4@@ -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 ; }
Signature · 1 line
Vitaly
PATCH RESEND 1/1 xen/blkfront: improve protection against issuing unsupported REQ_FUA
In reply to Vitaly KuznetsovGuard 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.
--- drivers/block/xen-blkfront.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/block/xen-blkfront.c +8 -6
@@ -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 ; }
Signature · 1 line
1.9.3