From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Chandan Babu R <chandan.babu@oracle.com>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/6] xfs: refactor __xfs_filemap_fault
Date: Thu, 20 Jun 2024 11:54:06 -0700 [thread overview]
Message-ID: <20240620185406.GB103034@frogsfrogsfrogs> (raw)
In-Reply-To: <20240619115426.332708-5-hch@lst.de>
On Wed, Jun 19, 2024 at 01:53:54PM +0200, Christoph Hellwig wrote:
> Split the write fault and DAX fault handling into separate helpers
> so that the main fault handler is easier to follow.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/xfs_file.c | 71 ++++++++++++++++++++++++++++++-----------------
> 1 file changed, 45 insertions(+), 26 deletions(-)
>
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 8aab2f66fe016f..51e50afd935895 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1252,7 +1252,7 @@ xfs_file_llseek(
> }
>
> static inline vm_fault_t
> -xfs_dax_fault(
> +xfs_dax_fault_locked(
> struct vm_fault *vmf,
> unsigned int order,
> bool write_fault)
> @@ -1273,6 +1273,45 @@ xfs_dax_fault(
> return ret;
> }
>
> +static vm_fault_t
> +xfs_dax_fault(
Oh, hey, you /did/ split the dax handling into two helpers.
Would you mind renaming this xfs_dax_read_fault since this doesn't
handle write faults?
With that changed,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> + struct vm_fault *vmf,
> + unsigned int order)
> +{
> + struct xfs_inode *ip = XFS_I(file_inode(vmf->vma->vm_file));
> + unsigned int lock_mode;
> + vm_fault_t ret;
> +
> + lock_mode = xfs_ilock_for_write_fault(ip);
> + ret = xfs_dax_fault_locked(vmf, order, false);
> + xfs_iunlock(ip, lock_mode);
> +
> + return ret;
> +}
> +
> +static vm_fault_t
> +xfs_write_fault(
> + struct vm_fault *vmf,
> + unsigned int order)
> +{
> + struct inode *inode = file_inode(vmf->vma->vm_file);
> + unsigned int lock_mode;
> + vm_fault_t ret;
> +
> + sb_start_pagefault(inode->i_sb);
> + file_update_time(vmf->vma->vm_file);
> +
> + lock_mode = xfs_ilock_for_write_fault(XFS_I(inode));
> + if (IS_DAX(inode))
> + ret = xfs_dax_fault_locked(vmf, order, true);
> + else
> + ret = iomap_page_mkwrite(vmf, &xfs_page_mkwrite_iomap_ops);
> + xfs_iunlock(XFS_I(inode), lock_mode);
> +
> + sb_end_pagefault(inode->i_sb);
> + return ret;
> +}
> +
> /*
> * Locking for serialisation of IO during page faults. This results in a lock
> * ordering of:
> @@ -1290,34 +1329,14 @@ __xfs_filemap_fault(
> bool write_fault)
> {
> struct inode *inode = file_inode(vmf->vma->vm_file);
> - struct xfs_inode *ip = XFS_I(inode);
> - vm_fault_t ret;
> - unsigned int lock_mode = 0;
>
> - trace_xfs_filemap_fault(ip, order, write_fault);
> -
> - if (write_fault) {
> - sb_start_pagefault(inode->i_sb);
> - file_update_time(vmf->vma->vm_file);
> - }
> -
> - if (IS_DAX(inode) || write_fault)
> - lock_mode = xfs_ilock_for_write_fault(XFS_I(inode));
> -
> - if (IS_DAX(inode)) {
> - ret = xfs_dax_fault(vmf, order, write_fault);
> - } else if (write_fault) {
> - ret = iomap_page_mkwrite(vmf, &xfs_page_mkwrite_iomap_ops);
> - } else {
> - ret = filemap_fault(vmf);
> - }
> -
> - if (lock_mode)
> - xfs_iunlock(XFS_I(inode), lock_mode);
> + trace_xfs_filemap_fault(XFS_I(inode), order, write_fault);
>
> if (write_fault)
> - sb_end_pagefault(inode->i_sb);
> - return ret;
> + return xfs_write_fault(vmf, order);
> + if (IS_DAX(inode))
> + return xfs_dax_fault(vmf, order);
> + return filemap_fault(vmf);
> }
>
> static inline bool
> --
> 2.43.0
>
>
next prev parent reply other threads:[~2024-06-20 18:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 11:53 clean up I/O path inode locking helpers and the page fault handler Christoph Hellwig
2024-06-19 11:53 ` [PATCH 1/6] xfs: move the dio write relocking out of xfs_ilock_for_iomap Christoph Hellwig
2024-06-20 18:40 ` Darrick J. Wong
2024-06-19 11:53 ` [PATCH 2/6] xfs: cleanup xfs_ilock_iocb_for_write Christoph Hellwig
2024-06-20 18:41 ` Darrick J. Wong
2024-06-19 11:53 ` [PATCH 3/6] xfs: simplify xfs_dax_fault Christoph Hellwig
2024-06-20 18:50 ` Darrick J. Wong
2024-06-21 5:05 ` Christoph Hellwig
2024-06-21 17:43 ` Darrick J. Wong
2024-06-19 11:53 ` [PATCH 4/6] xfs: refactor __xfs_filemap_fault Christoph Hellwig
2024-06-20 18:54 ` Darrick J. Wong [this message]
2024-06-21 5:08 ` Christoph Hellwig
2024-06-19 11:53 ` [PATCH 5/6] xfs: always take XFS_MMAPLOCK shared in xfs_dax_fault Christoph Hellwig
2024-06-20 18:56 ` Darrick J. Wong
2024-06-19 11:53 ` [PATCH 6/6] xfs: fold xfs_ilock_for_write_fault into xfs_write_fault Christoph Hellwig
2024-06-20 18:57 ` Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2024-06-23 5:44 clean up I/O path inode locking helpers and the page fault handler v2 Christoph Hellwig
2024-06-23 5:44 ` [PATCH 4/6] xfs: refactor __xfs_filemap_fault Christoph Hellwig
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=20240620185406.GB103034@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=chandan.babu@oracle.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox