Commit 6ae1be13 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: revert segment allocation for direct IO

Now we don't need to be too much careful about storage alignment for dio, since
its speed becomes quite fast and we'd better avoid any misalignment first.

Revert: 38aa0889 (f2fs: align direct_io'ed data to section)
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 20614711
...@@ -588,7 +588,6 @@ static int __allocate_data_block(struct dnode_of_data *dn) ...@@ -588,7 +588,6 @@ static int __allocate_data_block(struct dnode_of_data *dn)
struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode); struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
struct f2fs_summary sum; struct f2fs_summary sum;
struct node_info ni; struct node_info ni;
int seg = CURSEG_WARM_DATA;
pgoff_t fofs; pgoff_t fofs;
blkcnt_t count = 1; blkcnt_t count = 1;
...@@ -606,11 +605,8 @@ static int __allocate_data_block(struct dnode_of_data *dn) ...@@ -606,11 +605,8 @@ static int __allocate_data_block(struct dnode_of_data *dn)
get_node_info(sbi, dn->nid, &ni); get_node_info(sbi, dn->nid, &ni);
set_summary(&sum, dn->nid, dn->ofs_in_node, ni.version); set_summary(&sum, dn->nid, dn->ofs_in_node, ni.version);
if (dn->ofs_in_node == 0 && dn->inode_page == dn->node_page)
seg = CURSEG_DIRECT_IO;
allocate_data_block(sbi, NULL, dn->data_blkaddr, &dn->data_blkaddr, allocate_data_block(sbi, NULL, dn->data_blkaddr, &dn->data_blkaddr,
&sum, seg); &sum, CURSEG_WARM_DATA);
set_data_blkaddr(dn); set_data_blkaddr(dn);
/* update i_size */ /* update i_size */
......
...@@ -591,7 +591,6 @@ enum { ...@@ -591,7 +591,6 @@ enum {
CURSEG_WARM_NODE, /* direct node blocks of normal files */ CURSEG_WARM_NODE, /* direct node blocks of normal files */
CURSEG_COLD_NODE, /* indirect node blocks */ CURSEG_COLD_NODE, /* indirect node blocks */
NO_CHECK_TYPE, NO_CHECK_TYPE,
CURSEG_DIRECT_IO, /* to use for the direct IO path */
}; };
struct flush_cmd { struct flush_cmd {
......
...@@ -1346,25 +1346,21 @@ static void allocate_segment_by_default(struct f2fs_sb_info *sbi, ...@@ -1346,25 +1346,21 @@ static void allocate_segment_by_default(struct f2fs_sb_info *sbi,
stat_inc_seg_type(sbi, curseg); 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) void allocate_new_segments(struct f2fs_sb_info *sbi)
{ {
struct curseg_info *curseg;
unsigned int old_segno;
int i; int i;
if (test_opt(sbi, LFS)) if (test_opt(sbi, LFS))
return; return;
for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
__allocate_new_segments(sbi, i); curseg = CURSEG_I(sbi, i);
old_segno = curseg->segno;
SIT_I(sbi)->s_ops->allocate_segment(sbi, i, true);
locate_dirty_segment(sbi, old_segno);
}
} }
static const struct segment_allocation default_salloc_ops = { static const struct segment_allocation default_salloc_ops = {
...@@ -1498,25 +1494,11 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, ...@@ -1498,25 +1494,11 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
struct f2fs_summary *sum, int type) struct f2fs_summary *sum, int type)
{ {
struct sit_info *sit_i = SIT_I(sbi); struct sit_info *sit_i = SIT_I(sbi);
struct curseg_info *curseg; struct curseg_info *curseg = CURSEG_I(sbi, type);
bool direct_io = (type == CURSEG_DIRECT_IO);
if (direct_io) {
if (sbi->active_logs <= 4)
type = CURSEG_HOT_DATA;
else
type = CURSEG_WARM_DATA;
}
curseg = CURSEG_I(sbi, type);
mutex_lock(&curseg->curseg_mutex); mutex_lock(&curseg->curseg_mutex);
mutex_lock(&sit_i->sentry_lock); mutex_lock(&sit_i->sentry_lock);
/* direct_io'ed data is aligned to the segment for better performance */
if (direct_io && curseg->next_blkoff &&
!has_not_enough_free_secs(sbi, 0, 0))
__allocate_new_segments(sbi, type);
*new_blkaddr = NEXT_FREE_BLKADDR(sbi, curseg); *new_blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment