From patchwork Thu Aug 25 13:44:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Butsykin X-Patchwork-Id: 9299421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0140760757 for ; Thu, 25 Aug 2016 14:05:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E620629323 for ; Thu, 25 Aug 2016 14:05:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAE5F2934E; Thu, 25 Aug 2016 14:05:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F2B1B29323 for ; Thu, 25 Aug 2016 14:05:43 +0000 (UTC) Received: from localhost ([::1]:56482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcvHr-0005U0-5R for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Aug 2016 10:05:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcvD7-0001c9-AR for qemu-devel@nongnu.org; Thu, 25 Aug 2016 10:00:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcvD5-0006uw-GH for qemu-devel@nongnu.org; Thu, 25 Aug 2016 10:00:49 -0400 Received: from mail-db5eur01on0100.outbound.protection.outlook.com ([104.47.2.100]:19441 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcvCy-0006rC-3l; Thu, 25 Aug 2016 10:00:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/uiGmJphTOHfU8Aa7qj9d1pDCr2hYZAwk7U+fkMPYW0=; b=Er6WUFEApbc/q/IaCToqx3fJfJ+ziK8WCnUwWoyC8wvBzIZsrwxGHYwZyAsjI7ioqXMp3lypeh04KMt8g4wCGuFASlxYjuhIhYxaYSnPxzMg1H43ysyuolEdPFPwnjrWdW49gVpYFepNYCn+JRLPvJGz4Mip5XyhGM76eRPRjoY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pbutsykin@virtuozzo.com; Received: from pavelb-Z68P-DS3.sw.ru (195.214.232.10) by DB6PR0802MB2549.eurprd08.prod.outlook.com (10.172.251.147) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.9; Thu, 25 Aug 2016 13:45:31 +0000 From: Pavel Butsykin To: , Date: Thu, 25 Aug 2016 16:44:04 +0300 Message-ID: <20160825134421.20231-6-pbutsykin@virtuozzo.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160825134421.20231-1-pbutsykin@virtuozzo.com> References: <20160825134421.20231-1-pbutsykin@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AMSPR02CA0013.eurprd02.prod.outlook.com (10.242.225.141) To DB6PR0802MB2549.eurprd08.prod.outlook.com (10.172.251.147) X-MS-Office365-Filtering-Correlation-Id: b7ad83ca-c01f-480a-1cea-08d3ccee153b X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2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dRLRuTgplOqVE=; 4:AIw718/CYbnL1pQQtB02GQQxbI4jTfZo9rws09NdOt3ut/P3pgilawmqX3mCreKz6O0uE/7sJppt6MPjF2wJFGi1vixeTeY1PjXhUuy7Eouj9nNkX/bYD7ftqL8OQo098fsUDSYMLRDw6b4reMy4bakrmQ2OV7Az97zYeXTU9V0QjTKZU+lcGr4clEgLu5lS5juZfJAZCgDXdFJoEd5Cukk7xfUbIxo2trPZXZHCh7SsLUNTX4bSV9FLBxbH94YfXtQFzqe/6l2+Q70Bbh8TXMY1Q8DkuN951qID9rO9lzRaLiyx7mbj5Fx82k/CzDX9qPBzjrsvu7XwvscCHNcbHIIBkaBlEMA+mehO77ejgTahE/DDDuYLbEeTaj8i1108ETOQxCoYXjRQ8R6uATCRL/F2pSB9bt8eeMbvf2DGYQk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6043046)(6042046); SRVR:DB6PR0802MB2549; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0802MB2549; X-Forefront-PRVS: 0045236D47 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(86362001)(33646002)(1076002)(69596002)(5003940100001)(42186005)(68736007)(189998001)(92566002)(66066001)(106356001)(47776003)(6116002)(3846002)(586003)(36756003)(5001770100001)(97736004)(2906002)(4326007)(2950100001)(5660300001)(76176999)(48376002)(53416004)(105586002)(50466002)(81156014)(8676002)(50226002)(77096005)(81166006)(19580405001)(50986999)(229853001)(101416001)(7846002)(7736002)(305945005)(19580395003)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0802MB2549; H:pavelb-Z68P-DS3.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts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J7HH4ndXXeCXx9F+kpczjknAUvrJu+ZHL/UBdW9bOl4b7KIkbGin2ijNUnhRqRxrw02PImzR/rSDWb+vLk6F+sGXOQrmltAzrkh57jb195yotYsBMPERrf44UQ8dzu8+bkzcysunMv6PKPkVA/VtPWHKdB3khwmhjGl+iIMnS60nvqg9Qk0WS317ZVRPLlY9eG+vvE8obOhb2jP7fFf4GRnTov+peC9/Ps9aBa0gKMR7S9vUJYzBfpFN5l8SB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2549; 20:9cqasJ4FAIBYP6pkdaYgLzrScG7FXGxI/QPQsYR6ZjRJMe7c4iwHZPHvzsNAEG6ojY6Q4pZo3WCGhOTZcqk12usfY4iJAUFYCLVfbR8/yCicxdWFpLALRVFP2/acBnjPxYkWEfSRgJlTIvYLVEeNIvdRsmXd9cUlEQrPJyXM9vQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2016 13:45:31.3044 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2549 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.2.100 Subject: [Qemu-devel] [PATCH RFC 05/22] block/pcache: add aio requests into cache X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, den@openvz.org, jsnow@redhat.com, stefanha@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP For storing requests use an rbtree, here are add basic operations on the rbtree to work with cache nodes. Signed-off-by: Pavel Butsykin --- block/pcache.c | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 189 insertions(+), 1 deletion(-) diff --git a/block/pcache.c b/block/pcache.c index 7f221d6..f5022f9 100644 --- a/block/pcache.c +++ b/block/pcache.c @@ -27,6 +27,7 @@ #include "block/raw-aio.h" #include "qapi/error.h" #include "qapi/qmp/qstring.h" +#include "qemu/rbtree.h" #define PCACHE_DEBUG @@ -37,9 +38,53 @@ #define DPRINTF(fmt, ...) do { } while (0) #endif +typedef struct RbNodeKey { + uint64_t num; + uint32_t size; +} RbNodeKey; + +typedef struct BlockNode { + struct RbNode rb_node; + union { + RbNodeKey key; + struct { + uint64_t sector_num; + uint32_t nb_sectors; + }; + }; + QTAILQ_ENTRY(BlockNode) entry; +} BlockNode; + +typedef struct PCNode { + BlockNode cm; + + uint8_t *data; +} PCNode; + +typedef struct ReqStor { + struct { + struct RbRoot root; + CoMutex lock; + } tree; + + uint32_t curr_size; +} ReqStor; + +typedef struct BDRVPCacheState { + BlockDriverState **bs; + + ReqStor pcache; + + struct { + QTAILQ_HEAD(pcache_head, BlockNode) head; + CoMutex lock; + } list; +} BDRVPCacheState; + typedef struct PrefCacheAIOCB { BlockAIOCB common; + BDRVPCacheState *s; QEMUIOVector *qiov; uint64_t sector_num; uint32_t nb_sectors; @@ -64,6 +109,124 @@ static QemuOptsList runtime_opts = { }, }; +#define PCNODE(_n) ((PCNode *)(_n)) + +static int pcache_key_cmp(const RbNodeKey *key1, const RbNodeKey *key2) +{ + assert(key1 != NULL); + assert(key2 != NULL); + + if (key1->num >= key2->num + key2->size) { + return 1; + } + if (key1->num + key1->size <= key2->num) { + return -1; + } + + return 0; +} + +static void *node_insert(struct RbRoot *root, BlockNode *node) +{ + struct RbNode **new = &(root->rb_node), *parent = NULL; + + /* Figure out where to put new node */ + while (*new) { + BlockNode *this = container_of(*new, BlockNode, rb_node); + int result = pcache_key_cmp(&node->key, &this->key); + if (result == 0) { + return this; + } + parent = *new; + new = result < 0 ? &((*new)->rb_left) : &((*new)->rb_right); + } + /* Add new node and rebalance tree. */ + rb_link_node(&node->rb_node, parent, new); + rb_insert_color(&node->rb_node, root); + + return node; +} + +static inline PCNode *pcache_node_insert(struct RbRoot *root, PCNode *node) +{ + return node_insert(root, &node->cm); +} + +static inline void pcache_node_free(PCNode *node) +{ + g_free(node->data); + g_slice_free1(sizeof(*node), node); +} + +static inline void *pcache_node_alloc(RbNodeKey* key) +{ + PCNode *node = g_slice_alloc(sizeof(*node)); + + node->cm.sector_num = key->num; + node->cm.nb_sectors = key->size; + node->data = g_malloc(node->cm.nb_sectors << BDRV_SECTOR_BITS); + + return node; +} + +static bool pcache_node_find_and_create(PrefCacheAIOCB *acb, RbNodeKey *key, + PCNode **out_node) +{ + BDRVPCacheState *s = acb->s; + PCNode *new_node = pcache_node_alloc(key); + PCNode *found; + + qemu_co_mutex_lock(&s->pcache.tree.lock); + found = pcache_node_insert(&s->pcache.tree.root, new_node); + qemu_co_mutex_unlock(&s->pcache.tree.lock); + if (found != new_node) { + pcache_node_free(new_node); + *out_node = found; + return false; + } + atomic_add(&s->pcache.curr_size, new_node->cm.nb_sectors); + + qemu_co_mutex_lock(&s->list.lock); + QTAILQ_INSERT_HEAD(&s->list.head, &new_node->cm, entry); + qemu_co_mutex_unlock(&s->list.lock); + + *out_node = new_node; + return true; +} + +static inline void prefetch_init_key(PrefCacheAIOCB *acb, RbNodeKey* key) +{ + key->num = acb->sector_num; + key->size = acb->nb_sectors; +} + +enum { + PREFETCH_NEW_NODE = 0, + PREFETCH_FULL_UP = 1, + PREFETCH_PART_UP = 2 +}; + +static int32_t pcache_prefetch(PrefCacheAIOCB *acb) +{ + RbNodeKey key; + PCNode *node = NULL; + + prefetch_init_key(acb, &key); + if (pcache_node_find_and_create(acb, &key, &node)) { + return PREFETCH_NEW_NODE; + } + + /* Node covers the whole request */ + if (node->cm.sector_num <= acb->sector_num && + node->cm.sector_num + node->cm.nb_sectors >= acb->sector_num + + acb->nb_sectors) + { + return PREFETCH_FULL_UP; + } + + return PREFETCH_PART_UP; +} + static void pcache_aio_cb(void *opaque, int ret) { PrefCacheAIOCB *acb = opaque; @@ -80,6 +243,7 @@ static PrefCacheAIOCB *pcache_aio_get(BlockDriverState *bs, int64_t sector_num, { PrefCacheAIOCB *acb = qemu_aio_get(&pcache_aiocb_info, bs, cb, opaque); + acb->s = bs->opaque; acb->sector_num = sector_num; acb->nb_sectors = nb_sectors; acb->qiov = qiov; @@ -99,6 +263,8 @@ static BlockAIOCB *pcache_aio_readv(BlockDriverState *bs, PrefCacheAIOCB *acb = pcache_aio_get(bs, sector_num, qiov, nb_sectors, cb, opaque, QEMU_AIO_READ); + pcache_prefetch(acb); + bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, pcache_aio_cb, acb); return &acb->common; @@ -119,6 +285,17 @@ static BlockAIOCB *pcache_aio_writev(BlockDriverState *bs, return &acb->common; } +static void pcache_state_init(QemuOpts *opts, BDRVPCacheState *s) +{ + DPRINTF("pcache configure:\n"); + + s->pcache.tree.root = RB_ROOT; + qemu_co_mutex_init(&s->pcache.tree.lock); + QTAILQ_INIT(&s->list.head); + qemu_co_mutex_init(&s->list.lock); + s->pcache.curr_size = 0; +} + static int pcache_file_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { @@ -140,7 +317,9 @@ static int pcache_file_open(BlockDriverState *bs, QDict *options, int flags, if (local_err) { ret = -EINVAL; error_propagate(errp, local_err); + goto fail; } + pcache_state_init(opts, bs->opaque); fail: qemu_opts_del(opts); return ret; @@ -148,6 +327,15 @@ fail: static void pcache_close(BlockDriverState *bs) { + uint32_t cnt = 0; + BDRVPCacheState *s = bs->opaque; + BlockNode *node, *next; + QTAILQ_FOREACH_SAFE(node, &s->list.head, entry, next) { + QTAILQ_REMOVE(&s->list.head, node, entry); + pcache_node_free(PCNODE(node)); + cnt++; + } + DPRINTF("used %d nodes\n", cnt); } static void pcache_parse_filename(const char *filename, QDict *options, @@ -170,7 +358,7 @@ static bool pcache_recurse_is_first_non_filter(BlockDriverState *bs, static BlockDriver bdrv_pcache = { .format_name = "pcache", .protocol_name = "pcache", - .instance_size = 0, + .instance_size = sizeof(BDRVPCacheState), .bdrv_parse_filename = pcache_parse_filename, .bdrv_file_open = pcache_file_open,