aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorGu Zheng <guz.fnst@cn.fujitsu.com>2013-11-19 05:03:38 -0500
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-12-22 20:18:01 -0500
commitef86d70994b57cf8095d436da76c6684c83ef0b2 (patch)
tree92b686e0b9414399144c13e8b5e754c7736b3af2 /fs
parentda19b0dc5080db4e9138d4f5bc47d5fa9ce81c98 (diff)
f2fs: convert inc/dec_valid_node_count to inc/dec one count
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/f2fs.h32
-rw-r--r--fs/f2fs/node.c6
2 files changed, 18 insertions, 20 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 154f07604c11..b665ce492e1f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -706,50 +706,48 @@ static inline block_t __start_sum_addr(struct f2fs_sb_info *sbi)
706} 706}
707 707
708static inline bool inc_valid_node_count(struct f2fs_sb_info *sbi, 708static inline bool inc_valid_node_count(struct f2fs_sb_info *sbi,
709 struct inode *inode, 709 struct inode *inode)
710 unsigned int count)
711{ 710{
712 block_t valid_block_count; 711 block_t valid_block_count;
713 unsigned int valid_node_count; 712 unsigned int valid_node_count;
714 713
715 spin_lock(&sbi->stat_lock); 714 spin_lock(&sbi->stat_lock);
716 715
717 valid_block_count = sbi->total_valid_block_count + (block_t)count; 716 valid_block_count = sbi->total_valid_block_count + 1;
718 sbi->alloc_valid_block_count += (block_t)count;
719 valid_node_count = sbi->total_valid_node_count + count;
720
721 if (valid_block_count > sbi->user_block_count) { 717 if (valid_block_count > sbi->user_block_count) {
722 spin_unlock(&sbi->stat_lock); 718 spin_unlock(&sbi->stat_lock);
723 return false; 719 return false;
724 } 720 }
725 721
722 valid_node_count = sbi->total_valid_node_count + 1;
726 if (valid_node_count > sbi->total_node_count) { 723 if (valid_node_count > sbi->total_node_count) {
727 spin_unlock(&sbi->stat_lock); 724 spin_unlock(&sbi->stat_lock);
728 return false; 725 return false;
729 } 726 }
730 727
731 if (inode) 728 if (inode)
732 inode->i_blocks += count; 729 inode->i_blocks++;
733 sbi->total_valid_node_count = valid_node_count; 730
734 sbi->total_valid_block_count = valid_block_count; 731 sbi->alloc_valid_block_count++;
732 sbi->total_valid_node_count++;
733 sbi->total_valid_block_count++;
735 spin_unlock(&sbi->stat_lock); 734 spin_unlock(&sbi->stat_lock);
736 735
737 return true; 736 return true;
738} 737}
739 738
740static inline void dec_valid_node_count(struct f2fs_sb_info *sbi, 739static inline void dec_valid_node_count(struct f2fs_sb_info *sbi,
741 struct inode *inode, 740 struct inode *inode)
742 unsigned int count)
743{ 741{
744 spin_lock(&sbi->stat_lock); 742 spin_lock(&sbi->stat_lock);
745 743
746 f2fs_bug_on(sbi->total_valid_block_count < count); 744 f2fs_bug_on(!sbi->total_valid_block_count);
747 f2fs_bug_on(sbi->total_valid_node_count < count); 745 f2fs_bug_on(!sbi->total_valid_node_count);
748 f2fs_bug_on(inode->i_blocks < count); 746 f2fs_bug_on(!inode->i_blocks);
749 747
750 inode->i_blocks -= count; 748 inode->i_blocks--;
751 sbi->total_valid_node_count -= count; 749 sbi->total_valid_node_count--;
752 sbi->total_valid_block_count -= (block_t)count; 750 sbi->total_valid_block_count--;
753 751
754 spin_unlock(&sbi->stat_lock); 752 spin_unlock(&sbi->stat_lock);
755} 753}
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index e7b6826beac4..b843a5b3d5ee 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -502,7 +502,7 @@ static void truncate_node(struct dnode_of_data *dn)
502 502
503 /* Deallocate node address */ 503 /* Deallocate node address */
504 invalidate_blocks(sbi, ni.blk_addr); 504 invalidate_blocks(sbi, ni.blk_addr);
505 dec_valid_node_count(sbi, dn->inode, 1); 505 dec_valid_node_count(sbi, dn->inode);
506 set_node_addr(sbi, &ni, NULL_ADDR); 506 set_node_addr(sbi, &ni, NULL_ADDR);
507 507
508 if (dn->nid == dn->inode->i_ino) { 508 if (dn->nid == dn->inode->i_ino) {
@@ -851,7 +851,7 @@ struct page *new_node_page(struct dnode_of_data *dn,
851 if (!page) 851 if (!page)
852 return ERR_PTR(-ENOMEM); 852 return ERR_PTR(-ENOMEM);
853 853
854 if (!inc_valid_node_count(sbi, dn->inode, 1)) { 854 if (!inc_valid_node_count(sbi, dn->inode)) {
855 err = -ENOSPC; 855 err = -ENOSPC;
856 goto fail; 856 goto fail;
857 } 857 }
@@ -1560,7 +1560,7 @@ int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
1560 new_ni = old_ni; 1560 new_ni = old_ni;
1561 new_ni.ino = ino; 1561 new_ni.ino = ino;
1562 1562
1563 if (!inc_valid_node_count(sbi, NULL, 1)) 1563 if (!inc_valid_node_count(sbi, NULL))
1564 WARN_ON(1); 1564 WARN_ON(1);
1565 set_node_addr(sbi, &new_ni, NEW_ADDR); 1565 set_node_addr(sbi, &new_ni, NEW_ADDR);
1566 inc_valid_inode_count(sbi); 1566 inc_valid_inode_count(sbi);