I can do it when I get a chance. I am not familar with Filesystems stuff
- was looking for a project to start learning that stuff though. I have
that scatterlist stuff I am trying to get out of the way right now. Zhen
this is your thread :) do you have time to do this or should we just see
who gets free first?
Here's a patch for ext3. We don't need the page_count or the slab page
test with this.
diff -u --new-file --recursive -x GPATH -x GRTAGS -x GSYMS -x GTAGS -x CVS -x .svn -x .config -x .config.cmd -x .config.old linux-2.6.15-rc4/fs/jbd/commit.c linux-2.6.15-rc4.jbd/fs/jbd/commit.c
--- linux-2.6.15-rc4/fs/jbd/commit.c 2005-12-01 19:05:34.000000000 +0900
+++ linux-2.6.15-rc4.jbd/fs/jbd/commit.c 2005-12-07 07:50:58.000000000 +0900
@@ -261,7 +261,7 @@
struct buffer_head *bh = jh2bh(jh);
jbd_lock_bh_state(bh);
- kfree(jh->b_committed_data);
+ free_page((unsigned long) jh->b_committed_data);
jh->b_committed_data = NULL;
jbd_unlock_bh_state(bh);
}
@@ -745,14 +745,14 @@
* Otherwise, we can just throw away the frozen data now.
*/
if (jh->b_committed_data) {
- kfree(jh->b_committed_data);
+ free_page((unsigned long) jh->b_committed_data);
jh->b_committed_data = NULL;
if (jh->b_frozen_data) {
jh->b_committed_data = jh->b_frozen_data;
jh->b_frozen_data = NULL;
}
} else if (jh->b_frozen_data) {
- kfree(jh->b_frozen_data);
+ free_page((unsigned long) jh->b_frozen_data);
jh->b_frozen_data = NULL;
}
diff -u --new-file --recursive -x GPATH -x GRTAGS -x GSYMS -x GTAGS -x CVS -x .svn -x .config -x .config.cmd -x .config.old linux-2.6.15-rc4/fs/jbd/journal.c linux-2.6.15-rc4.jbd/fs/jbd/journal.c
--- linux-2.6.15-rc4/fs/jbd/journal.c 2005-12-01 19:05:34.000000000 +0900
+++ linux-2.6.15-rc4.jbd/fs/jbd/journal.c 2005-12-07 08:02:08.000000000 +0900
@@ -328,10 +328,10 @@
char *tmp;
jbd_unlock_bh_state(bh_in);
- tmp = jbd_rep_kmalloc(bh_in->b_size, GFP_NOFS);
+ tmp = (char *) __get_free_page(GFP_NOFS | __GFP_NOFAIL);
jbd_lock_bh_state(bh_in);
if (jh_in->b_frozen_data) {
- kfree(tmp);
+ free_page((unsigned long) tmp);
goto repeat;
}
@@ -1799,13 +1799,13 @@
printk(KERN_WARNING "%s: freeing "
"b_frozen_data\n",
__FUNCTION__);
- kfree(jh->b_frozen_data);
+ free_page((unsigned long) jh->b_frozen_data);
}
if (jh->b_committed_data) {
printk(KERN_WARNING "%s: freeing "
"b_committed_data\n",
__FUNCTION__);
- kfree(jh->b_committed_data);
+ free_page((unsigned long) jh->b_committed_data);
}
bh->b_private = NULL;
jh->b_bh = NULL; /* debug, really */
diff -u --new-file --recursive -x GPATH -x GRTAGS -x GSYMS -x GTAGS -x CVS -x .svn -x .config -x .config.cmd -x .config.old linux-2.6.15-rc4/fs/jbd/transaction.c linux-2.6.15-rc4.jbd/fs/jbd/transaction.c
--- linux-2.6.15-rc4/fs/jbd/transaction.c 2005-12-01 19:05:34.000000000 +0900
+++ linux-2.6.15-rc4.jbd/fs/jbd/transaction.c 2005-12-07 07:49:45.000000000 +0900
@@ -665,8 +665,8 @@
if (!frozen_buffer) {
JBUFFER_TRACE(jh, "allocate memory for buffer");
jbd_unlock_bh_state(bh);
- frozen_buffer = jbd_kmalloc(jh2bh(jh)->b_size,
- GFP_NOFS);
+ frozen_buffer =
+ (char *) jbd_get_free_page(GFP_NOFS);
if (!frozen_buffer) {
printk(KERN_EMERG
"%s: OOM for frozen_buffer\n",
@@ -724,7 +724,8 @@
journal_cancel_revoke(handle, jh);
out:
- kfree(frozen_buffer);
+ if (frozen_buffer)
+ free_page((unsigned long) frozen_buffer);
JBUFFER_TRACE(jh, "exit");
return error;
@@ -877,7 +878,7 @@
repeat:
if (!jh->b_committed_data) {
- committed_data = jbd_kmalloc(jh2bh(jh)->b_size, GFP_NOFS);
+ committed_data = (char *) jbd_get_free_page(GFP_NOFS);
if (!committed_data) {
printk(KERN_EMERG "%s: No memory for committed data\n",
__FUNCTION__);
@@ -903,7 +904,8 @@
jbd_unlock_bh_state(bh);
out:
journal_put_journal_head(jh);
- kfree(committed_data);
+ if (committed_data)
+ free_page((unsigned long) committed_data);
return err;
}
diff -u --new-file --recursive -x GPATH -x GRTAGS -x GSYMS -x GTAGS -x CVS -x .svn -x .config -x .config.cmd -x .config.old linux-2.6.15-rc4/include/linux/jbd.h linux-2.6.15-rc4.jbd/include/linux/jbd.h
--- linux-2.6.15-rc4/include/linux/jbd.h 2005-12-01 19:05:36.000000000 +0900
+++ linux-2.6.15-rc4.jbd/include/linux/jbd.h 2005-12-07 07:47:02.000000000 +0900
@@ -70,8 +70,8 @@
extern void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry);
#define jbd_kmalloc(size, flags) \
__jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
-#define jbd_rep_kmalloc(size, flags) \
- __jbd_kmalloc(__FUNCTION__, (size), (flags), 1)
+#define jbd_get_free_page(flags) \
+ __get_free_page((flags) | journal_oom_retry ? __GFP_NOFAIL : 0)
#define JFS_MIN_JOURNAL_BLOCKS 1024
hey I'm just like you, otherwise I wouldn't raise this concern. :)
Seems Tomonori have a good catch already.