linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: revert segment allocation for direct IO
@ 2016-11-11 21:03 Jaegeuk Kim
  2016-11-11 21:03 ` [PATCH 2/2] f2fs: allow dio read for LFS mode Jaegeuk Kim
  2016-11-25 16:01 ` [f2fs-dev] [PATCH 1/2] f2fs: revert segment allocation for direct IO Chao Yu
  0 siblings, 2 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2016-11-11 21:03 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

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: 38aa0889b250 (f2fs: align direct_io'ed data to section)

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/data.c    |  6 +-----
 fs/f2fs/f2fs.h    |  1 -
 fs/f2fs/segment.c | 36 +++++++++---------------------------
 3 files changed, 10 insertions(+), 33 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 47ded0c..ca53da5 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -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_summary sum;
 	struct node_info ni;
-	int seg = CURSEG_WARM_DATA;
 	pgoff_t fofs;
 	blkcnt_t count = 1;
 
@@ -606,11 +605,8 @@ static int __allocate_data_block(struct dnode_of_data *dn)
 	get_node_info(sbi, dn->nid, &ni);
 	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,
-								&sum, seg);
+						&sum, CURSEG_WARM_DATA);
 	set_data_blkaddr(dn);
 
 	/* update i_size */
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index a6e2ede..0496e82 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -591,7 +591,6 @@ enum {
 	CURSEG_WARM_NODE,	/* direct node blocks of normal files */
 	CURSEG_COLD_NODE,	/* indirect node blocks */
 	NO_CHECK_TYPE,
-	CURSEG_DIRECT_IO,	/* to use for the direct IO path */
 };
 
 struct flush_cmd {
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 7fb7dd3..4cc589a 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1346,25 +1346,21 @@ 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_segno;
 	int i;
 
 	if (test_opt(sbi, LFS))
 		return;
 
-	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++)
-		__allocate_new_segments(sbi, i);
+	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; 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 = {
@@ -1498,25 +1494,11 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
 		struct f2fs_summary *sum, int type)
 {
 	struct sit_info *sit_i = SIT_I(sbi);
-	struct curseg_info *curseg;
-	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);
+	struct curseg_info *curseg = CURSEG_I(sbi, type);
 
 	mutex_lock(&curseg->curseg_mutex);
 	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);
 
 	/*
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] f2fs: allow dio read for LFS mode
  2016-11-11 21:03 [PATCH 1/2] f2fs: revert segment allocation for direct IO Jaegeuk Kim
@ 2016-11-11 21:03 ` Jaegeuk Kim
  2016-11-25 15:54   ` [f2fs-dev] " Chao Yu
  2016-11-25 16:01 ` [f2fs-dev] [PATCH 1/2] f2fs: revert segment allocation for direct IO Chao Yu
  1 sibling, 1 reply; 5+ messages in thread
From: Jaegeuk Kim @ 2016-11-11 21:03 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

We can allow dio reads for LFS mode, while doing buffered writes for dio writes.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index ca53da5..996b9ae 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1732,7 +1732,7 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 
 	if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode))
 		return 0;
-	if (test_opt(F2FS_I_SB(inode), LFS))
+	if (rw == WRITE && test_opt(F2FS_I_SB(inode), LFS))
 		return 0;
 
 	trace_f2fs_direct_IO_enter(inode, offset, count, rw);
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [f2fs-dev] [PATCH 2/2] f2fs: allow dio read for LFS mode
  2016-11-11 21:03 ` [PATCH 2/2] f2fs: allow dio read for LFS mode Jaegeuk Kim
@ 2016-11-25 15:54   ` Chao Yu
  2016-11-25 18:14     ` Jaegeuk Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Chao Yu @ 2016-11-25 15:54 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel

On 2016/11/12 5:03, Jaegeuk Kim wrote:
> We can allow dio reads for LFS mode, while doing buffered writes for dio writes.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/data.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index ca53da5..996b9ae 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1732,7 +1732,7 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
>  
>  	if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode))
>  		return 0;
> -	if (test_opt(F2FS_I_SB(inode), LFS))
> +	if (rw == WRITE && test_opt(F2FS_I_SB(inode), LFS))

For LFS mode, we must disallow any IPU in main area including direct write,
instead of both direct read and write, so this patch relieves the restriction?

IIUC, please add:

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

>  		return 0;
>  
>  	trace_f2fs_direct_IO_enter(inode, offset, count, rw);
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [f2fs-dev] [PATCH 1/2] f2fs: revert segment allocation for direct IO
  2016-11-11 21:03 [PATCH 1/2] f2fs: revert segment allocation for direct IO Jaegeuk Kim
  2016-11-11 21:03 ` [PATCH 2/2] f2fs: allow dio read for LFS mode Jaegeuk Kim
@ 2016-11-25 16:01 ` Chao Yu
  1 sibling, 0 replies; 5+ messages in thread
From: Chao Yu @ 2016-11-25 16:01 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel

On 2016/11/12 5:03, Jaegeuk Kim wrote:
> 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: 38aa0889b250 (f2fs: align direct_io'ed data to section)
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> ---
>  fs/f2fs/data.c    |  6 +-----
>  fs/f2fs/f2fs.h    |  1 -
>  fs/f2fs/segment.c | 36 +++++++++---------------------------
>  3 files changed, 10 insertions(+), 33 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 47ded0c..ca53da5 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -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_summary sum;
>  	struct node_info ni;
> -	int seg = CURSEG_WARM_DATA;
>  	pgoff_t fofs;
>  	blkcnt_t count = 1;
>  
> @@ -606,11 +605,8 @@ static int __allocate_data_block(struct dnode_of_data *dn)
>  	get_node_info(sbi, dn->nid, &ni);
>  	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,
> -								&sum, seg);
> +						&sum, CURSEG_WARM_DATA);
>  	set_data_blkaddr(dn);
>  
>  	/* update i_size */
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index a6e2ede..0496e82 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -591,7 +591,6 @@ enum {
>  	CURSEG_WARM_NODE,	/* direct node blocks of normal files */
>  	CURSEG_COLD_NODE,	/* indirect node blocks */
>  	NO_CHECK_TYPE,
> -	CURSEG_DIRECT_IO,	/* to use for the direct IO path */
>  };
>  
>  struct flush_cmd {
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 7fb7dd3..4cc589a 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1346,25 +1346,21 @@ 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_segno;
>  	int i;
>  
>  	if (test_opt(sbi, LFS))
>  		return;
>  
> -	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++)
> -		__allocate_new_segments(sbi, i);
> +	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; 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 = {
> @@ -1498,25 +1494,11 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
>  		struct f2fs_summary *sum, int type)
>  {
>  	struct sit_info *sit_i = SIT_I(sbi);
> -	struct curseg_info *curseg;
> -	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);
> +	struct curseg_info *curseg = CURSEG_I(sbi, type);
>  
>  	mutex_lock(&curseg->curseg_mutex);
>  	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);
>  
>  	/*
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [f2fs-dev] [PATCH 2/2] f2fs: allow dio read for LFS mode
  2016-11-25 15:54   ` [f2fs-dev] " Chao Yu
@ 2016-11-25 18:14     ` Jaegeuk Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2016-11-25 18:14 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

On Fri, Nov 25, 2016 at 11:54:43PM +0800, Chao Yu wrote:
> On 2016/11/12 5:03, Jaegeuk Kim wrote:
> > We can allow dio reads for LFS mode, while doing buffered writes for dio writes.
> > 
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> >  fs/f2fs/data.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index ca53da5..996b9ae 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -1732,7 +1732,7 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
> >  
> >  	if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode))
> >  		return 0;
> > -	if (test_opt(F2FS_I_SB(inode), LFS))
> > +	if (rw == WRITE && test_opt(F2FS_I_SB(inode), LFS))
> 
> For LFS mode, we must disallow any IPU in main area including direct write,
> instead of both direct read and write, so this patch relieves the restriction?

Yup.

> 
> IIUC, please add:
> 
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> 
> Thanks,
> 
> >  		return 0;
> >  
> >  	trace_f2fs_direct_IO_enter(inode, offset, count, rw);
> > 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-25 18:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-11 21:03 [PATCH 1/2] f2fs: revert segment allocation for direct IO Jaegeuk Kim
2016-11-11 21:03 ` [PATCH 2/2] f2fs: allow dio read for LFS mode Jaegeuk Kim
2016-11-25 15:54   ` [f2fs-dev] " Chao Yu
2016-11-25 18:14     ` Jaegeuk Kim
2016-11-25 16:01 ` [f2fs-dev] [PATCH 1/2] f2fs: revert segment allocation for direct IO Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).