From nobody@FreeBSD.org  Sat Oct 13 06:30:25 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 88E3FDF1
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 13 Oct 2012 06:30:25 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 58A2A8FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 13 Oct 2012 06:30:25 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q9D6UOI4069004
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 13 Oct 2012 06:30:24 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id q9D6UON8069003;
	Sat, 13 Oct 2012 06:30:24 GMT
	(envelope-from nobody)
Message-Id: <201210130630.q9D6UON8069003@red.freebsd.org>
Date: Sat, 13 Oct 2012 06:30:24 GMT
From: Martin Birgmeier <Martin.Birgmeier@aon.at>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [zfs] zfs rollback leaves stale data in the buffer cache
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         172656
>Category:       kern
>Synopsis:       [zfs] zfs rollback leaves stale data in the buffer cache
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 13 06:40:00 UTC 2012
>Closed-Date:    Thu Oct 18 22:13:09 UTC 2012
>Last-Modified:  Thu Oct 18 22:13:09 UTC 2012
>Originator:     Martin Birgmeier
>Release:        FreeBSD 8.2.0 release
>Organization:
MBi at home
>Environment:
FreeBSD hal.xyzzy 8.2-RELEASE FreeBSD 8.2-RELEASE #4: Sat Aug 27 09:30:11 CEST 2011     root@hal.xyzzy:/z/OBJ/FreeBSD/amd64/RELENG_8_2_0_RELEASE/src/sys/XYZZY_SMP  amd64
>Description:
I am using a program whose purpose is to efficiently copy disk partitions to image files stored on zfs. Multiple backups in time are kept using snapshots of the file system on which these image files reside.

The program uses mmap(2) to map an image file into memory, then reads the disk partition to be backup up in fixed-size blocks (default 128k). For each block, it first compares the already stored data with the new one using memcmp(3), and does a write using memcpy(3) only if there is a mismatch. In this way, only the blocks which have changed are really written, keeping the zfs snapshots small.

Today I aborted such a backup after about 20000 blocks, of which about 20% were rewritten, and decided to do a zfs rollback of the backup file system and restart the backup again. To my surprise, the program indicated that these first 20000 blocks were already all identical, i.e., 0% had to be rewritten. Only after those 20000 blocks further rewrites started to occur.

I let this run for a while and then aborted again, this time without a zfs rollback. Restarting now resulted in about 20% of the first 20000 blocks being rewritten.

This indicates to me that the buffer cache was not cleared when the rollback was executed, and was only purged by data arriving later. However, the expected behavior clearly is that along with the rollback, the buffer cache is also cleared.

On Oracle's web site, the rollback operation is described as being equivalent to an unmount, rollback, and remount operation of the file system in question. The unmount should clear the cache.

>How-To-Repeat:
See description above describing the use case.
>Fix:


>Release-Note:
>Audit-Trail:

From: Andriy Gapon <avg@FreeBSD.org>
To: bug-followup@FreeBSD.org, Martin.Birgmeier@aon.at
Cc:  
Subject: Re: kern/172656: [zfs] zfs rollback leaves stale data in the buffer
 cache
Date: Wed, 17 Oct 2012 20:52:26 +0300

 Most likely you need to upgrade to a later 8.x release.
 See http://www.freebsd.org/cgi/query-pr.cgi?pr=160035 for additional details.
 Could you verify that the fix works?
 
 -- 
 Andriy Gapon

From: Martin Birgmeier <Martin.Birgmeier@aon.at>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/172656: [zfs] zfs rollback leaves stale data in the buffer
 cache
Date: Thu, 18 Oct 2012 18:58:03 +0200

 Thank you Andriy for quickly responding.
 
 Unfortunately, I cannot easily test the patch, as this is a production
 system.
 
 As I am quite sure your pointer is correct, please close this PR.
 
 Regards,
 
 Martin
 
State-Changed-From-To: open->closed 
State-Changed-By: avg 
State-Changed-When: Thu Oct 18 22:12:22 UTC 2012 
State-Changed-Why:  
Seems to be a duplicate of kern/160035.  Closing per the originator's 
agreement. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172656 
>Unformatted:
