X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=lwext4%2Fext4_bcache.h;h=938f13bb3f0191bb5fc922e196c458fe63d06035;hb=b8f9e381ce116851390ed96570bcbfdd4af29438;hp=c718a1134f51a4cc72e6ec1db2b59179ac7f028e;hpb=f7eb061d6c5e916767b66d952993bbb66d0fc8f7;p=lwext4.git diff --git a/lwext4/ext4_bcache.h b/lwext4/ext4_bcache.h index c718a11..938f13b 100644 --- a/lwext4/ext4_bcache.h +++ b/lwext4/ext4_bcache.h @@ -49,16 +49,10 @@ extern "C" { #include "queue.h" #define EXT4_BLOCK_ZERO() \ - {.uptodate = 0, .dirty = 0, .lb_id = 0, .data = 0} + {.lb_id = 0, .data = 0} /**@brief Single block descriptor*/ struct ext4_block { - /**@brief Uptodate flag*/ - bool uptodate; - - /**@brief Dirty flag*/ - bool dirty; - /**@brief Logical block ID*/ uint64_t lb_id; @@ -148,9 +142,17 @@ struct ext4_bcache { SLIST_HEAD(ext4_buf_dirty, ext4_buf) dirty_list; }; +/**@brief buffer state bits + * + * - BC♡UPTODATE: Buffer contains valid data. + * - BC_DIRTY: Buffer is dirty. + * - BC_FLUSH: Buffer will be immediately flushed, + * when no one references it. + */ enum bcache_state_bits { BC_UPTODATE, - BC_DIRTY + BC_DIRTY, + BC_FLUSH }; #define ext4_bcache_set_flag(buf, b) \ @@ -162,6 +164,22 @@ enum bcache_state_bits { #define ext4_bcache_test_flag(buf, b) \ (((buf)->flags & (1 << (b))) >> (b)) +static inline void ext4_bcache_set_dirty(struct ext4_buf *buf) { + ext4_bcache_set_flag(buf, BC_UPTODATE); + ext4_bcache_set_flag(buf, BC_DIRTY); +} + +static inline void ext4_bcache_clear_dirty(struct ext4_buf *buf) { + ext4_bcache_clear_flag(buf, BC_UPTODATE); + ext4_bcache_clear_flag(buf, BC_DIRTY); +} + +/**@brief Increment reference counter of buf by 1.*/ +#define ext4_bcache_inc_ref(buf) ((buf)->refctr++) + +/**@brief Decrement reference counter of buf by 1.*/ +#define ext4_bcache_dec_ref(buf) ((buf)->refctr--) + /**@brief Static initializer of block cache structure.*/ #define EXT4_BCACHE_STATIC_INSTANCE(__name, __cnt, __itemsize) \ static struct ext4_bcache __name = { \