Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux /proc/spl/kstat per-dataset statistics do not account for file writes performed with mmap #12994

Closed
drowfx opened this issue Jan 21, 2022 · 0 comments
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@drowfx
Copy link
Contributor

drowfx commented Jan 21, 2022

System information

Type Version/Name
Distribution Name Debian
Distribution Version Bullseye (11)
Kernel Version 5.10.0-11-amd64
Architecture x86_64
OpenZFS Version zfs-2.1.2-1~bpo11+1

Describe the problem you're observing

When a file on a ZFS dataset is opened for write and mmaped (with PROT_WRITE), and the file is written via the memory mapping, the writes are not accounted in the /proc/spl/kstat/zfs/<pool>/objset-<id> file: Neither the nwritten nor the writes field increase.
The data is being written to the ZFS fs, being visible in the usedbydataset property.

Describe how to reproduce the problem

The python script here reproduces the issue.
It first writes 512 MiB to a test file using write(), checks the writes in kstat. Then it writes 512 MiB to another test file using mmap() and checks the writes in kstat again. The usedbydataset is also checked to verify the data is being written.
Running the script with a test dataset gives the following output:

Writing 512 MiB using write(2)...
After writing with write: kstat: writes 512 nwritten 536870912
dataset size 518987776

Writing 512 MiB using mmap(2)...
After writing with mmap: kstat: writes: 0 nwritten 0
dataset size 1037869056

As you can see, the write using mmap is not accounted in kstat, even though the dataset size increases by roughly the expected amount.

The expected result would be that at least 1 writes and roughly 536870912 bytes are accounted for both write paths.

Include any warning/errors/backtraces from the system logs

N/A

@drowfx drowfx added the Type: Defect Incorrect behavior (e.g. crash, hang) label Jan 21, 2022
drowfx added a commit to drowfx/zfs that referenced this issue Jan 30, 2022
This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats.

Signed-off-by: Matthias Blankertz <[email protected]>
Issue openzfs#12994
drowfx added a commit to drowfx/zfs that referenced this issue Feb 3, 2022
This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats for both Linux and
FreeBSD.

Signed-off-by: Matthias Blankertz <[email protected]>
Issue openzfs#12994
tonyhutter pushed a commit to tonyhutter/zfs that referenced this issue Feb 15, 2022
This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats for both Linux and
FreeBSD.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Matthias Blankertz <[email protected]>
Closes openzfs#12994 
Closes openzfs#13044
tonyhutter pushed a commit to tonyhutter/zfs that referenced this issue Feb 16, 2022
This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats for both Linux and
FreeBSD.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Matthias Blankertz <[email protected]>
Closes openzfs#12994 
Closes openzfs#13044
tonyhutter pushed a commit to tonyhutter/zfs that referenced this issue Feb 17, 2022
This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats for both Linux and
FreeBSD.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Matthias Blankertz <[email protected]>
Closes openzfs#12994 
Closes openzfs#13044
nicman23 pushed a commit to nicman23/zfs that referenced this issue Aug 22, 2022
This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats for both Linux and
FreeBSD.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Matthias Blankertz <[email protected]>
Closes openzfs#12994 
Closes openzfs#13044
nicman23 pushed a commit to nicman23/zfs that referenced this issue Aug 22, 2022
This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats for both Linux and
FreeBSD.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Matthias Blankertz <[email protected]>
Closes openzfs#12994 
Closes openzfs#13044
snajpa pushed a commit to vpsfreecz/zfs that referenced this issue Oct 22, 2022
This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats for both Linux and
FreeBSD.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Matthias Blankertz <[email protected]>
Closes openzfs#12994 
Closes openzfs#13044
snajpa pushed a commit to vpsfreecz/zfs that referenced this issue Oct 22, 2022
This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats for both Linux and
FreeBSD.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Matthias Blankertz <[email protected]>
Closes openzfs#12994 
Closes openzfs#13044
snajpa pushed a commit to vpsfreecz/zfs that referenced this issue Oct 23, 2022
This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats for both Linux and
FreeBSD.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Matthias Blankertz <[email protected]>
Closes openzfs#12994 
Closes openzfs#13044
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

No branches or pull requests

1 participant