ref: 01423f78d01581812e8e1c018902af4a323d4c41
parent: 9fe8815522e8dc1bff0d825f52ababb9fbbab22f
author: ngkaho1234 <ngkaho1234@gmail.com>
date: Fri Dec 25 20:39:18 EST 2015
ext4_blockdev: add ext4_block_flush_lba routine.
--- a/lwext4/ext4_blockdev.c
+++ b/lwext4/ext4_blockdev.c
@@ -161,6 +161,19 @@
return EOK;
}
+int ext4_block_flush_lba(struct ext4_blockdev *bdev, uint64_t lba)
+{
+ int r = EOK;
+ struct ext4_buf *buf;
+ struct ext4_block b;
+ buf = ext4_bcache_find_get(bdev->bc, &b, lba);
+ if (buf) {
+ r = ext4_block_flush_buf(bdev, buf);
+ ext4_bcache_free(bdev->bc, &b);
+ }
+ return r;
+}
+
int ext4_block_cache_shake(struct ext4_blockdev *bdev)
{
struct ext4_buf *buf;
--- a/lwext4/ext4_blockdev.h
+++ b/lwext4/ext4_blockdev.h
@@ -169,6 +169,13 @@
* @return standard error code*/
int ext4_block_flush_buf(struct ext4_blockdev *bdev, struct ext4_buf *buf);
+/**@brief Flush data in buffer of given lba to disk,
+ * if that buffer exists in block cache.
+ * @param bdev block device descriptor
+ * @param lba logical block address
+ * @return standard error code*/
+int ext4_block_flush_lba(struct ext4_blockdev *bdev, uint64_t lba);
+
/**@brief Set logical block size in block device.
* @param bdev block device descriptor
* @param lb_size logical block size (in bytes)