diff options
| author | ngkaho1234 <ngkaho1234@gmail.com> | 2015-12-16 10:45:24 +0000 |
|---|---|---|
| committer | ngkaho1234 <ngkaho1234@gmail.com> | 2015-12-16 10:54:24 +0000 |
| commit | 3b136f8a7036606a9e6c130ee292da2a9ae39123 (patch) | |
| tree | c0783d7af6993cf6f17928e3115a5b10a837b8a7 | |
| parent | e299c8d66002d6b9c8d77b3c6c3247e0915fd8c6 (diff) | |
ext4_bcache: add new flag BC_FLUSH.
| -rw-r--r-- | lwext4/ext4_bcache.c | 7 | ||||
| -rw-r--r-- | lwext4/ext4_bcache.h | 10 |
2 files changed, 14 insertions, 3 deletions
diff --git a/lwext4/ext4_bcache.c b/lwext4/ext4_bcache.c index ab19c17..fb37f44 100644 --- a/lwext4/ext4_bcache.c +++ b/lwext4/ext4_bcache.c @@ -233,10 +233,13 @@ int ext4_bcache_free(struct ext4_bcache *bc, struct ext4_block *b) RB_INSERT(ext4_buf_lru, &bc->lru_root, buf); /* This buffer is ready to be flushed. */ if (ext4_bcache_test_flag(buf, BC_DIRTY)) { - if (bc->bdev->cache_write_back) + if (bc->bdev->cache_write_back && + !ext4_bcache_test_flag(buf, BC_FLUSH)) ext4_bcache_insert_dirty_node(bc, buf); - else + else { ext4_block_flush_buf(bc->bdev, buf); + ext4_bcache_clear_flag(buf, BC_FLUSH); + } } /* The buffer is invalidated...drop it. */ diff --git a/lwext4/ext4_bcache.h b/lwext4/ext4_bcache.h index 40431d2..938f13b 100644 --- a/lwext4/ext4_bcache.h +++ b/lwext4/ext4_bcache.h @@ -142,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) \ |
