Browse Source

ext4_bcache: remove free_delay member from ext4_bcache.

pull/11/head
ngkaho1234 9 years ago
committed by gkostka
parent
commit
08c696765f
  1. 15
      lwext4/ext4_bcache.c
  2. 7
      lwext4/ext4_bcache.h
  3. 10
      lwext4/ext4_blockdev.c

15
lwext4/ext4_bcache.c

@ -110,20 +110,14 @@ ext4_buf_alloc(struct ext4_bcache *bc, uint64_t lba)
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 @@ int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b,
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;
@ -242,10 +235,6 @@ int ext4_bcache_free(struct ext4_bcache *bc, struct ext4_block *b,
/*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) {
ext4_bcache_set_flag(buf, BC_DIRTY);

7
lwext4/ext4_bcache.h

@ -111,9 +111,6 @@ struct ext4_bcache {
/**@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 @@ int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b,
/**@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

10
lwext4/ext4_blockdev.c

@ -180,7 +180,7 @@ int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b,
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 @@ int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b)
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,14 +227,14 @@ int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b)
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;
}
b->dirty = false;
bdev->bwrite_ctr++;
}
ext4_bcache_free(bdev->bc, b, 0);
ext4_bcache_free(bdev->bc, b);
return EOK;
}

Loading…
Cancel
Save