Message ID | 89eb3a19d19c9b4bc19b6edbc708a8a33a911516.1723228772.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | fanotify: add pre-content hooks | expand |
On Fri, Aug 09, 2024 at 02:44:24PM -0400, Josef Bacik 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 | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > index 4cdc54dc9686..a00436dd29d1 100644 > --- a/fs/xfs/xfs_file.c > +++ b/fs/xfs/xfs_file.c > @@ -1328,8 +1328,13 @@ __xfs_filemap_fault( > > trace_xfs_filemap_fault(XFS_I(inode), order, write_fault); > > - if (write_fault) > - return xfs_write_fault(vmf, order); > + if (write_fault) { > + vm_fault_t ret = filemap_maybe_emit_fsnotify_event(vmf); > + if (unlikely(ret)) > + return ret; > + xfs_write_fault(vmf, order); > + } > + > if (IS_DAX(inode)) > return xfs_dax_read_fault(vmf, order); > return filemap_fault(vmf); Looks good now. Acked-by: Dave Chinner <dchinner@redhat.com>
On Fri, Aug 09, 2024 at 02:44:24PM -0400, Josef Bacik wrote: > - if (write_fault) > - return xfs_write_fault(vmf, order); > + if (write_fault) { > + vm_fault_t ret = filemap_maybe_emit_fsnotify_event(vmf); > + if (unlikely(ret)) > + return ret; > + xfs_write_fault(vmf, order); This now loses the return value from xfs_write_fault and falls through to actually do the read fault as well. I somehow doubt this can work at all as-is. Please also move the filemap_maybe_emit_fsnotify_event call into xfs_write_fault to keep the write fault handling isolated there, which is the reason that it exists.
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 4cdc54dc9686..a00436dd29d1 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1328,8 +1328,13 @@ __xfs_filemap_fault( trace_xfs_filemap_fault(XFS_I(inode), order, write_fault); - if (write_fault) - return xfs_write_fault(vmf, order); + if (write_fault) { + vm_fault_t ret = filemap_maybe_emit_fsnotify_event(vmf); + if (unlikely(ret)) + return ret; + xfs_write_fault(vmf, order); + } + if (IS_DAX(inode)) return xfs_dax_read_fault(vmf, order); return filemap_fault(vmf);
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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)