aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/checkpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/checkpoint.c')
-rw-r--r--fs/f2fs/checkpoint.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index d877f46c75ed..4aa521aa9bc3 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -308,16 +308,15 @@ void release_orphan_inode(struct f2fs_sb_info *sbi)
308 308
309void add_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) 309void add_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
310{ 310{
311 struct list_head *head, *this; 311 struct list_head *head;
312 struct orphan_inode_entry *new = NULL, *orphan = NULL; 312 struct orphan_inode_entry *new, *orphan;
313 313
314 new = f2fs_kmem_cache_alloc(orphan_entry_slab, GFP_ATOMIC); 314 new = f2fs_kmem_cache_alloc(orphan_entry_slab, GFP_ATOMIC);
315 new->ino = ino; 315 new->ino = ino;
316 316
317 spin_lock(&sbi->orphan_inode_lock); 317 spin_lock(&sbi->orphan_inode_lock);
318 head = &sbi->orphan_inode_list; 318 head = &sbi->orphan_inode_list;
319 list_for_each(this, head) { 319 list_for_each_entry(orphan, head, list) {
320 orphan = list_entry(this, struct orphan_inode_entry, list);
321 if (orphan->ino == ino) { 320 if (orphan->ino == ino) {
322 spin_unlock(&sbi->orphan_inode_lock); 321 spin_unlock(&sbi->orphan_inode_lock);
323 kmem_cache_free(orphan_entry_slab, new); 322 kmem_cache_free(orphan_entry_slab, new);
@@ -326,14 +325,10 @@ void add_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
326 325
327 if (orphan->ino > ino) 326 if (orphan->ino > ino)
328 break; 327 break;
329 orphan = NULL;
330 } 328 }
331 329
332 /* add new_oentry into list which is sorted by inode number */ 330 /* add new orphan entry into list which is sorted by inode number */
333 if (orphan) 331 list_add_tail(&new->list, &orphan->list);
334 list_add(&new->list, this->prev);
335 else
336 list_add_tail(&new->list, head);
337 spin_unlock(&sbi->orphan_inode_lock); 332 spin_unlock(&sbi->orphan_inode_lock);
338} 333}
339 334
@@ -561,14 +556,12 @@ static int __add_dirty_inode(struct inode *inode, struct dir_inode_entry *new)
561{ 556{
562 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 557 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
563 struct list_head *head = &sbi->dir_inode_list; 558 struct list_head *head = &sbi->dir_inode_list;
564 struct list_head *this; 559 struct dir_inode_entry *entry;
565 560
566 list_for_each(this, head) { 561 list_for_each_entry(entry, head, list)
567 struct dir_inode_entry *entry;
568 entry = list_entry(this, struct dir_inode_entry, list);
569 if (unlikely(entry->inode == inode)) 562 if (unlikely(entry->inode == inode))
570 return -EEXIST; 563 return -EEXIST;
571 } 564
572 list_add_tail(&new->list, head); 565 list_add_tail(&new->list, head);
573 stat_inc_dirty_dir(sbi); 566 stat_inc_dirty_dir(sbi);
574 return 0; 567 return 0;
@@ -618,7 +611,8 @@ void add_dirty_dir_inode(struct inode *inode)
618void remove_dirty_dir_inode(struct inode *inode) 611void remove_dirty_dir_inode(struct inode *inode)
619{ 612{
620 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 613 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
621 struct list_head *this, *head; 614 struct list_head *head;
615 struct dir_inode_entry *entry;
622 616
623 if (!S_ISDIR(inode->i_mode)) 617 if (!S_ISDIR(inode->i_mode))
624 return; 618 return;
@@ -630,9 +624,7 @@ void remove_dirty_dir_inode(struct inode *inode)
630 } 624 }
631 625
632 head = &sbi->dir_inode_list; 626 head = &sbi->dir_inode_list;
633 list_for_each(this, head) { 627 list_for_each_entry(entry, head, list) {
634 struct dir_inode_entry *entry;
635 entry = list_entry(this, struct dir_inode_entry, list);
636 if (entry->inode == inode) { 628 if (entry->inode == inode) {
637 list_del(&entry->list); 629 list_del(&entry->list);
638 stat_dec_dirty_dir(sbi); 630 stat_dec_dirty_dir(sbi);
@@ -654,15 +646,14 @@ done:
654struct inode *check_dirty_dir_inode(struct f2fs_sb_info *sbi, nid_t ino) 646struct inode *check_dirty_dir_inode(struct f2fs_sb_info *sbi, nid_t ino)
655{ 647{
656 648
657 struct list_head *this, *head; 649 struct list_head *head;
658 struct inode *inode = NULL; 650 struct inode *inode = NULL;
651 struct dir_inode_entry *entry;
659 652
660 spin_lock(&sbi->dir_inode_lock); 653 spin_lock(&sbi->dir_inode_lock);
661 654
662 head = &sbi->dir_inode_list; 655 head = &sbi->dir_inode_list;
663 list_for_each(this, head) { 656 list_for_each_entry(entry, head, list) {
664 struct dir_inode_entry *entry;
665 entry = list_entry(this, struct dir_inode_entry, list);
666 if (entry->inode->i_ino == ino) { 657 if (entry->inode->i_ino == ino) {
667 inode = entry->inode; 658 inode = entry->inode;
668 break; 659 break;