On 2018/1/4 2:58, Jaegeuk Kim wrote:
@@ -1590,11 +1598,17 @@ static inline int inc_valid_block_count(struct 
f2fs_sb_info *sbi,
        sbi->total_valid_block_count += (block_t)(*count);
        avail_user_block_count = sbi->user_block_count -
                                        sbi->current_reserved_blocks;
+
+       if (!(test_opt(sbi, RESERVE_ROOT) && capable(CAP_SYS_RESOURCE)))
+               avail_user_block_count -= sbi->root_reserved_blocks;

Should better be:

+       if (test_opt(sbi, RESERVE_ROOT) && !capable(CAP_SYS_RESOURCE))
+               avail_user_block_count -= sbi->root_reserved_blocks;

@@ -1783,9 +1797,13 @@ static inline int inc_valid_node_count(struct 
f2fs_sb_info *sbi,
spin_lock(&sbi->stat_lock); - valid_block_count = sbi->total_valid_block_count + 1;
-       if (unlikely(valid_block_count + sbi->current_reserved_blocks >
-                                               sbi->user_block_count)) {
+       valid_block_count = sbi->total_valid_block_count +
+                                       sbi->current_reserved_blocks + 1;
+

+       if (!(test_opt(sbi, RESERVE_ROOT) && capable(CAP_SYS_RESOURCE)))
+               valid_block_count += sbi->root_reserved_blocks;
+
should better be:

+       if (test_opt(sbi, RESERVE_ROOT) && !capable(CAP_SYS_RESOURCE))
+               valid_block_count += sbi->root_reserved_blocks;


+       if (unlikely(valid_block_count > sbi->user_block_count)) {
                spin_unlock(&sbi->stat_lock);
                goto enospc;
        }


--
Thanks,
Yunlong Song


Reply via email to