All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/4] xfs: split write fault handling out of __xfs_filemap_fault
Date: Tue, 29 Oct 2024 08:57:52 -0700	[thread overview]
Message-ID: <20241029155752.GW2386201@frogsfrogsfrogs> (raw)
In-Reply-To: <20241029151214.255015-3-hch@lst.de>

On Tue, Oct 29, 2024 at 04:11:58PM +0100, Christoph Hellwig wrote:
> Only two of the callers of __xfs_filemap_fault every handle read faults.
> Split the write_fault handling out of __xfs_filemap_fault so that all
> callers call that directly either conditionally or unconditionally and
> only leave the read fault handling in __xfs_filemap_fault.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

This seems pretty straightforward so
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_file.c | 41 +++++++++++++++++++----------------------
>  1 file changed, 19 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 20f7f92b8867..0b8e36f8703c 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1434,6 +1434,16 @@ xfs_dax_read_fault(
>  	return ret;
>  }
>  
> +/*
> + * Locking for serialisation of IO during page faults. This results in a lock
> + * ordering of:
> + *
> + * mmap_lock (MM)
> + *   sb_start_pagefault(vfs, freeze)
> + *     invalidate_lock (vfs/XFS_MMAPLOCK - truncate serialisation)
> + *       page_lock (MM)
> + *         i_lock (XFS - extent map serialisation)
> + */
>  static vm_fault_t
>  xfs_write_fault(
>  	struct vm_fault		*vmf,
> @@ -1471,26 +1481,13 @@ xfs_write_fault(
>  	return ret;
>  }
>  
> -/*
> - * Locking for serialisation of IO during page faults. This results in a lock
> - * ordering of:
> - *
> - * mmap_lock (MM)
> - *   sb_start_pagefault(vfs, freeze)
> - *     invalidate_lock (vfs/XFS_MMAPLOCK - truncate serialisation)
> - *       page_lock (MM)
> - *         i_lock (XFS - extent map serialisation)
> - */
>  static vm_fault_t
>  __xfs_filemap_fault(
>  	struct vm_fault		*vmf,
> -	unsigned int		order,
> -	bool			write_fault)
> +	unsigned int		order)
>  {
>  	struct inode		*inode = file_inode(vmf->vma->vm_file);
>  
> -	if (write_fault)
> -		return xfs_write_fault(vmf, order);
>  	if (IS_DAX(inode))
>  		return xfs_dax_read_fault(vmf, order);
>  
> @@ -1511,9 +1508,9 @@ xfs_filemap_fault(
>  	struct vm_fault		*vmf)
>  {
>  	/* DAX can shortcut the normal fault path on write faults! */
> -	return __xfs_filemap_fault(vmf, 0,
> -			IS_DAX(file_inode(vmf->vma->vm_file)) &&
> -			xfs_is_write_fault(vmf));
> +	if (IS_DAX(file_inode(vmf->vma->vm_file)) && xfs_is_write_fault(vmf))
> +		return xfs_write_fault(vmf, 0);
> +	return __xfs_filemap_fault(vmf, 0);
>  }
>  
>  static vm_fault_t
> @@ -1525,15 +1522,16 @@ xfs_filemap_huge_fault(
>  		return VM_FAULT_FALLBACK;
>  
>  	/* DAX can shortcut the normal fault path on write faults! */
> -	return __xfs_filemap_fault(vmf, order,
> -			xfs_is_write_fault(vmf));
> +	if (xfs_is_write_fault(vmf))
> +		return xfs_write_fault(vmf, order);
> +	return __xfs_filemap_fault(vmf, order);
>  }
>  
>  static vm_fault_t
>  xfs_filemap_page_mkwrite(
>  	struct vm_fault		*vmf)
>  {
> -	return __xfs_filemap_fault(vmf, 0, true);
> +	return xfs_write_fault(vmf, 0);
>  }
>  
>  /*
> @@ -1545,8 +1543,7 @@ static vm_fault_t
>  xfs_filemap_pfn_mkwrite(
>  	struct vm_fault		*vmf)
>  {
> -
> -	return __xfs_filemap_fault(vmf, 0, true);
> +	return xfs_write_fault(vmf, 0);
>  }
>  
>  static const struct vm_operations_struct xfs_file_vm_ops = {
> -- 
> 2.45.2
> 
> 

  reply	other threads:[~2024-10-29 15:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-29 15:11 misc page fault handler cleanups Christoph Hellwig
2024-10-29 15:11 ` [PATCH 1/4] xfs: split the page fault trace event Christoph Hellwig
2024-10-29 15:51   ` Darrick J. Wong
2024-10-29 15:11 ` [PATCH 2/4] xfs: split write fault handling out of __xfs_filemap_fault Christoph Hellwig
2024-10-29 15:57   ` Darrick J. Wong [this message]
2024-10-29 15:11 ` [PATCH 3/4] xfs: remove __xfs_filemap_fault Christoph Hellwig
2024-10-29 16:00   ` Darrick J. Wong
2024-10-29 15:12 ` [PATCH 4/4] xfs: remove xfs_page_mkwrite_iomap_ops Christoph Hellwig
2024-10-29 15:56   ` Darrick J. Wong
2024-10-30  4:45     ` Christoph Hellwig
2024-10-29 20:54 ` misc page fault handler cleanups Dave Chinner

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=20241029155752.GW2386201@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.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.