|
@@ -1024,18 +1024,22 @@ static void allocate_segment_by_default(struct f2fs_sb_info *sbi,
|
|
|
stat_inc_seg_type(sbi, curseg);
|
|
|
}
|
|
|
|
|
|
+static void __allocate_new_segments(struct f2fs_sb_info *sbi, int type)
|
|
|
+{
|
|
|
+ struct curseg_info *curseg = CURSEG_I(sbi, type);
|
|
|
+ unsigned int old_segno;
|
|
|
+
|
|
|
+ old_segno = curseg->segno;
|
|
|
+ SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
|
|
|
+ locate_dirty_segment(sbi, old_segno);
|
|
|
+}
|
|
|
+
|
|
|
void allocate_new_segments(struct f2fs_sb_info *sbi)
|
|
|
{
|
|
|
- struct curseg_info *curseg;
|
|
|
- unsigned int old_curseg;
|
|
|
int i;
|
|
|
|
|
|
- for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
|
|
|
- curseg = CURSEG_I(sbi, i);
|
|
|
- old_curseg = curseg->segno;
|
|
|
- SIT_I(sbi)->s_ops->allocate_segment(sbi, i, true);
|
|
|
- locate_dirty_segment(sbi, old_curseg);
|
|
|
- }
|
|
|
+ for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++)
|
|
|
+ __allocate_new_segments(sbi, i);
|
|
|
}
|
|
|
|
|
|
static const struct segment_allocation default_salloc_ops = {
|
|
@@ -1148,11 +1152,18 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
|
|
|
{
|
|
|
struct sit_info *sit_i = SIT_I(sbi);
|
|
|
struct curseg_info *curseg;
|
|
|
+ bool direct_io = (type == CURSEG_DIRECT_IO);
|
|
|
+
|
|
|
+ type = direct_io ? CURSEG_WARM_DATA : type;
|
|
|
|
|
|
curseg = CURSEG_I(sbi, type);
|
|
|
|
|
|
mutex_lock(&curseg->curseg_mutex);
|
|
|
|
|
|
+ /* direct_io'ed data is aligned to the segment for better performance */
|
|
|
+ if (direct_io && curseg->next_blkoff)
|
|
|
+ __allocate_new_segments(sbi, type);
|
|
|
+
|
|
|
*new_blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);
|
|
|
|
|
|
/*
|