Browse Source

ext4: make sure blocks are not contaminated with data in block cache.

pull/11/head
ngkaho1234 9 years ago
parent
commit
46c3c339d1
  1. 17
      lwext4/ext4.c

17
lwext4/ext4.c

@ -1497,6 +1497,10 @@ int ext4_fwrite(ext4_file *f, const void *buf, size_t size, size_t *wcnt)
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 @@ int ext4_fwrite(ext4_file *f, const void *buf, size_t size, size_t *wcnt)
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 @@ int ext4_fwrite(ext4_file *f, const void *buf, size_t size, size_t *wcnt)
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)
@ -1593,6 +1606,10 @@ int ext4_fwrite(ext4_file *f, const void *buf, size_t size, size_t *wcnt)
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);
if (r != EOK)

Loading…
Cancel
Save