linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext3: avoid sending down non-refcounted pages
@ 2005-12-08  9:09 FUJITA Tomonori
  2005-12-08 10:18 ` Andreas Dilger
  0 siblings, 1 reply; 13+ messages in thread
From: FUJITA Tomonori @ 2005-12-08  9:09 UTC (permalink / raw)
  To: michaelc, hch, linux-fsdevel, ext2-devel, open-iscsi

If file systems don't send down non-refcounted pages, it makes life
much easier for open-iscsi because it uses tcp_sendpage.

Can we reach agreement?

Christoph said that he'll take care of xfs. This patch makes ext3 use
normal pages instead of kmalloc'ed pages.


Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>


diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c
index 002ad2b..01b8a6a 100644
--- a/fs/jbd/commit.c
+++ b/fs/jbd/commit.c
@@ -261,7 +261,7 @@ void journal_commit_transaction(journal_
 			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 @@ restart_loop:
 		 * 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 --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index e4b516a..cab8c31 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -328,10 +328,10 @@ repeat:
 		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 @@ static void __journal_remove_journal_hea
 				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 --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 429f4b2..16e741d 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -665,8 +665,8 @@ repeat:
 			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 @@ done:
 	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 @@ int journal_get_undo_access(handle_t *ha
 
 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 @@ repeat:
 	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 --git a/include/linux/jbd.h b/include/linux/jbd.h
index dcde7ad..5b72dc8 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -70,8 +70,8 @@ extern int journal_enable_debug;
 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
 

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-12-12 20:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-08  9:09 [PATCH] ext3: avoid sending down non-refcounted pages FUJITA Tomonori
2005-12-08 10:18 ` Andreas Dilger
2005-12-08 12:39   ` [Ext2-devel] " FUJITA Tomonori
2005-12-08 13:42   ` allowed pages in the block later, was " Christoph Hellwig
2005-12-08 13:58     ` Pekka Enberg
2005-12-12 17:27       ` allowed pages in the block later, was " Christoph Hellwig
2005-12-08 18:18     ` allowed pages in the block later, was Re: [Ext2-devel] " Mike Christie
2005-12-08 18:22       ` Mike Christie
2005-12-08 19:20         ` Pekka Enberg
2005-12-11  0:47     ` Andrew Morton
2005-12-11  8:44       ` allowed pages in the block later, was " Arjan van de Ven
2005-12-12 17:25       ` allowed pages in the block later, was Re: [Ext2-devel] " Christoph Hellwig
2005-12-12 20:12         ` Andrew Morton

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 NNTP newsgroup(s).