summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorngkaho1234 <ngkaho1234@gmail.com>2015-12-25 12:07:01 +0000
committerngkaho1234 <ngkaho1234@gmail.com>2015-12-25 23:28:51 +0800
commitcb473bbcead90b2541817f81f7a030d6e8215185 (patch)
tree16a68abfe22c0f0b2d9ff072dee6f00088c438b6
parent1366373d0c66281935e9e0fc71f52f5919a3a085 (diff)
ext4_journal: set buffer dirty if it does not belong to any transaction.
When calling jbd_trans_set_block_dirty, if a buffer does not belong to any other transaction, it will be set dirty.
-rw-r--r--lwext4/ext4_journal.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/lwext4/ext4_journal.c b/lwext4/ext4_journal.c
index ada92ff..059606b 100644
--- a/lwext4/ext4_journal.c
+++ b/lwext4/ext4_journal.c
@@ -1123,23 +1123,26 @@ int jbd_trans_set_block_dirty(struct jbd_trans *trans,
{
struct jbd_buf *buf;
- buf = calloc(1, sizeof(struct jbd_buf));
- if (!buf)
- return ENOMEM;
+ if (!ext4_bcache_test_flag(block->buf, BC_DIRTY) &&
+ block->buf->end_write != jbd_trans_end_write) {
+ buf = calloc(1, sizeof(struct jbd_buf));
+ if (!buf)
+ return ENOMEM;
- buf->trans = trans;
- buf->block = *block;
- ext4_bcache_inc_ref(block->buf);
+ buf->trans = trans;
+ buf->block = *block;
+ ext4_bcache_inc_ref(block->buf);
- /* If the content reach the disk, notify us
- * so that we may do a checkpoint. */
- block->buf->end_write = jbd_trans_end_write;
- block->buf->end_write_arg = buf;
+ /* If the content reach the disk, notify us
+ * so that we may do a checkpoint. */
+ block->buf->end_write = jbd_trans_end_write;
+ block->buf->end_write_arg = buf;
- trans->data_cnt++;
- LIST_INSERT_HEAD(&trans->buf_list, buf, buf_node);
+ trans->data_cnt++;
+ LIST_INSERT_HEAD(&trans->buf_list, buf, buf_node);
- ext4_bcache_set_dirty(block->buf);
+ ext4_bcache_set_dirty(block->buf);
+ }
return EOK;
}