diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index febcfbadcdfa..3bf2ce46fa09 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -461,8 +461,8 @@ static inline void __set_inuse(struct f2fs_sb_info *sbi, struct free_segmap_info *free_i = FREE_I(sbi); unsigned int secno = GET_SEC_FROM_SEG(sbi, segno); - set_bit(segno, free_i->free_segmap); - free_i->free_segments--; + if (!test_and_set_bit(segno, free_i->free_segmap)) + free_i->free_segments--; if (!test_and_set_bit(secno, free_i->free_secmap)) free_i->free_sections--; }