[PATCH v4 07/18] block/reqlist: reqlist_find_conflict(): use ranges_overlap()

Vladimir Sementsov-Ogievskiy posted 18 patches 3 years, 11 months ago
Maintainers: Wen Congyang <wencongyang2@huawei.com>, Markus Armbruster <armbru@redhat.com>, John Snow <jsnow@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Xie Changlong <xiechanglong.d@gmail.com>, Eric Blake <eblake@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>, Hanna Reitz <hreitz@redhat.com>, Fam Zheng <fam@euphon.net>
There is a newer version of this series
[PATCH v4 07/18] block/reqlist: reqlist_find_conflict(): use ranges_overlap()
Posted by Vladimir Sementsov-Ogievskiy 3 years, 11 months ago
Let's reuse convenient helper.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/reqlist.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/reqlist.c b/block/reqlist.c
index 5e320ba649..09fecbd48c 100644
--- a/block/reqlist.c
+++ b/block/reqlist.c
@@ -13,6 +13,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/range.h"
 
 #include "block/reqlist.h"
 
@@ -35,7 +36,7 @@ BlockReq *reqlist_find_conflict(BlockReqList *reqs, int64_t offset,
     BlockReq *r;
 
     QLIST_FOREACH(r, reqs, list) {
-        if (offset + bytes > r->offset && offset < r->offset + r->bytes) {
+        if (ranges_overlap(offset, bytes, r->offset, r->bytes)) {
             return r;
         }
     }
-- 
2.31.1


Re: [PATCH v4 07/18] block/reqlist: reqlist_find_conflict(): use ranges_overlap()
Posted by Hanna Reitz 3 years, 11 months ago
On 16.02.22 20:46, Vladimir Sementsov-Ogievskiy wrote:
> Let's reuse convenient helper.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   block/reqlist.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Hanna Reitz <hreitz@redhat.com>