Help with filing a [maybe] ZFS/mmap bug.

Harald Schmalzbauer h.schmalzbauer at omnilan.de
Mon Nov 25 18:42:54 UTC 2013


 Bezüglich Andriy Gapon's Nachricht vom 18.11.2013 10:38 (localtime):
> ...
>>> Here is a patch (for head) that should fix the described above issue:
>>>
>>> diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
>>> b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
>>> index 2e2cbd6..4fcd571 100644
>>> --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
>>> +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
>>> @@ -328,6 +328,20 @@ page_busy(vnode_t *vp, int64_t start, int64_t off, int64_t
>>> nbytes)
>>> {
>>> 	vm_object_t obj;
>>> 	vm_page_t pp;
>>> +	int64_t end;
>>> +
>>> +	/*
>>> +	 * At present vm_page_clear_dirty extends the cleared range to DEV_BSIZE
>>> +	 * aligned boundaries, if the range is not aligned.  As a result a
>>> +	 * DEV_BSIZE subrange with partially dirty data may get marked as clean.
>>> +	 * It may happen that all DEV_BSIZE subranges are marked clean and thus
>>> +	 * the whole page would be considred clean despite have some dirty data.
>>> +	 * For this reason we should shrink the range to DEV_BSIZE aligned
>>> +	 * boundaries before calling vm_page_clear_dirty.
>>> +	 */
>>> +	end = rounddown2(off + nbytes, DEV_BSIZE);
>>> +	off = roundup2(off, DEV_BSIZE);
>>> +	nbytes = end - off;
>>>
>>> 	obj = vp->v_object;
>>> 	zfs_vmobject_assert_wlocked(obj);
>>> @@ -362,7 +376,8 @@ page_busy(vnode_t *vp, int64_t start, int64_t off, int64_t
>>> nbytes)
>>> 			ASSERT3U(pp->valid, ==, VM_PAGE_BITS_ALL);
>>> 			vm_object_pip_add(obj, 1);
>>> 			pmap_remove_write(pp);
>>> -			vm_page_clear_dirty(pp, off, nbytes);
>>> +			if (nbytes != 0)
>>> +				vm_page_clear_dirty(pp, off, nbytes);
>>> 		}
>>> 		break;
>>> 	}
>>
>> 9.2 does not seem to have a rounddown2() macro.
> Thanks for the heads-up!
> You could use a plain rounddown() or just 'x & ~(DEV_BSIZE - 1)'.

Hello,

saw that this fix made it int 9-stable:
http://svnweb.freebsd.org/base/stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c?r1=255517&r2=258555

But it uses rounddown2(), so I guess it's not workit atm, right?

Thanks,

-Harry


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20131125/d0c05c5f/attachment.sig>


More information about the freebsd-stable mailing list