shithub: lwext4

Download patch

ref: 02cad7eee3a935c99dfd5163accb214af503a32a
parent: e353c4e1812bff98f28c464f6b999a9b47dc8f7a
author: ngkaho1234 <ngkaho1234@gmail.com>
date: Thu Dec 24 00:19:10 EST 2015

ext4_journal: add trans parameter to jbd_trans_get_access routine.

--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -2562,7 +2562,7 @@
 
 			switch (rand() % 2) {
 			case 0:
-				r = jbd_trans_get_access(journal, &block);
+				r = jbd_trans_get_access(journal, t, &block);
 				if (r != EOK) {
 					jbd_journal_free_trans(journal, t,
 							       true);
--- a/lwext4/ext4_journal.c
+++ b/lwext4/ext4_journal.c
@@ -1094,9 +1094,11 @@
 
 /**@brief  gain access to it before making any modications.
  * @param  journal current journal session
+ * @param  trans transaction
  * @param  block descriptor
  * @return standard error code.*/
 int jbd_trans_get_access(struct jbd_journal *journal,
+			 struct jbd_trans *trans,
 			 struct ext4_block *block)
 {
 	int r = EOK;
@@ -1105,7 +1107,8 @@
 	/* If the buffer has already been modified, we should
 	 * flush dirty data in this buffer to disk.*/
 	if (ext4_bcache_test_flag(block->buf, BC_DIRTY) &&
-	    block->buf->end_write == jbd_trans_end_write) {
+	    block->buf->end_write == jbd_trans_end_write &&
+	    block->buf->end_write_arg != trans) {
 		r = ext4_block_flush_buf(fs->bdev, block->buf);
 	}
 	return r;
--- a/lwext4/ext4_journal.h
+++ b/lwext4/ext4_journal.h
@@ -56,6 +56,7 @@
 int jbd_journal_stop(struct jbd_journal *journal);
 struct jbd_trans *jbd_journal_new_trans(struct jbd_journal *journal);
 int jbd_trans_get_access(struct jbd_journal *journal,
+			 struct jbd_trans *trans,
 			 struct ext4_block *block);
 int jbd_trans_set_block_dirty(struct jbd_trans *trans,
 			      struct ext4_block *block);