Received: by 10.213.65.68 with SMTP id h4csp1856775imn; Mon, 19 Mar 2018 15:23:20 -0700 (PDT) X-Google-Smtp-Source: AG47ELstGUpyuoAJcAPtUEFg69bTzJ2NUcgYXkQCID4UmNh9cMtSCsKPdFMu9gq6SQkVkz8OwkeO X-Received: by 10.99.122.80 with SMTP id j16mr10352219pgn.5.1521498200534; Mon, 19 Mar 2018 15:23:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521498200; cv=none; d=google.com; s=arc-20160816; b=twXXPgJVZIpaZJbDU9HXIFHpO+MXY3F0JuPqcpNDVip0WE4qiwIO9BthUazSV7WVdG yXB7wNX+B0zz+XlKuFK61MMWUMTXGoKROce3ofxeR7wvgjdSGi7mUPSEtDn16pbnkZrP /fGzwV9L6/JBAmpFHdcnB0ynChrvLMrVQkky+Myem7PLu8YJsJPRReUAdOSFONcFk4+N 5AfcKk7375bgbs80exo81kUGEFUOWwK3p3XudJZo0Ow4TLA/Iq5f31YfQkhEdFfnAX3T lNegYIc0beTfqwIsS+cPRP5BwzvE8KGLLz1XUP1lpz947zaFpyXlITWkh/gsGexNyU0C 4VwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=TEKTCpn3E7OBR1J6mwhPeHVsv/G1l5wDAJdeaxQXaA8=; b=yfQjMghZLk9vtUTxV/qbHgaMMNa8xZzG1y5Jsut09UPJ4tWM8YeyKiN+fSn6JNm3Sh ZJYx/uhwytu3Et8PkmXvM8PqrgDX+aqgcEBANAsG6WXuYbqXEV7B98nyZ3FsGKpM9wnb hkGNS/7vNSbiKNKWWPncvVVh/BPvUauT+BG9frGKoXNF5HRJhibnbAiyP9EmViZodAqk HvsrHOpcgMb2cfwO4lcVhf1+CBdXbjMYl91umGtiJOd0qz1Mq4UNLO763MjjpDV5d8e/ yczga+Dz5DiY+2Fkts6MuHUS8RXETQqK0DAgKsEMp8bhv/KrGDjE03RGp2gkqZELxCrP FbDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Rau4B3gD; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1-v6si215600pld.236.2018.03.19.15.23.06; Mon, 19 Mar 2018 15:23: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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Rau4B3gD; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032511AbeCSWVF (ORCPT + 99 others); Mon, 19 Mar 2018 18:21:05 -0400 Received: from mail-dm3nam03on0129.outbound.protection.outlook.com ([104.47.41.129]:48439 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933930AbeCSPtR (ORCPT ); Mon, 19 Mar 2018 11:49:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=TEKTCpn3E7OBR1J6mwhPeHVsv/G1l5wDAJdeaxQXaA8=; b=Rau4B3gDyVZJMKwGs0OV90MzrEnA+YwlPdPyYur62p4oqPI6Sw0O83+O4TGg7zjkALwNzm3/dyUxUQZfnr2sMUTB09OoGlxEEj4TJShm3/w/fLW9NIqVkbtRzW57IDbxCpBt11Ju/FoaRQqwzXr+T9IEs1Xl1HZfNbjkXpk97vE= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0936.namprd21.prod.outlook.com (52.132.131.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.609.2; Mon, 19 Mar 2018 15:49:02 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:49:02 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Tang Junhui , Michael Lyle , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 084/124] bcache: segregate flash only volume write streams Thread-Topic: [PATCH AUTOSEL for 4.15 084/124] bcache: segregate flash only volume write streams Thread-Index: AQHTv5m7zix04b3usU+3E80iFYT6FQ== Date: Mon, 19 Mar 2018 15:48:32 +0000 Message-ID: <20180319154645.11350-84-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0936;7:6b0ImkSOsoLlkBPDB5kOAEdwHze42Y7XouxbWGnltu6wg81DEgzoEZieVYWHi9HJTjgOnPsRNgKO0/tH55I+uJTvkdGA2gDTgefuRhxrlXndsYh4ekUNChoM3EJK1Fzqqn1LshvBaARq4b/EllyTRpzpQh27oQDuFkclof2QFgyiX+cZdFK+fcPmHriiu9jw0Q3huHxz837xbkxY1mVOvg9HdvlN6OMChwNhNq0FsrUGLiDE+q66SUVQ2iLNBNEh;20:xHQnDL8/2wY3HPJ+L9xrr7IiC381qcxGaMjhrNhwyrVUf4jANlKRKuo/6XvLCjWCvXy2oAXEZxOL/cpS+KIlAF9n5OtfbCDPPcWOqe6diLvBIJ/BeDWaYhetY4IdgLlJB7jIu49VqQA0BlqtpcnWdriz7PYIoLq1WOAga4iGuxY= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d43d762e-42cd-41d1-b934-08d58db0f01f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0936; x-ms-traffictypediagnostic: DM5PR2101MB0936: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231221)(944501300)(52105095)(6055026)(61426038)(61427038)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:DM5PR2101MB0936;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0936; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(39860400002)(366004)(376002)(396003)(199004)(189003)(2900100001)(3280700002)(2950100002)(10290500003)(66066001)(106356001)(76176011)(86612001)(6666003)(478600001)(5250100002)(6512007)(6486002)(107886003)(36756003)(97736004)(72206003)(25786009)(6436002)(53936002)(7736002)(2501003)(54906003)(110136005)(105586002)(10090500001)(2906002)(86362001)(305945005)(5660300001)(316002)(8676002)(6346003)(1076002)(3846002)(3660700001)(81156014)(4326008)(14454004)(26005)(6116002)(102836004)(8936002)(81166006)(6506007)(186003)(22452003)(59450400001)(99286004)(68736007)(575784001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0936;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: 86UFOqWYnfCeeUb6Fvge/mXpRsYGtyiw0lIGjzVp5pO/rrWkKgQJZDRVDVzYmXFyW/k4Y6r7amfu4IW6eGbtBfGZzfItYtFgoWL/I3pGjKYabdXa/1OEAKsGueMfnTMDJz7Ev6Krrrb8srr9UthvgOu7r0Yp+9bjUedPWJmmvTQWRE1TVIrNozaBiDpFTNILqZwz8f8PmcVkjnLiRlZIdpFrK9b4pl7U6iR/K5oqYFrk/j7GUr61LH/gTEzjgYtRXA8wVMSXXH+4gxMu1t6QefB09TckkLvG737UEH0Kjp0bWmRaB93LnoVpOcZY0lfmIwZNpRASzaeUIlrDNitf8g== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: d43d762e-42cd-41d1-b934-08d58db0f01f X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:48:32.5955 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0936 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/md/bcache/alloc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index a0cc1bc6d884..6cc6c0f9c3a9 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c @@ -525,15 +525,21 @@ struct open_bucket { =20 /* * We keep multiple buckets open for writes, and try to segregate differen= t - * 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 f= lash + * only volume write streams from cached devices, secondly we look for a b= ucket + * 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 a= t 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 copyin= g 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 w= ill + * be marked as dirty and won't be reclaimed, though the dirty data of cac= hed + * 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 th= at * data to the same buckets it'd get invalidated at the same time. @@ -550,7 +556,10 @@ static struct open_bucket *pick_data_bucket(struct cac= he_set *c, struct open_bucket *ret, *ret_task =3D NULL; =20 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)]) !=3D + UUID_FLASH_ONLY(&c->uuids[KEY_INODE(search)])) + continue; + else if (!bkey_cmp(&ret->key, search)) goto found; else if (ret->last_write_point =3D=3D write_point) ret_task =3D ret; --=20 2.14.1