aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2013-07-18 05:02:31 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-07-30 02:17:03 -0400
commit1cd14cafc694bcedc5017a4f0dcb3c3faddec622 (patch)
tree367eb533ab6475ccec4f809f7117fc845a64abbe
parent4559071063270999d016c92a0b9241692cbbb522 (diff)
f2fs: update file name in the inode block during f2fs_rename
The error is reproducible by: 0. mkfs.f2fs /dev/sdb1 & mount 1. touch test1 2. touch test2 3. mv test1 test2 4. umount 5. dumpt.f2fs -i 4 /dev/sdb1 After this, when we retrieve the inode->i_name of test2 by dump.f2fs, we get test1 instead of test2. This is because f2fs didn't update the file name during the f2fs_rename. So, this patch fixes that. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r--fs/f2fs/dir.c15
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/namei.c5
3 files changed, 21 insertions, 0 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 89ecb3785321..d1bb2606b313 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -276,6 +276,21 @@ static void init_dent_inode(const struct qstr *name, struct page *ipage)
276 set_page_dirty(ipage); 276 set_page_dirty(ipage);
277} 277}
278 278
279int update_dent_inode(struct inode *inode, const struct qstr *name)
280{
281 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
282 struct page *page;
283
284 page = get_node_page(sbi, inode->i_ino);
285 if (IS_ERR(page))
286 return PTR_ERR(page);
287
288 init_dent_inode(name, page);
289 f2fs_put_page(page, 1);
290
291 return 0;
292}
293
279static int make_empty_dir(struct inode *inode, 294static int make_empty_dir(struct inode *inode,
280 struct inode *parent, struct page *page) 295 struct inode *parent, struct page *page)
281{ 296{
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 2dfd584bf79f..a6858c75259d 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -953,6 +953,7 @@ struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **);
953ino_t f2fs_inode_by_name(struct inode *, struct qstr *); 953ino_t f2fs_inode_by_name(struct inode *, struct qstr *);
954void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, 954void f2fs_set_link(struct inode *, struct f2fs_dir_entry *,
955 struct page *, struct inode *); 955 struct page *, struct inode *);
956int update_dent_inode(struct inode *, const struct qstr *);
956int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *); 957int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *);
957void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *); 958void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *);
958int f2fs_make_empty(struct inode *, struct inode *); 959int f2fs_make_empty(struct inode *, struct inode *);
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 64c07169df05..32972787f12f 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -427,6 +427,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
427 if (!new_entry) 427 if (!new_entry)
428 goto out_dir; 428 goto out_dir;
429 429
430 if (update_dent_inode(old_inode, &new_dentry->d_name)) {
431 f2fs_put_page(new_page, 1);
432 goto out_dir;
433 }
434
430 f2fs_set_link(new_dir, new_entry, new_page, old_inode); 435 f2fs_set_link(new_dir, new_entry, new_page, old_inode);
431 436
432 new_inode->i_ctime = CURRENT_TIME; 437 new_inode->i_ctime = CURRENT_TIME;