Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
f2fs: avoid data race between FI_DIRTY_INODE flag and update_inode
Browse files Browse the repository at this point in the history
FI_DIRTY_INODE flag is not covered by inode page lock, so it can be unset
at any time like below.

Thread #1                        Thread #2
- lock_page(ipage)
- update i_fields
                                 - update i_size/i_blocks/and so on
				 - set FI_DIRTY_INODE
- reset FI_DIRTY_INODE
- set_page_dirty(ipage)

In this case, we can lose the latest i_field information.

Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
Jaegeuk Kim committed Jul 22, 2016
1 parent 3bcbb3c commit c6f2251
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/f2fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ int update_inode(struct inode *inode, struct page *node_page)
{
struct f2fs_inode *ri;

f2fs_inode_synced(inode);

f2fs_wait_on_page_writeback(node_page, NODE, true);

ri = F2FS_INODE(node_page);
Expand Down Expand Up @@ -264,7 +266,6 @@ int update_inode(struct inode *inode, struct page *node_page)

__set_inode_rdev(inode, ri);
set_cold_node(inode, node_page);
f2fs_inode_synced(inode);

/* deleted inode */
if (inode->i_nlink == 0)
Expand Down

0 comments on commit c6f2251

Please sign in to comment.