mbox series

[0/5] Remove zero_user()

Message ID 20250612143443.2848197-1-willy@infradead.org
Headers show
Series Remove zero_user() | expand

Message

Matthew Wilcox (Oracle) June 12, 2025, 2:34 p.m. UTC
The zero_user() API is almost unused these days.  Finish the job of
removing it.

Matthew Wilcox (Oracle) (5):
  bio: Use memzero_page() in bio_truncate()
  null_blk: Use memzero_page()
  direct-io: Use memzero_page()
  ceph: Convert ceph_zero_partial_page() to use a folio
  mm: Remove zero_user()

 block/bio.c                   |  4 ++--
 drivers/block/null_blk/main.c |  2 +-
 fs/ceph/file.c                | 21 ++++++++++-----------
 fs/direct-io.c                |  2 +-
 include/linux/highmem.h       |  6 ------
 5 files changed, 14 insertions(+), 21 deletions(-)

Comments

Viacheslav Dubeyko June 12, 2025, 7:36 p.m. UTC | #1
On Thu, 2025-06-12 at 15:34 +0100, Matthew Wilcox (Oracle) wrote:
> Retrieve a folio from the pagecache instead of a page and operate on it.
> Removes several hidden calls to compound_head() along with calls to
> deprecated functions like wait_on_page_writeback() and find_lock_page().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  fs/ceph/file.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index a7254cab44cc..d5c674d2ba8a 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -2530,18 +2530,17 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
>  	return generic_file_llseek(file, offset, whence);
>  }
>  
> -static inline void ceph_zero_partial_page(
> -	struct inode *inode, loff_t offset, unsigned size)
> +static inline void ceph_zero_partial_page(struct inode *inode,
> +		loff_t offset, size_t size)
>  {
> -	struct page *page;
> -	pgoff_t index = offset >> PAGE_SHIFT;
> -
> -	page = find_lock_page(inode->i_mapping, index);
> -	if (page) {
> -		wait_on_page_writeback(page);
> -		zero_user(page, offset & (PAGE_SIZE - 1), size);
> -		unlock_page(page);
> -		put_page(page);
> +	struct folio *folio;
> +
> +	folio = filemap_lock_folio(inode->i_mapping, offset >> PAGE_SHIFT);
> +	if (folio) {
> +		folio_wait_writeback(folio);
> +		folio_zero_range(folio, offset_in_folio(folio, offset), size);
> +		folio_unlock(folio);
> +		folio_put(folio);
>  	}
>  }
>  

Looks really good. And filemap_lock_folio() is more efficient than
find_lock_page() now.

Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>

Thanks,
Slava.
Christoph Hellwig June 13, 2025, 5:24 a.m. UTC | #2
On Thu, Jun 12, 2025 at 03:34:36PM +0100, Matthew Wilcox (Oracle) wrote:
> The zero_user() API is almost unused these days.  Finish the job of
> removing it.

Both the block layer users really should use bvec based helpers.
I was planning to get to that this merge window.  Can we queue up
just the other two removals for and remove zero_user after -rc1
to reduce conflicts?
Matthew Wilcox (Oracle) June 13, 2025, 7:51 p.m. UTC | #3
On Fri, Jun 13, 2025 at 07:24:32AM +0200, Christoph Hellwig wrote:
> On Thu, Jun 12, 2025 at 03:34:36PM +0100, Matthew Wilcox (Oracle) wrote:
> > The zero_user() API is almost unused these days.  Finish the job of
> > removing it.
> 
> Both the block layer users really should use bvec based helpers.
> I was planning to get to that this merge window.  Can we queue up
> just the other two removals for and remove zero_user after -rc1
> to reduce conflicts?

If I'd known you were doing that, I wouldn't've bothered.  However,
Andrew's taken the patches now, so I'm inclined to leave them in.
No matter which tree it gets merged through, this is a relatively easy
conflict to resolve (ie just take your version).  I have some more
patches which build on the removal of zero_user() so it'd be nice to
not hold them up.
Andrew Morton June 13, 2025, 8:04 p.m. UTC | #4
On Fri, 13 Jun 2025 20:51:06 +0100 Matthew Wilcox <willy@infradead.org> wrote:

> On Fri, Jun 13, 2025 at 07:24:32AM +0200, Christoph Hellwig wrote:
> > On Thu, Jun 12, 2025 at 03:34:36PM +0100, Matthew Wilcox (Oracle) wrote:
> > > The zero_user() API is almost unused these days.  Finish the job of
> > > removing it.
> > 
> > Both the block layer users really should use bvec based helpers.
> > I was planning to get to that this merge window.  Can we queue up
> > just the other two removals for and remove zero_user after -rc1
> > to reduce conflicts?
> 
> If I'd known you were doing that, I wouldn't've bothered.  However,
> Andrew's taken the patches now, so I'm inclined to leave them in.
> No matter which tree it gets merged through, this is a relatively easy
> conflict to resolve (ie just take your version).  I have some more
> patches which build on the removal of zero_user() so it'd be nice to
> not hold them up.

Sure, Christoph, please just proceed with the block changes and we can
see what the conflicts look like when Stephen hits them.  If Matthew's
series needs modification then so be it.