diff mbox series

[v5,16/18] xfs: add pre-content fsnotify hook for write faults

Message ID 12aebe1a4f039d0234ea74393a39614c0244f7e0.1725481503.git.josef@toxicpanda.com (mailing list archive)
State Not Applicable, archived
Headers show
Series fanotify: add pre-content hooks | expand

Commit Message

Josef Bacik Sept. 4, 2024, 8:28 p.m. UTC
xfs has it's own handling for write faults, so we need to add the
pre-content fsnotify hook for this case.  Reads go through filemap_fault
so they're handled properly there.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/xfs/xfs_file.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Amir Goldstein Sept. 5, 2024, 8:29 a.m. UTC | #1
On Wed, Sep 4, 2024 at 10:29 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> xfs has it's own handling for write faults, so we need to add the
> pre-content fsnotify hook for this case.  Reads go through filemap_fault
> so they're handled properly there.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  fs/xfs/xfs_file.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 4cdc54dc9686..3e385756017f 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1283,6 +1283,10 @@ xfs_write_fault(
>         unsigned int            lock_mode = XFS_MMAPLOCK_SHARED;
>         vm_fault_t              ret;
>
> +       ret = filemap_fsnotify_fault(vmf);
> +       if (unlikely(ret))
> +               return ret;
> +
>         sb_start_pagefault(inode->i_sb);
>         file_update_time(vmf->vma->vm_file);
>
> --
> 2.43.0
>

The end result is so much nicer than early sketches ;)

 Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Thanks,
Amir.
diff mbox series

Patch

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 4cdc54dc9686..3e385756017f 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1283,6 +1283,10 @@  xfs_write_fault(
 	unsigned int		lock_mode = XFS_MMAPLOCK_SHARED;
 	vm_fault_t		ret;
 
+	ret = filemap_fsnotify_fault(vmf);
+	if (unlikely(ret))
+		return ret;
+
 	sb_start_pagefault(inode->i_sb);
 	file_update_time(vmf->vma->vm_file);