ref: 46c3c339d15e69ac633e122b95861151d6af1c62
parent: 01423f78d01581812e8e1c018902af4a323d4c41
author: ngkaho1234 <ngkaho1234@gmail.com>
date: Fri Dec 25 21:18:09 EST 2015
ext4: make sure blocks are not contaminated with data in block cache.
--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -1497,6 +1497,10 @@
if (r != EOK)
goto Finish;
+ r = ext4_block_flush_lba(f->mp->fs.bdev, fblk);
+ if (r != EOK)
+ goto Finish;
+
off = fblk * block_size + unalg;
r = ext4_block_writebytes(f->mp->fs.bdev, off, u8_buf, len);
if (r != EOK)
@@ -1521,6 +1525,8 @@
fblock_count = 0;
while (size >= block_size) {
+ uint32_t i;
+
while (iblk_idx < iblock_last) {
if (iblk_idx < ifile_blocks) {
r = ext4_fs_init_inode_dblk_idx(&ref, iblk_idx,
@@ -1550,6 +1556,13 @@
fblock_count++;
}
+ for (i = 0;i < fblock_count;i++) {
+ r = ext4_block_flush_lba(f->mp->fs.bdev, fblock_start + i);
+ if (r != EOK)
+ goto Finish;
+
+ }
+
r = ext4_blocks_set_direct(f->mp->fs.bdev, u8_buf, fblock_start,
fblock_count);
if (r != EOK)
@@ -1592,6 +1605,10 @@
/*Node size sholud be updated.*/
goto out_fsize;
}
+
+ r = ext4_block_flush_lba(f->mp->fs.bdev, fblk);
+ if (r != EOK)
+ goto Finish;
off = fblk * block_size;
r = ext4_block_writebytes(f->mp->fs.bdev, off, u8_buf, size);