From: "Øyvind Harboe" <oyvind.harboe@zylin.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] JFFS2 eats memory
Date: Tue, 13 Jul 2004 13:41:00 -0000 [thread overview]
Message-ID: <1089726079.6288.5.camel@famine> (raw)
In-Reply-To: <1089713133.2899.117.camel@hades.cambridge.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 308 bytes --]
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
[-- Attachment #2: memleakfix.txt --]
[-- Type: text/x-patch, Size: 2041 bytes --]
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
[-- Attachment #3: Type: text/plain, Size: 148 bytes --]
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
next prev parent reply other threads:[~2004-07-13 13:41 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-12 14:42 Øyvind Harboe
2004-07-13 7:40 ` Andrew Lunn
2004-07-13 7:53 ` Andrew Lunn
2004-07-13 8:09 ` Øyvind Harboe
2004-07-13 8:31 ` Øyvind Harboe
2004-07-13 7:58 ` Øyvind Harboe
2004-07-13 9:30 ` David Woodhouse
2004-07-13 9:49 ` Øyvind Harboe
2004-07-13 10:05 ` David Woodhouse
2004-07-13 10:39 ` Øyvind Harboe
2004-07-13 13:41 ` Øyvind Harboe [this message]
2004-07-13 23:01 ` [ECOS] " David Woodhouse
2004-07-14 8:15 ` Øyvind Harboe
2004-07-19 14:25 ` Øyvind Harboe
2004-07-19 15:15 ` David Woodhouse
2004-07-19 16:32 ` Øyvind Harboe
2004-07-20 6:42 ` David Woodhouse
2004-07-20 7:51 ` Øyvind Harboe
2004-07-20 14:25 ` David Woodhouse
2004-07-20 15:51 ` Øyvind Harboe
2004-07-20 16:08 ` David Woodhouse
2004-07-20 20:29 ` Øyvind Harboe
2004-07-21 2:28 ` David Woodhouse
2004-07-21 7:54 ` Øyvind Harboe
[not found] ` <1090410703.4280.10.camel@localhost.localdomain>
2004-07-21 12:50 ` Øyvind Harboe
2004-07-21 16:33 ` David Woodhouse
2004-07-20 13:46 ` Øyvind Harboe
2004-07-13 10:08 ` [ECOS] " Thomas Koeller
2008-04-08 15:28 Jürgen Lambrecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1089726079.6288.5.camel@famine \
--to=oyvind.harboe@zylin.com \
--cc=dwmw2@infradead.org \
--cc=ecos-discuss@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).