提交 7dc4f001 编写于 作者: C Christoph Hellwig 提交者: Christoph Hellwig

hfsplus: make sure sync writes out all metadata

hfsplus stores all metadata except for the volume headers in special
inodes.  While these are marked hashed and periodically written out
by the flusher threads, we can't rely on that for sync.  For the case
of a data integrity sync the VM has life-lock avoidance code that
avoids writing inodes again that are redirtied during the sync,
which is something that can happen easily for hfsplus.  So make sure
we explicitly write out the metadata inodes at the beginning of
hfsplus_sync_fs.
Signed-off-by: NChristoph Hellwig <hch@tuxera.com>
上级 358f26d5
...@@ -164,6 +164,22 @@ int hfsplus_sync_fs(struct super_block *sb, int wait) ...@@ -164,6 +164,22 @@ int hfsplus_sync_fs(struct super_block *sb, int wait)
sb->s_dirt = 0; sb->s_dirt = 0;
/*
* Explicitly write out the special metadata inodes.
*
* While these special inodes are marked as hashed and written
* out peridocically by the flusher threads we redirty them
* during writeout of normal inodes, and thus the life lock
* prevents us from getting the latest state to disk.
*/
error = filemap_write_and_wait(sbi->cat_tree->inode->i_mapping);
error2 = filemap_write_and_wait(sbi->ext_tree->inode->i_mapping);
if (!error)
error = error2;
error2 = filemap_write_and_wait(sbi->alloc_file->i_mapping);
if (!error)
error = error2;
mutex_lock(&sbi->vh_mutex); mutex_lock(&sbi->vh_mutex);
mutex_lock(&sbi->alloc_mutex); mutex_lock(&sbi->alloc_mutex);
vhdr->free_blocks = cpu_to_be32(sbi->free_blocks); vhdr->free_blocks = cpu_to_be32(sbi->free_blocks);
...@@ -176,9 +192,11 @@ int hfsplus_sync_fs(struct super_block *sb, int wait) ...@@ -176,9 +192,11 @@ int hfsplus_sync_fs(struct super_block *sb, int wait)
write_backup = 1; write_backup = 1;
} }
error = hfsplus_submit_bio(sb->s_bdev, error2 = hfsplus_submit_bio(sb->s_bdev,
sbi->part_start + HFSPLUS_VOLHEAD_SECTOR, sbi->part_start + HFSPLUS_VOLHEAD_SECTOR,
sbi->s_vhdr, WRITE_SYNC); sbi->s_vhdr, WRITE_SYNC);
if (!error)
error = error2;
if (!write_backup) if (!write_backup)
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册