All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Theodore Tso <tytso@mit.edu>,
	Andreas Dilger <adilger.kernel@dilger.ca>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 01/31] fs: Add FGP_WRITEBEGIN
Date: Sun, 05 Mar 2023 14:23:19 +0530	[thread overview]
Message-ID: <87mt4rmveo.fsf@doe.com> (raw)
In-Reply-To: <20230126202415.1682629-2-willy@infradead.org>

"Matthew Wilcox (Oracle)" <willy@infradead.org> writes:

> This particular combination of flags is used by most filesystems
> in their ->write_begin method, although it does find use in a
> few other places.  Before folios, it warranted its own function
> (grab_cache_page_write_begin()), but I think that just having specialised
> flags is enough.  It certainly helps the few places that have been
> converted from grab_cache_page_write_begin() to __filemap_get_folio().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Looks good to me. With small comment below.

Please feel free to add -
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

> ---
>  fs/ext4/move_extent.c    | 5 ++---
>  fs/iomap/buffered-io.c   | 2 +-
>  fs/netfs/buffered_read.c | 3 +--
>  include/linux/pagemap.h  | 2 ++
>  mm/folio-compat.c        | 4 +---
>  5 files changed, 7 insertions(+), 9 deletions(-)

After below patch got added to mainline, we should use FGP_WRITEBEGIN
flag in fs/nfs/file.c as well.

54d99381b7371d2999566d1fb4ea88d46cf9d865
Author:     Trond Myklebust <trond.myklebust@hammerspace.com>
CommitDate: Tue Feb 14 14:22:32 2023 -0500

NFS: Convert nfs_write_begin/end to use folios


In fact we don't even need the helper
(nfs_folio_grab_cache_write_begin()) anymore, since we can directly pass
FGP_WRITEBEGIN flag in __filemap_get_folio() in the caller itself.

static struct folio *
nfs_folio_grab_cache_write_begin(struct address_space *mapping, pgoff_t index)
{
	unsigned fgp_flags = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE;

	return __filemap_get_folio(mapping, index, fgp_flags,
				   mapping_gfp_mask(mapping));
}


-ritesh

