fiemap: add fsync after write split file name
If device abnormal restart during upgrade, update_engine just
created split cow image file and wrote the name to xxx-cow-img.img.
After restart, update_engine will report following err:
06-30 08:48:06.466 root 8918 8920 E gsid : Error removing image
product_b-cow-img: File name too long
That is because SplitFiemap::Create->DetermineMaximumFileSize
open xxx-cow-img.img to get some info, then fsync and unlink this
file.
On device use f2fs, after restart, f2fs_recover_fsync_data will
recover this file with inode block sync to ufs in following path:
DetermineMaximumFileSize
->FiemapWriter::Open
->AllocateFile
This make xxx-cow-img.img file content corruption.
Update_engine call TryCancelUpdate to clean up the residual files
of last upgrade, cannot read valid split file name from
xxx-cow-img.img, then report err log mentioned above.
Add fsync, f2fs can use correct inode to recover related files.
This can reduce the probability of this issue.
Test: abnormal restart when upgrade
Change-Id: Iceb3e5604d90495350c5fb1fb3433732372f3fec
Signed-off-by: lijiazi <lijiazi@xiaomi.com>
This commit is contained in:
parent
615bf4ef14
commit
ebff7b8b97
1 changed files with 1 additions and 0 deletions
|
|
@ -136,6 +136,7 @@ FiemapStatus SplitFiemap::Create(const std::string& file_path, uint64_t file_siz
|
|||
return FiemapStatus::FromErrno(errno);
|
||||
}
|
||||
}
|
||||
fsync(fd.get());
|
||||
|
||||
// Unset this bit, so we don't unlink on destruction.
|
||||
out->creating_ = false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue