Skip to content

Avert possible deadlock with splice() and fanotify

Amir Goldstein linux-fsdevel lkml 2 versions – Applied

Status from this message: Applied to the vfs.rw branch of the vfs/vfs.git tree.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 15 repliesApplied
  2. v12 patches 9 repliesSuperseded

Changes in v2 from the cover letter

- Add patch to deal with nfsd/ksmbd server-side-copy
- Shorten helper name to splice_file_range()
- Added assertion for flags value in generic_copy_file_range()
- Added RVB from Jan

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3fs: fork splice_file_range() from do_splice_direct()fs/ceph/file.c fs/read_write.c fs/splice.c +2 more+66 -358 replies
2/3fs: move file_start_write() into direct_splice_actor()fs/overlayfs/copy_up.c fs/read_write.c fs/splice.c+16 -71 reply
3/3fs: use do_splice_direct() for nfsd/ksmbd server-side-copyfs/read_write.c+23 -138 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchJan KaraJeff LaytonChristoph HellwigBert Karwatzki
1/3R-b A-b
2/3R-b R-b
3/3R-b R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/3] Avert possible deadlock with splice() and fanotify

Christian,

Josef has helped me see the light and figure out how to avoid the possible deadlock, which involves:
- splice() from source file in a loop mounted fs to dest file in a host fs, where the loop image file is
- fsfreeze on host fs
- write to host fs in context of fanotify permission event handler (FAN_ACCESS_PERM) on the splice source file

The first patch should not be changing any logic. I only build tested the ceph patch, so hoping to get an Acked-by/Tested-by from Jeff.

The following patches rids us of the deadlock by not holding file_start_write() while reading from splice source file in the cases where source and destination can be on different arbitrary filesystems.

The patches apply and tested on top of vfs.rw branch.

Thanks,
Amir.

Changes since v1:
- Add patch to deal with nfsd/ksmbd server-side-copy
- Shorten helper name to splice_file_range()
- Added assertion for flags value in generic_copy_file_range()
- Added RVB from Jan

Amir Goldstein (3):
fs: fork splice_file_range() from do_splice_direct()
fs: move file_start_write() into direct_splice_actor()
fs: use do_splice_direct() for nfsd/ksmbd server-side-copy

 fs/ceph/file.c         |  9 +++--
 fs/overlayfs/copy_up.c |  2 -
 fs/read_write.c        | 42 +++++++++++---------
 fs/splice.c            | 88 +++++++++++++++++++++++++++++++-----------
 include/linux/fs.h     |  2 -
 include/linux/splice.h | 13 ++++---
 6 files changed, 103 insertions(+), 53 deletions(-)
Signature · 1 line
2.34.1