Summary: | [msdosfs] returns cached truncated data | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Alan Somers <asomers> | ||||
Component: | kern | Assignee: | Konstantin Belousov <kib> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Many People | CC: | emaste, kib, pho | ||||
Priority: | --- | Keywords: | needs-patch, needs-qa | ||||
Version: | CURRENT | Flags: | koobs:
mfc-stable12?
koobs: mfc-stable11? |
||||
Hardware: | Any | ||||||
OS: | Any | ||||||
See Also: | https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=233783 | ||||||
Attachments: |
|
Description
Alan Somers
![]() ![]() (In reply to Alan Somers from comment #0) This is somewhat strange. What is the block size on your testing file system ? Call sequence is msdosfs_setattr()->detrunc()->vtruncbuf()->vnode_pager_setsize(), and the last call zeroes the invalid portion of the partially valid last page. I suspect that in your test case block size is greater than the page size, and lingering pages from the last block after the new EOF are not cleared. If I am right, then the attached patch might fix it to you: Created attachment 203344 [details]
msdosfs: zero tail of the last block on truncation for VREG vnodes as well.
I'm creating my filesystem with the default settings on a 1GB device; I'm not sure what block size is the default. Your patch fixes the problem. Does it suggest a bug in vnode_pager_setsize? (In reply to Alan Somers from comment #3) newfs should report its type (fat32 most likely) and block size. No, vnode_pager_setsize() operates as intended, the pages after EOF are wired by the buffer and not released when we invalidate buffers that we can. I will commit the patch after Peter does some sanity checking for it, hopefully. (In reply to Konstantin Belousov from comment #4) Sure, I'll test your patch. I reproduced the problem and verified that the patch fixed this. I ran the few msdosfs tests I have on both i386 and amd64. No problems seen. A commit references this bug: Author: kib Date: Wed Apr 3 17:02:19 UTC 2019 New revision: 345847 URL: https://svnweb.freebsd.org/changeset/base/345847 Log: msdosfs: zero tail of the last block on truncation for VREG vnodes as well. Despite the call to vtruncbuf() from detrunc(), which results in zeroing part of the partial page after EOF, there still is a possibility to retain the stale data which is revived on file enlargement. If the filesystem block size is greater than the page size, partial block might keep other after-EOF pages wired and they get reused then. Fix it by zeroing whole part of the partial buffer after EOF, not relying on vnode_pager_setsize(). PR: 236977 Reported by: asomers Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Changes: head/sys/fs/msdosfs/msdosfs_denode.c A commit references this bug: Author: pho Date: Tue Apr 9 07:36:40 UTC 2019 New revision: 346047 URL: https://svnweb.freebsd.org/changeset/base/346047 Log: Added a msdosfs regression test. PR: 236977 Sponsored by: Dell EMC Isilon Changes: user/pho/stress2/misc/truncate8.sh Already MFCed by r346074. I don't know why the bugzilla didn't notice. |