f2fs: do not assign a new segment for dio under space shortage
authorJaegeuk Kim <jaegeuk@kernel.org>
Tue, 11 Aug 2015 17:17:27 +0000 (10:17 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 14 Aug 2015 23:02:13 +0000 (16:02 -0700)
If there is not enough free segment, we should not assign a new segment
explicitly. Otherwise, we can run out of free segment.

Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/segment.c

index 7d53cb44c6170d381a84f8d7fbae467e207893b6..bf1605dbce93d6ee3ad389b26f8e3bd0fc9812f6 100644 (file)
@@ -1225,7 +1225,8 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
        mutex_lock(&sit_i->sentry_lock);
 
        /* direct_io'ed data is aligned to the segment for better performance */
-       if (direct_io && curseg->next_blkoff)
+       if (direct_io && curseg->next_blkoff &&
+                               !has_not_enough_free_secs(sbi, 0))
                __allocate_new_segments(sbi, type);
 
        *new_blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);