Received: by 10.192.165.156 with SMTP id m28csp66183imm; Tue, 10 Apr 2018 16:32:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/zeRUvF5jnuIBPlUloGGF+f/bZQkNXVIUHij403TlJWPQC6mK2oz+i3jP+H7YT8GPTnxRT X-Received: by 2002:a17:902:206:: with SMTP id 6-v6mr2465799plc.376.1523403140900; Tue, 10 Apr 2018 16:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523403140; cv=none; d=google.com; s=arc-20160816; b=no3UdsTXLOph5GpYp3OD4jzoDLFo37wvy4Gbes7/TuF+CzitAf4pXDd6654f1/IX+V iz1yltEowedmj04FuLvjIoGLC3pROvAyA4qMTFAOiUxq46PKmDdB2eX13Dt1+SbJEeuQ yIZ0RiM/saLivh/HZAiCCJaL8BjlouwOb4lHPNtvhUWhg7iWTuLuyO9LGjSCr2ZohnVw C6n3Z2pE7jTZVR/2yZQZ13L2ySJOYP3exn8bz08RbdeW79vEb1B/tQGHuuvMu9WTO2sj xEimuwsbelrrSk+73vgcrNOr+3JL4o4XVjCJWAfdIYgpjlqdX5x2dol3wSnJVJtpsi1v 8Hyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8In49jJwn31I/o/8iQCwOFJiEfMlLipXff47myKEqqM=; b=B4Bme/LCQVC1eI8DWhiSLW5a9zMUXGkxAkFdmyaAmHnkWz0USxui/yjtkZvdtS3qOY ELLbojT5pPRRBnIbNUl5tYZVwOvagnqs6pAgdfVj7eYzg+c1cqz0JS3tqdeI5DuL4nXS z+P436FkB/6ueqg0s/bDC3E14Ggy+I7nrywNYmcQMLE1R6+7LFnFF9nmlMcDOuhyfzhb tuadDg4rKLThP+eTye2UzRD/tk8wDnsXsevT8rZHXDr9jv8aRz2RCUOg4+w++jeyCTFY R3u4wc13lGgJitZbKmLNopqsLuePaz2Stj53rUeZ++vh2WFk8s4y/cc/k+168wF/I/+J LO5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p88si2880247pfk.134.2018.04.10.16.31.44; Tue, 10 Apr 2018 16:32:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754445AbeDJW37 (ORCPT + 99 others); Tue, 10 Apr 2018 18:29:59 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39768 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754410AbeDJW3z (ORCPT ); Tue, 10 Apr 2018 18:29:55 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1C351D4F; Tue, 10 Apr 2018 22:29:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tang Junhui , Michael Lyle , Jens Axboe , Sasha Levin Subject: [PATCH 4.15 074/168] bcache: segregate flash only volume write streams Date: Wed, 11 Apr 2018 00:23:36 +0200 Message-Id: <20180410212803.372546299@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tang Junhui [ Upstream commit 4eca1cb28d8b0574ca4f1f48e9331c5f852d43b9 ] In such scenario that there are some flash only volumes , and some cached devices, when many tasks request these devices in writeback mode, the write IOs may fall to the same bucket as bellow: | cached data | flash data | cached data | cached data| flash data| then after writeback of these cached devices, the bucket would be like bellow bucket: | free | flash data | free | free | flash data | So, there are many free space in this bucket, but since data of flash only volumes still exists, so this bucket cannot be reclaimable, which would cause waste of bucket space. In this patch, we segregate flash only volume write streams from cached devices, so data from flash only volumes and cached devices can store in different buckets. Compare to v1 patch, this patch do not add a additionally open bucket list, and it is try best to segregate flash only volume write streams from cached devices, sectors of flash only volumes may still be mixed with dirty sectors of cached device, but the number is very small. [mlyle: fixed commit log formatting, permissions, line endings] Signed-off-by: Tang Junhui Reviewed-by: Michael Lyle Signed-off-by: Michael Lyle Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/md/bcache/alloc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c @@ -525,15 +525,21 @@ struct open_bucket { /* * We keep multiple buckets open for writes, and try to segregate different - * write streams for better cache utilization: first we look for a bucket where - * the last write to it was sequential with the current write, and failing that - * we look for a bucket that was last used by the same task. + * write streams for better cache utilization: first we try to segregate flash + * only volume write streams from cached devices, secondly we look for a bucket + * where the last write to it was sequential with the current write, and + * failing that we look for a bucket that was last used by the same task. * * The ideas is if you've got multiple tasks pulling data into the cache at the * same time, you'll get better cache utilization if you try to segregate their * data and preserve locality. * - * For example, say you've starting Firefox at the same time you're copying a + * For example, dirty sectors of flash only volume is not reclaimable, if their + * dirty sectors mixed with dirty sectors of cached device, such buckets will + * be marked as dirty and won't be reclaimed, though the dirty data of cached + * device have been written back to backend device. + * + * And say you've starting Firefox at the same time you're copying a * bunch of files. Firefox will likely end up being fairly hot and stay in the * cache awhile, but the data you copied might not be; if you wrote all that * data to the same buckets it'd get invalidated at the same time. @@ -550,7 +556,10 @@ static struct open_bucket *pick_data_buc struct open_bucket *ret, *ret_task = NULL; list_for_each_entry_reverse(ret, &c->data_buckets, list) - if (!bkey_cmp(&ret->key, search)) + if (UUID_FLASH_ONLY(&c->uuids[KEY_INODE(&ret->key)]) != + UUID_FLASH_ONLY(&c->uuids[KEY_INODE(search)])) + continue; + else if (!bkey_cmp(&ret->key, search)) goto found; else if (ret->last_write_point == write_point) ret_task = ret;