Bug 260242 - [fusefs] fuse_vnop_copy_file_range does not evict cache for destination file
Summary: [fusefs] fuse_vnop_copy_file_range does not evict cache for destination file
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Alan Somers
URL: https://reviews.freebsd.org/D33280
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-05 19:08 UTC by Alan Somers
Modified: 2022-01-03 03:10 UTC (History)
1 user (show)

See Also:
asomers: mfc-stable13+
asomers: mfc-stable12-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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(-)