Re: [PATCH v2] f2fs: add app/fs io stat

2017-08-09 Thread Chao Yu
Hi Jaegeuk,

On 2017/8/10 12:45, Jaegeuk Kim wrote:
> Hi Chao,
> 
> I've fixed the below in f2fs.git.

Thank you fox fixing it. :)

Thanks,



Re: [PATCH v2] f2fs: add app/fs io stat

2017-08-09 Thread Jaegeuk Kim
Hi Chao,

I've fixed the below in f2fs.git.

On 08/02, Chao Yu wrote:
> From: Chao Yu 
> 
> This patch enables inner app/fs io stats and introduces below virtual fs
> nodes for exposing stats info:
> /sys/fs/f2fs//iostat_enable
> /proc/fs/f2fs//iostat_info
> 
> Signed-off-by: Chao Yu 
> ---
> v2:
> - reorganize printed info of iostat_info.
> - add discard stats.
>  fs/f2fs/checkpoint.c | 34 +-
>  fs/f2fs/data.c   | 35 +++
>  fs/f2fs/f2fs.h   | 59 
> +---
>  fs/f2fs/file.c   |  7 ++-
>  fs/f2fs/gc.c |  3 +++
>  fs/f2fs/inline.c |  1 +
>  fs/f2fs/node.c   | 15 +++--
>  fs/f2fs/segment.c| 21 +--
>  fs/f2fs/super.c  |  4 
>  fs/f2fs/sysfs.c  | 52 +
>  10 files changed, 200 insertions(+), 31 deletions(-)
> 
> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> index 3c84a2520796..da5b49183e09 100644
> --- a/fs/f2fs/checkpoint.c
> +++ b/fs/f2fs/checkpoint.c
> @@ -230,8 +230,9 @@ void ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t 
> index)
>   ra_meta_pages(sbi, index, BIO_MAX_PAGES, META_POR, true);
>  }
>  
> -static int f2fs_write_meta_page(struct page *page,
> - struct writeback_control *wbc)
> +static int __f2fs_write_meta_page(struct page *page,
> + struct writeback_control *wbc,
> + enum iostat_type io_type)
>  {
>   struct f2fs_sb_info *sbi = F2FS_P_SB(page);
>  
> @@ -244,7 +245,7 @@ static int f2fs_write_meta_page(struct page *page,
>   if (unlikely(f2fs_cp_error(sbi)))
>   goto redirty_out;
>  
> - write_meta_page(sbi, page);
> + write_meta_page(sbi, page, io_type);
>   dec_page_count(sbi, F2FS_DIRTY_META);
>  
>   if (wbc->for_reclaim)
> @@ -263,6 +264,12 @@ static int f2fs_write_meta_page(struct page *page,
>   return AOP_WRITEPAGE_ACTIVATE;
>  }
>  
> +static int f2fs_write_meta_page(struct page *page,
> + struct writeback_control *wbc)
> +{
> + return __f2fs_write_meta_page(page, wbc, FS_META_IO);
> +}
> +
>  static int f2fs_write_meta_pages(struct address_space *mapping,
>   struct writeback_control *wbc)
>  {
> @@ -283,7 +290,7 @@ static int f2fs_write_meta_pages(struct address_space 
> *mapping,
>  
>   trace_f2fs_writepages(mapping->host, wbc, META);
>   diff = nr_pages_to_write(sbi, META, wbc);
> - written = sync_meta_pages(sbi, META, wbc->nr_to_write);
> + written = sync_meta_pages(sbi, META, wbc->nr_to_write, FS_META_IO);
>   mutex_unlock(&sbi->cp_mutex);
>   wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff);
>   return 0;
> @@ -295,7 +302,7 @@ static int f2fs_write_meta_pages(struct address_space 
> *mapping,
>  }
>  
>  long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
> - long nr_to_write)
> + long nr_to_write, enum iostat_type io_type)
>  {
>   struct address_space *mapping = META_MAPPING(sbi);
>   pgoff_t index = 0, end = ULONG_MAX, prev = ULONG_MAX;
> @@ -346,7 +353,7 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum 
> page_type type,
>   if (!clear_page_dirty_for_io(page))
>   goto continue_unlock;
>  
> - if (mapping->a_ops->writepage(page, &wbc)) {
> + if (__f2fs_write_meta_page(page, &wbc, io_type)) {
>   unlock_page(page);
>   break;
>   }
> @@ -904,7 +911,14 @@ int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum 
> inode_type type)
>   if (inode) {
>   unsigned long cur_ino = inode->i_ino;
>  
> + if (is_dir)
> + F2FS_I(inode)->cp_task = current;
> +
>   filemap_fdatawrite(inode->i_mapping);
> +
> + if (is_dir)
> + F2FS_I(inode)->cp_task = NULL;
> +
>   iput(inode);
>   /* We need to give cpu to another writers. */
>   if (ino == cur_ino) {
> @@ -1017,7 +1031,7 @@ static int block_operations(struct f2fs_sb_info *sbi)
>  
>   if (get_pages(sbi, F2FS_DIRTY_NODES)) {
>   up_write(&sbi->node_write);
> - err = sync_node_pages(sbi, &wbc, false);
> + err = sync_node_pages(sbi, &wbc, false, FS_CP_NODE_IO);
>   if (err) {
>   up_write(&sbi->node_change);
>   f2fs_unlock_all(sbi);
> @@ -1115,7 +1129,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, 
> struct cp_control *cpc)
>  
>   /* Flush all the NAT/SIT pages */
>   while (get_pages(sbi, F2FS_DIRTY_META)) {
> - sync_meta_pages(sbi, META, LONG_MAX);
> +