checkpoint.c (76f60268e70a700c04c85e1b0d520c94062a40a2) checkpoint.c (ed57c27f736f6d8a51e442610c800ee0c3d83977)
1/*
2 * fs/f2fs/checkpoint.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 538 unchanged lines hidden (view full) ---

547fail_no_cp:
548 kfree(sbi->ckpt);
549 return -EINVAL;
550}
551
552static int __add_dirty_inode(struct inode *inode, struct dir_inode_entry *new)
553{
554 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
1/*
2 * fs/f2fs/checkpoint.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 538 unchanged lines hidden (view full) ---

547fail_no_cp:
548 kfree(sbi->ckpt);
549 return -EINVAL;
550}
551
552static int __add_dirty_inode(struct inode *inode, struct dir_inode_entry *new)
553{
554 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
555 struct list_head *head = &sbi->dir_inode_list;
556 struct dir_inode_entry *entry;
557
555
558 list_for_each_entry(entry, head, list)
559 if (unlikely(entry->inode == inode))
560 return -EEXIST;
556 if (is_inode_flag_set(F2FS_I(inode), FI_DIRTY_DIR))
557 return -EEXIST;
561
558
562 list_add_tail(&new->list, head);
559 set_inode_flag(F2FS_I(inode), FI_DIRTY_DIR);
560 F2FS_I(inode)->dirty_dir = new;
561 list_add_tail(&new->list, &sbi->dir_inode_list);
563 stat_inc_dirty_dir(sbi);
564 return 0;
565}
566
567void set_dirty_dir_page(struct inode *inode, struct page *page)
568{
569 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
570 struct dir_inode_entry *new;

--- 32 unchanged lines hidden (view full) ---

603
604 if (ret)
605 kmem_cache_free(inode_entry_slab, new);
606}
607
608void remove_dirty_dir_inode(struct inode *inode)
609{
610 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
562 stat_inc_dirty_dir(sbi);
563 return 0;
564}
565
566void set_dirty_dir_page(struct inode *inode, struct page *page)
567{
568 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
569 struct dir_inode_entry *new;

--- 32 unchanged lines hidden (view full) ---

602
603 if (ret)
604 kmem_cache_free(inode_entry_slab, new);
605}
606
607void remove_dirty_dir_inode(struct inode *inode)
608{
609 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
611 struct list_head *head;
612 struct dir_inode_entry *entry;
613
614 if (!S_ISDIR(inode->i_mode))
615 return;
616
617 spin_lock(&sbi->dir_inode_lock);
610 struct dir_inode_entry *entry;
611
612 if (!S_ISDIR(inode->i_mode))
613 return;
614
615 spin_lock(&sbi->dir_inode_lock);
618 if (get_dirty_dents(inode)) {
616 if (get_dirty_dents(inode) ||
617 !is_inode_flag_set(F2FS_I(inode), FI_DIRTY_DIR)) {
619 spin_unlock(&sbi->dir_inode_lock);
620 return;
621 }
622
618 spin_unlock(&sbi->dir_inode_lock);
619 return;
620 }
621
623 head = &sbi->dir_inode_list;
624 list_for_each_entry(entry, head, list) {
625 if (entry->inode == inode) {
626 list_del(&entry->list);
627 stat_dec_dirty_dir(sbi);
628 spin_unlock(&sbi->dir_inode_lock);
629 kmem_cache_free(inode_entry_slab, entry);
630 goto done;
631 }
632 }
622 entry = F2FS_I(inode)->dirty_dir;
623 list_del(&entry->list);
624 F2FS_I(inode)->dirty_dir = NULL;
625 clear_inode_flag(F2FS_I(inode), FI_DIRTY_DIR);
626 stat_dec_dirty_dir(sbi);
633 spin_unlock(&sbi->dir_inode_lock);
627 spin_unlock(&sbi->dir_inode_lock);
628 kmem_cache_free(inode_entry_slab, entry);
634
629
635done:
636 /* Only from the recovery routine */
637 if (is_inode_flag_set(F2FS_I(inode), FI_DELAY_IPUT)) {
638 clear_inode_flag(F2FS_I(inode), FI_DELAY_IPUT);
639 iput(inode);
640 }
641}
642
630 /* Only from the recovery routine */
631 if (is_inode_flag_set(F2FS_I(inode), FI_DELAY_IPUT)) {
632 clear_inode_flag(F2FS_I(inode), FI_DELAY_IPUT);
633 iput(inode);
634 }
635}
636
643struct inode *check_dirty_dir_inode(struct f2fs_sb_info *sbi, nid_t ino)
644{
645
646 struct list_head *head;
647 struct inode *inode = NULL;
648 struct dir_inode_entry *entry;
649
650 spin_lock(&sbi->dir_inode_lock);
651
652 head = &sbi->dir_inode_list;
653 list_for_each_entry(entry, head, list) {
654 if (entry->inode->i_ino == ino) {
655 inode = entry->inode;
656 break;
657 }
658 }
659 spin_unlock(&sbi->dir_inode_lock);
660 return inode;
661}
662
663void sync_dirty_dir_inodes(struct f2fs_sb_info *sbi)
664{
665 struct list_head *head;
666 struct dir_inode_entry *entry;
667 struct inode *inode;
668retry:
669 spin_lock(&sbi->dir_inode_lock);
670

--- 289 unchanged lines hidden ---
637void sync_dirty_dir_inodes(struct f2fs_sb_info *sbi)
638{
639 struct list_head *head;
640 struct dir_inode_entry *entry;
641 struct inode *inode;
642retry:
643 spin_lock(&sbi->dir_inode_lock);
644

--- 289 unchanged lines hidden ---