From: Daniel Stodden Subject: Re: Tagging Xen 4.0.0 first release candidate / pygrub dom0 caching bug Date: Thu, 28 Jan 2010 11:34:36 -0800 Message-ID: <1264707276.29805.2670.camel@agari.van.xensource.com> References: <20100106135005.GG25902@reaktio.net> <20100121122850.GT2861@reaktio.net> <1264099473.12544.3736.camel@agari.van.xensource.com> <1264101384.12544.3765.camel@agari.van.xensource.com> <1264102647.21707.2.camel@localhost.localdomain> <20100121210115.GY2861@reaktio.net> <1264110801.12544.3824.camel@agari.van.xensource.com> <20100127092719.GE2861@reaktio.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20100127092719.GE2861@reaktio.net> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Pasi =?ISO-8859-1?Q?K=E4rkk=E4inen?= Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Wed, 2010-01-27 at 04:27 -0500, Pasi K=C3=A4rkk=C3=A4inen wrote: > On Thu, Jan 21, 2010 at 01:53:21PM -0800, Daniel Stodden wrote: > > On Thu, 2010-01-21 at 16:01 -0500, Pasi K=C3=A4rkk=C3=A4inen wrote: > > > On Thu, Jan 21, 2010 at 07:37:27PM +0000, Ian Campbell wrote: > > > > On Thu, 2010-01-21 at 19:16 +0000, Daniel Stodden wrote:=20 > > > > > On Thu, 2010-01-21 at 13:44 -0500, Daniel Stodden wrote: > > > > > > On Thu, 2010-01-21 at 07:28 -0500, Pasi K=C3=A4rkk=C3=A4inen = wrote: > > > > > > > On Wed, Jan 06, 2010 at 03:50:05PM +0200, Pasi K=C3=A4rkk=C3= =A4inen wrote: > > > > > > > > On Tue, Jan 05, 2010 at 06:42:05AM +0000, Keir Fraser wro= te: > > > > > > > > > I plan to tag -rc1 later this week. If you have any out= standing patches, > > > > > > > > > please send them to the list now. > > > > > > > > >=20 > > > > > > > >=20 > > > > > > > > Hmm.. I just remembered this pygrub bug: > > > > > > > > https://bugzilla.redhat.com/show_bug.cgi?id=3D466681 > > > > > > > >=20 > > > > > > > > pygrub doesn't use O_DIRECT so sometimes it gets old info= rmation > > > > > > > > from dom0 kernel cache - and fails to use the updated dom= U grub.conf. > > > > > > > >=20 > > > > > > > > Redhat seems to have patches available for testing.. not = for > > > > > > > > xen-unstable though. > > > > > > > >=20 > > > > > > > > I've personally hit this bug many times. > > > > > > > >=20 > > > > > > >=20 > > > > > > > It seems Redhat guys have a fix available.. they fixed the = problem by=20 > > > > > > > patching dom0 kernel blkback. > > > > > > >=20 > > > > > > > More details about the fix here: > > > > > > > https://bugzilla.redhat.com/show_bug.cgi?id=3D466681 > > > > > > >=20 > > > > > > > Should this be applied to 2.6.18-xen and pv_ops dom0 kernel= s aswell?=20 > > > > > >=20 > > > > > > Only to 2.6.18.=20 > > > > > >=20 > > > > > > It's obsolete after 2.6.27. > > > > > > O_DIRECT gained page cache invalidation in the meantime. > > > > >=20 > > > > > Aiiee, sorry. I guess this one only applies to tapdisks. The pa= ge cache > > > > > invalidation only covers the filemap. That obviously won't fix = blkback > > > > > bios on raw devices. > > > > >=20 > > > > > Ian Campbell recently noted he came across a different fix, whi= ch adds > > > > > direct-io to e2fsprogs. > > > >=20 > > > > I noted the thread because the root problem seemed interesting an= d > > > > worthy of investigation, but I should have made it clear that I d= idn't > > > > think messing with direct-io in e2fsprogs was the correct solutio= n. I > > > > think the majority of the participants in the thread thought that= too. > > > > The biggest problem is that it only solves the issue in the one s= pecific > > > > case of things which use e2fsprogs and not in general, we can't g= o round > > > > adding O_DIRECT to everything which might be used to access these= disks. > > > >=20 > > >=20 > > > Yeah, it should be fixed in blkback.. who knows, some users might b= e using=20 > > > other tools in dom0 aswell, not just pygrub. > >=20 > > Fully agreed. > >=20 > > But: One thing about the rhel patch isn't immediately clear to me. Th= e > > invalidate step apparently goes into the VBD creation. > >=20 >=20 > With the RH kernel blkback kernel patch/fix: >=20 > 1) xm create domU > 2) pygrub runs, caching stuff in dom0 kernel cache > 3) domU is started, the patched blkback driver flushes dom0 kernel cach= e when the disk backend is created > 4) grub.conf is modified in the guest > 5) domU shuts down >=20 > 6) xm create domU > 7) pygrub runs, and gets the new updated grub.conf, since there's nothi= ng in the dom0 kernel cache, since it was flushed in 3) > 8) domU is started, blkback again flushes the dom0 kernel cache to prev= ent future problems >=20 > That'w how I understood it.. > > > I don't see why this is sufficient, my understanding was that pygrub > > would rather read stale data after boot, then run, then shutdown, the= n > > reboot. > >=20 > > Which rather suggests flushing during shutdown (?). > >=20 >=20 > disk IO from the domU blkfront is not cached in dom0,=20 > so it's enough to flush during the disk backend creation?=20 Yes. By flush I meant discarding the cache entries left from 2), not some writeback. You're right, it doesn't matter as long as the disk is not buffered somewhere while still opened by the backend. > pygrub is the only player here who gets stuff in the dom0 cache. > > Or rather on both ends. Because 1) installing a guest by copying a VD= I > > image 2) failing to properly close the raw device to get the caches > > flushed before 3) booting the VM is another potential problem. > >=20 > > We used to see the latter becoming an issue in the past. > >=20 >=20 > I guess it wouldn't hurt to also flush during shutdown.. ? I don't really mind. Xenserver accesses the disks only by attaching them to dom0, right now that's actually my preferred alternative. The blkback thing can hardly hurt, so let's pull it in. I'd mainly wonder a little barrier utility for the control stack wouldn't be a way more flexible solution. So instead of patching some particular backend to fix the world of e2fsprogs, or (worse) patching e2fsprogs themselves, let pygrub call some program with in turn does some ioctl(barrier) magic on the node to discard potentially stale mappings. Daniel