Patch review reguest: zfs_znode.c

Martin Matuska mm at FreeBSD.org
Wed Aug 24 17:38:03 UTC 2011


On 24. 8. 2011 15:45, Kostik Belousov wrote:
> On Wed, Aug 24, 2011 at 03:14:47PM +0200, Martin Matuska wrote:
>> Hi Kostik,
>>
>> could you please review the attached patch?
>>
>> It fixes kern/160035 and kern/156933.
>> http://www.freebsd.org/cgi/query-pr.cgi?pr=160035
>>
>> The function zfs_rezget() is called as part of zfs_resume_fs().
>> Suspending and resuming a ZFS filesystem is used in three cases:
>> 1.) zfs rollback
>> 2.) snapshot receive on a mounted fs (zfs recv -F)
>> 3.) zfs upgrade
>>
>> In case 1.) and 2.) the filesystem usually changes (changed/deleted/new files/directories).
>>
>> To make sure we don't have mmaped wrong data we have to invalidate
>> buffers for all vnodes of the resuming fs.
>>
>> Thank you very much,
>> Martin 
>>
> Uh. Does ZFS use the buffer cache at all ?
>
> Could it be that all you need is a call to vm_object_page_remove(vp->v_object,
> 0, 0) ?
Yes, that seems to be enough.
Updated patch attached.

-- 
Martin Matuska
FreeBSD committer
http://blog.vx.sk

-------------- next part --------------
Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
===================================================================
--- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c	(revision 225140)
+++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c	(working copy)
@@ -1343,6 +1343,12 @@
 
 	zp->z_unlinked = (zp->z_links == 0);
 	zp->z_blksz = doi.doi_data_block_size;
+
+	if (ZTOV(zp)->v_object != NULL) {
+		VM_OBJECT_LOCK(ZTOV(zp)->v_object);
+		vm_object_page_remove(ZTOV(zp)->v_object, 0, 0, 0);
+		VM_OBJECT_UNLOCK(ZTOV(zp)->v_object);
+	}
 	if (zp->z_size != size && ZTOV(zp) != NULL)
 		vnode_pager_setsize(ZTOV(zp), zp->z_size);
 


More information about the zfs-devel mailing list