[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 02/11] block/reqlist: add reqlist_new_req() and reqlist_free_r
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v7 02/11] block/reqlist: add reqlist_new_req() and reqlist_free_req() |
Date: |
Sat, 4 Sep 2021 19:24:19 +0300 |
Add convenient helpers for heap allocation of requests.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
include/block/reqlist.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/block/reqlist.h b/include/block/reqlist.h
index b904d80216..32dc87666f 100644
--- a/include/block/reqlist.h
+++ b/include/block/reqlist.h
@@ -64,4 +64,24 @@ void coroutine_fn reqlist_shrink_req(BlockReq *req, int64_t
new_bytes);
*/
void coroutine_fn reqlist_remove_req(BlockReq *req);
+/* Allocate, initialize and add to the list new request. */
+static inline BlockReq *reqlist_new_req(BlockReqList *reqs, uint64_t offset,
+ uint64_t bytes)
+{
+ BlockReq *req = g_new(BlockReq, 1);
+
+ reqlist_init_req(reqs, req, offset, bytes);
+
+ return req;
+}
+
+/* Remove request and g_free it. */
+static inline void reqlist_free_req(BlockReq *req)
+{
+ if (req) {
+ reqlist_remove_req(req);
+ g_free(req);
+ }
+}
+
#endif /* REQLIST_H */
--
2.29.2
- [PATCH v7 00/11] qcow2: fix parallel rewrite and discard (reqlist), Vladimir Sementsov-Ogievskiy, 2021/09/04
- [PATCH v7 02/11] block/reqlist: add reqlist_new_req() and reqlist_free_req(),
Vladimir Sementsov-Ogievskiy <=
- [PATCH v7 01/11] block/reqlist: drop extra assertion, Vladimir Sementsov-Ogievskiy, 2021/09/04
- [PATCH v7 03/11] iotests: add qcow2-discard-during-rewrite, Vladimir Sementsov-Ogievskiy, 2021/09/04
- [PATCH v7 04/11] qcow2: introduce qcow2_parse_compressed_cluster_descriptor(), Vladimir Sementsov-Ogievskiy, 2021/09/04
- [PATCH v7 05/11] qcow2: refactor qcow2_co_preadv_task() to have one return, Vladimir Sementsov-Ogievskiy, 2021/09/04
- [PATCH v7 06/11] qcow2: prepare for tracking guest io requests in data_file, Vladimir Sementsov-Ogievskiy, 2021/09/04
- [PATCH v7 08/11] qcow2: introduce is_cluster_free() helper, Vladimir Sementsov-Ogievskiy, 2021/09/04
- [PATCH v7 07/11] qcow2: track guest io requests in data_file, Vladimir Sementsov-Ogievskiy, 2021/09/04
- [PATCH v7 10/11] block/reqlist: implement reqlist_mark_req_invalid(), Vladimir Sementsov-Ogievskiy, 2021/09/04
- [PATCH v7 09/11] qcow2: don't reallocate host clusters under guest operation, Vladimir Sementsov-Ogievskiy, 2021/09/04
- [PATCH v7 11/11] qcow2: use reqlist_mark_req_invalid(), Vladimir Sementsov-Ogievskiy, 2021/09/04