Date: Tue, 23 Aug 2011 21:27:56 +0200 (CEST) From: Martin Matuska <mm@FreeBSD.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/160035: [zfs] zfs rollback does not invalidate mmapped cache Message-ID: <20110823192756.7C8031954A2@mail.vx.sk> Resent-Message-ID: <201108231930.p7NJUAVJ071582@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 160035
>Category: kern
>Synopsis: [zfs] zfs rollback does not invalidate mmapped cache
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Aug 23 19:30:10 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Martin Matuska
>Release: FreeBSD 9.0-BETA1 amd64
>Organization:
>Environment:
>Description:
ZFS rollback does not invalidate mmapped cache - this may lead to a different
or corrupted view of files after a rollback (or clone swap).
This bug is related to kern/156933
>How-To-Repeat:
dd if=/dev/zero of=/tmp/testfile bs=1m count=64
zpool create test /tmp/testfile
echo "First text" > /test/file.txt
zfs snapshot test@s1
echo "Second text" > /test/file.txt
tail /test/file.txt
zfs rollback test@s1
cat /test/file.txt
Without the tail command (mmap) the file reads properly "First text".
With tail it reads cached "Second text" a remount of /test is required -
the on-disk data is correct but cached data incorrect.
The cached pages should get properly invalidated.
>Fix:
The problem may be in zfs_vnops.c, zfs_inactive():
Original OpenSolaris implementation contains:
if (zp->z_sa_hdl == NULL) {
/*
* The fs has been unmounted, or we did a
* suspend/resume and this file no longer exists.
*/
if (vn_has_cached_data(vp)) {
(void) pvn_vplist_dirty(vp, 0, zfs_null_putapage,
B_INVAL, cr);
}
Our implementation misses the "if (vn_has_cached_data(vp))" part.
The function vm_object_sync() might be a possible solution to invalidate
the pages.
>Release-Note:
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110823192756.7C8031954A2>
