Bug 2148853 - [virtiofs] file size is increasing when writing to the same address with mmap() on virtiofs backed paths
Summary: [virtiofs] file size is increasing when writing to the same address with mmap...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: virtiofsd
Version: 9.2
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: German Maglione
QA Contact: xiagao
URL:
Whiteboard:
Depends On: 2123070
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-11-28 07:30 UTC by xiagao
Modified: 2023-08-09 08:46 UTC (History)
8 users (show)

Fixed In Version: virtiofsd-1.5.0-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 07:46:45 UTC
Type: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Gitlab virtio-fs virtiofsd issues 67 0 None opened Unexpected behavior observed when using mmap on virtiofs backed paths 2022-11-29 09:32:09 UTC
Gitlab virtio-fs virtiofsd merge_requests 143 0 None opened passthrough: Set `RWF_APPEND` on non-cached writes on append only files 2022-11-29 09:32:37 UTC
Red Hat Issue Tracker RHELPLAN-140571 0 None None None 2022-11-28 08:13:02 UTC
Red Hat Product Errata RHBA-2023:2334 0 None None None 2023-05-09 07:47:06 UTC

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


Note You need to log in before you can comment on or make changes to this bug.