From owner-freebsd-bugs@FreeBSD.ORG Tue Aug 23 19:30:11 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A3631065677 for ; Tue, 23 Aug 2011 19:30:11 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D00428FC20 for ; Tue, 23 Aug 2011 19:30:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p7NJUAXT071583 for ; Tue, 23 Aug 2011 19:30:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p7NJUAVJ071582; Tue, 23 Aug 2011 19:30:10 GMT (envelope-from gnats) Resent-Date: Tue, 23 Aug 2011 19:30:10 GMT Resent-Message-Id: <201108231930.p7NJUAVJ071582@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Martin Matuska Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E9E61065672 for ; Tue, 23 Aug 2011 19:28:00 +0000 (UTC) (envelope-from mm@mail.vx.sk) Received: from mail.vx.sk (mail.vx.sk [IPv6:2a01:4f8:100:1043::3]) by mx1.freebsd.org (Postfix) with ESMTP id D88758FC14 for ; Tue, 23 Aug 2011 19:27:59 +0000 (UTC) Received: from core.vx.sk (localhost [127.0.0.1]) by mail.vx.sk (Postfix) with ESMTP id C44331954B0 for ; Tue, 23 Aug 2011 21:27:58 +0200 (CEST) Received: from mail.vx.sk ([127.0.0.1]) by core.vx.sk (mail.vx.sk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id z28Z9HH7iltE for ; Tue, 23 Aug 2011 21:27:56 +0200 (CEST) Received: by mail.vx.sk (Postfix, from userid 1001) id 7C8031954A2; Tue, 23 Aug 2011 21:27:56 +0200 (CEST) Message-Id: <20110823192756.7C8031954A2@mail.vx.sk> Date: Tue, 23 Aug 2011 21:27:56 +0200 (CEST) From: Martin Matuska To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: kern/160035: [zfs] zfs rollback does not invalidate mmapped cache X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Martin Matuska List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Aug 2011 19:30:11 -0000 >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: