diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-02-11 17:17:20 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-02-11 17:17:20 -0500 |
commit | 90b2fc64f0a6d6a6706eae0a90038ed576d5d4b6 (patch) | |
tree | cc76f9ae4611fee079e85fbff06596815cd1e363 /fs/f2fs | |
parent | e9750824114ff939d9da299e73651add6aa65456 (diff) | |
parent | b7f7a5e0be94d13875a1c6c9aa65eeb11a46fc1b (diff) |
Merge branch 'f2fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs into dev
Pull f2fs cleanup patches from Al Viro:
f2fs: get rid of fake on-stack dentries
f2fs: switch init_inode_metadata() to passing parent and name separately
f2fs: switch new_inode_page() from dentry to qstr
f2fs: init_dent_inode() should take qstr
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Conflicts:
fs/f2fs/recovery.c
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/dir.c | 29 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 12 | ||||
-rw-r--r-- | fs/f2fs/node.c | 4 | ||||
-rw-r--r-- | fs/f2fs/recovery.c | 12 |
4 files changed, 29 insertions, 28 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 | ||
268 | void init_dent_inode(struct dentry *dentry, struct page *ipage) | 268 | void 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 | ||
284 | static int init_inode_metadata(struct inode *inode, struct dentry *dentry) | 284 | static 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 | ||
374 | 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) |
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; |
435 | add_dentry: | 432 | add_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++) |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index c3462b69917e..cc2213afdcc7 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -889,12 +889,18 @@ struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **); | |||
889 | ino_t f2fs_inode_by_name(struct inode *, struct qstr *); | 889 | ino_t f2fs_inode_by_name(struct inode *, struct qstr *); |
890 | void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, | 890 | void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, |
891 | struct page *, struct inode *); | 891 | struct page *, struct inode *); |
892 | void init_dent_inode(struct dentry *, struct page *); | 892 | void init_dent_inode(const struct qstr *, struct page *); |
893 | int f2fs_add_link(struct dentry *, struct inode *); | 893 | int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *); |
894 | void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *); | 894 | void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *); |
895 | int f2fs_make_empty(struct inode *, struct inode *); | 895 | int f2fs_make_empty(struct inode *, struct inode *); |
896 | bool f2fs_empty_dir(struct inode *); | 896 | bool f2fs_empty_dir(struct inode *); |
897 | 897 | ||
898 | static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode) | ||
899 | { | ||
900 | return __f2fs_add_link(dentry->d_parent->d_inode, &dentry->d_name, | ||
901 | inode); | ||
902 | } | ||
903 | |||
898 | /* | 904 | /* |
899 | * super.c | 905 | * super.c |
900 | */ | 906 | */ |
@@ -918,7 +924,7 @@ void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *); | |||
918 | int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); | 924 | int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); |
919 | int truncate_inode_blocks(struct inode *, pgoff_t); | 925 | int truncate_inode_blocks(struct inode *, pgoff_t); |
920 | int remove_inode_page(struct inode *); | 926 | int remove_inode_page(struct inode *); |
921 | int new_inode_page(struct inode *, struct dentry *); | 927 | int new_inode_page(struct inode *, const struct qstr *); |
922 | struct page *new_node_page(struct dnode_of_data *, unsigned int); | 928 | struct page *new_node_page(struct dnode_of_data *, unsigned int); |
923 | void ra_node_page(struct f2fs_sb_info *, nid_t); | 929 | void ra_node_page(struct f2fs_sb_info *, nid_t); |
924 | struct page *get_node_page(struct f2fs_sb_info *, pgoff_t); | 930 | struct page *get_node_page(struct f2fs_sb_info *, pgoff_t); |
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 43ce16422b75..0da252c78af8 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
@@ -780,7 +780,7 @@ int remove_inode_page(struct inode *inode) | |||
780 | return 0; | 780 | return 0; |
781 | } | 781 | } |
782 | 782 | ||
783 | int new_inode_page(struct inode *inode, struct dentry *dentry) | 783 | int new_inode_page(struct inode *inode, const struct qstr *name) |
784 | { | 784 | { |
785 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); | 785 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); |
786 | struct page *page; | 786 | struct page *page; |
@@ -790,7 +790,7 @@ int new_inode_page(struct inode *inode, struct dentry *dentry) | |||
790 | set_new_dnode(&dn, inode, NULL, NULL, inode->i_ino); | 790 | set_new_dnode(&dn, inode, NULL, NULL, inode->i_ino); |
791 | mutex_lock_op(sbi, NODE_NEW); | 791 | mutex_lock_op(sbi, NODE_NEW); |
792 | page = new_node_page(&dn, 0); | 792 | page = new_node_page(&dn, 0); |
793 | init_dent_inode(dentry, page); | 793 | init_dent_inode(name, page); |
794 | mutex_unlock_op(sbi, NODE_NEW); | 794 | mutex_unlock_op(sbi, NODE_NEW); |
795 | if (IS_ERR(page)) | 795 | if (IS_ERR(page)) |
796 | return PTR_ERR(page); | 796 | return PTR_ERR(page); |
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index 01e1a03b54c8..b235215ac138 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 | err = f2fs_add_link(&dent, inode); | 68 | err = __f2fs_add_link(dir, &name, inode); |
71 | } | 69 | } |
72 | iput(dir); | 70 | iput(dir); |
73 | out: | 71 | out: |