kern/160035: [zfs] zfs rollback does not invalidate mmapped cache

Martin Matuska mm at FreeBSD.org
Tue Aug 23 19:30:11 UTC 2011


>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 at s1
echo "Second text" > /test/file.txt
tail /test/file.txt
zfs rollback test at 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:


More information about the freebsd-bugs mailing list