From: Jan Kara Subject: Re: [PATCH] Fix ext2 error reporting on fsync Date: Sun, 22 Jan 2006 23:32:58 +0100 Message-ID: <20060122223253.GA28667@atrey.karlin.mff.cuni.cz> References: <20060112142656.GB14235@atrey.karlin.mff.cuni.cz> <20060112124717.6e242802.akpm@osdl.org> <200601122108.55103.mason@suse.com> <20060112181628.63c4bf39.akpm@osdl.org> <20060118224652.GA6434@atrey.karlin.mff.cuni.cz> <20060118150646.7514ba5f.akpm@osdl.org> <20060119122125.GA12563@atrey.karlin.mff.cuni.cz> <20060119131648.68d7c6eb.akpm@osdl.org> <20060120134118.GK668@atrey.karlin.mff.cuni.cz> <20060120132402.51ee5151.akpm@osdl.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: mason@suse.com, linux-fsdevel@vger.kernel.org Return-path: Received: from atrey.karlin.mff.cuni.cz ([195.113.31.123]:15796 "EHLO atrey.karlin.mff.cuni.cz") by vger.kernel.org with ESMTP id S932239AbWAVWc7 (ORCPT ); Sun, 22 Jan 2006 17:32:59 -0500 To: Andrew Morton Content-Disposition: inline In-Reply-To: <20060120132402.51ee5151.akpm@osdl.org> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org > Jan Kara wrote: > > > > > Jan Kara wrote: > > > > > > > > > (If you're proposing that we walk the buffer_head list until we somehow > > > > > find the list_head or hlist_head which is embedded within the desired > > > > > address_space then yes2, but how do we know where to terminate the search?) > > > > Yes, that's it. If the list is not circular, then it's easy to find > > > > it's head. So what I suggest is to change private_list from a circular > > > > list of list_head structures to the non-circular one. And because > > > > non-circular list is already implemented in hlist macros I'd simply use > > > > those. The only minor hack is that mapping would not contain hlist_head > > > > but hlist_node with pprev set to NULL so that we easily recognize it when > > > > traversing backwards. Is it clearer now? > > > > > > Ah, yes. It could get pretty inefficient in some corner cases, I guess. A > > > 4GB file will have up to 1000 buffers on that list so we're looking at > > > potentially O(1000000) operations. > > > > > > Plan B is to stick with a doubly-linked list, but mark the address_space's > > > list_head by setting bit 0 of its list_head.next to 1. > > > > > > The challenge is to implement this in a manner which Linus doesn't notice ;) > > In the mean time I though of an improvement of our cunning plan ;) We > > could reserve a bit in bh_state. Something like BH_Neighbor_EIO. If > > buffer is going to be thrown out from private_list (and has BH_Write_EIO > > or BH_Neighbor_EIO set) we find another victim (previous buffer on the > > list) and mark it by BH_Neighbor_EIO. If the buffer was the first one, > > we can set error on the mapping. By this we get rid of going through the > > long link list. > > I guess I like this solution enough so that I start coding ;). > > hm. > > Another approach would be to allocate a new buffer_head which "belongs" to > the address_space. So instead of doing: > > bh<->bh<->address_space<->bh<->bh > > we do: > > address_space > ^ > | > v > bh<->bh<->bh'<->bh<->bh > > and set a magic bit in bh' which says "this is not a real bh; your > address_space is at *b_private". Yes, that's a good idea. It simplifies the coding. Actually we don't need the pointer to the mapping and detection of special buffer head if we use my bit propagation as I wrote in my last email. We just eventually set bit BH_Neighbor_EIO in the fake buffer head and we check it in the fsync_buffers_list() and return EIO in that case. Honza -- Jan Kara SuSE CR Labs