Bug 260242

Summary: [fusefs] fuse_vnop_copy_file_range does not evict cache for destination file
Product: Base System Reporter: Alan Somers <asomers>
Component: kernAssignee: Alan Somers <asomers>
Status: Closed FIXED    
Severity: Affects Only Me CC: piotr.konopelko
Priority: --- Flags: asomers: mfc-stable13+
asomers: mfc-stable12-
Version: 13.0-RELEASE   
Hardware: Any   
OS: Any   
URL: https://reviews.freebsd.org/D33280

Description Alan Somers freebsd_committer freebsd_triage 2021-12-05 19:08:19 UTC
FUSE_COPY_FILE_RANGE instructs the server to write to a file.  The fusefs module ought to evict any cached data in the range that it instructs the server to write.  Unfortunately, today I noticed by inspection that it does not.  This leads to a risk of data corruption when using copy_file_range with a FUSE file system that supports it (most don't).  I should have a patch soon.
Comment 1 commit-hook freebsd_committer freebsd_triage 2021-12-07 04:42:55 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=41ae9f9e644d1196bebacdb3748670f36b354384

commit 41ae9f9e644d1196bebacdb3748670f36b354384
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2021-12-05 20:39:10 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2021-12-07 04:41:50 +0000

    fusefs: invalidate the cache during copy_file_range

    FUSE_COPY_FILE_RANGE instructs the server to write data to a file.
    fusefs must invalidate any cached data within the written range.

    PR:             260242
    MFC after:      2 weeks
    Reviewed by:    pfg
    Differential Revision: https://reviews.freebsd.org/D33280

 sys/fs/fuse/fuse_vnops.c               | 10 +++++
 tests/sys/fs/fusefs/copy_file_range.cc | 78 ++++++++++++++++++++++++++++++++++
 tests/sys/fs/fusefs/utils.cc           |  4 +-
 tests/sys/fs/fusefs/utils.hh           |  3 +-
 4 files changed, 92 insertions(+), 3 deletions(-)
Comment 2 Alan Somers freebsd_committer freebsd_triage 2021-12-07 04:45:57 UTC
MFC not needed to stable/12 because it does not have copy_file_range.
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-01-03 03:09:16 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=642399932d58e880ac4a65ab6011a94292b37134

commit 642399932d58e880ac4a65ab6011a94292b37134
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2021-12-05 20:39:10 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2022-01-03 03:03:54 +0000

    fusefs: invalidate the cache during copy_file_range

    FUSE_COPY_FILE_RANGE instructs the server to write data to a file.
    fusefs must invalidate any cached data within the written range.

    PR:             260242
    Reviewed by:    pfg
    Differential Revision: https://reviews.freebsd.org/D33280

    (cherry picked from commit 41ae9f9e644d1196bebacdb3748670f36b354384)

 sys/fs/fuse/fuse_vnops.c               | 10 +++++
 tests/sys/fs/fusefs/copy_file_range.cc | 78 ++++++++++++++++++++++++++++++++++
 tests/sys/fs/fusefs/utils.cc           |  4 +-
 tests/sys/fs/fusefs/utils.hh           |  3 +-
 4 files changed, 92 insertions(+), 3 deletions(-)