aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/dir.c')
-rw-r--r--fs/f2fs/dir.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 989980e16d0b..c395c5012973 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -265,7 +265,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,
265 mutex_unlock_op(sbi, DENTRY_OPS); 265 mutex_unlock_op(sbi, DENTRY_OPS);
266} 266}
267 267
268void init_dent_inode(struct dentry *dentry, struct page *ipage) 268void init_dent_inode(const struct qstr *name, struct page *ipage)
269{ 269{
270 struct f2fs_node *rn; 270 struct f2fs_node *rn;
271 271
@@ -274,20 +274,19 @@ void init_dent_inode(struct dentry *dentry, struct page *ipage)
274 274
275 wait_on_page_writeback(ipage); 275 wait_on_page_writeback(ipage);
276 276
277 /* copy dentry info. to this inode page */ 277 /* copy name info. to this inode page */
278 rn = (struct f2fs_node *)page_address(ipage); 278 rn = (struct f2fs_node *)page_address(ipage);
279 rn->i.i_namelen = cpu_to_le32(dentry->d_name.len); 279 rn->i.i_namelen = cpu_to_le32(name->len);
280 memcpy(rn->i.i_name, dentry->d_name.name, dentry->d_name.len); 280 memcpy(rn->i.i_name, name->name, name->len);
281 set_page_dirty(ipage); 281 set_page_dirty(ipage);
282} 282}
283 283
284static int init_inode_metadata(struct inode *inode, struct dentry *dentry) 284static int init_inode_metadata(struct inode *inode,
285 struct inode *dir, const struct qstr *name)
285{ 286{
286 struct inode *dir = dentry->d_parent->d_inode;
287
288 if (is_inode_flag_set(F2FS_I(inode), FI_NEW_INODE)) { 287 if (is_inode_flag_set(F2FS_I(inode), FI_NEW_INODE)) {
289 int err; 288 int err;
290 err = new_inode_page(inode, dentry); 289 err = new_inode_page(inode, name);
291 if (err) 290 if (err)
292 return err; 291 return err;
293 292
@@ -310,7 +309,7 @@ static int init_inode_metadata(struct inode *inode, struct dentry *dentry)
310 if (IS_ERR(ipage)) 309 if (IS_ERR(ipage))
311 return PTR_ERR(ipage); 310 return PTR_ERR(ipage);
312 set_cold_node(inode, ipage); 311 set_cold_node(inode, ipage);
313 init_dent_inode(dentry, ipage); 312 init_dent_inode(name, ipage);
314 f2fs_put_page(ipage, 1); 313 f2fs_put_page(ipage, 1);
315 } 314 }
316 if (is_inode_flag_set(F2FS_I(inode), FI_INC_LINK)) { 315 if (is_inode_flag_set(F2FS_I(inode), FI_INC_LINK)) {
@@ -371,7 +370,7 @@ next:
371 goto next; 370 goto next;
372} 371}
373 372
374int f2fs_add_link(struct dentry *dentry, struct inode *inode) 373int __f2fs_add_link(struct inode *dir, const struct qstr *name, struct inode *inode)
375{ 374{
376 unsigned int bit_pos; 375 unsigned int bit_pos;
377 unsigned int level; 376 unsigned int level;
@@ -380,17 +379,15 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
380 f2fs_hash_t dentry_hash; 379 f2fs_hash_t dentry_hash;
381 struct f2fs_dir_entry *de; 380 struct f2fs_dir_entry *de;
382 unsigned int nbucket, nblock; 381 unsigned int nbucket, nblock;
383 struct inode *dir = dentry->d_parent->d_inode;
384 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 382 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
385 const char *name = dentry->d_name.name; 383 size_t namelen = name->len;
386 size_t namelen = dentry->d_name.len;
387 struct page *dentry_page = NULL; 384 struct page *dentry_page = NULL;
388 struct f2fs_dentry_block *dentry_blk = NULL; 385 struct f2fs_dentry_block *dentry_blk = NULL;
389 int slots = GET_DENTRY_SLOTS(namelen); 386 int slots = GET_DENTRY_SLOTS(namelen);
390 int err = 0; 387 int err = 0;
391 int i; 388 int i;
392 389
393 dentry_hash = f2fs_dentry_hash(name, dentry->d_name.len); 390 dentry_hash = f2fs_dentry_hash(name->name, name->len);
394 level = 0; 391 level = 0;
395 current_depth = F2FS_I(dir)->i_current_depth; 392 current_depth = F2FS_I(dir)->i_current_depth;
396 if (F2FS_I(dir)->chash == dentry_hash) { 393 if (F2FS_I(dir)->chash == dentry_hash) {
@@ -433,7 +430,7 @@ start:
433 ++level; 430 ++level;
434 goto start; 431 goto start;
435add_dentry: 432add_dentry:
436 err = init_inode_metadata(inode, dentry); 433 err = init_inode_metadata(inode, dir, name);
437 if (err) 434 if (err)
438 goto fail; 435 goto fail;
439 436
@@ -442,7 +439,7 @@ add_dentry:
442 de = &dentry_blk->dentry[bit_pos]; 439 de = &dentry_blk->dentry[bit_pos];
443 de->hash_code = dentry_hash; 440 de->hash_code = dentry_hash;
444 de->name_len = cpu_to_le16(namelen); 441 de->name_len = cpu_to_le16(namelen);
445 memcpy(dentry_blk->filename[bit_pos], name, namelen); 442 memcpy(dentry_blk->filename[bit_pos], name->name, name->len);
446 de->ino = cpu_to_le32(inode->i_ino); 443 de->ino = cpu_to_le32(inode->i_ino);
447 set_de_type(de, inode); 444 set_de_type(de, inode);
448 for (i = 0; i < slots; i++) 445 for (i = 0; i < slots; i++)