bg_ref.dirty = true;
+ ext4_bcache_invalidate_lba(fs->bdev->bc, baddr, 1);
/* Release block group reference */
return ext4_fs_put_block_group_ref(&bg_ref);
}
bg_first++;
}
+ ext4_bcache_invalidate_lba(fs->bdev->bc, first, count);
/*All blocks should be released*/
ext4_assert(count == 0);
return rc;
bc->ref_blocks--;
}
+void ext4_bcache_invalidate_lba(struct ext4_bcache *bc,
+ uint64_t from,
+ uint32_t cnt)
+{
+ uint64_t end = from + cnt - 1;
+ struct ext4_buf *tmp = ext4_buf_lookup(bc, from), *buf;
+ RB_FOREACH_FROM(buf, ext4_buf_lba, tmp) {
+ if (buf->lba > end)
+ break;
+
+ /* Clear both dirty and up-to-date flags. */
+ ext4_bcache_clear_dirty(buf);
+ }
+}
+
struct ext4_buf *
ext4_bcache_find_get(struct ext4_bcache *bc, struct ext4_block *b,
uint64_t lba)
* @param buf buffer*/
void ext4_bcache_drop_buf(struct ext4_bcache *bc, struct ext4_buf *buf);
+/**@brief Invalidate a range of buffers.
+ * @param bc block cache descriptor
+ * @param from starting lba
+ * @param cnt block counts
+ * @param buf buffer*/
+void ext4_bcache_invalidate_lba(struct ext4_bcache *bc,
+ uint64_t from,
+ uint32_t cnt);
+
/**@brief Find existing buffer from block cache memory.
* Unreferenced block allocation is based on LRU
* (Last Recently Used) algorithm.