xref: /freebsd-src/sys/cddl/compat/opensolaris/kern/opensolaris_vm.c (revision fdafd315ad0d0f28a11b9fb4476a9ab059c62b92)
189f6b863SAttilio Rao /*-
289f6b863SAttilio Rao  * Copyright (c) 2013 EMC Corp.
389f6b863SAttilio Rao  * All rights reserved.
489f6b863SAttilio Rao  *
589f6b863SAttilio Rao  * Redistribution and use in source and binary forms, with or without
689f6b863SAttilio Rao  * modification, are permitted provided that the following conditions
789f6b863SAttilio Rao  * are met:
889f6b863SAttilio Rao  * 1. Redistributions of source code must retain the above copyright
989f6b863SAttilio Rao  *    notice, this list of conditions and the following disclaimer.
1089f6b863SAttilio Rao  * 2. Redistributions in binary form must reproduce the above copyright
1189f6b863SAttilio Rao  *    notice, this list of conditions and the following disclaimer in the
1289f6b863SAttilio Rao  *    documentation and/or other materials provided with the distribution.
1389f6b863SAttilio Rao  *
1489f6b863SAttilio Rao  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
1589f6b863SAttilio Rao  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1689f6b863SAttilio Rao  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1789f6b863SAttilio Rao  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
1889f6b863SAttilio Rao  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1989f6b863SAttilio Rao  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2089f6b863SAttilio Rao  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2189f6b863SAttilio Rao  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2289f6b863SAttilio Rao  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2389f6b863SAttilio Rao  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2489f6b863SAttilio Rao  * SUCH DAMAGE.
2589f6b863SAttilio Rao  */
2689f6b863SAttilio Rao 
2789f6b863SAttilio Rao #include <sys/param.h>
28*a421e878SKonstantin Belousov #include <sys/systm.h>
2989f6b863SAttilio Rao #include <sys/lock.h>
3089f6b863SAttilio Rao #include <sys/freebsd_rwlock.h>
3189f6b863SAttilio Rao 
3289f6b863SAttilio Rao #include <vm/vm.h>
3389f6b863SAttilio Rao #include <vm/vm_param.h>
3489f6b863SAttilio Rao #include <vm/vm_object.h>
3589f6b863SAttilio Rao #include <vm/vm_page.h>
3689f6b863SAttilio Rao #include <vm/vm_pager.h>
3789f6b863SAttilio Rao 
3889f6b863SAttilio Rao const int zfs_vm_pagerret_bad = VM_PAGER_BAD;
3989f6b863SAttilio Rao const int zfs_vm_pagerret_error = VM_PAGER_ERROR;
4089f6b863SAttilio Rao const int zfs_vm_pagerret_ok = VM_PAGER_OK;
41f77ffe1bSAndriy Gapon const int zfs_vm_pagerput_sync = VM_PAGER_PUT_SYNC;
42f77ffe1bSAndriy Gapon const int zfs_vm_pagerput_inval = VM_PAGER_PUT_INVAL;
4389f6b863SAttilio Rao 
4489f6b863SAttilio Rao void
zfs_vmobject_assert_wlocked(vm_object_t object)4589f6b863SAttilio Rao zfs_vmobject_assert_wlocked(vm_object_t object)
4689f6b863SAttilio Rao {
4789f6b863SAttilio Rao 
4889f6b863SAttilio Rao 	/*
4989f6b863SAttilio Rao 	 * This is not ideal because FILE/LINE used by assertions will not
5089f6b863SAttilio Rao 	 * be too helpful, but it must be an hard function for
5189f6b863SAttilio Rao 	 * compatibility reasons.
5289f6b863SAttilio Rao 	 */
5389f6b863SAttilio Rao 	VM_OBJECT_ASSERT_WLOCKED(object);
5489f6b863SAttilio Rao }
5589f6b863SAttilio Rao 
5689f6b863SAttilio Rao void
zfs_vmobject_wlock(vm_object_t object)5789f6b863SAttilio Rao zfs_vmobject_wlock(vm_object_t object)
5889f6b863SAttilio Rao {
5989f6b863SAttilio Rao 
6089f6b863SAttilio Rao 	VM_OBJECT_WLOCK(object);
6189f6b863SAttilio Rao }
6289f6b863SAttilio Rao 
6389f6b863SAttilio Rao void
zfs_vmobject_wunlock(vm_object_t object)6489f6b863SAttilio Rao zfs_vmobject_wunlock(vm_object_t object)
6589f6b863SAttilio Rao {
6689f6b863SAttilio Rao 
6789f6b863SAttilio Rao 	VM_OBJECT_WUNLOCK(object);
6889f6b863SAttilio Rao }
69