From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11474 invoked by alias); 13 Jul 2004 13:41:22 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 11465 invoked from network); 13 Jul 2004 13:41:21 -0000 Received: from unknown (HELO mail.broadpark.no) (217.13.4.2) by sourceware.org with SMTP; 13 Jul 2004 13:41:21 -0000 Received: from famine (217-13-20-38.dd.nextgentel.com [217.13.20.38]) by mail.broadpark.no (Postfix) with ESMTP id 320482D45; Tue, 13 Jul 2004 15:41:51 +0200 (MEST) From: =?ISO-8859-1?Q?=D8yvind?= Harboe To: David Woodhouse Cc: ecos-discuss@sources.redhat.com In-Reply-To: <1089713133.2899.117.camel@hades.cambridge.redhat.com> References: <1089643331.3951.42.camel@famine> <1089711000.2899.96.camel@hades.cambridge.redhat.com> <1089712151.5995.21.camel@famine> <1089713133.2899.117.camel@hades.cambridge.redhat.com> Content-Type: multipart/mixed; boundary="=-r+SwA1f8QfDYgNlND/Fz" Message-Id: <1089726079.6288.5.camel@famine> Mime-Version: 1.0 Date: Tue, 13 Jul 2004 13:41:00 -0000 Subject: Re: [ECOS] JFFS2 eats memory X-SW-Source: 2004-07/txt/msg00179.txt.bz2 --=-r+SwA1f8QfDYgNlND/Fz Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-length: 307 After your walkthrough if the approach on IRC, I came up with this patch, which seems to take care of the problem. If there is a consensus that this is something that would be generally useful for eCos/JFFS2 users, I'll be happy to clean it up and submit a patch. -- Øyvind Harboe http://www.zylin.com --=-r+SwA1f8QfDYgNlND/Fz Content-Disposition: attachment; filename=memleakfix.txt Content-Type: text/x-patch; name=memleakfix.txt; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Content-length: 2041 Index: nodemgmt.c =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/src/nodemgmt.c,v retrieving revision 1.6 diff -w -u -r1.6 nodemgmt.c --- nodemgmt.c 11 Dec 2003 23:33:54 -0000 1.6 +++ nodemgmt.c 13 Jul 2004 13:35:44 -0000 @@ -549,6 +549,60 @@ printk(KERN_WARNING "Short write in obliterating obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen); return; } + + // Merge obsolete nodes into its previous node, i.e. always leave + // one node behind so as not to screw up ref_totlen() + if (ref->next_in_ino!=NULL) + { + bool moreToDo; + do { + moreToDo=false; + struct jffs2_inode_cache *ic; + ic = jffs2_raw_ref_to_ic(ref); + + // unlink the node and + struct jffs2_raw_node_ref *raw; + struct jffs2_raw_node_ref *prev=NULL; + raw = ic->nodes; + for (raw = ic->nodes; raw != (void *)ic; raw = raw->next_in_ino) { + // if this node *and* the previous *physical node* are obsolete, combine them. + if ((prev!=NULL)&&ref_obsolete(raw)) { + // now take take it off the physcial list, unless it is the + // first node. + struct jffs2_raw_node_ref *t; + struct jffs2_raw_node_ref *phys_prev=NULL; + t=jeb->first_node; + while (t!=NULL) { + if ((phys_prev!=NULL)&&(t==raw)&&ref_obsolete(prev)) { + // take it off the inode list. + prev->next_in_ino=t->next_in_ino; + + // take it off the physical list + phys_prev->next_phys=t->next_phys; + // update last physical entry pointer... + if (jeb->last_node==t) { + jeb->last_node=t->next_phys; + } + + // update physical __totlen field. + phys_prev->__totlen+=t->__totlen; + + + jffs2_free_raw_node_ref(raw); + moreToDo=true; + + break; + } + phys_prev=t; + t=t->next_phys; + } + break; + } + prev=raw; + } + } while (moreToDo); + } + } #if CONFIG_JFFS2_FS_DEBUG > 0 --=-r+SwA1f8QfDYgNlND/Fz Content-Type: text/plain; charset=us-ascii Content-length: 148 -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss --=-r+SwA1f8QfDYgNlND/Fz--