We use f2fs_finalize_device to fsync previous data in
checkpoint area before write last CP pack, in order to avoid
cp corruption in sudden-power-off case. But this function will
close the device, so this patch introduce a function to call
fsync() only.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
write_nat_bits(sbi, sb, cp, sbi->cur_cp);
/* in case of sudden power off */
- f2fs_finalize_device();
+ f2fs_fsync_device();
/* write the last cp */
ret = dev_write_block(cp, cp_blk_no++);
extern int f2fs_get_device_info(void);
extern int get_device_info(int);
extern void f2fs_finalize_device(void);
+extern void f2fs_fsync_device(void);
extern int dev_read(void *, __u64, size_t);
extern int dev_write(void *, __u64, size_t);
return dev_readahead(blk_addr << F2FS_BLKSIZE_BITS, F2FS_BLKSIZE);
}
+void f2fs_fsync_device(void)
+{
+ int i;
+
+ for (i = 0; i < c.ndevs; i++) {
+ if (fsync(c.devices[i].fd) < 0)
+ MSG(0, "\tError: Could not conduct fsync!!!\n");
+ }
+}
+
void f2fs_finalize_device(void)
{
int i;