diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2012-12-10 03:52:48 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2012-12-10 23:43:45 -0500 |
commit | 6666e6aa9f36b2bfd6b30072c07b34f2a24becf1 (patch) | |
tree | 29a4b75710c8dc3e8df25617aae0b6e51359f1f3 /fs/f2fs/inode.c | |
parent | 3cd8a23948b29301f8f67b8d70c5c18fabbc05e1 (diff) |
f2fs: fix tracking parent inode number
Previously, f2fs didn't track the parent inode number correctly which is stored
in each f2fs_inode. In the case of the following scenario, a bug can be occured.
Let's suppose there are one directory, "/b", and two files, "/a" and "/b/a".
- pino of "/a" is ROOT_INO.
- pino of "/b/a" is DIR_B_INO.
Then,
# sync
: The inode pages of "/a" and "/b/a" contain the parent inode numbers as
ROOT_INO and DIR_B_INO respectively.
# mv /a /b/a
: The parent inode number of "/a" should be changed to DIR_B_INO, but f2fs
didn't do that. Ref. f2fs_set_link().
In order to fix this clearly, I added i_pino in f2fs_inode_info, and whenever
it needs to be changed like in f2fs_add_link() and f2fs_set_link(), it is
updated temporarily in f2fs_inode_info.
And later, f2fs_write_inode() stores the latest information to the inode pages.
For power-off-recovery, f2fs_sync_file() triggers simply f2fs_write_inode().
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/inode.c')
-rw-r--r-- | fs/f2fs/inode.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index aa4ef4f48ffd..df5fb381ebf1 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c | |||
@@ -107,6 +107,7 @@ static int do_read_inode(struct inode *inode) | |||
107 | fi->flags = 0; | 107 | fi->flags = 0; |
108 | fi->data_version = le64_to_cpu(F2FS_CKPT(sbi)->checkpoint_ver) - 1; | 108 | fi->data_version = le64_to_cpu(F2FS_CKPT(sbi)->checkpoint_ver) - 1; |
109 | fi->i_advise = ri->i_advise; | 109 | fi->i_advise = ri->i_advise; |
110 | fi->i_pino = le32_to_cpu(ri->i_pino); | ||
110 | get_extent_info(&fi->ext, ri->i_ext); | 111 | get_extent_info(&fi->ext, ri->i_ext); |
111 | f2fs_put_page(node_page, 1); | 112 | f2fs_put_page(node_page, 1); |
112 | return 0; | 113 | return 0; |
@@ -200,6 +201,7 @@ void update_inode(struct inode *inode, struct page *node_page) | |||
200 | ri->i_current_depth = cpu_to_le32(F2FS_I(inode)->i_current_depth); | 201 | ri->i_current_depth = cpu_to_le32(F2FS_I(inode)->i_current_depth); |
201 | ri->i_xattr_nid = cpu_to_le32(F2FS_I(inode)->i_xattr_nid); | 202 | ri->i_xattr_nid = cpu_to_le32(F2FS_I(inode)->i_xattr_nid); |
202 | ri->i_flags = cpu_to_le32(F2FS_I(inode)->i_flags); | 203 | ri->i_flags = cpu_to_le32(F2FS_I(inode)->i_flags); |
204 | ri->i_pino = cpu_to_le32(F2FS_I(inode)->i_pino); | ||
203 | ri->i_generation = cpu_to_le32(inode->i_generation); | 205 | ri->i_generation = cpu_to_le32(inode->i_generation); |
204 | set_page_dirty(node_page); | 206 | set_page_dirty(node_page); |
205 | } | 207 | } |