diff mbox series

[v15,17/17] iomap: Convert iomap_migrate_page to use folios

Message ID 20210719184001.1750630-18-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Folio support in block + iomap layers | expand

Commit Message

Matthew Wilcox July 19, 2021, 6:40 p.m. UTC
The arguments are still pages for now, but we can use folios internally
and cut out a lot of calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/iomap/buffered-io.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Christoph Hellwig July 20, 2021, 7:21 a.m. UTC | #1
On Mon, Jul 19, 2021 at 07:40:01PM +0100, Matthew Wilcox (Oracle) wrote:
> The arguments are still pages for now, but we can use folios internally
> and cut out a lot of calls to compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
kernel test robot July 20, 2021, 1:30 p.m. UTC | #2
Hi "Matthew,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.14-rc2 next-20210720]
[cannot apply to xfs-linux/for-next block/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Matthew-Wilcox-Oracle/Folio-support-in-block-iomap-layers/20210720-152323
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2734d6c1b1a089fb593ef6a23d4b70903526fe0c
config: openrisc-randconfig-p002-20210720 (attached as .config)
compiler: or1k-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/c560a69342e882de7f1fd097fa2589e8d330eba0
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Matthew-Wilcox-Oracle/Folio-support-in-block-iomap-layers/20210720-152323
        git checkout c560a69342e882de7f1fd097fa2589e8d330eba0
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross ARCH=openrisc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

         |                                  ^
   include/asm-generic/bug.h:65:36: note: in expansion of macro 'unlikely'
      65 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
         |                                    ^~~~~~~~
   fs/iomap/buffered-io.c:207:2: note: in expansion of macro 'BUG_ON'
     207 |  BUG_ON(folio->index);
         |  ^~~~~~
   fs/iomap/buffered-io.c:207:14: error: invalid use of undefined type 'struct folio'
     207 |  BUG_ON(folio->index);
         |              ^~
   include/linux/compiler.h:35:19: note: in definition of macro '__branch_check__'
      35 |           expect, is_constant); \
         |                   ^~~~~~~~~~~
   include/asm-generic/bug.h:65:36: note: in expansion of macro 'unlikely'
      65 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
         |                                    ^~~~~~~~
   fs/iomap/buffered-io.c:207:2: note: in expansion of macro 'BUG_ON'
     207 |  BUG_ON(folio->index);
         |  ^~~~~~
   fs/iomap/buffered-io.c:208:9: error: implicit declaration of function 'folio_multi' [-Werror=implicit-function-declaration]
     208 |  BUG_ON(folio_multi(folio));
         |         ^~~~~~~~~~~
   include/linux/compiler.h:33:34: note: in definition of macro '__branch_check__'
      33 |    ______r = __builtin_expect(!!(x), expect); \
         |                                  ^
   include/asm-generic/bug.h:65:36: note: in expansion of macro 'unlikely'
      65 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
         |                                    ^~~~~~~~
   fs/iomap/buffered-io.c:208:2: note: in expansion of macro 'BUG_ON'
     208 |  BUG_ON(folio_multi(folio));
         |  ^~~~~~
   fs/iomap/buffered-io.c:211:9: error: implicit declaration of function 'kmap_local_folio'; did you mean 'kmap_local_fork'? [-Werror=implicit-function-declaration]
     211 |  addr = kmap_local_folio(folio, 0);
         |         ^~~~~~~~~~~~~~~~
         |         kmap_local_fork
   fs/iomap/buffered-io.c:211:7: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     211 |  addr = kmap_local_folio(folio, 0);
         |       ^
   fs/iomap/buffered-io.c: In function 'iomap_readpage_actor':
   fs/iomap/buffered-io.c:251:19: error: invalid use of undefined type 'struct folio'
     251 |   zero_user(&folio->page, poff, plen);
         |                   ^~
   fs/iomap/buffered-io.c:263:44: error: invalid use of undefined type 'struct folio'
     263 |   if (__bio_try_merge_page(ctx->bio, &folio->page, plen, poff,
         |                                            ^~
   fs/iomap/buffered-io.c:270:43: error: invalid use of undefined type 'struct folio'
     270 |   gfp_t gfp = mapping_gfp_constraint(folio->mapping, GFP_KERNEL);
         |                                           ^~
   fs/iomap/buffered-io.c: In function 'iomap_readpage':
   fs/iomap/buffered-io.c:309:24: warning: initialization of 'struct folio *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     309 |  struct folio *folio = page_folio(page);
         |                        ^~~~~~~~~~
   fs/iomap/buffered-io.c:311:29: error: invalid use of undefined type 'struct folio'
     311 |  struct inode *inode = folio->mapping->host;
         |                             ^~
   fs/iomap/buffered-io.c:319:28: error: implicit declaration of function 'folio_pos' [-Werror=implicit-function-declaration]
     319 |   ret = iomap_apply(inode, folio_pos(folio) + poff, len - poff,
         |                            ^~~~~~~~~
   fs/iomap/buffered-io.c: In function 'iomap_readahead_actor':
   fs/iomap/buffered-io.c:360:21: error: implicit declaration of function 'readahead_folio'; did you mean 'readahead_count'? [-Werror=implicit-function-declaration]
     360 |    ctx->cur_folio = readahead_folio(ctx->rac);
         |                     ^~~~~~~~~~~~~~~
         |                     readahead_count
   fs/iomap/buffered-io.c:360:19: warning: assignment to 'struct folio *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     360 |    ctx->cur_folio = readahead_folio(ctx->rac);
         |                   ^
   fs/iomap/buffered-io.c: In function 'iomap_is_partially_uptodate':
   fs/iomap/buffered-io.c:427:24: warning: initialization of 'struct folio *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     427 |  struct folio *folio = page_folio(page);
         |                        ^~~~~~~~~~
   fs/iomap/buffered-io.c: In function 'iomap_releasepage':
   fs/iomap/buffered-io.c:454:24: warning: initialization of 'struct folio *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     454 |  struct folio *folio = page_folio(page);
         |                        ^~~~~~~~~~
   fs/iomap/buffered-io.c:456:31: error: invalid use of undefined type 'struct folio'
     456 |  trace_iomap_releasepage(folio->mapping->host, folio_pos(folio),
         |                               ^~
   fs/iomap/buffered-io.c:464:6: error: implicit declaration of function 'folio_test_dirty' [-Werror=implicit-function-declaration]
     464 |  if (folio_test_dirty(folio) || folio_test_writeback(folio))
         |      ^~~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c:464:33: error: implicit declaration of function 'folio_test_writeback' [-Werror=implicit-function-declaration]
     464 |  if (folio_test_dirty(folio) || folio_test_writeback(folio))
         |                                 ^~~~~~~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c: In function 'iomap_invalidatepage':
   fs/iomap/buffered-io.c:474:24: warning: initialization of 'struct folio *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     474 |  struct folio *folio = page_folio(page);
         |                        ^~~~~~~~~~
   fs/iomap/buffered-io.c:476:34: error: invalid use of undefined type 'struct folio'
     476 |  trace_iomap_invalidatepage(folio->mapping->host, offset, len);
         |                                  ^~
   fs/iomap/buffered-io.c:484:3: error: implicit declaration of function 'folio_cancel_dirty' [-Werror=implicit-function-declaration]
     484 |   folio_cancel_dirty(folio);
         |   ^~~~~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c: In function 'iomap_migrate_page':
   fs/iomap/buffered-io.c:495:24: warning: initialization of 'struct folio *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     495 |  struct folio *folio = page_folio(page);
         |                        ^~~~~~~~~~
   fs/iomap/buffered-io.c:496:27: warning: initialization of 'struct folio *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     496 |  struct folio *newfolio = page_folio(newpage);
         |                           ^~~~~~~~~~
>> fs/iomap/buffered-io.c:499:8: error: implicit declaration of function 'folio_migrate_mapping' [-Werror=implicit-function-declaration]
     499 |  ret = folio_migrate_mapping(mapping, newfolio, folio, 0);
         |        ^~~~~~~~~~~~~~~~~~~~~
>> fs/iomap/buffered-io.c:507:3: error: implicit declaration of function 'folio_migrate_copy' [-Werror=implicit-function-declaration]
     507 |   folio_migrate_copy(newfolio, folio);
         |   ^~~~~~~~~~~~~~~~~~
>> fs/iomap/buffered-io.c:509:3: error: implicit declaration of function 'folio_migrate_flags'; did you mean 'do_migrate_pages'? [-Werror=implicit-function-declaration]
     509 |   folio_migrate_flags(newfolio, folio);
         |   ^~~~~~~~~~~~~~~~~~~
         |   do_migrate_pages
   fs/iomap/buffered-io.c: In function '__iomap_write_begin':
   fs/iomap/buffered-io.c:559:2: error: implicit declaration of function 'folio_clear_error' [-Werror=implicit-function-declaration]
     559 |  folio_clear_error(folio);
         |  ^~~~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c:575:29: error: invalid use of undefined type 'struct folio'
     575 |    zero_user_segments(&folio->page, poff, from, to,
         |                             ^~
   fs/iomap/buffered-io.c: In function 'iomap_write_begin':
   fs/iomap/buffered-io.c:596:52: error: 'FGP_STABLE' undeclared (first use in this function)
     596 |  unsigned fgp = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE | FGP_NOFS;
         |                                                    ^~~~~~~~~~
   fs/iomap/buffered-io.c:596:52: note: each undeclared identifier is reported only once for each function it appears in
   fs/iomap/buffered-io.c:612:10: error: implicit declaration of function '__filemap_get_folio' [-Werror=implicit-function-declaration]
     612 |  folio = __filemap_get_folio(inode->i_mapping, pos >> PAGE_SHIFT, fgp,
         |          ^~~~~~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c:612:8: warning: assignment to 'struct folio *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     612 |  folio = __filemap_get_folio(inode->i_mapping, pos >> PAGE_SHIFT, fgp,
         |        ^
   fs/iomap/buffered-io.c:619:9: error: implicit declaration of function 'folio_file_page' [-Werror=implicit-function-declaration]
     619 |  page = folio_file_page(folio, pos >> PAGE_SHIFT);
         |         ^~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c:619:7: warning: assignment to 'struct page *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     619 |  page = folio_file_page(folio, pos >> PAGE_SHIFT);
         |       ^
   fs/iomap/buffered-io.c:636:2: error: implicit declaration of function 'folio_put'; did you mean 'bio_put'? [-Werror=implicit-function-declaration]
     636 |  folio_put(folio);
         |  ^~~~~~~~~
         |  bio_put
   fs/iomap/buffered-io.c: In function '__iomap_write_end':
   fs/iomap/buffered-io.c:649:2: error: implicit declaration of function 'flush_dcache_folio'; did you mean 'flush_cache_all'? [-Werror=implicit-function-declaration]
     649 |  flush_dcache_folio(folio);
         |  ^~~~~~~~~~~~~~~~~~
         |  flush_cache_all
   fs/iomap/buffered-io.c:665:2: error: implicit declaration of function 'filemap_dirty_folio' [-Werror=implicit-function-declaration]
     665 |  filemap_dirty_folio(inode->i_mapping, folio);
         |  ^~~~~~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c: In function 'iomap_write_end_inline':
   fs/iomap/buffered-io.c:678:7: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     678 |  addr = kmap_local_folio(folio, 0);
         |       ^
   fs/iomap/buffered-io.c: In function 'iomap_write_end':
   fs/iomap/buffered-io.c:691:22: warning: initialization of 'struct page *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     691 |  struct page *page = folio_file_page(folio, pos >> PAGE_SHIFT);
         |                      ^~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c: In function 'iomap_write_actor':
   fs/iomap/buffered-io.c:765:8: warning: assignment to 'struct page *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     765 |   page = folio_file_page(folio, pos >> PAGE_SHIFT);
         |        ^
   fs/iomap/buffered-io.c: In function 'iomap_zero':
   fs/iomap/buffered-io.c:891:12: warning: passing argument 1 of 'zero_user' makes pointer from integer without a cast [-Wint-conversion]
     891 |  zero_user(folio_file_page(folio, pos >> PAGE_SHIFT), offset, bytes);
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |            |
         |            int
   In file included from include/linux/bio.h:8,
                    from include/linux/blkdev.h:18,
                    from include/linux/iomap.h:11,
                    from fs/iomap/buffered-io.c:9:
   include/linux/highmem.h:231:43: note: expected 'struct page *' but argument is of type 'int'
     231 | static inline void zero_user(struct page *page,
         |                              ~~~~~~~~~~~~~^~~~
   fs/iomap/buffered-io.c:892:2: error: implicit declaration of function 'folio_mark_accessed' [-Werror=implicit-function-declaration]
     892 |  folio_mark_accessed(folio);
         |  ^~~~~~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c: In function 'iomap_folio_mkwrite_actor':
   fs/iomap/buffered-io.c:970:39: error: invalid use of undefined type 'struct folio'
     970 |   ret = __block_write_begin_int(&folio->page, pos, length, NULL,
         |                                       ^~
   fs/iomap/buffered-io.c:974:28: error: invalid use of undefined type 'struct folio'
     974 |   block_commit_write(&folio->page, 0, length);
         |                            ^~
   fs/iomap/buffered-io.c:977:3: error: implicit declaration of function 'folio_mark_dirty' [-Werror=implicit-function-declaration]
     977 |   folio_mark_dirty(folio);
         |   ^~~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c: In function 'iomap_page_mkwrite':
   fs/iomap/buffered-io.c:985:24: warning: initialization of 'struct folio *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     985 |  struct folio *folio = page_folio(vmf->page);
         |                        ^~~~~~~~~~
   fs/iomap/buffered-io.c:991:2: error: implicit declaration of function 'folio_lock'; did you mean 'osq_lock'? [-Werror=implicit-function-declaration]
     991 |  folio_lock(folio);
         |  ^~~~~~~~~~
         |  osq_lock
   fs/iomap/buffered-io.c:992:8: error: implicit declaration of function 'folio_mkwrite_check_truncate'; did you mean 'page_mkwrite_check_truncate'? [-Werror=implicit-function-declaration]
     992 |  ret = folio_mkwrite_check_truncate(folio, inode);
         |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |        page_mkwrite_check_truncate
   fs/iomap/buffered-io.c:1008:2: error: implicit declaration of function 'folio_wait_stable' [-Werror=implicit-function-declaration]
    1008 |  folio_wait_stable(folio);
         |  ^~~~~~~~~~~~~~~~~
   fs/iomap/buffered-io.c: In function 'iomap_finish_folio_write':
   fs/iomap/buffered-io.c:1030:3: error: implicit declaration of function 'folio_end_writeback'; did you mean 'file_end_write'? [-Werror=implicit-function-declaration]
    1030 |   folio_end_writeback(folio);
         |   ^~~~~~~~~~~~~~~~~~~
         |   file_end_write
   fs/iomap/buffered-io.c: In function 'iomap_add_to_ioend':
   fs/iomap/buffered-io.c:1280:38: error: invalid use of undefined type 'struct folio'
    1280 |  wbc_account_cgroup_owner(wbc, &folio->page, len);


vim +/folio_migrate_mapping +499 fs/iomap/buffered-io.c

   489	
   490	#ifdef CONFIG_MIGRATION
   491	int
   492	iomap_migrate_page(struct address_space *mapping, struct page *newpage,
   493			struct page *page, enum migrate_mode mode)
   494	{
   495		struct folio *folio = page_folio(page);
   496		struct folio *newfolio = page_folio(newpage);
   497		int ret;
   498	
 > 499		ret = folio_migrate_mapping(mapping, newfolio, folio, 0);
   500		if (ret != MIGRATEPAGE_SUCCESS)
   501			return ret;
   502	
   503		if (folio_test_private(folio))
   504			folio_attach_private(newfolio, folio_detach_private(folio));
   505	
   506		if (mode != MIGRATE_SYNC_NO_COPY)
 > 507			folio_migrate_copy(newfolio, folio);
   508		else
 > 509			folio_migrate_flags(newfolio, folio);
   510		return MIGRATEPAGE_SUCCESS;
   511	}
   512	EXPORT_SYMBOL_GPL(iomap_migrate_page);
   513	#endif /* CONFIG_MIGRATION */
   514	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Darrick J. Wong July 21, 2021, 12:02 a.m. UTC | #3
On Mon, Jul 19, 2021 at 07:40:01PM +0100, Matthew Wilcox (Oracle) wrote:
> The arguments are still pages for now, but we can use folios internally
> and cut out a lot of calls to compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Didn't I RVb this last time? ;)
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/iomap/buffered-io.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 60d3b7af61d1..cf56b19fb101 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -492,19 +492,21 @@ int
>  iomap_migrate_page(struct address_space *mapping, struct page *newpage,
>  		struct page *page, enum migrate_mode mode)
>  {
> +	struct folio *folio = page_folio(page);
> +	struct folio *newfolio = page_folio(newpage);
>  	int ret;
>  
> -	ret = migrate_page_move_mapping(mapping, newpage, page, 0);
> +	ret = folio_migrate_mapping(mapping, newfolio, folio, 0);
>  	if (ret != MIGRATEPAGE_SUCCESS)
>  		return ret;
>  
> -	if (page_has_private(page))
> -		attach_page_private(newpage, detach_page_private(page));
> +	if (folio_test_private(folio))
> +		folio_attach_private(newfolio, folio_detach_private(folio));
>  
>  	if (mode != MIGRATE_SYNC_NO_COPY)
> -		migrate_page_copy(newpage, page);
> +		folio_migrate_copy(newfolio, folio);
>  	else
> -		migrate_page_states(newpage, page);
> +		folio_migrate_flags(newfolio, folio);
>  	return MIGRATEPAGE_SUCCESS;
>  }
>  EXPORT_SYMBOL_GPL(iomap_migrate_page);
> -- 
> 2.30.2
>
diff mbox series

Patch

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 60d3b7af61d1..cf56b19fb101 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -492,19 +492,21 @@  int
 iomap_migrate_page(struct address_space *mapping, struct page *newpage,
 		struct page *page, enum migrate_mode mode)
 {
+	struct folio *folio = page_folio(page);
+	struct folio *newfolio = page_folio(newpage);
 	int ret;
 
-	ret = migrate_page_move_mapping(mapping, newpage, page, 0);
+	ret = folio_migrate_mapping(mapping, newfolio, folio, 0);
 	if (ret != MIGRATEPAGE_SUCCESS)
 		return ret;
 
-	if (page_has_private(page))
-		attach_page_private(newpage, detach_page_private(page));
+	if (folio_test_private(folio))
+		folio_attach_private(newfolio, folio_detach_private(folio));
 
 	if (mode != MIGRATE_SYNC_NO_COPY)
-		migrate_page_copy(newpage, page);
+		folio_migrate_copy(newfolio, folio);
 	else
-		migrate_page_states(newpage, page);
+		folio_migrate_flags(newfolio, folio);
 	return MIGRATEPAGE_SUCCESS;
 }
 EXPORT_SYMBOL_GPL(iomap_migrate_page);