From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-dm3nam03on0096.outbound.protection.outlook.com ([104.47.41.96]:59104 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966953AbeCSQOW (ORCPT ); Mon, 19 Mar 2018 12:14:22 -0400 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 3.18 094/102] bcache: segregate flash only volume write streams Date: Mon, 19 Mar 2018 16:13:29 +0000 Message-ID: <20180319161117.17833-94-alexander.levin@microsoft.com> References: <20180319161117.17833-1-alexander.levin@microsoft.com> In-Reply-To: <20180319161117.17833-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: 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 ea47980949ef..f8c5bc719783 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c @@ -514,15 +514,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. @@ -539,7 +545,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