summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2013-05-28 09:19:22 +0900
committerChanho Park <chanho61.park@samsung.com>2014-11-18 11:43:49 +0900
commitcd30815328214eada9b1d2db98d4f083db1c484d (patch)
tree1c71e05788e9283f3ca5ad32262cd810e0aca0c6
parentd459aab1f3a0b7b91a3450769b1d85611acdefc5 (diff)
downloadlinux-3.10-cd30815328214eada9b1d2db98d4f083db1c484d.tar.gz
linux-3.10-cd30815328214eada9b1d2db98d4f083db1c484d.tar.bz2
linux-3.10-cd30815328214eada9b1d2db98d4f083db1c484d.zip
f2fs: fix dentry recovery routine
The error scenario is: 1. create /a (1.a link /a /b) 2. sync 3. unlinke /a 4. create /a 5. fsync /a 6. Sudden power-off When the f2fs recovers the fsynced dentry, /a, we discover an exsiting dentry at f2fs_find_entry() in recover_dentry(). In such the case, we should unlink the existing dentry and its inode and then recover newly created dentry. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r--fs/f2fs/recovery.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 0dd2ce1b492..539ca32f448 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -44,9 +44,10 @@ static int recover_dentry(struct page *ipage, struct inode *inode)
struct f2fs_node *raw_node = (struct f2fs_node *)kaddr;
struct f2fs_inode *raw_inode = &(raw_node->i);
nid_t pino = le32_to_cpu(raw_inode->i_pino);
+ struct f2fs_dir_entry *de;
struct qstr name;
struct page *page;
- struct inode *dir;
+ struct inode *dir, *einode;
int err = 0;
dir = check_dirty_dir_inode(F2FS_SB(inode->i_sb), pino);
@@ -61,13 +62,26 @@ static int recover_dentry(struct page *ipage, struct inode *inode)
name.len = le32_to_cpu(raw_inode->i_namelen);
name.name = raw_inode->i_name;
-
- if (f2fs_find_entry(dir, &name, &page)) {
+retry:
+ de = f2fs_find_entry(dir, &name, &page);
+ if (de && inode->i_ino == le32_to_cpu(de->ino)) {
kunmap(page);
f2fs_put_page(page, 0);
- } else {
- err = __f2fs_add_link(dir, &name, inode);
+ goto out;
+ }
+ if (de) {
+ einode = f2fs_iget(inode->i_sb, le32_to_cpu(de->ino));
+ if (IS_ERR(einode)) {
+ WARN_ON(1);
+ if (PTR_ERR(einode) == -ENOENT)
+ err = -EEXIST;
+ goto out;
+ }
+ f2fs_delete_entry(de, page, einode);
+ iput(einode);
+ goto retry;
}
+ err = __f2fs_add_link(dir, &name, inode);
out:
f2fs_msg(inode->i_sb, KERN_NOTICE, "recover_inode and its dentry: "
"ino = %x, name = %s, dir = %lx, err = %d",