diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-01-25 16:15:43 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-08 02:55:04 -0500 |
commit | b7f7a5e0be94d13875a1c6c9aa65eeb11a46fc1b (patch) | |
tree | 69145a46a70aae7ba6bf0e03b46617bbb74f1a1b /fs/f2fs | |
parent | 69f24eac55725859a89c440ee2d19f36fa09e8fc (diff) |
f2fs: get rid of fake on-stack dentries
those should never be used for a lot of reasons...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/dir.c | 12 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 8 | ||||
-rw-r--r-- | fs/f2fs/recovery.c | 12 |
3 files changed, 17 insertions, 15 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 208a804180d6..47df9252ad6a 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c | |||
@@ -370,7 +370,7 @@ next: | |||
370 | goto next; | 370 | goto next; |
371 | } | 371 | } |
372 | 372 | ||
373 | int f2fs_add_link(struct dentry *dentry, struct inode *inode) | 373 | int __f2fs_add_link(struct inode *dir, const struct qstr *name, struct inode *inode) |
374 | { | 374 | { |
375 | unsigned int bit_pos; | 375 | unsigned int bit_pos; |
376 | unsigned int level; | 376 | unsigned int level; |
@@ -379,17 +379,15 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode) | |||
379 | f2fs_hash_t dentry_hash; | 379 | f2fs_hash_t dentry_hash; |
380 | struct f2fs_dir_entry *de; | 380 | struct f2fs_dir_entry *de; |
381 | unsigned int nbucket, nblock; | 381 | unsigned int nbucket, nblock; |
382 | struct inode *dir = dentry->d_parent->d_inode; | ||
383 | struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); | 382 | struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); |
384 | const char *name = dentry->d_name.name; | 383 | size_t namelen = name->len; |
385 | size_t namelen = dentry->d_name.len; | ||
386 | struct page *dentry_page = NULL; | 384 | struct page *dentry_page = NULL; |
387 | struct f2fs_dentry_block *dentry_blk = NULL; | 385 | struct f2fs_dentry_block *dentry_blk = NULL; |
388 | int slots = GET_DENTRY_SLOTS(namelen); | 386 | int slots = GET_DENTRY_SLOTS(namelen); |
389 | int err = 0; | 387 | int err = 0; |
390 | int i; | 388 | int i; |
391 | 389 | ||
392 | dentry_hash = f2fs_dentry_hash(name, dentry->d_name.len); | 390 | dentry_hash = f2fs_dentry_hash(name->name, name->len); |
393 | level = 0; | 391 | level = 0; |
394 | current_depth = F2FS_I(dir)->i_current_depth; | 392 | current_depth = F2FS_I(dir)->i_current_depth; |
395 | if (F2FS_I(dir)->chash == dentry_hash) { | 393 | if (F2FS_I(dir)->chash == dentry_hash) { |
@@ -432,7 +430,7 @@ start: | |||
432 | ++level; | 430 | ++level; |
433 | goto start; | 431 | goto start; |
434 | add_dentry: | 432 | add_dentry: |
435 | err = init_inode_metadata(inode, dir, &dentry->d_name); | 433 | err = init_inode_metadata(inode, dir, name); |
436 | if (err) | 434 | if (err) |
437 | goto fail; | 435 | goto fail; |
438 | 436 | ||
@@ -441,7 +439,7 @@ add_dentry: | |||
441 | de = &dentry_blk->dentry[bit_pos]; | 439 | de = &dentry_blk->dentry[bit_pos]; |
442 | de->hash_code = dentry_hash; | 440 | de->hash_code = dentry_hash; |
443 | de->name_len = cpu_to_le16(namelen); | 441 | de->name_len = cpu_to_le16(namelen); |
444 | memcpy(dentry_blk->filename[bit_pos], name, namelen); | 442 | memcpy(dentry_blk->filename[bit_pos], name->name, name->len); |
445 | de->ino = cpu_to_le32(inode->i_ino); | 443 | de->ino = cpu_to_le32(inode->i_ino); |
446 | set_de_type(de, inode); | 444 | set_de_type(de, inode); |
447 | for (i = 0; i < slots; i++) | 445 | for (i = 0; i < slots; i++) |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index bfdc10741ff1..6895ecc351ed 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -868,11 +868,17 @@ ino_t f2fs_inode_by_name(struct inode *, struct qstr *); | |||
868 | void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, | 868 | void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, |
869 | struct page *, struct inode *); | 869 | struct page *, struct inode *); |
870 | void init_dent_inode(const struct qstr *, struct page *); | 870 | void init_dent_inode(const struct qstr *, struct page *); |
871 | int f2fs_add_link(struct dentry *, struct inode *); | 871 | int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *); |
872 | void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *); | 872 | void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *); |
873 | int f2fs_make_empty(struct inode *, struct inode *); | 873 | int f2fs_make_empty(struct inode *, struct inode *); |
874 | bool f2fs_empty_dir(struct inode *); | 874 | bool f2fs_empty_dir(struct inode *); |
875 | 875 | ||
876 | static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode) | ||
877 | { | ||
878 | return __f2fs_add_link(dentry->d_parent->d_inode, &dentry->d_name, | ||
879 | inode); | ||
880 | } | ||
881 | |||
876 | /* | 882 | /* |
877 | * super.c | 883 | * super.c |
878 | */ | 884 | */ |
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index b571fee677d5..62000422879a 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c | |||
@@ -42,7 +42,7 @@ static int recover_dentry(struct page *ipage, struct inode *inode) | |||
42 | { | 42 | { |
43 | struct f2fs_node *raw_node = (struct f2fs_node *)kmap(ipage); | 43 | struct f2fs_node *raw_node = (struct f2fs_node *)kmap(ipage); |
44 | struct f2fs_inode *raw_inode = &(raw_node->i); | 44 | struct f2fs_inode *raw_inode = &(raw_node->i); |
45 | struct dentry dent, parent; | 45 | struct qstr name; |
46 | struct f2fs_dir_entry *de; | 46 | struct f2fs_dir_entry *de; |
47 | struct page *page; | 47 | struct page *page; |
48 | struct inode *dir; | 48 | struct inode *dir; |
@@ -57,17 +57,15 @@ static int recover_dentry(struct page *ipage, struct inode *inode) | |||
57 | goto out; | 57 | goto out; |
58 | } | 58 | } |
59 | 59 | ||
60 | parent.d_inode = dir; | 60 | name.len = le32_to_cpu(raw_inode->i_namelen); |
61 | dent.d_parent = &parent; | 61 | name.name = raw_inode->i_name; |
62 | dent.d_name.len = le32_to_cpu(raw_inode->i_namelen); | ||
63 | dent.d_name.name = raw_inode->i_name; | ||
64 | 62 | ||
65 | de = f2fs_find_entry(dir, &dent.d_name, &page); | 63 | de = f2fs_find_entry(dir, &name, &page); |
66 | if (de) { | 64 | if (de) { |
67 | kunmap(page); | 65 | kunmap(page); |
68 | f2fs_put_page(page, 0); | 66 | f2fs_put_page(page, 0); |
69 | } else { | 67 | } else { |
70 | f2fs_add_link(&dent, inode); | 68 | __f2fs_add_link(dir, &name, inode); |
71 | } | 69 | } |
72 | iput(dir); | 70 | iput(dir); |
73 | out: | 71 | out: |