>
> diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
> index 2de9829aed63..0cb361f0a4fe 100644
> --- a/fs/ext4/move_extent.c
> +++ b/fs/ext4/move_extent.c
> @@ -126,7 +126,6 @@ mext_folio_double_lock(struct inode *inode1, struct inode *inode2,
>  {
>  	struct address_space *mapping[2];
>  	unsigned int flags;
> -	unsigned fgp_flags = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE;
>
>  	BUG_ON(!inode1 || !inode2);
>  	if (inode1 < inode2) {
> @@ -139,14 +138,14 @@ mext_folio_double_lock(struct inode *inode1, struct inode *inode2,
>  	}
>
>  	flags = memalloc_nofs_save();
> -	folio[0] = __filemap_get_folio(mapping[0], index1, fgp_flags,
> +	folio[0] = __filemap_get_folio(mapping[0], index1, FGP_WRITEBEGIN,
>  			mapping_gfp_mask(mapping[0]));
>  	if (!folio[0]) {
>  		memalloc_nofs_restore(flags);
>  		return -ENOMEM;
>  	}
>
> -	folio[1] = __filemap_get_folio(mapping[1], index2, fgp_flags,
> +	folio[1] = __filemap_get_folio(mapping[1], index2, FGP_WRITEBEGIN,
>  			mapping_gfp_mask(mapping[1]));
>  	memalloc_nofs_restore(flags);
>  	if (!folio[1]) {
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 6f4c97a6d7e9..10a203515583 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -467,7 +467,7 @@ EXPORT_SYMBOL_GPL(iomap_is_partially_uptodate);
>   */
>  struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos)
>  {
> -	unsigned fgp = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE | FGP_NOFS;
> +	unsigned fgp = FGP_WRITEBEGIN | FGP_NOFS;
>  	struct folio *folio;
>
>  	if (iter->flags & IOMAP_NOWAIT)
> diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c
> index 7679a68e8193..e3d754a9e1b0 100644
> --- a/fs/netfs/buffered_read.c
> +++ b/fs/netfs/buffered_read.c
> @@ -341,14 +341,13 @@ int netfs_write_begin(struct netfs_inode *ctx,
>  {
>  	struct netfs_io_request *rreq;
>  	struct folio *folio;
> -	unsigned int fgp_flags = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE;
>  	pgoff_t index = pos >> PAGE_SHIFT;
>  	int ret;
>
>  	DEFINE_READAHEAD(ractl, file, NULL, mapping, index);
>
>  retry:
> -	folio = __filemap_get_folio(mapping, index, fgp_flags,
> +	folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN,
>  				    mapping_gfp_mask(mapping));
>  	if (!folio)
>  		return -ENOMEM;
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 9f1081683771..47069662f4b8 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -507,6 +507,8 @@ pgoff_t page_cache_prev_miss(struct address_space *mapping,
>  #define FGP_ENTRY		0x00000080
>  #define FGP_STABLE		0x00000100
>
> +#define FGP_WRITEBEGIN		(FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE)
> +
>  struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
>  		int fgp_flags, gfp_t gfp);
>  struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index,
> diff --git a/mm/folio-compat.c b/mm/folio-compat.c
> index 18c48b557926..668350748828 100644
> --- a/mm/folio-compat.c
> +++ b/mm/folio-compat.c
> @@ -106,9 +106,7 @@ EXPORT_SYMBOL(pagecache_get_page);
>  struct page *grab_cache_page_write_begin(struct address_space *mapping,
>  					pgoff_t index)
>  {
> -	unsigned fgp_flags = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE;
> -
> -	return pagecache_get_page(mapping, index, fgp_flags,
> +	return pagecache_get_page(mapping, index, FGP_WRITEBEGIN,
>  			mapping_gfp_mask(mapping));
>  }
>  EXPORT_SYMBOL(grab_cache_page_write_begin);
> --
> 2.35.1

  reply	other threads:[~2023-03-05  8:53 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 20:23 [PATCH 00/31] Convert most of ext4 to folios Matthew Wilcox (Oracle)
2023-01-26 20:23 ` [PATCH 01/31] fs: Add FGP_WRITEBEGIN Matthew Wilcox (Oracle)
2023-03-05  8:53   ` Ritesh Harjani [this message]
2023-03-14 22:00   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 02/31] fscrypt: Add some folio helper functions Matthew Wilcox (Oracle)
2023-01-27  3:02   ` Eric Biggers
2023-01-27 16:13     ` Matthew Wilcox
2023-01-27 16:21       ` Eric Biggers
2023-01-27 16:37         ` Matthew Wilcox
2023-03-14 22:05       ` Theodore Ts'o
2023-03-14 23:12         ` Eric Biggers
2023-03-15  2:53           ` Theodore Ts'o
2023-03-05  9:06   ` Ritesh Harjani
2023-01-26 20:23 ` [PATCH 03/31] ext4: Convert ext4_bio_write_page() to use a folio Matthew Wilcox (Oracle)
2023-01-28 16:53   ` kernel test robot
2023-01-28 19:07   ` kernel test robot
2023-03-05 11:18   ` Ritesh Harjani
2023-03-14 22:07   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 04/31] ext4: Convert ext4_finish_bio() to use folios Matthew Wilcox (Oracle)
2023-03-06  9:10   ` Ritesh Harjani
2023-03-23  3:26     ` Matthew Wilcox
2023-03-23 14:51       ` Darrick J. Wong
2023-03-23 15:30         ` Matthew Wilcox
2023-03-27  0:58           ` Christoph Hellwig
2023-03-27  0:57         ` Christoph Hellwig
2023-03-14 22:08   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 05/31] ext4: Convert ext4_writepage() to use a folio Matthew Wilcox (Oracle)
2023-03-06 18:45   ` Ritesh Harjani
2023-03-14 22:26     ` Theodore Ts'o
2023-03-23  3:29       ` Matthew Wilcox
2023-01-26 20:23 ` [PATCH 06/31] ext4: Turn mpage_process_page() into mpage_process_folio() Matthew Wilcox (Oracle)
2023-03-14 22:27   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 07/31] ext4: Convert mpage_submit_page() to mpage_submit_folio() Matthew Wilcox (Oracle)
2023-03-14 22:28   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 08/31] ext4: Convert ext4_bio_write_page() to ext4_bio_write_folio() Matthew Wilcox (Oracle)
2023-03-14 22:31   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 09/31] ext4: Convert ext4_readpage_inline() to take a folio Matthew Wilcox (Oracle)
2023-03-14 22:31   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 10/31] ext4: Convert ext4_convert_inline_data_to_extent() to use " Matthew Wilcox (Oracle)
2023-03-14 22:36   ` Theodore Ts'o
2023-03-23 17:14     ` Matthew Wilcox
2023-01-26 20:23 ` [PATCH 11/31] ext4: Convert ext4_try_to_write_inline_data() " Matthew Wilcox (Oracle)
2023-03-14 22:37   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 12/31] ext4: Convert ext4_da_convert_inline_data_to_extent() " Matthew Wilcox (Oracle)
2023-01-26 20:23 ` [PATCH 13/31] ext4: Convert ext4_da_write_inline_data_begin() " Matthew Wilcox (Oracle)
2023-01-26 20:23 ` [PATCH 14/31] ext4: Convert ext4_read_inline_page() to ext4_read_inline_folio() Matthew Wilcox (Oracle)
2023-03-14 22:38   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 15/31] ext4: Convert ext4_write_inline_data_end() to use a folio Matthew Wilcox (Oracle)
2023-03-14 22:39   ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 16/31] ext4: Convert ext4_write_begin() " Matthew Wilcox (Oracle)
2023-03-14 22:40   ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 17/31] ext4: Convert ext4_write_end() " Matthew Wilcox (Oracle)
2023-03-14 22:41   ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 18/31] ext4: Use a folio in ext4_journalled_write_end() Matthew Wilcox (Oracle)
2023-03-14 22:41   ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 19/31] ext4: Convert ext4_journalled_zero_new_buffers() to use a folio Matthew Wilcox (Oracle)
2023-03-14 22:46   ` Theodore Ts'o
2023-03-24  4:15     ` Matthew Wilcox
2023-01-26 20:24 ` [PATCH 20/31] ext4: Convert __ext4_block_zero_page_range() " Matthew Wilcox (Oracle)
2023-03-05 12:26   ` Ritesh Harjani
2023-01-26 20:24 ` [PATCH 21/31] ext4: Convert __ext4_journalled_writepage() to take " Matthew Wilcox (Oracle)
2023-03-14 22:47   ` Theodore Ts'o
2023-03-24  4:55     ` Matthew Wilcox
2023-01-26 20:24 ` [PATCH 22/31] ext4: Convert ext4_page_nomap_can_writeout() " Matthew Wilcox (Oracle)
2023-03-14 22:50   ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 23/31] ext4: Use a folio in ext4_da_write_begin() Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 24/31] ext4: Convert ext4_mpage_readpages() to work on folios Matthew Wilcox (Oracle)
2023-01-27  4:15   ` Eric Biggers
2023-01-27 16:08     ` Matthew Wilcox
2023-03-05 11:26       ` Ritesh Harjani
2023-01-26 20:24 ` [PATCH 25/31] ext4: Convert ext4_block_write_begin() to take a folio Matthew Wilcox (Oracle)
2023-03-06  6:51   ` Ritesh Harjani
2023-03-06  8:27     ` Matthew Wilcox
2023-03-06 15:21       ` Ritesh Harjani
2023-03-15  4:40         ` Matthew Wilcox
2023-03-15 14:57           ` Ritesh Harjani
2023-01-26 20:24 ` [PATCH 26/31] ext4: Convert ext4_writepage() " Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 27/31] ext4: Use a folio in ext4_page_mkwrite() Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 28/31] ext4: Use a folio iterator in __read_end_io() Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 29/31] ext4: Convert mext_page_mkuptodate() to take a folio Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 30/31] ext4: Convert pagecache_read() to use " Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 31/31] ext4: Use a folio in ext4_read_merkle_tree_page Matthew Wilcox (Oracle)
2023-03-15 17:57 ` [PATCH 00/31] Convert most of ext4 to folios Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mt4rmveo.fsf@doe.com \
    --to=ritesh.list@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.