Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iWc3O-0003x8-TX for mharc-grub-devel@gnu.org; Mon, 18 Nov 2019 03:06:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47990) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWc3J-0003u3-9X for grub-devel@gnu.org; Mon, 18 Nov 2019 03:06:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iWc3G-0004ZA-Rz for grub-devel@gnu.org; Mon, 18 Nov 2019 03:06:28 -0500 Received: from m4a0039g.houston.softwaregrp.com ([15.124.2.85]:48583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iWc3G-0003jz-LB for grub-devel@gnu.org; Mon, 18 Nov 2019 03:06:26 -0500 Received: FROM m4a0039g.houston.softwaregrp.com (15.120.17.146) BY m4a0039g.houston.softwaregrp.com WITH ESMTP FOR grub-devel@gnu.org; Mon, 18 Nov 2019 08:05:04 +0000 Received: from M9W0068.microfocus.com (2002:f79:bf::f79:bf) by M4W0334.microfocus.com (2002:f78:1192::f78:1192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 18 Nov 2019 08:05:24 +0000 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (15.124.72.13) by M9W0068.microfocus.com (15.121.0.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10 via Frontend Transport; Mon, 18 Nov 2019 08:05:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eX3ziCioRpNVqN63H1rceER8VfCW3H7J4oUwAMdC1kqZSj9N2Y6ug0N6cGiQgQjXDK1cKurU7UK7ERsE4CoAVpS7Bp8iJOPHo3sYGGaPcFRqbdZC1G39cppLIEDUO46kp/Y2P3WGL/cnS03E5wLr60aFkkSvL0VLIi3Itwko38gGDF3vq7jQ8mIzqXgZjAmHj6IRK/r8046IPwu0TTwt5921gPDnlpV25/8++uXasNBgA9w2A7eID61h64wtSq3cgt0qidp2iRyXfCRDxfLFz8QyPO3OB1DmbBfPre8NVKCjGk1Av8HlBX8pUQ/Tdqir3qFptmMILgC+enssQdP0RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s5D/oUPiETSKXhrfeL/EXY0OD++OmNjxRho1+YjDso0=; b=BuGvUTDNC1KgOCswTUwTh8RxikjfQqio5u66ougKb8G0ORhsv9nk8GnMOthfdoTHAPBksS5kGMFyq4Mpzdw2UV6tCql0UIoY84jcsrneaqhOg9WnpuVnp+T745xWy8ctcVYrJd7HCXiJ6hvlVwPzAb1L8jQj1AvdmDvZBA5f67/T/7CDgMtuyXhHhAECgibD4f9C9yQb8uEMsKKxg106X2P9D11B1q5WFp/ZBAroomJocDTANGZPwRb9kHYIxd/skF7bnlzHo7KSlbhdFmBsoxftuqoA74f+rFEYCiVXL6mplNPLzljz3iwVxzvAxP8D/ibBzHhJ01pJwvs/YS65+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Received: from BY5PR18MB3122.namprd18.prod.outlook.com (10.255.139.11) by BY5PR18MB3364.namprd18.prod.outlook.com (10.255.136.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.28; Mon, 18 Nov 2019 08:05:23 +0000 Received: from BY5PR18MB3122.namprd18.prod.outlook.com ([fe80::297d:fc41:ae2a:13d9]) by BY5PR18MB3122.namprd18.prod.outlook.com ([fe80::297d:fc41:ae2a:13d9%5]) with mapi id 15.20.2451.029; Mon, 18 Nov 2019 08:05:23 +0000 From: Michael Chang To: The development of GNU GRUB Subject: Re: [PATCH] lvm: add lvm cache logical volume handling Thread-Topic: [PATCH] lvm: add lvm cache logical volume handling Thread-Index: AQHVg+kcyQnYrvfSdkigs0DupfD//KdoFvWAgAEsfICAALIJAIAm0IWA Date: Mon, 18 Nov 2019 08:05:22 +0000 Message-ID: <20191118080515.GA22406@mazu> References: <20191016061516.32129-1-mchang@suse.com> <20191023104823.uxaqf5uxkr6jr3lx@tomti.i.net-space.pl> <20191024044351.GA8270@mazu> <20191024152104.u3uywhpknw2sjwmi@tomti.i.net-space.pl> In-Reply-To: <20191024152104.u3uywhpknw2sjwmi@tomti.i.net-space.pl> Accept-Language: zh-TW, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR03CA0035.apcprd03.prod.outlook.com (2603:1096:203:2f::23) To BY5PR18MB3122.namprd18.prod.outlook.com (2603:10b6:a03:1af::11) authentication-results: spf=none (sender IP is ) smtp.mailfrom=MChang@suse.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [60.251.47.116] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6ddfa169-640e-481a-b14c-08d76bfe0fae x-ms-traffictypediagnostic: BY5PR18MB3364: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 0225B0D5BC x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(7916004)(39860400002)(376002)(346002)(396003)(136003)(366004)(189003)(199004)(11346002)(446003)(486006)(6916009)(66946007)(14454004)(66476007)(66556008)(66446008)(478600001)(64756008)(33656002)(81166006)(81156014)(80792005)(6246003)(316002)(25786009)(99286004)(5660300002)(8676002)(1076003)(186003)(386003)(6506007)(55236004)(3846002)(305945005)(102836004)(26005)(7736002)(476003)(2906002)(86362001)(66066001)(6116002)(8936002)(966005)(33716001)(229853002)(6486002)(14444005)(6512007)(6436002)(9686003)(6306002)(256004)(71190400001)(52116002)(76176011)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY5PR18MB3364; H:BY5PR18MB3122.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: suse.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oEzQk6iCJmMGLg7TBmafGg2jyft22uZzKlOYyLQ+CtHhrRyQRIm2jfMUnfWJyU4+ww38oS45Ftl4SBEu/c74mlhDNlDrVbD8bYG7BXBmnEvyjthduY/ZAzHhMT2Pc5qV45nST560pQZE0Rk5CJUVbe3mLJ+awvf99CH8/v94buNIvp8pS5cM7yEgnuEp9WaXo7Cm8NptTC3Ir2tFERUag+SWbYwHSJP5HQ0bHVu9hg50msYEZobqG9MAZjseeG/P/1SubMij0rRBXLx/cYPUIGdjXHhWbGqFgGLdkeeTazMb2SqPhn2hP6b2yaWGnwMxyKvkmneQG7aG9YLacr95pTq+L8ApM9MIIWM2kaT6A1rShOpsWFZnem0hityZsp1+4FCzUcEGW20BKzN/F5Nmt87qhChLMsCMK6Ax9iuoDhoaSNnz4UQ578bLcxt6fSrZ Content-Type: text/plain; charset="us-ascii" Content-ID: <1AE7D5AAD6DFC5489FE0EE240ED10659@namprd18.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 6ddfa169-640e-481a-b14c-08d76bfe0fae X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Nov 2019 08:05:22.7885 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 856b813c-16e5-49a5-85ec-6f081e13b527 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: SahH/c4OrS6O0U60niTWg4UUaaRumlDbB+s4LK6cj8TfDGMohL0oDUF7eDox7AIo X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR18MB3364 X-OriginatorOrg: suse.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 15.124.2.85 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Nov 2019 08:06:30 -0000 On Thu, Oct 24, 2019 at 05:21:04PM +0200, Daniel Kiper wrote: > On Thu, Oct 24, 2019 at 04:43:58AM +0000, Michael Chang wrote: > > On Wed, Oct 23, 2019 at 12:48:23PM +0200, Daniel Kiper wrote: > > > On Wed, Oct 16, 2019 at 06:15:30AM +0000, Michael Chang wrote: > > > > The lvm cache logical volume is the logical volume consisting of th= e > > > > original and the cache pool logical volume. The original is usually= on a > > > > larger and slower storage device while the cache pool is on a small= er > > > > and faster one. The performance of the original volume can be impro= ved > > > > by storing the frequently used data on the cache pool to utilize th= e > > > > greater performance of faster device. > > > > > > > > The default cache mode "writethrough" ensures that any data written= will > > > > be stored both in the cache and on the origin LV, therefore grub ca= n go > > > > straight to read the original lv as no data loss is guarenteed. > > > > > > > > The second cache mode is "writeback", which delays writing from the > > > > cache pool back to the origin LV to have increased performance. The > > > > drawback is potential data loss if losing the associated cache devi= ce. > > > > > > > > During the boot time grub reads the LVM offline i.e. LVM volumes ar= e not > > > > activated and mounted, IMHO it should be fine to read directly from > > > > original lv since all cached data should have been flushed back in = the > > > > process of taking it offline. > > > > > > Is it possible to enforce all GRUB writes to the original device inst= ead > > > of cache during installation process? > > > > I couldn't give concrete answer whether it is possible, but it sounds t= o > > me not good idea because in general bypassing the cache could > > potentially break the consistency of data and the data being cached. > > > > Perhaps some system calls could help to sync the data out of the lvm > > cache to the original LV during installation process. It seems fsync > > does it for us, but I didn't have good idea either if it is enough. >=20 > May I ask you to investigate that and if it is needed add required > install code. I mean fsync(), etc. As far as what I learned, the fsync did not write back dirty cache to the orginal device, instead it would update associated cache metadata to complete the write transaction with the cache device and then having the write cache up to date. Without the operation, metadata is commited every second and data would be completely lost/evaporated if power failure happened in between.=20 To write back dirty cache, as lvm cache did not support dirty cache flush per block range, there'no way to do it for file. Instead the "cleaner" policy is implemented and can be used to write back "all" dirty blocks in a cache, which effectively drain all dirty cache gradually to attain and last in the "clean" state, which can be useful for shrinking or decommissioning a cache. The result and effect is not what we are looking for here.=20 In conclusion, it seems no way to enforce all grub writes to the original device. That means grub may suffer from power failure that leads to dirty cache not being flushed and is inept reading data flagged as dirty in cache. But even though, as long as such case is only subjected to writeback mode that is generally difficult to deal with data lost whenever accident comes up, I'd still like to propose my (relatively simple) patch and treat reading dirty data in cache as an enhancement to be more resilience to potential data loss. Thanks, Michael >=20 > Daniel >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel