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>
This commit is contained in:
Al Viro 2013-01-25 16:15:43 -05:00
parent 69f24eac55
commit b7f7a5e0be
3 changed files with 17 additions and 15 deletions

View file

@ -370,7 +370,7 @@ static int room_for_filename(struct f2fs_dentry_block *dentry_blk, int slots)
goto next; goto next;
} }
int f2fs_add_link(struct dentry *dentry, struct inode *inode) int __f2fs_add_link(struct inode *dir, const struct qstr *name, struct inode *inode)
{ {
unsigned int bit_pos; unsigned int bit_pos;
unsigned int level; unsigned int level;
@ -379,17 +379,15 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
f2fs_hash_t dentry_hash; f2fs_hash_t dentry_hash;
struct f2fs_dir_entry *de; struct f2fs_dir_entry *de;
unsigned int nbucket, nblock; unsigned int nbucket, nblock;
struct inode *dir = dentry->d_parent->d_inode;
struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
const char *name = dentry->d_name.name; size_t namelen = name->len;
size_t namelen = dentry->d_name.len;
struct page *dentry_page = NULL; struct page *dentry_page = NULL;
struct f2fs_dentry_block *dentry_blk = NULL; struct f2fs_dentry_block *dentry_blk = NULL;
int slots = GET_DENTRY_SLOTS(namelen); int slots = GET_DENTRY_SLOTS(namelen);
int err = 0; int err = 0;
int i; int i;
dentry_hash = f2fs_dentry_hash(name, dentry->d_name.len); dentry_hash = f2fs_dentry_hash(name->name, name->len);
level = 0; level = 0;
current_depth = F2FS_I(dir)->i_current_depth; current_depth = F2FS_I(dir)->i_current_depth;
if (F2FS_I(dir)->chash == dentry_hash) { if (F2FS_I(dir)->chash == dentry_hash) {
@ -432,7 +430,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
++level; ++level;
goto start; goto start;
add_dentry: add_dentry:
err = init_inode_metadata(inode, dir, &dentry->d_name); err = init_inode_metadata(inode, dir, name);
if (err) if (err)
goto fail; goto fail;
@ -441,7 +439,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
de = &dentry_blk->dentry[bit_pos]; de = &dentry_blk->dentry[bit_pos];
de->hash_code = dentry_hash; de->hash_code = dentry_hash;
de->name_len = cpu_to_le16(namelen); de->name_len = cpu_to_le16(namelen);
memcpy(dentry_blk->filename[bit_pos], name, namelen); memcpy(dentry_blk->filename[bit_pos], name->name, name->len);
de->ino = cpu_to_le32(inode->i_ino); de->ino = cpu_to_le32(inode->i_ino);
set_de_type(de, inode); set_de_type(de, inode);
for (i = 0; i < slots; i++) for (i = 0; i < slots; i++)

View file

@ -868,11 +868,17 @@ ino_t f2fs_inode_by_name(struct inode *, struct qstr *);
void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, void f2fs_set_link(struct inode *, struct f2fs_dir_entry *,
struct page *, struct inode *); struct page *, struct inode *);
void init_dent_inode(const struct qstr *, struct page *); void init_dent_inode(const struct qstr *, struct page *);
int f2fs_add_link(struct dentry *, struct inode *); int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *);
void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *); void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *);
int f2fs_make_empty(struct inode *, struct inode *); int f2fs_make_empty(struct inode *, struct inode *);
bool f2fs_empty_dir(struct inode *); bool f2fs_empty_dir(struct inode *);
static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
{
return __f2fs_add_link(dentry->d_parent->d_inode, &dentry->d_name,
inode);
}
/* /*
* super.c * super.c
*/ */

View file

@ -42,7 +42,7 @@ static int recover_dentry(struct page *ipage, struct inode *inode)
{ {
struct f2fs_node *raw_node = (struct f2fs_node *)kmap(ipage); struct f2fs_node *raw_node = (struct f2fs_node *)kmap(ipage);
struct f2fs_inode *raw_inode = &(raw_node->i); struct f2fs_inode *raw_inode = &(raw_node->i);
struct dentry dent, parent; struct qstr name;
struct f2fs_dir_entry *de; struct f2fs_dir_entry *de;
struct page *page; struct page *page;
struct inode *dir; struct inode *dir;
@ -57,17 +57,15 @@ static int recover_dentry(struct page *ipage, struct inode *inode)
goto out; goto out;
} }
parent.d_inode = dir; name.len = le32_to_cpu(raw_inode->i_namelen);
dent.d_parent = &parent; name.name = raw_inode->i_name;
dent.d_name.len = le32_to_cpu(raw_inode->i_namelen);
dent.d_name.name = raw_inode->i_name;
de = f2fs_find_entry(dir, &dent.d_name, &page); de = f2fs_find_entry(dir, &name, &page);
if (de) { if (de) {
kunmap(page); kunmap(page);
f2fs_put_page(page, 0); f2fs_put_page(page, 0);
} else { } else {
f2fs_add_link(&dent, inode); __f2fs_add_link(dir, &name, inode);
} }
iput(dir); iput(dir);
out: out: