Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2148853

Summary: [virtiofs] file size is increasing when writing to the same address with mmap() on virtiofs backed paths
Product: Red Hat Enterprise Linux 9 Reporter: xiagao
Component: virtiofsdAssignee: German Maglione <gmaglione>
Status: CLOSED ERRATA QA Contact: xiagao
Severity: medium Docs Contact:
Priority: medium    
Version: 9.2CC: coli, gmaglione, jinzhao, juzhang, kwolf, lijin, vgoyal, virt-maint
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: virtiofsd-1.5.0-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 07:46:45 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2123070    
Bug Blocks:    

Description xiagao 2022-11-28 07:30:04 UTC
Description of problem:
This bug comes from an upstream issue and can be reproduced downstream.
https://gitlab.com/virtio-fs/virtiofsd/-/issues/67

'''
When using python and writing to a mmap file, I am seeing with cache mode auto and always that the file is increasing in size each time I write to it.
'''

Version-Release number of selected component (if applicable):
qemu-kvm-7.1.0-3.el9.x86_64
virtiofsd-1.4.0-1.el9.x86_64
kernel-5.14.0-178.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. start virtiofsd
# /usr/libexec/virtiofsd -o source=/home/test  --socket-path=/tmp/sock1 --cache auto
2. boot up a rhel920 guest
3. in guest, mount virtiofs
# mount -t virtiofs myfs /mnt/test
4. write to the same space of a file with mmap 
```

[root@vm-74-75 test]# cat mmap_test.py 
import mmap
import struct
l = 1024
f = open("./test.db", "a+b")
f.truncate(l)
m = mmap.mmap(f.fileno(), 1024, access=mmap.ACCESS_WRITE)
m[0:4] = b"0000"
m.flush()
print(m.size())
m[0:4] = b"0000"
m.flush()
print(m.size())

```

Actual results:
# python3 mmap_test.py 
2048
4096


Expected results:
The file size will not be changed.

Additional info:

Comment 5 xiagao 2022-12-29 07:27:24 UTC
Test passed with the fixed virtiofsd version, file size is NOT increasing when writing to the same address with mmap() on virtiofs backed paths, so verify the bug.

[root@bootp-73-75-32 mm]# python3 mmap_test.py 
1024
1024
1024
1024


pkg:
virtiofsd-1.5.0-1.el9.x86_64
qemu-kvm-7.2.0-1.el9
5.14.0-219.el9.x86_64(host)
5.14.0-226.el9.x86_64(guest)

Comment 7 errata-xmlrpc 2023-05-09 07:46:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virtiofsd bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2334