ref: 08c696765fb280e41b2637fa17b49d9272c8f865
parent: 91f46286cc54a2c7a327feb10eec830b41089ecc
author: ngkaho1234 <ngkaho1234@gmail.com>
date: Mon Nov 23 10:07:01 EST 2015
ext4_bcache: remove free_delay member from ext4_bcache.
--- a/lwext4/ext4_bcache.c
+++ b/lwext4/ext4_bcache.c
@@ -110,20 +110,14 @@
if (!data)
return NULL;
- buf = malloc(sizeof(struct ext4_buf));
+ buf = calloc(1, sizeof(struct ext4_buf));
if (!buf) {
free(data);
return NULL;
}
- buf->flags = 0;
buf->lba = lba;
buf->data = data;
- buf->lru_id = 0;
- buf->refctr = 0;
- memset(&buf->lba_node, 0, sizeof(buf->lba_node));
- memset(&buf->lru_node, 0, sizeof(buf->lru_node));
- memset(&buf->dirty_node, 0, sizeof(buf->dirty_node));
return buf;
}
@@ -223,8 +217,7 @@
return EOK;
}
-int ext4_bcache_free(struct ext4_bcache *bc, struct ext4_block *b,
- uint8_t free_delay)
+int ext4_bcache_free(struct ext4_bcache *bc, struct ext4_block *b)
{
struct ext4_buf *buf = b->buf;
@@ -241,10 +234,6 @@
/*Just decrease reference counter*/
buf->refctr--;
-
- /* TODO: it looks useless... */
- if (free_delay)
- bc->free_delay = free_delay;
/* If buffer is modified, buf will be mark up-to-date and dirty. */
if (b->dirty) {
--- a/lwext4/ext4_bcache.h
+++ b/lwext4/ext4_bcache.h
@@ -111,9 +111,6 @@
/**@brief Last recently used counter*/
uint32_t lru_ctr;
- /**@brief Writeback free delay mode*/
- uint8_t free_delay;
-
/**@brief Currently referenced datablocks*/
uint32_t ref_blocks;
@@ -188,10 +185,8 @@
/**@brief Free block from cache memory (decrement reference counter).
* @param bc block cache descriptor
* @param b block to free
- * @param cache writeback mode
* @return standard error code*/
-int ext4_bcache_free(struct ext4_bcache *bc, struct ext4_block *b,
- uint8_t free_delay);
+int ext4_bcache_free(struct ext4_bcache *bc, struct ext4_block *b);
/**@brief Return a full status of block cache.
* @param bc block cache descriptor
--- a/lwext4/ext4_blockdev.c
+++ b/lwext4/ext4_blockdev.c
@@ -180,7 +180,7 @@
r = bdev->bread(bdev, b->data, pba, pb_cnt);
if (r != EOK) {
- ext4_bcache_free(bdev->bc, b, 0);
+ ext4_bcache_free(bdev->bc, b);
b->lb_id = 0;
return r;
}
@@ -209,11 +209,11 @@
if (bdev->cache_write_back) {
/*Free cache block and mark as free delayed*/
- return ext4_bcache_free(bdev->bc, b, bdev->cache_write_back);
+ return ext4_bcache_free(bdev->bc, b);
}
if (b->buf->refctr > 1)
- return ext4_bcache_free(bdev->bc, b, 0);
+ return ext4_bcache_free(bdev->bc, b);
/*We handle the dirty flag ourselves.*/
if (ext4_bcache_test_flag(b->buf, BC_DIRTY) || b->dirty) {
@@ -227,7 +227,7 @@
ext4_bcache_clear_flag(b->buf, BC_DIRTY);
if (r != EOK) {
b->dirty = true;
- ext4_bcache_free(bdev->bc, b, 0);
+ ext4_bcache_free(bdev->bc, b);
return r;
}
@@ -234,7 +234,7 @@
b->dirty = false;
bdev->bwrite_ctr++;
}
- ext4_bcache_free(bdev->bc, b, 0);
+ ext4_bcache_free(bdev->bc, b);
return EOK;
}