diff -purN orig/fs/ubifs/journal.c linux-2.6.37/fs/ubifs/journal.c
--- orig/fs/ubifs/journal.c	2011-03-04 15:44:41.568667187 -0500
+++ linux-2.6.37/fs/ubifs/journal.c	2011-03-04 17:28:01.878665040 -0500
@@ -689,8 +689,8 @@ int ubifs_jnl_write_data(struct ubifs_in
 			 const union ubifs_key *key, const void *buf, int len)
 {
 	struct ubifs_data_node *data;
-	int err, lnum, offs, compr_type, out_len;
-	int dlen = UBIFS_DATA_NODE_SZ + UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR;
+	int err, lnum, offs, compr_type, out_len, allocated = 1;
+	int dlen = UBIFS_JNL_DATA_NODE_SZ;
 	struct ubifs_inode *ui = ubifs_inode(inode);

 	dbg_jnl("ino %lu, blk %u, len %d, key %s",
@@ -698,9 +698,13 @@ int ubifs_jnl_write_data(struct ubifs_in
 		DBGKEY(key));
 	ubifs_assert(len <= UBIFS_BLOCK_SIZE);

-	data = kmalloc(dlen, GFP_NOFS);
-	if (!data)
-		return -ENOMEM;
+	data = kmalloc(dlen, GFP_NOFS | __GFP_NOWARN);
+	if (!data) {
+		/* If kmalloc() fails, fall back to using a shared buffer */
+		allocated = 0;
+		mutex_lock(&c->write_reserve_mutex);
+		data = &c->write_reserve.node;
+	}

 	data->ch.node_type = UBIFS_DATA_NODE;
 	key_write(c, key, &data->key);
@@ -736,7 +740,10 @@ int ubifs_jnl_write_data(struct ubifs_in
 		goto out_ro;

 	finish_reservation(c);
-	kfree(data);
+	if (!allocated)
+		mutex_unlock(&c->write_reserve_mutex);
+	else
+		kfree(data);
 	return 0;

 out_release:
@@ -745,7 +752,10 @@ out_ro:
 	ubifs_ro_mode(c, err);
 	finish_reservation(c);
 out_free:
-	kfree(data);
+	if (!allocated)
+		mutex_unlock(&c->write_reserve_mutex);
+	else
+		kfree(data);
 	return err;
 }

diff -purN orig/fs/ubifs/super.c linux-2.6.37/fs/ubifs/super.c
--- orig/fs/ubifs/super.c	2011-03-04 15:44:41.568667187 -0500
+++ linux-2.6.37/fs/ubifs/super.c	2011-03-04 16:56:35.628665311 -0500
@@ -1929,6 +1929,7 @@ static int ubifs_fill_super(struct super
 	mutex_init(&c->mst_mutex);
 	mutex_init(&c->umount_mutex);
 	mutex_init(&c->bu_mutex);
+	mutex_init(&c->write_reserve_mutex);
 	init_waitqueue_head(&c->cmt_wq);
 	c->buds = RB_ROOT;
 	c->old_idx = RB_ROOT;
diff -purN orig/fs/ubifs/ubifs.h linux-2.6.37/fs/ubifs/ubifs.h
--- orig/fs/ubifs/ubifs.h	2011-03-04 15:44:41.568667187 -0500
+++ linux-2.6.37/fs/ubifs/ubifs.h	2011-03-04 17:03:28.408664874 -0500
@@ -158,6 +158,19 @@
 #define UBIFS_MAX_BULK_READ 32

 /*
+ * How much space is needed for a single write buffer when writing out a
+ * journal data node.
+ */
+#define UBIFS_JNL_DATA_NODE_SZ \
+	(UBIFS_DATA_NODE_SZ + UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR)
+
+/* Used as a static buffer for journal writes, in case kmalloc() fails */
+union ubifs_write_reserve_buf {
+	struct ubifs_data_node node;
+	__u8 buf[UBIFS_JNL_DATA_NODE_SZ];
+};
+
+/*
  * Lockdep classes for UBIFS inode @ui_mutex.
  */
 enum {
@@ -1249,6 +1262,9 @@ struct ubifs_info {
 	int max_bu_buf_len;
 	struct mutex bu_mutex;
 	struct bu_info bu;
+	
+	struct mutex write_reserve_mutex;
+	union ubifs_write_reserve_buf write_reserve;

 	int log_lebs;
 	long long log_bytes;
